From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8049DC5AD49 for ; Tue, 3 Jun 2025 20:59:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E5A306B0517; Tue, 3 Jun 2025 16:59:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E0AFB6B0518; Tue, 3 Jun 2025 16:59:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D20446B0519; Tue, 3 Jun 2025 16:59:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id B3CD26B0517 for ; Tue, 3 Jun 2025 16:59:51 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 69E001A1760 for ; Tue, 3 Jun 2025 20:59:51 +0000 (UTC) X-FDA: 83515306182.12.7E978EE Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf18.hostedemail.com (Postfix) with ESMTP id 0F00C1C0007 for ; Tue, 3 Jun 2025 20:59:48 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=a8VhylAd; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=RZsHFvqs; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=a8VhylAd; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=RZsHFvqs; spf=pass (imf18.hostedemail.com: domain of pfalcato@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=pfalcato@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1748984389; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Tbh/wSI18MgZkL0lNSZSfVY7UbYTbmhbITCCvYgLRSk=; b=MxzPWoYSXvgQWWzk9Gwe2yMRgBMVlbOi8jkgROdRbTXvC5FNt1BB0e7FGdoiJDU13LYp0T UdR6U5PLDaMkalyraWRpF4WcOxbRVTR7xuzN2fGtkYTLz9D5HisR38pk/ZnwCiMpZCBpGv IYl0t6bbS2Oc+3jcPKG30lJtLR5Iksc= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=a8VhylAd; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=RZsHFvqs; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=a8VhylAd; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=RZsHFvqs; spf=pass (imf18.hostedemail.com: domain of pfalcato@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=pfalcato@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1748984389; a=rsa-sha256; cv=none; b=Mp3yYAUTuKXRNR5/d94EIlkZLEuHRGbDP+qWNSRnHvzdKSH2bVW2qkHja4PLkrxnqQSAbh sl/xusD0PQq8cGsJ06MHWXJqA9j6i6yYw7htuTd3dJhLCj/Hkm5/ddIEMdCLR2BdjSeK04 D8XdM0YzzuozRexLbMWGPPpkklVeyQQ= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5322F21C25; Tue, 3 Jun 2025 20:59:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1748984387; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Tbh/wSI18MgZkL0lNSZSfVY7UbYTbmhbITCCvYgLRSk=; b=a8VhylAd/iR4bokazEEmD2YvoNRPwofTT94bxIw3DM5XpP2Tojo6GsaSnZ/kQwdAIik83Z X/iTZPZDbClKOlSGLFYcWNnJ+TfZQXPznvqE0fHi9umjSSx7vv9ChYg8zWVwhfUO6lbF6n ynDFUe2xvMzNcoi2RSYNDwee+uPruoI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1748984387; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Tbh/wSI18MgZkL0lNSZSfVY7UbYTbmhbITCCvYgLRSk=; b=RZsHFvqsiqbegcvpCXl4VFK3KcYyLW3Fq+NCy2bUCuOMp5BqE1nWeq3NJ9gk6JhdhWUIrX yHoYjdHicmf9jZDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1748984387; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Tbh/wSI18MgZkL0lNSZSfVY7UbYTbmhbITCCvYgLRSk=; b=a8VhylAd/iR4bokazEEmD2YvoNRPwofTT94bxIw3DM5XpP2Tojo6GsaSnZ/kQwdAIik83Z X/iTZPZDbClKOlSGLFYcWNnJ+TfZQXPznvqE0fHi9umjSSx7vv9ChYg8zWVwhfUO6lbF6n ynDFUe2xvMzNcoi2RSYNDwee+uPruoI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1748984387; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Tbh/wSI18MgZkL0lNSZSfVY7UbYTbmhbITCCvYgLRSk=; b=RZsHFvqsiqbegcvpCXl4VFK3KcYyLW3Fq+NCy2bUCuOMp5BqE1nWeq3NJ9gk6JhdhWUIrX yHoYjdHicmf9jZDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 78D6D13A1D; Tue, 3 Jun 2025 20:59:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id tvIpGkJiP2iDGwAAD6G6ig (envelope-from ); Tue, 03 Jun 2025 20:59:46 +0000 Date: Tue, 3 Jun 2025 21:59:46 +0100 From: Pedro Falcato To: Lorenzo Stoakes Cc: Barry Song <21cnbao@gmail.com>, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Barry Song , "Liam R. Howlett" , David Hildenbrand , Vlastimil Babka , Jann Horn , Suren Baghdasaryan , Lokesh Gidra , Tangquan Zheng Subject: Re: [PATCH RFC v2] mm: use per_vma lock for MADV_DONTNEED Message-ID: References: <20250530104439.64841-1-21cnbao@gmail.com> <0b96ce61-a52c-4036-b5b6-5c50783db51f@lucifer.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0b96ce61-a52c-4036-b5b6-5c50783db51f@lucifer.local> X-Rspamd-Action: no action X-Rspamd-Queue-Id: 0F00C1C0007 X-Stat-Signature: uxhqhbrnhqkjeasrpsniqgejpxje5h1h X-Rspam-User: X-Rspamd-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HWRqzTBw4tu7CG/HDTRAs7FnDxzvstRpAQ9thMB2kLhEgT3ieqlKplg10QKOjrToemIjZQEB4Num5i7Ifq7/HyXzSGSOyoEQzzNe8Rca/vJ61AsmnkGukRz4shMU27Eb+Ld/iQbFFX8W56FBiLBgsgvpQoI7ofay2gwHsmiYIxwHSuRc0O9Tm/o/6LcxzBwoUZq82b4O+sHi96LsKNoCZFReax6+YNxdFbq0riu3bWdqXVooZxz5zG0DYMOUVEbu2Xk9WPS9C+mkdchFeqY+z4qDDtL9AlJbp04XRdQd8fxZOy7VpGv3osN0Yu6Oxu8S8B1M4REkyz1Tw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Tue, Jun 03, 2025 at 07:43:04PM +0100, Lorenzo Stoakes wrote: > Hi Barry, > > As promised, I enclose a patch to give a sense of how I think we might > thread state through this operation. > > There's a todo on the untagged stuff so you can figure that out. This is > based on the v1 so it might not encompass everything you addressed in the > v2. > > Passing in madv_behavior to madvise_walk_vmas() twice kinda sucks, I > _despise_ the void *arg function ptr stuff there added just for the anon > vma name stuff (ughhh) so might be the only sensible way of threading > state. > > I don't need any attribution, so please use this patch as you see > fit/adapt/delete/do whatever with it, just an easier way for me to show the > idea! > > I did some very basic testing and it seems to work, but nothing deeper. > > Cheers, Lorenzo > > ----8<---- > >From ff4ba0115cb31a0630b6f8c02c68f11b3fb71f7a Mon Sep 17 00:00:00 2001 > From: Lorenzo Stoakes > Date: Tue, 3 Jun 2025 18:22:55 +0100 > Subject: [PATCH] mm/madvise: support VMA read locks for MADV_DONTNEED[_LOCKED] > > Refactor the madvise() code to retain state about the locking mode utilised > for traversing VMAs. > > Then use this mechanism to permit VMA locking to be done later in the > madvise() logic and also to allow altering of the locking mode to permit > falling back to an mmap read lock if required. > Just as a quick drive-by comment: I was playing around with using per-vma locks for GUP and mm_populate a few weeks ago. I never actually finished the work (and I still plan on getting around doing it Eventually(tm)), but my final concept of an approach was to simply read-lock every VMA in a range (if that fails, go back to the mmap_lock). I *think* it works, and doesn't have the same limitation for single VMAs. I understand this is a super handwavy suggestion, but I know this discussion has been happening and I just wanted to get this idea out of obscure IRC logs :) -- Pedro