【问题标题】:printk in tcp_cubic.ctcp_cubic.c 中的 printk
【发布时间】:2012-04-23 11:59:09
【问题描述】:

我在 tcp_cubic.c 中包含了以下 printk 语句

static u32 bictcp_recalc_ssthresh(struct sock *sk)
{
  ..

  if (tp->snd_cwnd < ca->last_max_cwnd && fast_convergence)

      ca->last_max_cwnd = (tp->snd_cwnd * (BICTCP_BETA_SCALE + beta))
          / (2 * BICTCP_BETA_SCALE);
  else
      ca->last_max_cwnd = tp->snd_cwnd;

  ca->loss_cwnd = tp->snd_cwnd;


  printk(KERN_INFO "ssthresh is %s", snd_cwnd); // <<<--- here

  return max((tp->snd_cwnd * beta) / BICTCP_BETA_SCALE, 2U);

}

但它没有打印 dmesg 或 syslog 中的值。这是为什么呢?

【问题讨论】:

  • 你怎么确定这个函数被调用了?在这个函数中插入一个dumpstack() 函数调用,并确保这个函数被调用

标签: c linux-kernel kernel printk


【解决方案1】:

在 Linux 3.1(例如)中,DEFAULT_MESSAGE_LOGLEVEL 的值为 4,KERN_INFO 为 6。尝试使用类似 KERN_ALERT(值为 1)的内容进行打印。

您可以通过读取/修改此 proc 文件来检查或更改您的默认日志级别:

cat /proc/sys/kernel/printk 

有关此文件的更多信息,请参阅man 5 proc。

【讨论】:

  • 通过在 tcp_cubic.c 中更改为 KERN_ALERT 并在 cat /proc/sys/kernel/printk 中查看输出,它显示 4 4 1 7。所以我想知道我应该怎么做在更改 tcp_cubic.c 中的 printk 语句后,即我应该编译还是应该只查看 syslog 而不编译,或者我应该通过为其编写单独的 Makefile 来执行 insmod。
猜你喜欢
  • 1970-01-01
  • 2015-10-27
  • 1970-01-01
  • 1970-01-01
  • 2017-07-03
  • 1970-01-01
  • 2014-11-10
  • 2011-08-19
  • 2016-08-07
相关资源
最近更新 更多