From nobody Thu Dec 18 20:19:08 2025 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6EE021B0424 for ; Wed, 18 Dec 2024 13:05:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734527141; cv=none; b=swvuSY9gorLWzj/mg+zOv3OzCA59mtcSzgbEwEB+PtySTY786cLsq7+Y2Y6GVBoF1PnS60OaJ2ziZFvR9w2UalX5VubpsolWS/Cxg98bSaUbLZOlJLK5BDzhV6pmzaMcyGuU84BEapE/8zlsh0AhVr7311OKidE+ICI14UiBEsk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734527141; c=relaxed/simple; bh=gsn2MxaDHMIkVDeNJoAZ1GXzg4UbDMQdMp9AlgDJXWI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QDggprYVkBXIRRa61+0VcC7Bwc0/eeKZ42Ivla56z11HZCdRlq7mAhc0ck+lZoZ6m+e+ge4n5Cp+27Hzl9XENwaRZJ4bPLudoH3QCAfBBGOGdEA20wyHs3e8EtG+F6AeCZSnN74/oHS6LnkAu6fr0LJHkG1OkSsUzRvBd5KDzqQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=IivdJq3z; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="IivdJq3z" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-21636268e43so78249855ad.2 for ; Wed, 18 Dec 2024 05:05:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1734527139; x=1735131939; darn=vger.kernel.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=IivdJq3zwTbBWUsPy2MsCP/5HmRbrv/2yQa+fwmHxKVx0Yvj7bbyZ80AM6lvy9O285 cUHneJFlqIG4sTmzj56M7TR87h1kU76i285aRYZtELUEy9prvihgOoxnn1rzDquUwui5 IUAQuYQP90EfzAVlIp26nn/r5g74vfIWxi6zcway74EXyO2FM+W5y5bUscUWk5KJYWsy TEHR7M5ONoh7GK4a1bgRANf/YF0yBUh3XaaMGUQvYkdTLxq4+BXBk0+6RYinhkeb69xQ EdqWqNtultUYStJrcbEKa8esFMU2sF87VBupLBTawrjDcGA0XuK/I/0AqiD8xozFaW8M XuIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734527139; x=1735131939; 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=tIQJT7ayTi46rW5E9qZdePUv9kZ0r9M/8KC2YrNGPo2ROqGpOh856tpfE5cpAIsanf I1we0MLe1CIsZqfN9eBAW5derH6+5MzKOd4QvzcDsr4TfQO7mgmJF6YW/aZt+c/Pl+me UBlgCteW9U30XLZJ65dOcZNXkkwTvIteL35AAL6cmpQ4UQagRDAJKm0PqKhUHKnXgQZL TZa03L7Ut1nsUjNxEpaVnYTY5Hj4Ro+qOQgTH0AB8DYubx0PN2p952PKuY3+AEc3kFoe pTUZ+Y8XVnQZVs2EE0w/jTNGghuc2NisOgEk76YxK8egJDTvVFyQMeEjSPCSkoYs14jU XyKg== X-Forwarded-Encrypted: i=1; AJvYcCWfhqzo4GE+LLFc8rR2NpuITp8a3EJWWhRvZluGK+VxU5e32uDUH+UQtJLc0glZzBQtBn271zf8O+3UCrI=@vger.kernel.org X-Gm-Message-State: AOJu0YyTFi5a4Zc9L04UgrTqok85tLB9m1n8TUboKoWOlsxFK6udQ+1/ sfj/WKY37T2b+fmdtAgOlFs9Ine3h70eQP5oN24XfxjcyxmKFc64I2XqiVQLz8Q= X-Gm-Gg: ASbGnctHjEnzSkURAzGgsWyjts80W2PtbDWHYz2xlCi11QIYMR2RV4IwL8gYr47+tLm 8v5p6/LVb019twnMG4LIIY8YXtw7GH0nex8G48aJ11G+/XGqwEd6eLlLu+85S+s59OvUdmK6BKI Uam+fq6oHZMKzViIJZL7pQIlorURz7NcJ4HmVldvk+58NQJv9/BTjQJ3/E5AFNp6cCUDO4Az7bD t/3uzeFuEgSK1V/ZZUbADCCT8mNFzDRU/jxAAhKytmZB1lkrOy0PTr9GERlbIpQ9mZfZ6wMufxU D/EU9cjh6PVExZmWfBVdNw== X-Google-Smtp-Source: AGHT+IEBex3adiI4KuoLgCHeY1D81j9Q6JTE0T6gwcWqf4Lz8nOg8PmUUMxAQoz8nfmNTBwOZklCxg== X-Received: by 2002:a17:903:2448:b0:216:6769:9eea with SMTP id d9443c01a7336-218d72477d0mr41450855ad.37.1734527138569; Wed, 18 Dec 2024 05:05:38 -0800 (PST) Received: from C02DW0BEMD6R.bytedance.net ([139.177.225.238]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-218a1db755dsm75751825ad.42.2024.12.18.05.05.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 05:05:37 -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, vishal.moola@gmail.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qi Zheng , linux-s390@vger.kernel.org Subject: [PATCH v2 04/15] s390: pgtable: add statistics for PUD and P4D level page table Date: Wed, 18 Dec 2024 21:04:40 +0800 Message-Id: <64401d867f3a965f60e9c8d09099b42f21749a47.1734526570.git.zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/pgallo= c.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 =3D crst_table_alloc(mm); =20 - 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; } =20 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); } =20 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long add= ress) { unsigned long *table =3D 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; } =20 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); } =20 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long vma= ddr) 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); } =20 -/* - * 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 =3D 1; - tlb->freed_tables =3D 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 *tl= b, pud_t *pud, { if (mm_pud_folded(tlb->mm)) return; + pagetable_pud_dtor(virt_to_ptdesc(pud)); tlb->mm->context.flush_mm =3D 1; tlb->freed_tables =3D 1; tlb->cleared_p4ds =3D 1; tlb_remove_ptdesc(tlb, pud); } =20 +/* + * 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 =3D 1; + tlb->freed_tables =3D 1; + tlb_remove_ptdesc(tlb, p4d); +} =20 #endif /* _S390_TLB_H */ --=20 2.20.1