linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Yang Shi <yang@os.amperecomputing.com>
Cc: Liu Shixin <liushixin2@huawei.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Chengming Zhou <chengming.zhou@linux.dev>,
	Kefeng Wang <wangkefeng.wang@huawei.com>,
	Nanyong Sun <sunnanyong@huawei.com>,
	Muchun Song <muchun.song@linux.dev>,
	Qi Zheng <zhengqi.arch@bytedance.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: khugepaged: fix call hpage_collapse_scan_file() for anonymous vma
Date: Fri, 10 Jan 2025 19:01:38 +0000	[thread overview]
Message-ID: <Z4Fukra_N1cRxFYs@casper.infradead.org> (raw)
In-Reply-To: <8e773a7c-e1dd-4e0e-8349-8aa52f39d85a@os.amperecomputing.com>

On Fri, Jan 10, 2025 at 10:04:42AM -0800, Yang Shi wrote:
> On 1/9/25 8:31 PM, Matthew Wilcox wrote:
> > On Thu, Jan 09, 2025 at 09:00:24AM -0800, Yang Shi wrote:
> > > Thanks for catching this. It sounds a little bit weird to have vm_file for
> > > an anonymous VMA. I'm not sure why we should keep such special case. It
> > > seems shared mapping is treated as shmem file mapping. So can we set vm_file
> > > to NULL when mmap'ing /dev/zero for private mapping? Something like:
> > > 
> > > diff --git a/drivers/char/mem.c b/drivers/char/mem.c
> > > index 169eed162a7f..fc332efc5c11 100644
> > > --- a/drivers/char/mem.c
> > > +++ b/drivers/char/mem.c
> > > @@ -527,6 +527,7 @@ static int mmap_zero(struct file *file, struct
> > > vm_area_struct *vma)
> > >          if (vma->vm_flags & VM_SHARED)
> > >                  return shmem_zero_setup(vma);
> > >          vma_set_anonymous(vma);
> > > +       vma->vm_file = NULL;
> > >          return 0;
> > >   }
> > I'm wary this might cause other bugs somewhere.  rc6 is a bit late to be
> > introducing such a subtle change.
> 
> Thanks for the extra caution. Applying the proposed fix in khugepaged code
> is fine to me either. We can try to kill the special case later.
> 
> Looking at the code further, I think we should do more to make private
> /dev/zero mapping an anonymous mapping:

I'm still nervous about this.  We map device inodes in a lot of places.


  reply	other threads:[~2025-01-10 19:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-09  7:00 Liu Shixin
2025-01-09 13:40 ` Matthew Wilcox
2025-01-10  2:29   ` Liu Shixin
2025-01-09 17:00 ` Yang Shi
2025-01-10  2:08   ` Baolin Wang
2025-01-10  2:32   ` Liu Shixin
2025-01-10  4:31   ` Matthew Wilcox
2025-01-10 18:04     ` Yang Shi
2025-01-10 19:01       ` Matthew Wilcox [this message]
2025-01-10 19:40         ` Yang Shi
2025-01-11  3:54           ` Liu Shixin
2025-01-13 18:51             ` Yang Shi

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=Z4Fukra_N1cRxFYs@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=chengming.zhou@linux.dev \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liushixin2@huawei.com \
    --cc=muchun.song@linux.dev \
    --cc=sunnanyong@huawei.com \
    --cc=wangkefeng.wang@huawei.com \
    --cc=yang@os.amperecomputing.com \
    --cc=zhengqi.arch@bytedance.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