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: 12907615 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BCA98C43334 for ; Wed, 6 Jul 2022 09:01:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ijDx9lstfBgoUsgDuNvu3HyxgBf0ddLDjvjibTFufqE=; b=hwfUwBmtqAlwU1 bUhovPGChK9vKG+o7PxRU64Dm/aT8HSuMYtg+UeVzLVeSj5xI/dSRgHTYoD5C0C/Qf/bTLoVY2+ne rO3q+kzF0JTpYexGc2XX65PhA+OE0x2DTvQ0QEyNUD93hT5Or8SUf0gzd240FCFGy3dGBkKjWNsBF smBp3VmLivkkVdfmoV6DrwsWV0SfQ5qQ6NDYbrJgHcO7Q9CZiPFN5iYul2c3v32prgi2HvuofaIox GrAPzSRWuRi8d+0Y3d5ipS+CRQC5TPqSdfDfAQq4WJKuUv9u+X1rYY1iVbMM7p3JfuEeevBTSZ17E OQ5NIHnRYh8TteW05L8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o90t1-007ZQr-AX; Wed, 06 Jul 2022 08:59:55 +0000 Received: from out199-5.us.a.mail.aliyun.com ([47.90.199.5]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o90sd-007ZBD-54 for linux-arm-kernel@lists.infradead.org; Wed, 06 Jul 2022 08:59:33 +0000 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220706_015931_507201_620E7CFA X-CRM114-Status: GOOD ( 10.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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(-)