From patchwork Mon Dec 23 09:40:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13918671 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 018CAE7718B for ; Mon, 23 Dec 2024 09:44:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 906086B009B; Mon, 23 Dec 2024 04:44:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B5C66B009C; Mon, 23 Dec 2024 04:44:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7585B6B009D; Mon, 23 Dec 2024 04:44:23 -0500 (EST) 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 5747B6B009B for ; Mon, 23 Dec 2024 04:44:23 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id F39F1C0526 for ; Mon, 23 Dec 2024 09:44:22 +0000 (UTC) X-FDA: 82925737650.16.18A12EE Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) by imf01.hostedemail.com (Postfix) with ESMTP id 5E1CA40017 for ; Mon, 23 Dec 2024 09:43:52 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=dTxtKPH6; spf=pass (imf01.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.179 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734947021; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xY41yoAggnrpKZDOvMIy0+FhpPRF9QFn+bDK7HKPzWw=; b=79R8awp2CZ50a4THD8L7005w1u8k+K6ZmytWCjZGjlPnkxehx2jIEl/VF1L5MlWQnaidxC 73+6QImL1s4XVZoxqFfC4Y4sbN4QyMpyymD/lyKlLuQ3sl/OZ+nsqdDAxbu5fDphAUS2nM wLvLaGnJsqMM8LwnbHvQWxlOCsXoRMg= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=dTxtKPH6; spf=pass (imf01.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.179 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734947021; a=rsa-sha256; cv=none; b=6Kuy8ACEibrjsphiVlelQ9IS4EmNFZvS7GisHmBnruo8lgPV/b6wRRmbHL6ve2qB3AY8YP BLCFoTzrDYaNLi3WEe/VNlo2upV7XXCHOvCut0yVLeD3ea2XSTe2iRFTnlhnPEAWfJB43I DSFa+d+UAcGKiYeO8NO8vVY5+vn5TR0= Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-7ea9739647bso2563603a12.0 for ; Mon, 23 Dec 2024 01:44:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1734947060; x=1735551860; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xY41yoAggnrpKZDOvMIy0+FhpPRF9QFn+bDK7HKPzWw=; b=dTxtKPH6qVUaUi/wWWd9ZPwogxL1MGRxqLi0YCSJz28w2g5gn61u49kZ2xtw0RGFbb JEDwHLj9Z7Pct9NdaATmX5dJ+gGEMPvRq4uSaWhsa5N3XYb1eE5znRQ2eff+Q2Va7uuk d6zVM2dbptINW0xZ+F4+lsRbj0d4E7dUFV6RVRSVYEqlBCBosPHKKoZT22KxLbkuo7EQ clnksrT0iMzR7hCI2YPTSNbsoRGG+SrjWGDU+XIktQcVpCmRa6qPYQNxzD43Iyky8EOs m8UA2hGr5Z24VL49Krwm3KnPFaFivt0m2iCRF/mZrSqelb5Tz8siWyg6VO4r3AHfgvuG cMvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734947060; x=1735551860; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xY41yoAggnrpKZDOvMIy0+FhpPRF9QFn+bDK7HKPzWw=; b=dW0nQhn/J25Wc+iq3DfDnsqRM2LlvhhJFLFQ20oJrv3d2O2bWGakz9PKTgZklVwOjH YZcxDW0jhbSDK8yaGAypM0fiFIJhLGz4OrhZBFQ3TyQwLuoB704ZPQd0nwtDHMva54S6 ldy7DJ4OV0tF7illUcFbC+yXlrHukn8ohXge6BqAW0m2Cr6BYWDRX8a7CCCGM8vC1jra Gg7YoNyVIVZ4ZIHiQTI/VFrNkYsjTMzDCL7QEjSz8KMjjcjT1/w6aK8ooNn5iAgXA6CO QeGbXVflYczAul+qKEEVfyoqLZ2OlYoAvyaOvgxP+h04pOhBerBvHEbb1SQaUk6cMBwX KIHw== X-Gm-Message-State: AOJu0YwKp/njDvosZzjSlyFdW7hKwBcUvbvNJq4jAXGoz9OSkb87BbVZ KFQRIwW46TDWoCCd+ydU6QtT3OzWmn9Rmp7crmbhcPxiMe7TaiiAgGRq8X/4rtk= X-Gm-Gg: ASbGncs4Cd558SZtJga2ze7thWQ48yI5wEvJhFy6MrQyoOEIx65TsDA5cVxy7MPTFnV u9ytJO9wSMQV/SXF8sUCeqRTKTwFBlWpXFnkNhZDuZyXeook04yHHiERtG1wOmkRxu2qpvDeiXG hKluhtNO7uMQMuzw7yqSw+6rw4MAO/Z75uU/5t9jYNm2Te+acKDHFPpxCLtBTG7sAOTAnR5Jm1L FxWkwD0ngNZMID5JQJgLVMmcxVPprdOyW+yXR1gGAhhW/YRoKqhvHFo7r99Hb4Vj1+azkTTFx7D JGLq3o/ZpxiVG00Ehned3w== X-Google-Smtp-Source: AGHT+IF7O/ZMCvOOtywTANPL1zwoTq06yXXDMhnBrPgrfov3E/r1DzhOhOYD8wImAojzeP7TdceoFw== X-Received: by 2002:a05:6a21:3285:b0:1e1:aad7:d50d with SMTP id adf61e73a8af0-1e5e084b681mr22018514637.46.1734947059944; Mon, 23 Dec 2024 01:44:19 -0800 (PST) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.150]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8486c6sm7468309b3a.85.2024.12.23.01.44.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Dec 2024 01:44:19 -0800 (PST) From: Qi Zheng To: peterz@infradead.org, agordeev@linux.ibm.com, kevin.brodsky@arm.com, tglx@linutronix.de, david@redhat.com, jannh@google.com, hughd@google.com, yuzhao@google.com, willy@infradead.org, muchun.song@linux.dev, vbabka@kernel.org, lorenzo.stoakes@oracle.com, akpm@linux-foundation.org, rientjes@google.com, vishal.moola@gmail.com, arnd@arndb.de, will@kernel.org, aneesh.kumar@kernel.org, npiggin@gmail.com, dave.hansen@linux.intel.com, rppt@kernel.org, ryan.roberts@arm.com Cc: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-arch@vger.kernel.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, loongarch@lists.linux.dev, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-sh@vger.kernel.org, linux-um@lists.infradead.org, Qi Zheng Subject: [PATCH v3 06/17] s390: pgtable: add statistics for PUD and P4D level page table Date: Mon, 23 Dec 2024 17:40:52 +0800 Message-Id: <35be22a2b1666df729a9fc108c2da5cce266e4be.1734945104.git.zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 5E1CA40017 X-Rspam-User: X-Stat-Signature: 1pd7y1rkja9fdnaszcafpe196fbgg7ka X-HE-Tag: 1734947032-297404 X-HE-Meta: U2FsdGVkX18FsQJ1TwON+8zF2nj9VHeVCkF8VQtSKonnK/fuTCwnAVkQsjfoqkvBvqghf0c4jPSJhPa9OermrK+ZtaOvRUaxOhOI8gc9Xm/fPz5chUQaB4E89yfrzSmfKymOBBw0YERIuhqPv2+5hlHS8I7cFp/9Leb9TiOZQgzYfjfIIY48HXJKPo1rYUxjgF0PiH3GdveWquMzB6O7+O4yhZLosXpGXC6VK3/Of8VeJXKZN/ll72YBWGUpHbfouppTfz+to9F9MY7GrRKALPzz6NLWDBZNaU/eUX6e5jS6Abm9Hyy7Pq8XdeKr9bxW6bpa0kHCQ36y8NWJuLrtPZItmK8RcoQL4q/IUZlz6qKTXeI+ETh+seq5c751WCvQT8xaw3uF7d5Xn723kvxb5brwucwhmvb5IYeoAJfJGPqfP+8ruy4+MUktil+QgrMuBM5nbn8vsPrA0HLYytL9qPclGxXdwaMN+IQn+KmdV/vKVsefzb5vT/U/NToisYDQUyd4iNoWM75tC36goJcNVO9mdSNBWQ6zQHWHPMoepIDqiLgOrNMMDcXDGV9tqRB2Ny6AcPtIpNBP8uao/rnK5J7IqOdMmcZ01D+kYgByo7l1AyxWjfPj6U5W0TesR5dCHwiH7kU4qujMmpZEwbVKiixrmhBKFd3cAjZqiUfODS9Zme302U57B7BDrlMidDXmg6jv2+bOmgmiBB2cjC+INMW12HQdUJNt7WR9t3GbErDhVcDCKrfqBmY/1sdwcMc9hZKSSi+ZQDe2Vh4RWz46P/QlbKcnIBQHOXdQOHlGEeQaAzhD7VtZQKMWWXCrx8xkx4kE/BCPrJrkxIauFCkVehk5/xc5hSasFjdNh2h4wyVzQI6VDCPH2bbEZdFgnXDE51/x76YKPlo+gOit3sUDZ/qHfMmpsAtpYcfDJHraTdAjpIOHHcsheVfRlHnrdzyQk2KXs3crzI55xB6uj9l ALmFogBT WozZ8a86kpxY0wLI2vdKFvhQiyHMOl2nn97hn1XmrrwEveLg2cAQXjzdlNxQGYIJ61T8Z/b8etxeSjvZRPuCSv40g6ZR0VWBSzXOqkSxgt5EdlGzCVz/1pqKrz/CjMaP+m5MCrQ9q1rdZAxlZNI7Sh3tM3yrdtGjmUW/WOw06MCWhQdFBtYHaifZBfyvTjydk624h/eZmy/KWAE33x76p5le7XYY3Qiudw15Yhh+0wMpMA1/OzbnXfdubKkYzLUAUeIDfexHSR9XgoKPurvi8/P6b2nHuH59/p7AEOzZ8xchCmtfnZzVLxt/qx8iTMDarZ1/NiSXk8higefJjIlgsLZ7c++qemgUCNa2przI9cUEBJaMxRZ0bgOxDJpq+p/ZFRMubSUy+VgW8I0R3+hy/Q84S406cOB2ZzNG0dHyQe2U+w6v+qq004D1XnR2dXsSSkL8BAx5RrORDbdaHMWR/2mLuzw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000017, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Like PMD and PTE level page table, also add statistics for PUD and P4D page table. Signed-off-by: Qi Zheng Suggested-by: Peter Zijlstra (Intel) Cc: linux-s390@vger.kernel.org --- arch/s390/include/asm/pgalloc.h | 29 +++++++++++++++++++------- arch/s390/include/asm/tlb.h | 37 +++++++++++++++++---------------- 2 files changed, 40 insertions(+), 26 deletions(-) diff --git a/arch/s390/include/asm/pgalloc.h b/arch/s390/include/asm/pgalloc.h index 7b84ef6dc4b6d..a0c1ca5d8423c 100644 --- a/arch/s390/include/asm/pgalloc.h +++ b/arch/s390/include/asm/pgalloc.h @@ -53,29 +53,42 @@ static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long address) { unsigned long *table = crst_table_alloc(mm); - if (table) - crst_table_init(table, _REGION2_ENTRY_EMPTY); + if (!table) + return NULL; + crst_table_init(table, _REGION2_ENTRY_EMPTY); + pagetable_p4d_ctor(virt_to_ptdesc(table)); + return (p4d_t *) table; } static inline void p4d_free(struct mm_struct *mm, p4d_t *p4d) { - if (!mm_p4d_folded(mm)) - crst_table_free(mm, (unsigned long *) p4d); + if (mm_p4d_folded(mm)) + return; + + pagetable_p4d_dtor(virt_to_ptdesc(p4d)); + crst_table_free(mm, (unsigned long *) p4d); } static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long address) { unsigned long *table = crst_table_alloc(mm); - if (table) - crst_table_init(table, _REGION3_ENTRY_EMPTY); + + if (!table) + return NULL; + crst_table_init(table, _REGION3_ENTRY_EMPTY); + pagetable_pud_ctor(virt_to_ptdesc(table)); + return (pud_t *) table; } static inline void pud_free(struct mm_struct *mm, pud_t *pud) { - if (!mm_pud_folded(mm)) - crst_table_free(mm, (unsigned long *) pud); + if (mm_pud_folded(mm)) + return; + + pagetable_pud_dtor(virt_to_ptdesc(pud)); + crst_table_free(mm, (unsigned long *) pud); } static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long vmaddr) diff --git a/arch/s390/include/asm/tlb.h b/arch/s390/include/asm/tlb.h index e95b2c8081eb8..b946964afce8e 100644 --- a/arch/s390/include/asm/tlb.h +++ b/arch/s390/include/asm/tlb.h @@ -110,24 +110,6 @@ static inline void pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd, tlb_remove_ptdesc(tlb, pmd); } -/* - * p4d_free_tlb frees a pud table and clears the CRSTE for the - * region second table entry from the tlb. - * If the mm uses a four level page table the single p4d is freed - * as the pgd. p4d_free_tlb checks the asce_limit against 8PB - * to avoid the double free of the p4d in this case. - */ -static inline void p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d, - unsigned long address) -{ - if (mm_p4d_folded(tlb->mm)) - return; - __tlb_adjust_range(tlb, address, PAGE_SIZE); - tlb->mm->context.flush_mm = 1; - tlb->freed_tables = 1; - tlb_remove_ptdesc(tlb, p4d); -} - /* * pud_free_tlb frees a pud table and clears the CRSTE for the * region third table entry from the tlb. @@ -140,11 +122,30 @@ static inline void pud_free_tlb(struct mmu_gather *tlb, pud_t *pud, { if (mm_pud_folded(tlb->mm)) return; + pagetable_pud_dtor(virt_to_ptdesc(pud)); tlb->mm->context.flush_mm = 1; tlb->freed_tables = 1; tlb->cleared_p4ds = 1; tlb_remove_ptdesc(tlb, pud); } +/* + * p4d_free_tlb frees a p4d table and clears the CRSTE for the + * region second table entry from the tlb. + * If the mm uses a four level page table the single p4d is freed + * as the pgd. p4d_free_tlb checks the asce_limit against 8PB + * to avoid the double free of the p4d in this case. + */ +static inline void p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d, + unsigned long address) +{ + if (mm_p4d_folded(tlb->mm)) + return; + pagetable_p4d_dtor(virt_to_ptdesc(p4d)); + __tlb_adjust_range(tlb, address, PAGE_SIZE); + tlb->mm->context.flush_mm = 1; + tlb->freed_tables = 1; + tlb_remove_ptdesc(tlb, p4d); +} #endif /* _S390_TLB_H */