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 A61F6C54EBC for ; Thu, 12 Jan 2023 10:55:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D0D28E0002; Thu, 12 Jan 2023 05:55:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 281068E0001; Thu, 12 Jan 2023 05:55:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 148F38E0002; Thu, 12 Jan 2023 05:55:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 05DCC8E0001 for ; Thu, 12 Jan 2023 05:55:18 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A2D7EA0DB3 for ; Thu, 12 Jan 2023 10:55:17 +0000 (UTC) X-FDA: 80345840274.01.384D638 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf10.hostedemail.com (Postfix) with ESMTP id 84DA1C000A for ; Thu, 12 Jan 2023 10:55:15 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=elaAoNGP; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=7kRp2d48; spf=pass (imf10.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673520915; a=rsa-sha256; cv=none; b=R2N1rv1I2jMex4CUaY3hq4cetLgCBnyNIOAncctJbfI4qp7dy1qCc1elr6/EXF1hF5A/hK kSykEwsmm9csmpso0/7EzKORS84EKf3KqpKcf6fxKTYGdYWmGbq3QRadqVg1w6oqbafaoR 9SyL0dL4gBfao8g4RW1fog2ur/3nbHA= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=elaAoNGP; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=7kRp2d48; spf=pass (imf10.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673520915; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=whGPt03J1CPs9FsWnT2ZYn3HZP04QDqHTeMEVO3NILs=; b=nthixv2myyPmIKunebPi41oRNwlvzZ132ibuyG7W61SImajZ9OrcYX+j0h6rSau/KqqF5i RcdCO/xV2NJ+jbrvuxRd4ytCki5Hv/Xg+wwR+5wtewpSaLUXGwBFh+jnXFj6XOv4hIr6gw HMOF32TQL7UW1uj90NltHLoBI+zq5q4= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BA2003E9EA; Thu, 12 Jan 2023 10:55:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1673520913; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=whGPt03J1CPs9FsWnT2ZYn3HZP04QDqHTeMEVO3NILs=; b=elaAoNGP/NY3U6WtYJASzz3uWdUPQNheEtZHsQWvxAeQg/OTkMuKGHKKT+B5CpiYuvDKbO BiF6WeOqiocxp0d8vm4FHUruSgGXzeWvhlI9olQvq4FbuyxHYr51JP3sTpJEGYhdbvfYrV jPeS0DDDK/RqSMDM5kqCz2JUZN0+G0A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1673520913; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=whGPt03J1CPs9FsWnT2ZYn3HZP04QDqHTeMEVO3NILs=; b=7kRp2d48Vr+kTB/rqAxN1ePRyxQIhfyzNf+G9q1BB2+wxoDUJqxyC7SUKgdWkfJWt6OEVk KLmYf9UShMsqMKBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8663713776; Thu, 12 Jan 2023 10:55:13 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id trjaHxHnv2NFLgAAMHmgww (envelope-from ); Thu, 12 Jan 2023 10:55:13 +0000 Message-ID: <50cc1bfc-6cee-dc98-7ed9-cc3f0c863c02@suse.cz> Date: Thu, 12 Jan 2023 11:55:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH v3 4/5] mm: mlock: update the interface to use folios Content-Language: en-US To: Lorenzo Stoakes , linux-mm@kvack.org, Andrew Morton , linux-kernel@vger.kernel.org Cc: Matthew Wilcox , Hugh Dickins , Liam Howlett , William Kucharski , Christian Brauner , Jonathan Corbet , Mike Rapoport , Joel Fernandes , Geert Uytterhoeven References: From: Vlastimil Babka In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Queue-Id: 84DA1C000A X-Rspamd-Server: rspam01 X-Stat-Signature: 49enbcjwrs9xpotf4bbcs7gzbhdn1jqj X-HE-Tag: 1673520915-737977 X-HE-Meta: U2FsdGVkX188zVALxt/ta90bAJjBh9Ezcwwzh8Xv02dXASDD7b+Fmg6KgKwcE7uL2xWYnT3Co1piAtuV1Rc0rfdsrCAXeS9FR/ARDQgN+P4oImnmRHkJFAe4XB1nZeo3y5NgKlXX3dF4Ti+y6f/ZJ5vfwUM5IzUOGuYcc8D+743DCA3zX7a/y+Fr35o+nYEqHMWI4bt7a8gT2jAJGsWanmKpJV2uLq5miOMa0lm1IGt3oMFMQ3vtnQPmHdKs/rzl9b+XAQSQhvLjP7Muro5Akj5NrYmZ6MS7JuZIwggLcknjHf8e6La0QWLyRma2eDhkiN5yp+o0HaidPvhPmTvpmkVTy5E0zsncgnPUxUureeP7MFds327bA8PtrHSYG+2Se4WR6uGsn++Zqe9W3k9k22UPKQP6xg7sfoha693Yif1BCINR67GqKV1A/Uv8PZwbuEA2vc/dMFc0a2dcgubuianZCaJfE5EOUmkobODID7tGhUyEE8sp3uA1o89zz2vWSBf2oLCMKhBa9aJGaGaXzp3te/dEhPkVRy7tsZC+tx24t0chzwfpv2Mgqvn+WXaGABbDntczWDmQhPdtJX92PM+IWvWibkd72kaTD/iS63TR+IGNr+yRx8CKW7MSPl08MdYPPswbfEwbiWT7CkkNlmyVkGeoF9mmLO6O7XQYIJYyKnx2fXgiIjaTsvQMLm28ayewbgJ/YxNUbLnJgspXMcGvCYPAKA85347pZuKcf4JDfyserdDAle+uQn5dQJNcY+uk8chGjiicQEozlvITx7/Bs585cBGT8gOPI+KER6lRqmrpRYqfxSrr+GPrp5JPGdYBS0Cw0wwHVqXK+eLOtscYa9SAXwOyYIadIaZN7gPexXVeJwMVnzLEvCmmVvXpxQx8hLv4Bnhvs7FrVSwCrF/X4CrPofcC 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: On 12/26/22 09:44, Lorenzo Stoakes wrote: > This patch updates the mlock interface to accept folios rather than pages, > bringing the interface in line with the internal implementation. > > munlock_vma_page() still requires a page_folio() conversion, however this > is consistent with the existent mlock_vma_page() implementation and a > product of rmap still dealing in pages rather than folios. > > Signed-off-by: Lorenzo Stoakes Acked-by: Vlastimil Babka With some suggestion: > --- > mm/internal.h | 26 ++++++++++++++++---------- > mm/mlock.c | 32 +++++++++++++++----------------- > mm/swap.c | 2 +- > 3 files changed, 32 insertions(+), 28 deletions(-) > > diff --git a/mm/internal.h b/mm/internal.h > index 1d6f4e168510..8a6e83315369 100644 > --- a/mm/internal.h > +++ b/mm/internal.h > @@ -515,10 +515,9 @@ extern int mlock_future_check(struct mm_struct *mm, unsigned long flags, > * should be called with vma's mmap_lock held for read or write, > * under page table lock for the pte/pmd being added or removed. > * > - * mlock is usually called at the end of page_add_*_rmap(), > - * munlock at the end of page_remove_rmap(); but new anon > - * pages are managed by lru_cache_add_inactive_or_unevictable() > - * calling mlock_new_page(). > + * mlock is usually called at the end of page_add_*_rmap(), munlock at > + * the end of page_remove_rmap(); but new anon folios are managed by > + * folio_add_lru_vma() calling mlock_new_folio(). > * > * @compound is used to include pmd mappings of THPs, but filter out > * pte mappings of THPs, which cannot be consistently counted: a pte > @@ -547,15 +546,22 @@ static inline void mlock_vma_page(struct page *page, > mlock_vma_folio(page_folio(page), vma, compound); > } > > -void munlock_page(struct page *page); > -static inline void munlock_vma_page(struct page *page, > +void munlock_folio(struct folio *folio); > + > +static inline void munlock_vma_folio(struct folio *folio, > struct vm_area_struct *vma, bool compound) > { > if (unlikely(vma->vm_flags & VM_LOCKED) && > - (compound || !PageTransCompound(page))) > - munlock_page(page); > + (compound || !folio_test_large(folio))) > + munlock_folio(folio); > +} > + > +static inline void munlock_vma_page(struct page *page, > + struct vm_area_struct *vma, bool compound) > +{ > + munlock_vma_folio(page_folio(page), vma, compound); > } > -void mlock_new_page(struct page *page); > +void mlock_new_folio(struct folio *folio); > bool need_mlock_page_drain(int cpu); > void mlock_page_drain_local(void); > void mlock_page_drain_remote(int cpu); I think these drain related functions could use a rename as well? Maybe replace "page" with "fbatch" or "folio_batch"? Even the old name isn't great, should have been "pagevec". But maybe it would fit patch 2/5 rather than 4/5 as it's logically internal even if in a .h file.