Re: [patch] oom: change warning for deprecated oom_adj to avoidWARN_ONCE()

From: Borislav Petkov
Date: Thu Aug 04 2011 - 03:48:31 EST


On Wed, Aug 03, 2011 at 11:04:55PM -0700, David Rientjes wrote:
> > > - WARN_ONCE(1, "%s (%d): /proc/%d/oom_adj is deprecated, please use /proc/%d/oom_score_adj instead.\n",
> > > - current->comm, task_pid_nr(current), task_pid_nr(task),
> > > - task_pid_nr(task));
> > > + if (!warning_printed) {
> > > + warning_printed = true;
> > > + printk("\n===============================================================================\n");
> > > + printk("%s (%d): /proc/%d/oom_adj is deprecated, please use /proc/%d/oom_score_adj instead.\n",
> > > + current->comm, task_pid_nr(current), task_pid_nr(task),
> > > + task_pid_nr(task));
> > > + printk("===============================================================================\n\n");
> >
> > You're missing the KERN_WARNING level.
>
> It's intentional because (i) I'm using a multi-line notification with
> newlines and (ii) I don't want to be considered as a kernel warning. It's
> just for consumption by userspace and doesn't indicate a kernel issue.

I see.

> > Why don't you use pr_warn_once +
> > pr_cont_once? No need for the warning_printed too, it gets defined in
> > another scope by the pr_warn_once macro automatically.
> >
>
> Because using pr_warn_once + pr_cont_once for a multi-line notification is
> racy and I don't want three separated static variables? pr_cont_once()
> shouldn't be used unless synchronized.

Or maybe do:

pr_info_once("\n===============================================================================\n"
"%s (%d): /proc/%d/oom_adj is deprecated, please use /proc/%d/oom_score_adj instead.\n"
"===============================================================================\n\n",
current->comm, task_pid_nr(current), task_pid_nr(task), task_pid_nr(task));

so as to not be a warning and still hide the warning_printed thing. You
could even save yourself the last repeated argument by enumerating the
format specifiers:

pr_info_once("\n===============================================================================\n"
"%1$s (%2$d): /proc/%3$d/oom_adj is deprecated, please use /proc/%3$d/oom_score_adj instead.\n"
"===============================================================================\n\n",
current->comm, task_pid_nr(current), task_pid_nr(task));

It seems to build fine here.

Oh well. :-)

--
Regards/Gruss,
Boris.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/