linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Alex Shi <alex.shi@linux.alibaba.com>
To: Lorenzo Stoakes <lstoakes@gmail.com>,
	syzbot <syzbot+ce635500093181f39c1c@syzkaller.appspotmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-mm <linux-mm@kvack.org>,
	Linux-Next Mailing List <linux-next@vger.kernel.org>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	syzkaller-bugs <syzkaller-bugs@googlegroups.com>,
	Hui Su <sh_def@163.com>
Subject: Re: linux-next boot error: WARNING in prepare_kswapd_sleep
Date: Wed, 25 Nov 2020 14:24:51 +0800	[thread overview]
Message-ID: <bda71012-f2e2-9a4c-5dcb-7ad14655c2f5@linux.alibaba.com> (raw)
In-Reply-To: <CAA5enKZ=6=AoknavW4RJ+T+aiPBFSf8uEjJ+ODcc+nMTD2k5kQ@mail.gmail.com>



在 2020/11/25 上午1:59, Lorenzo Stoakes 写道:
> On Tue, 24 Nov 2020 at 07:54, syzbot
> <syzbot+ce635500093181f39c1c@syzkaller.appspotmail.com> wrote:
>> syzbot found the following issue on:
>>
>> HEAD commit:    d9137320 Add linux-next specific files for 20201124
> 
> This appears to be a product of 4b2904f3 ("mm/memcg: add missed
> warning in mem_cgroup_lruvec") adding a VM_WARN_ON_ONCE() to
> mem_cgroup_lruvec, which when invoked from a function other than
> mem_cgroup_page_lruvec() can in fact be called with the condition
> false.
> If we move the check back into mem_cgroup_page_lruvec() it resolves
> the issue. I enclose a simple version of this below, happy to submit
> as a proper patch if this is the right approach:
> 
> 
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> index 87ed56dc75f9..27cc40a490b2 100644
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -618,7 +618,6 @@ static inline struct lruvec
> *mem_cgroup_lruvec(struct mem_cgroup *memcg,
>                 goto out;
>         }
> 
> -       VM_WARN_ON_ONCE(!memcg);
>         if (!memcg)
>                 memcg = root_mem_cgroup;
> 
> @@ -645,6 +644,7 @@ static inline struct lruvec
> *mem_cgroup_lruvec(struct mem_cgroup *memcg,
>  static inline struct lruvec *mem_cgroup_page_lruvec(struct page *page,
>                                                 struct pglist_data *pgdat)
>  {
> +       VM_WARN_ON_ONCE_PAGE(!page_memcg(page), page);
>         return mem_cgroup_lruvec(page_memcg(page), pgdat);
>  }
> 

Acked.

Right. Would you like to remove the bad commit 4b2904f3 ("mm/memcg: add missed
 warning in mem_cgroup_lruvec") and replace yours.

and further more, could you like try another patch?

Thanks
Alex

From 073b222bd06a96c39656b0460c705e48c7eedafc Mon Sep 17 00:00:00 2001
From: Alex Shi <alex.shi@linux.alibaba.com>
Date: Wed, 25 Nov 2020 14:06:33 +0800
Subject: [PATCH] mm/memcg: bail out early when !memcg in mem_cgroup_lruvec

In some scenarios, we call NULL memcg in mem_cgroup_lruvec(NULL, pgdat)
so we could get out early to skip unnecessary check.

Also warning if both parameter are NULL.

Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
---
 include/linux/memcontrol.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 3a995bb3157f..5e4da83eb9ce 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -613,7 +613,9 @@ static inline struct lruvec *mem_cgroup_lruvec(struct mem_cgroup *memcg,
 	struct mem_cgroup_per_node *mz;
 	struct lruvec *lruvec;
 
-	if (mem_cgroup_disabled()) {
+	VM_WARN_ON_ONCE(!memcg && !pgdat);
+
+	if (mem_cgroup_disabled() || !memcg) {
 		lruvec = &pgdat->__lruvec;
 		goto out;
 	}
-- 
2.29.GIT



  reply	other threads:[~2020-11-25  6:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-24  7:54 linux-next boot error: WARNING in prepare_kswapd_sleep syzbot
2020-11-24 17:59 ` Lorenzo Stoakes
2020-11-25  6:24   ` Alex Shi [this message]
2020-11-25 11:25     ` Lorenzo Stoakes
2020-11-25 11:22 ` [PATCH] mm/memcg: warn on missing memcg on mem_cgroup_page_lruvec() Lorenzo Stoakes
2020-11-25 12:15   ` Alex Shi
2020-11-25 22:27     ` Stephen Rothwell

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=bda71012-f2e2-9a4c-5dcb-7ad14655c2f5@linux.alibaba.com \
    --to=alex.shi@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-next@vger.kernel.org \
    --cc=lstoakes@gmail.com \
    --cc=sfr@canb.auug.org.au \
    --cc=sh_def@163.com \
    --cc=syzbot+ce635500093181f39c1c@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    /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).