Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp183291iog; Fri, 24 Jun 2022 01:50:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1saVp0Js5jNgLbR9k0rhZfJMjV1iFOonYBkdxSQWXI7REjHs2C5n18yRLkBw2UuPu0YQsSn X-Received: by 2002:a17:902:d4c2:b0:166:46c9:577b with SMTP id o2-20020a170902d4c200b0016646c9577bmr42845077plg.66.1656060639963; Fri, 24 Jun 2022 01:50:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656060639; cv=none; d=google.com; s=arc-20160816; b=x5U6E5hzArjurIHphuCrPgqVESnL/wyxrwd4jSlZWsml/zlaDJVpwqJFiY+X+cG2wD 4Att5vTh6blIEF/khFoYgZsohMzJFtg8VFWn3SuMtG63BInJVOGwcfbzlBbmq2LbvDxU aSbTMOduMYpPlNfeCzSRiE2xHHPUaPhTYbhjjJedGIQPnRBw4MxaQ3BlRs3leO6D8BXA PgHzCpDyMSdOXLDkVwuI7WYh9Rupw5E85W9Aj2GkaK962MKP7Yb8A149Wj8UTx04G5l9 YaRcbqqUdKbHF6udvHhoV+UnHi5y4IWqiBq4yBOLypnuPomIwiL9oHyxAWfa+hoLwvJc 4J3A== 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:subject:user-agent:mime-version:date:message-id; bh=LlRgDNT/PJPZ7DRmJGyQvOq1LBcGKAF4iGaQUEFLYmQ=; b=NLjgk+EdyqfFvSyaaAvFC215qE4MTQg2z3Zu5v7zw9OviAsZ1v0EC2eOkTH92/Q33v twzqb1zOJidxmKqmoIFk1r1ucCnglg6UbmF6x94H4OYYUkyo0+keAnI4y0hQAPnAq2z5 vnHxPeITucHB8Xs8j+FA1bVZggAWLe9hqL1LoT1WNQSf6PAOIFM/G+pIc9C3Rrx1VrDc hZ9AWXgStEg3g/KyV3BANifPmw18Ho/ZwrnUoJ30LxPhyHzg06Q13zdshmmBlEhrKMxg NYDNLVEHri07kODMAzOdyM9ttldtU/BxQNEhKxm/VPiYx3t5mDzZw5mnF1tqNAX2/qc9 /B0w== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x186-20020a6386c3000000b004087c2017fdsi1928238pgd.413.2022.06.24.01.50.26; Fri, 24 Jun 2022 01:50:39 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229923AbiFXIlq (ORCPT + 99 others); Fri, 24 Jun 2022 04:41:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229464AbiFXIlq (ORCPT ); Fri, 24 Jun 2022 04:41:46 -0400 Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB6506B8C4 for ; Fri, 24 Jun 2022 01:41:44 -0700 (PDT) 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 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 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()?