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 32047CCA47C for ; Sun, 3 Jul 2022 14:28:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B714F6B0074; Sun, 3 Jul 2022 10:28:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B1EA26B0073; Sun, 3 Jul 2022 10:28:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E8CB8E0001; Sun, 3 Jul 2022 10:28:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 930806B0072 for ; Sun, 3 Jul 2022 10:28:30 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 6A9D4120552 for ; Sun, 3 Jul 2022 14:28:30 +0000 (UTC) X-FDA: 79646019180.26.27ED75C Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf15.hostedemail.com (Postfix) with ESMTP id F0904A0048 for ; Sun, 3 Jul 2022 14:28:27 +0000 (UTC) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 263CKcEm019430; Sun, 3 Jul 2022 14:28:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=pp1; bh=ozJNy3LQn43tBza0iUEN2b2WnMuRcMdo6NOyX1L4m28=; b=pgQCi2Dbg1xLoXueOUO26HxABNBjnnDP00Zbsay4+MD0fJYzd+TdHminS8/ClEXTrEzK 8Rv3o5/ij/VROJ8yKgdw+5/ESSPxgUuVaAp0jUJXikzoLnJzcHZXEvv9gBI/5zhW1kkF Ld0SDL8cwTkdiXFq41VOuDH/b9uMDPLOeuYGYisfawPyBPrknipmqJ9df2K8xdQJpHI3 Qaa3Vez4fzg48NJMH0wXeaE8qGPzHzJpgSeaRJX/3/duL2CG1bZ2v6jOEHLjxg0bdo/B eRt1ujE0Rq2xmQwsvtmkv5atx7OTpW7p+edkor5WT1mbufw4kr7YHFgQN7UezamH7SXy vw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3h3b1mj1ce-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 03 Jul 2022 14:28:23 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 263ESM7N012636; Sun, 3 Jul 2022 14:28:22 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3h3b1mj1c2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 03 Jul 2022 14:28:22 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 263ELWpK010513; Sun, 3 Jul 2022 14:28:20 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03ams.nl.ibm.com with ESMTP id 3h2dn8shkr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 03 Jul 2022 14:28:20 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 263ESIdq19530118 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 3 Jul 2022 14:28:18 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6E02842041; Sun, 3 Jul 2022 14:28:18 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D4DEF4203F; Sun, 3 Jul 2022 14:28:17 +0000 (GMT) Received: from linux.ibm.com (unknown [9.145.191.226]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Sun, 3 Jul 2022 14:28:17 +0000 (GMT) Date: Sun, 3 Jul 2022 17:28:15 +0300 From: Mike Rapoport To: Baolin Wang Cc: Matthew Wilcox , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v3 2/3] mm: Add PUD level pagetable account Message-ID: References: <6a6a768634b9ce8537154264e35e6a66a79b6ca8.1656586863.git.baolin.wang@linux.alibaba.com> <1234a28a-dca0-5836-9066-4ab2d4fbcc95@linux.alibaba.com> <17df0d3c-caaf-ee34-f702-1d4e7674887f@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <17df0d3c-caaf-ee34-f702-1d4e7674887f@linux.alibaba.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: PH5VaFDTS_wazcqZIoZps9_7V-Er-vpy X-Proofpoint-ORIG-GUID: fxtT3PDirMY2o-X1oY79FkkBeS1YYEAa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-03_09,2022-06-28_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 clxscore=1015 spamscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2207030062 ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=pgQCi2Db; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf15.hostedemail.com: domain of rppt@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=rppt@linux.ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656858508; a=rsa-sha256; cv=none; b=xQbtB8BvMPZngttJKLgg3Hrjw5mRK4FxnKFiI1QUqSeaKekS/RL9lOyPfE8LCqroK0CPXF rghjgfvQsFac3Lj5HiXOQLLfZX3c+sUhh+tALnrUZO0IC7n/bqy/TscTfjlTSJj9VTgS2c V1D0qI16IMewfcTPUFVimYe2efO9JfE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656858508; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ozJNy3LQn43tBza0iUEN2b2WnMuRcMdo6NOyX1L4m28=; b=JH/cKoqkJTQM6kyLXrXpuPlDVA9QzkYKMNLPYE24cKqdwhkURlMeHRNTMWSSijxrPrBCpW iumwM6ocwxWJ3QXa+DHF4onJYo09GLknzCJH251Bv94xysKKLjeSSYs2cd6zWC/87H5T9t Z1d/jeAtxzkjOW6sFFY5b7wLRfI5MX8= X-Stat-Signature: yxmcg8k7xoiej61dgtf7xurkd4zb1hgs X-Rspamd-Queue-Id: F0904A0048 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=pgQCi2Db; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf15.hostedemail.com: domain of rppt@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=rppt@linux.ibm.com X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1656858507-940897 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 Sun, Jul 03, 2022 at 10:06:32PM +0800, Baolin Wang wrote: > > > On 7/3/2022 11:40 AM, Matthew Wilcox wrote: > > On Fri, Jul 01, 2022 at 04:04:21PM +0800, Baolin Wang wrote: > > > > Using pgtable_pud_page_ctor() and pgtable_pud_page_dtor() would be > > > > consistent with what we currently have for PTEs and PMDs. > > > > > > > > This applies to all the additions of pgtable_page_dec() and > > > > pgtable_page_inc(). > > > > > > OK. I can add pgtable_pud_page_ctor() and pgtable_pud_page_dtor() helpers to > > > keep consistent, which are just wrappers of pgtable_page_inc() and > > > pgtable_page_dec(). > > > > I think you misunderstand Mike. > > > > Don't add pgtable_page_inc() and pgtable_page_dec(). Just add > > pgtable_pud_page_ctor() and pgtable_pud_page_dtor(). At least, that > > was what I said last time you posted these patches. > > My concern is that I need another helpers for kernel page table allocation > helpers, if only adding pgtable_pud_page_ctor() and pgtable_pud_page_dtor() > like below: > > static inline void pgtable_pud_page_ctor(struct page *page) > { > __SetPageTable(page); > inc_lruvec_page_state(page, NR_PAGETABLE); > } > > static inline void pgtable_pud_page_dtor(struct page *page) > { > __ClearPageTable(page); > dec_lruvec_page_state(page, NR_PAGETABLE); > } > > So for kernel pte page table allocation, I need another similar helpers like > below. However they do the samething with > pgtable_pud_page_ctor/pgtable_pud_page_dtor, so I am not sure this is good > for adding these duplicate code. > > static inline void pgtable_kernel_pte_page_ctor(struct page *page) > { > __SetPageTable(page); > inc_lruvec_page_state(page, NR_PAGETABLE); > } > > static inline void pgtable_kernel_pte_page_dtor(struct page *page) > { > __ClearPageTable(page); > dec_lruvec_page_state(page, NR_PAGETABLE); > } > > Instead adding a common helpers seems more readable to me, which can also > simplify original pgtable_pmd_page_dtor()/pgtable_pmd_page_ctor(). Something > like below. > > static inline void pgtable_page_inc(struct page *page) > { > __SetPageTable(page); > inc_lruvec_page_state(page, NR_PAGETABLE); > } > > static inline void pgtable_page_dec(struct page *page) > { > __ClearPageTable(page); > dec_lruvec_page_state(page, NR_PAGETABLE); > } > > static inline void pgtable_pud_page_ctor(struct page *page) > { > pgtable_page_inc(page); > } > > static inline void pgtable_pud_page_dtor(struct page *page) > { > pgtable_page_dec(page); > } > > For kernel pte page table, we can just use > pgtable_page_inc/pgtable_page_dec(), or adding > pgtable_kernel_pte_page_ctor/pgtable_kernel_pte_page_dtor, which just > wrappers of pgtable_page_inc() and pgtable_page_dec(). > > Matthew and Mike, how do you think? Thanks. I actually meant to add pgtable_pud_page_ctor/dtor() as a wrapper for the new helper to keep pud tables allocation consistent with pmd and pte and as a provision for the time we'll have per-page pud locks. For the accounting of the kernel page tables a new helper does make sense because there are no locks to initialize for the kernel page tables. I can't say that I'm happy with the pgtable_page_inc/dec names, though. Maybe page_{set,clear}_pgtable()? -- Sincerely yours, Mike.