mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: David Rientjes <rientjes@google.com>
Cc: Andi Kleen <andi@firstfloor.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [patch] oom: change warning for deprecated oom_adj to avoid WARN_ONCE()
Date: Wed, 3 Aug 2011 08:10:16 +0200	[thread overview]
Message-ID: <20110803061016.GC16170@liondog.tnic> (raw)
In-Reply-To: <alpine.DEB.2.00.1108020236140.18935@chino.kir.corp.google.com>

On Tue, Aug 02, 2011 at 02:54:01AM -0700, David Rientjes wrote:
> On Mon, 1 Aug 2011, Andi Kleen wrote:
> 
> > Simply backtraces are not supposed to happen unless something 
> > is really broken. That's not the case here. The old distribution
> > works perfectly fine and will continue to do so.
> > 
> 
> It won't work perfectly fine in a year when the tunable is removed 
> completely and the code that was writing OOM_DISABLE to /proc/pid/oom_adj 
> just fails and the task that was supposed to be prevented from being 
> killed at all costs may now be killed.  The printk_once() over the past 
> year didn't get that fixed up like the other applications I mentioned did, 
> so we need to attract more attention.
> 
> > I still think reverting this patch is the right thing to do.
> > 
> 
> Reverting the patch is ludicrous, otherwise there is little possibility 
> that the remaining users of the deprecated interface will change if they 
> haven't done so already.  I'm perfectly happy with changing it to a 
> different style of warning other than using WARN_ONCE() like I've already 
> said.  That doesn't require a revert.
> 
> I'm fine with this patch if Linus would like to apply it.
> 
> 
> oom: change warning for deprecated oom_adj to avoid WARN_ONCE()
> 
> WARN_ONCE() emits a stack trace to the kernel log which leads userspace 
> parsers to interpret it as being a serious error or malfunction within the 
> kernel.  Change the warning to appear more like a lockdep warning while 
> still trying to preserve the intention of be8f684d73d8 (oom: make 
> deprecated use of oom_adj more verbose) to attract more attention to the 
> use of a deprecated interface.
> 
> Reported-by: Andi Kleen <andi@firstfloor.org>
> Signed-off-by: David Rientjes <rientjes@google.com>
> ---
>  fs/proc/base.c |   13 ++++++++++---
>  1 files changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/proc/base.c b/fs/proc/base.c
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -1066,6 +1066,7 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
>  	char buffer[PROC_NUMBUF];
>  	int oom_adjust;
>  	unsigned long flags;
> +	static bool warning_printed;
>  	int err;
>  
>  	memset(buffer, 0, sizeof(buffer));
> @@ -1118,9 +1119,15 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
>  	 * Warn that /proc/pid/oom_adj is deprecated, see
>  	 * Documentation/feature-removal-schedule.txt.
>  	 */
> -	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. 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.

-- 
Regards/Gruss,
    Boris.

  reply	other threads:[~2011-08-03  6:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-02  0:52 Revert needed: udev spewing warnons on common systems in 3.0 Andi Kleen
2011-08-02  1:32 ` Andrew Morton
2011-08-02  1:41   ` Linus Torvalds
2011-08-02  2:22     ` David Rientjes
2011-08-02  9:16       ` Alan Cox
2011-08-02  9:53         ` David Rientjes
2011-08-02 10:11           ` Alan Cox
2011-08-02 11:22             ` David Miller
2011-08-02 14:45             ` Andi Kleen
2011-08-02 21:50               ` David Rientjes
2011-08-02 21:45             ` David Rientjes
2011-08-02 22:06               ` Andi Kleen
2011-08-02 11:20           ` David Miller
2011-08-02  2:34 ` David Rientjes
2011-08-02  6:07   ` Andi Kleen
2011-08-02  9:54     ` [patch] oom: change warning for deprecated oom_adj to avoid WARN_ONCE() David Rientjes
2011-08-03  6:10       ` Borislav Petkov [this message]
2011-08-04  6:04         ` David Rientjes
2011-08-04  7:48           ` Borislav Petkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110803061016.GC16170@liondog.tnic \
    --to=bp@alien8.de \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rientjes@google.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®