linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Linux-Next Mailing List <linux-next@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [patch] mm: memcg: make sure memory.events is uptodate when waking pollers fix
Date: Fri, 6 Apr 2018 11:54:41 -0400	[thread overview]
Message-ID: <20180406155441.GA20806@cmpxchg.org> (raw)
In-Reply-To: <20180406145330.4d166464@canb.auug.org.au>

On Fri, Apr 06, 2018 at 02:53:30PM +1000, Stephen Rothwell wrote:
> Hi Andrew,
> 
> After merging the akpm-current tree, today's linux-next build (x86_64
> allmodconfig) produced this warning:
> 
> mm/memcontrol.c: In function 'memory_events_show':
> mm/memcontrol.c:5453:23: warning: array subscript is above array bounds [-Warray-bounds]
>       atomic_long_read(&memcg->memory_events[OOM_KILL]));
>                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Introduced by commit
> 
>   725844c87a0d ("mm: memcg: make sure memory.events is uptodate when waking pollers")

Ah, silly, I missed that warning. The below fixes it.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 04ea2b104ee2..9bac6dc26e09 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5199,8 +5199,7 @@ static int memory_events_show(struct seq_file *m, void *v)
 		   atomic_long_read(&memcg->memory_events[MEMCG_MAX]));
 	seq_printf(m, "oom %lu\n",
 		   atomic_long_read(&memcg->memory_events[MEMCG_OOM]));
-	seq_printf(m, "oom_kill %lu\n",
-		   atomic_long_read(&memcg->memory_events[OOM_KILL]));
+	seq_printf(m, "oom_kill %lu\n", memcg_sum_events(memcg, OOM_KILL));
 
 	return 0;
 }

  reply	other threads:[~2018-04-06 15:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-06  4:53 linux-next: build warning after merge of the akpm-current tree Stephen Rothwell
2018-04-06 15:54 ` Johannes Weiner [this message]
2018-04-06 16:11   ` [patch] mm: memcg: make sure memory.events is uptodate when waking pollers fix Michal Hocko

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=20180406155441.GA20806@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=sfr@canb.auug.org.au \
    /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;
as well as URLs for NNTP newsgroup(s).