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 C55A88F54 for ; Fri, 10 Jan 2025 04:32:09 +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=1736483535; cv=none; b=onhV1vus6ClPakf+l7LQKQVw6ZoWw7hTV8V2rtds5f8Kd/JgipW/nqDmBGtu2zAMK7w67IKjtOTlOBnKgYoWu1fi89gRD8/GIwqzoSbgu+8N+pwBUdiFULqprXS7nIL2DL3RpYTc2yow4o0gvi9Zytd/OcNboT/7aKSyuGVPJuM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736483535; c=relaxed/simple; bh=gf1WjD9P6+7vmm9/gMBzK1ROZHBtSK7MGupCich43QQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KlK/9bzPZtSDmzz6Rw7WY91Ka60ZGlaneFx5058Ta9QylCgUjRDO+dPh9pEsuTi8EspONtB2dgRFq9DNeydZ1AWkBJeS2cED9RQKDMYHCu8TgkuBIYoJmEakeBB1eA66OH0WcbUPWB8M8cCVYm9pYRHPPeZaJSHnfAAty3Izdfk= 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=sH4OKI7t; 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="sH4OKI7t" 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=JsLZV1rT0ZbvlEH8OwdROMNPQ47w8QsVOqhVyaii2Os=; b=sH4OKI7tg30V9fG/zagRDK7Scs KhcwpRhRMSGCvGuK2kLIHJoppuW8UyeElqZoLCLAm447Nxf8bPmDxWf3oWKCoLSW7BsTRAuhcKzOF AWiJLAqxf6QtSRbdArmPtjDYsun1B7hB7FPqnD8XstM2HfEblpEd6xbOXRZEYNF7eJo+Oeg15bvbT k30zuCRNnX6IWCpryy5mc7+iJF/Gl0vmug4onVXC9PAOFHwJG3WnDy9NhteSMxxUrWNk6Yc/whOd2 3OWnZ2nN+2NvtBBQ8ttYGidAVAksn4/GQPN0OdzYYiWORCKCunWbwvDzJwmrZZ+23t3i6xZaSs2BG EN0lgrPw==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tW6gd-0000000BP7a-2d0i; Fri, 10 Jan 2025 04:31:55 +0000 Date: Fri, 10 Jan 2025 04:31:55 +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> 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: <037d4442-4d2d-4aeb-8091-5efffc374d36@os.amperecomputing.com> 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.