From patchwork Sat Dec 14 09:02:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13908429 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 8C972E77180 for ; Sat, 14 Dec 2024 09:04:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1EAE96B0093; Sat, 14 Dec 2024 04:04:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 173AF6B0095; Sat, 14 Dec 2024 04:04:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F06A86B0096; Sat, 14 Dec 2024 04:04:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id CC04A6B0093 for ; Sat, 14 Dec 2024 04:04:16 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5FBE3B0F9A for ; Sat, 14 Dec 2024 09:04:16 +0000 (UTC) X-FDA: 82892977104.07.63529E3 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by imf05.hostedemail.com (Postfix) with ESMTP id A5081100019 for ; Sat, 14 Dec 2024 09:03:23 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=U6rnIxeP; spf=pass (imf05.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.216.45 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=1734167034; 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=PLGKRzIB8HXo0VMNVO8Y1nbnLVdnH3jBTxV4FtFLzdM=; b=P+HHLbwgnGTi0j2ZSTp9QPiYE/WBECUMa/hlhjiCTsLfI3J8qXEP52xYeQWbRYGIoeSny4 tCSCHTMsXlf93NgwRIJQ28YOvzTI0R5bHChJ76JQ/KVG818xFO63ITaOUstMVQ68wCmhNv pO09AjaG42AVcNg7PXf05oomB8iIjhk= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=U6rnIxeP; spf=pass (imf05.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.216.45 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=1734167034; a=rsa-sha256; cv=none; b=2i2bO5twtFGN5zrRUDcnMARo55irCiV5LBXTAu3nY0oA4bwo2zh3oAqtrMMrVAf0b1lgEJ 87TOGxnDs0Kx7l0K0dS6wIkrLIxrCssbWVQAbUzEmANV1VylxaxGXziAVVmqzy2VKYZwqz rQqng84bOLAsi9KbFVZUG+UtZeea0iY= Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2ef70c7efa5so1715404a91.2 for ; Sat, 14 Dec 2024 01:04:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1734167053; x=1734771853; 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=PLGKRzIB8HXo0VMNVO8Y1nbnLVdnH3jBTxV4FtFLzdM=; b=U6rnIxePfvfQHAroRyZ1q4GytjuozRzXhzx51RxwAwEbUKnAExPPCxKmZChZ/GsJk4 0/JqpyuYZzS2bHDQto2pjZV5QvdG0sxGg6zxWZZd8MyvnDDjN1qTBlzBGAhggwpLY3tz 7k++RczcuILW9eVt8QegVWDjHvckCPvyAU7rFc+H+7CtrNkyMhqYAV0086ufuwCixMXw U1qYdu7UgAIlGm2zfM0Pbx+NU2XST/FWb1r9uwo40BKRVNXcxuNdSdRV2AcPCraldpcS DE/B0Fd9k4CTC9Al0Fi4z7XPGr3j576lAwMggFzMQWK8RRwhwpSvECL4lhA74f9/T5M+ 0Ohw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734167053; x=1734771853; 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=PLGKRzIB8HXo0VMNVO8Y1nbnLVdnH3jBTxV4FtFLzdM=; b=KYTEotQuukA1hMI/O8yd6SloBcTgHItZM9/kzGK1qFxGWDwuCiHIZBqEze/hX4ClhQ amevVzgqT1kibPc4c8kRWUbBgQZvW9nFb54+NZwvUui03H76LBANLBJoRCVxKUGAzk+2 OQlPSunqkR787pgKYo6z21wI3y98UqYZ/pWVF2VfA2d14juvbZ4t8Iz7NX9LHDJ53CgI H6h8hPiQNMW7Kx+uYaJJVBLu/GEzaRDy39ezzntrnSs3q6UGG10uX4uqTDI2NaTcUsCa avGSMRvCcUCHYx9EWxeMg5AiGzcpbEHygucjiCu8ugpKyLA4+vzSYgtONR44Gcwyd47F /yTg== X-Gm-Message-State: AOJu0YwR+srAkEAmvV7gWXpButB4juhIs2GjGVPrMxswPNzsz2mm+oc3 BcvQ5QUXrJLTgQykB5wRPaLTZPSCUMXpq9Y3tKaAX0uWbKkzkeo/RRRETeJtWFc= X-Gm-Gg: ASbGncsSvds855/jAJ69G2Y6Oehsacv++yQddkVK/pad7VNpi4gWteyiOSwK5bZqA+0 j7Luwofz4k021Ce7NIyFj7uqhnnZlwZ6wxrlpMJN/zhF2EgwrK82ldlHltjfplImN7PQnJsNtj/ XkJcMsqMsRP0Z3+n4I47/T5s16SDNOrsj43taNgZ7gN8S8TbqMzFOSUUhXdJWFLdegnPv7UzFve noCPPrfYNEDHzsn7K4IjTTNiTMSnbr6XY4pNKyac87J2W2F555bK13X14AdioPUpoUXnqADsdUB DaxdwU0h8syeCaPH4Rx6bjMtJSqnbA== X-Google-Smtp-Source: AGHT+IEUuhlzMDGPbhHcy72Znz6SKiudYIj5PWGCvj9lWM7sC/HnXgPB6JSnynFl46+kyeoAQCdvNg== X-Received: by 2002:a17:90b:3848:b0:2ee:d797:408b with SMTP id 98e67ed59e1d1-2f28fa55c45mr8606530a91.2.1734167053262; Sat, 14 Dec 2024 01:04:13 -0800 (PST) Received: from C02DW0BEMD6R.bytedance.net ([2409:8a28:f4f:a9a4:5d46:4ef0:daa9:1db8]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-801d5a90ba0sm905731a12.16.2024.12.14.01.04.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Dec 2024 01:04:12 -0800 (PST) From: Qi Zheng To: peterz@infradead.org, 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 Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qi Zheng , linux-s390@vger.kernel.org Subject: [PATCH 04/12] s390: pgtable: add statistics for PUD and P4D level page table Date: Sat, 14 Dec 2024 17:02:50 +0800 Message-Id: X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: A5081100019 X-Rspamd-Server: rspam12 X-Stat-Signature: 5y775sgfs31zxj7xwi99nj4p1ixzzj7g X-Rspam-User: X-HE-Tag: 1734167003-634067 X-HE-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7oetORmduWi4dnJ7V3ZpeXC2kBkS165aUarWIHD9tPwKy2aQnsQqUMvS3ICjxpLaKBWePtFqOqHNbJCdrDZQdFRBcw7coUxdYcrQJWXWeoI3+0YlzJdl32jw5AqQd5K8+aq3Og4lW0kPus5X3Y1va0FPa11ecQ5gjUOZoQhdwo2UN8sEaNf4erln+5WktMVoAiPP5NCtfcMV+yqJEbqxO4dI0o8BD8jqY059/3i2kth0tv/1qRYOQQTNy4A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.011612, 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 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 */