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 DB28CC43334 for ; Fri, 24 Jun 2022 08:41:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 731348E0203; Fri, 24 Jun 2022 04:41:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E0638E01F6; Fri, 24 Jun 2022 04:41:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5AAF08E0203; Fri, 24 Jun 2022 04:41:48 -0400 (EDT) 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 47B288E01F6 for ; Fri, 24 Jun 2022 04:41:48 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 203756091B for ; Fri, 24 Jun 2022 08:41:48 +0000 (UTC) X-FDA: 79612486296.22.0081141 Received: from out30-44.freemail.mail.aliyun.com (out30-44.freemail.mail.aliyun.com [115.124.30.44]) by imf09.hostedemail.com (Postfix) with ESMTP id 8E894140009 for ; Fri, 24 Jun 2022 08:41:45 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0VHGOxn4_1656060101; Received: from 30.97.49.29(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VHGOxn4_1656060101) by smtp.aliyun-inc.com; Fri, 24 Jun 2022 16:41:42 +0800 Message-ID: <1db60157-9f26-cc09-9a8d-2813a3a3ac95@linux.alibaba.com> Date: Fri, 24 Jun 2022 16:41:47 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [RFC PATCH v2 1/3] mm: Factor out the pagetable pages account into new helper function To: Matthew Wilcox Cc: akpm@linux-foundation.org, rppt@linux.ibm.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656060107; a=rsa-sha256; cv=none; b=eedwbCF2ubdyQDqYa7Dp1ygdItmU7rIVgfPCTQezYqOM8CyyE+HDlAs+fmQc08kn0sUhWB zUKccZoq+i8TWpgoZ7/64rxhTd7/mN8rowj7rSqy17L4X1D/+ThgZjOFWbp9G/JVGlBGj7 AgaagnWtMDMRj0gqMOuSl4YzOjt9g10= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.44 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656060107; 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; bh=LlRgDNT/PJPZ7DRmJGyQvOq1LBcGKAF4iGaQUEFLYmQ=; b=a/Bau/X8hp1QJuJlwRSi+hVbj0C9FSY5ZWK/oDD4eaDiJqVsb9T7L0disn0nGinAXEG9mB /HIPWZWs8ukn3PtZwKWQF6L9VkctQrBDBRlRnEmBdMZirkcjDrv2SZ55Z20eOYEMXM8YOS Jl8qielcJzbA/pn793jrqbFpIHM+wo4= X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 8E894140009 Authentication-Results: imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.44 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Rspam-User: X-Stat-Signature: 3swio5orcpx3iihcyy39ruiapr4ngn6z X-HE-Tag: 1656060105-119553 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 6/24/2022 12:07 AM, Matthew Wilcox wrote: > On Wed, Jun 22, 2022 at 04:58:52PM +0800, Baolin Wang wrote: >> +static inline void pgtable_set_and_inc(struct page *page) >> +{ >> + __SetPageTable(page); >> + inc_lruvec_page_state(page, NR_PAGETABLE); >> +} > > I don't like the names. The accounting is also wrong for non-order-0 > allocations. It should be > > mod_lruvec_page_state(page, NR_PAGETABLE, compound_nr(page)) Yes, seems need another patch to convert using compound_nr(). > > but it's probably better to change the API to pass in the number of > pages instead of recalculating it. Lots of callers will not calculate the number of pages, so I think we can just add the compound_nr() in the API firstly, which also can avoid changing lots of callers. > I can't think of a good name. What's wrong with just adding > > static inline bool pgtable_pud_page_ctor(struct page *page) > > to go along with the pte and pmd variants? IMHO that means we will need another function like pgtable_kernel_pte_page_ctor/dtor() to account kernel pagetable, however they do the same thing. So a common function which only do '__SetPageTable' and account pagetable will be more helpful. So how about pgtable_page_inc()/pgtable_page_dec()?