lkml.org 
[lkml]   [2014]   [Jan]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] lib/vsprintf: add %pT[C012] format specifier
From
Date
Pavel Machek wrote:
> > + * Please use this wrapper function which will be updated in the future to read
> > + * @tsk->comm in a consistent way.
> > + */
> > +static inline int commcmp(const struct task_struct *tsk, const char *comm)
> > +{
> > + return strcmp(tsk->comm, comm);
> > +}
>
> Is this useful to something? Printing command name is
> useful. Comparing it...?
>

(a) Using tsk->comm for reducing duplicated printk() messages.

if (strcmp(p->comm, last_comm)) {
printk("hello\n");
strcpy(last_comm, p->comm);
}

(b) Using tsk->pid for reducing duplicated printk() messages.

if (p->pid != last_pid) {
printk("hello\n");
last_pid = p->pid;
}

(c) Using printk_ratelimit() for reducing printk() flooding.

printk_ratelimit("hello\n");

(d) Using plain printk().

printk("hello\n");

(e) Other purposes. (e.g. drivers/target/iscsi/iscsi_target_tq.c )

if (!strncmp(current->comm, ISCSI_RX_THREAD_NAME,
strlen(ISCSI_RX_THREAD_NAME)))
thread_called = ISCSI_RX_THREAD;
else if (!strncmp(current->comm, ISCSI_TX_THREAD_NAME,
strlen(ISCSI_TX_THREAD_NAME)))
thread_called = ISCSI_TX_THREAD;

commcmp() and commcpy() are for wrappring (a).
Though (a) should consider changing to (b) or (c).

(e) should be rewritten not to depend on current->comm .


\
 
 \ /
  Last update: 2014-01-06 15:21    [W:0.215 / U:0.452 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site