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 70D4718B0F for ; Wed, 14 Jan 2026 04:18:27 +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=1768364311; cv=none; b=fNZMytiYJrSzdijKBQ7oie7KpP4MPtUYocBMbd9dfXotx1X31ELe7s2tneK2mqT+T7Ws8h+cRhNJx3q0zRJeJ/BSH9Aw+J4PQyf5V9aJZ33x8hYi4bjbo7tmcKKnjFNEXA1FucT/GXw88QhKE6en4qC9l8mBsMXVNgbZx0m+wK8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768364311; c=relaxed/simple; bh=1eAHy8G13yqyD+hDsV0vas6CX9M1W3xdEzkb8KJ98fM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=f5Riba1KBM6RAVF5Up42dYxEWgs9rxuRWkBbblJYPm0LOG/aTjcgqkptA0d6nBmdDZVGEfDB1n5R8QsLj8C9Gb26tvu4nSTF+S3bGw7djZaG8K2qFYEd5734oLAiI5dPRViY8kp49MIyd3ZnOKyetVLl7iGYei4cYrGqV85qc5I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (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=M/Ble0jw; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (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="M/Ble0jw" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=zBxU2eKSNmP9tO8O5sNS43LQrbMo3ik3+QWCjvr1x9s=; b=M/Ble0jwJPOjujGaAlUGrGXdYX igMnEekYGz9MFyjMGCsDBQB63dBGPsdYvnDP37KtN4qqHY/f3Frvuo3hyJSkMIuLJhKw18xr899Fl KLpr7nv7eWj6xDb+1h1nhBAkPBilirCcs2VTHyK7OVThfOCedBLIc01Nh/B1dDsafsrVesaMpIXTf K/hvtpqWtUcYxH1b8MhdA6abdCWeYzYEA7h28MEYzgFkQ8wld0dgPjbjP2WyAQDy2xWI8IR3D5qo/ 6nrIrEaADDkRo9737JewAlG9VYkyIoN1PH82ML0dzlDfojruTclmxD1zYEvQ9RPw8qpTlBJwJsnnN TzN2tWuQ==; Received: from willy by casper.infradead.org with local (Exim 4.98.2 #2 (Red Hat Linux)) id 1vfsKq-00000005faS-0WeX; Wed, 14 Jan 2026 04:18:20 +0000 Date: Wed, 14 Jan 2026 04:18:19 +0000 From: Matthew Wilcox To: wang.yaxin@zte.com.cn Cc: akpm@linux-foundation.org, liam.howlett@oracle.com, lorenzo.stoakes@oracle.com, david@kernel.org, vbabka@suse.cz, jannh@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, xu.xin16@zte.com.cn, yang.yang29@zte.com.cn, fan.yu9@zte.com.cn, he.peilin@zte.com.cn, tu.qiang35@zte.com.cn, qiu.yutan@zte.com.cn, jiang.kun2@zte.com.cn, lu.zhongjun@zte.com.cn Subject: Re: [PATCH linux-next] mm/madvise: prefer VMA lock for MADV_REMOVE Message-ID: References: <202601141124178748cM66DJW2fzNea7Uym1mG@zte.com.cn> 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=us-ascii Content-Disposition: inline In-Reply-To: <202601141124178748cM66DJW2fzNea7Uym1mG@zte.com.cn> On Wed, Jan 14, 2026 at 11:24:17AM +0800, wang.yaxin@zte.com.cn wrote: > - mark_mmap_lock_dropped(madv_behavior); > + /* > + * Prefer VMA read lock path: when operating under VMA lock, we avoid > + * dropping/reacquiring the mmap lock and directly perform the filesystem > + * operation while the VMA is read-locked. We still take and drop a file > + * reference to protect against concurrent file changes. How does taking a reference prevent file changes? What do you mean by "file changes" anyway? > + * When operating under mmap read lock (fallback), preserve existing > + * behaviour: mark lock dropped, coordinate with userfaultfd_remove(), > + * temporarily drop mmap_read_lock around vfs_fallocate(), and then > + * reacquire it. This is not the way to write an inline comment; that's how you describe what you've done in the changelog. > @@ -1033,12 +1045,19 @@ static long madvise_remove(struct madvise_behavior *madv_behavior) > + ((loff_t)vma->vm_pgoff << PAGE_SHIFT); > > /* > - * Filesystem's fallocate may need to take i_rwsem. We need to > - * explicitly grab a reference because the vma (and hence the > - * vma's reference to the file) can go away as soon as we drop > - * mmap_lock. > + * Execute filesystem punch-hole under appropriate locking. > + * - VMA lock path: no mmap lock held; call vfs_fallocate() directly. > + * - mmap lock path: follow existing protocol including UFFD coordination > + * and temporary mmap_read_unlock/lock around the filesystem call. Again, I don't like what you've done here with the comments.