From patchwork Wed Jul 6 08:59:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 12907610 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 6E3A8C43334 for ; Wed, 6 Jul 2022 08:59:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C16AB6B0071; Wed, 6 Jul 2022 04:59:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BC7126B0073; Wed, 6 Jul 2022 04:59:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A8EC36B0074; Wed, 6 Jul 2022 04:59:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 962986B0071 for ; Wed, 6 Jul 2022 04:59:31 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 619F220E4F for ; Wed, 6 Jul 2022 08:59:31 +0000 (UTC) X-FDA: 79656076542.25.0CCC0B5 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by imf07.hostedemail.com (Postfix) with ESMTP id 755FA40011 for ; Wed, 6 Jul 2022 08:59:28 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R381e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=33;SR=0;TI=SMTPD_---0VIXd7j9_1657097961; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VIXd7j9_1657097961) by smtp.aliyun-inc.com; Wed, 06 Jul 2022 16:59:22 +0800 From: Baolin Wang To: akpm@linux-foundation.org Cc: rppt@linux.ibm.com, willy@infradead.org, will@kernel.org, aneesh.kumar@linux.ibm.com, npiggin@gmail.com, peterz@infradead.org, catalin.marinas@arm.com, chenhuacai@kernel.org, kernel@xen0n.name, tsbogend@alpha.franken.de, dave.hansen@linux.intel.com, luto@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, arnd@arndb.de, guoren@kernel.org, monstr@monstr.eu, jonas@southpole.se, stefan.kristiansson@saunalahti.fi, shorne@gmail.com, baolin.wang@linux.alibaba.com, x86@kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-csky@vger.kernel.org, openrisc@lists.librecores.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 0/3] Add PUD and kernel PTE level pagetable account Date: Wed, 6 Jul 2022 16:59:14 +0800 Message-Id: X-Mailer: git-send-email 1.8.3.1 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657097971; a=rsa-sha256; cv=none; b=G3kKv6ryhi6J96YNae1a6RnzgrdqiC3VkgYsAhaMaRE1CntJmjvTpySU932Xle22THTBbr A7FaSdsQJ4CLadYh9Hc3ONoZYIvIexErdqc9j+2OPuAWbG4cN+pLhSFe71dgOEypBaiFUQ y+Z3cheFJ5DEYpCnz93T6RAVFt2zwMI= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.132 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=1657097971; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=ITutpa+bOhiNbKA2/RiyunO2Ke0skpdc6Coe0ejbASk=; b=TAvR6dEelAeVJEgm+g7xm00DKAVhuWl5704hpXZibld346ivBZ5QHd57qrfjBnNwKS9i5u WbEmz+hKO/pSurpwamEVlKhYJQSQZYgNDw771PmtFki1HOr25olGKxaLebUCludZp/IyJC tf9zhdYUceEyDm+lCyd6qm6ZPK23960= Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: ja9uymmq4ehriax8xdca87yda7a5om5x X-Rspamd-Queue-Id: 755FA40011 X-HE-Tag: 1657097968-829221 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: Hi, Now we will miss to account the PUD level pagetable and kernel PTE level pagetable, as well as missing to set the PG_table flags for these pagetable pages, which will get an inaccurate pagetable accounting, and miss PageTable() validation in some cases. So this patch set introduces new helpers to help to account PUD and kernel PTE pagetable pages. Note there are still some architectures specific pagetable allocation that need to account the pagetable pages, which need more investigation and cleanup in future. Changes from RFC v3: - Rebased on 20220706 linux-next. - Introduce new pgtable_pud_page_ctor/dtor() and rename the helpers. - Change back to use inc_lruvec_page_state()/dec_lruvec_page_state(). - Update some commit message. link: https://lore.kernel.org/all/cover.1656586863.git.baolin.wang@linux.alibaba.com/ Changes from RFC v2: - Convert to use mod_lruvec_page_state() for non-order-0 case. - Rename the helpers. - Update some commit messages. - Remove unnecessary __GFP_HIGHMEM clear. link: https://lore.kernel.org/all/cover.1655887440.git.baolin.wang@linux.alibaba.com/ Changes from RFC v1: - Update some commit message. - Add missing pgtable_clear_and_dec() on X86 arch. - Use __free_page() to free pagetable which can avoid duplicated virt_to_page(). link: https://lore.kernel.org/all/cover.1654271618.git.baolin.wang@linux.alibaba.com/ Baolin Wang (3): mm: Factor out the pagetable pages account into new helper function mm: Add PUD level pagetable account mm: Add kernel PTE level pagetable pages account arch/arm64/include/asm/tlb.h | 5 ++++- arch/csky/include/asm/pgalloc.h | 2 +- arch/loongarch/include/asm/pgalloc.h | 12 +++++++++--- arch/microblaze/mm/pgtable.c | 2 +- arch/mips/include/asm/pgalloc.h | 12 +++++++++--- arch/openrisc/mm/ioremap.c | 2 +- arch/x86/mm/pgtable.c | 7 +++++-- include/asm-generic/pgalloc.h | 26 ++++++++++++++++++++++---- include/linux/mm.h | 34 ++++++++++++++++++++++++++-------- 9 files changed, 78 insertions(+), 24 deletions(-)