From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B10724B238 for ; Fri, 10 Jan 2025 19:01:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736535706; cv=none; b=ciJUPu1vKGwzqmAUtKEAUKX6YWeFNPDAa+eI7jGpyfTbzgmLAgkHjnTJmaGfRJkIgF92bA4QeF4IEYRiJuo84fO5rwi0K2HS+CJWDFADAagYzpDInTFPAIjupFkM2zuud/fTh0zZrWj2W4rueWLUM5IjeO181q6/Lb/FqnqsA1I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736535706; c=relaxed/simple; bh=b3QC6EdQZS+wDfrz2t7Q6bGRXwIVdcNYu09u05arAWk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nf8vVy0kgzN46qXa1R8uo5G1Cfjqyle9bO8WZl2TTm+H9MyEHAFwZIgnh4viNb4tm0KShNL1aFj+ZTxwZf7+jAWPerodQMGz0f1yPykPG5sz5Jj0ehmDxPJxY0mOUUOXTQf1OM86TWjHDGcQXvAG8qUQ/3FJrx/e3MBKYaFNO0w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=l00/ui3M; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="l00/ui3M" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=q1i8rljs3Gh9LpFws/XGlM5n39kz/FWZi4Jf8kWWcd0=; b=l00/ui3MmKgaF7EbE9ofGdfJvR 6Y0qpwkSKC2oJxxRD7pYns1JT9yUGzjkX6+28ES/hQAtzzjKjU/WTb1WdGFmUp4jA1M0JCbYVTiKT kcU3MVaTd1VzOWKnLeZ9YXMAKWi9g4+RuRbXQKjL4J+a39y6KtIrjtFdMki1XnLocrY5F3h7PFkmg YHQ9X5grKy8flRU++vdtZKfzLgzRzoU9x6ozQC6X7MRDQco+hTwLlgnqSqrxBA56Pby9QDhyd0HNt yO0qRLWN2+YZBNn8zGojgdLh1ToNK76oEIpvX0WRDi0I8PYvloqXPm302EnycxrsVKdT1h55A9iCX n9FrcazQ==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tWKGI-0000000ECsS-1JGF; Fri, 10 Jan 2025 19:01:38 +0000 Date: Fri, 10 Jan 2025 19:01:38 +0000 From: Matthew Wilcox To: Yang Shi Cc: Liu Shixin , Andrew Morton , Chengming Zhou , Kefeng Wang , Nanyong Sun , Muchun Song , Qi Zheng , Johannes Weiner , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: khugepaged: fix call hpage_collapse_scan_file() for anonymous vma Message-ID: References: <20250109070059.369257-1-liushixin2@huawei.com> <037d4442-4d2d-4aeb-8091-5efffc374d36@os.amperecomputing.com> <8e773a7c-e1dd-4e0e-8349-8aa52f39d85a@os.amperecomputing.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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.