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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4377C433EF for ; Fri, 24 Jun 2022 08:41:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230050AbiFXIlr (ORCPT ); Fri, 24 Jun 2022 04:41:47 -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 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()?