Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp62916rwb; Thu, 12 Jan 2023 03:36:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXtMZMT2w9YADRrSczTGanmqzcwnc5nUFM4GWdQegT5uNW5Wby7Bh+CLLbjJ4uSnC3j2ZjYB X-Received: by 2002:a05:6402:548e:b0:479:8303:dc1c with SMTP id fg14-20020a056402548e00b004798303dc1cmr59280157edb.7.1673523375873; Thu, 12 Jan 2023 03:36:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673523375; cv=none; d=google.com; s=arc-20160816; b=wDbkfTpwpaso+Zk4WJgixvXFse2g/EyERS3qyBigzvQq4SRh3o3wDTSJ/27POd3JeW 9dnmvV5113WEY2+mFcYxYcwpKa/fmI49HqZ9/4Twy71Rilii+sRMBYQZIbzgZihE8iTo 5P1hq1fT0p+AmZu0gGzIrq8mGGrwpjWnzKqT5scQvfFQuPqr3ysTO1uVrf5VYmmU6/Uf BdLbRySCAQ2d9+P4lnQ0jbt5swXiFiksohr6ruYY5dHqEGAy3mANd0QcXeQRzgB+XskY g2AK6QIaMOpB+n84Ck1JgbNCEeETJxAmkIGQleZw2gJs9qXFWh0kO1uOWPs4J9zVQrM0 4Dpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=whGPt03J1CPs9FsWnT2ZYn3HZP04QDqHTeMEVO3NILs=; b=BvpwVqpW1jga37RRIwVFBnwZ3aRYPFkVvXTEadd5NNFuokXzjqb7KuvTzY3JTmU6Pw oFL9pbF0mcDOhXJT+VTLtpYeCEBdEPeAN0PxcwDhttoNlUJ594+aAEjHDkidV/FrHYNP Lz5D04fD9lnh8R5oT9+SPIKaP6nUylp4jp4R8nOd1EIKJKAqgDSlEr2anCvnyibTmFT7 DR/gn5/Z7mo9NQQ0aAFuC2gRWXwawSPlSpNr+lFzLp7JeCoxpgPkWfROlg5UOw8iTe1I +gfxX3pf3gQdF7FPeZaVf0sJMW+ztSmcxh6XrDbNggjzhiefuA6IJQ2h32KOhWQ1ZX9C ZImQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=elaAoNGP; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h2-20020a056402280200b00493969bd008si21062356ede.121.2023.01.12.03.36.03; Thu, 12 Jan 2023 03:36:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=elaAoNGP; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236069AbjALLDg (ORCPT + 51 others); Thu, 12 Jan 2023 06:03:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232440AbjALLCt (ORCPT ); Thu, 12 Jan 2023 06:02:49 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46B6656898 for ; Thu, 12 Jan 2023 02:55:16 -0800 (PST) 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-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.