From patchwork Wed Jan 8 06:57:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13930204 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 53D9EE77188 for ; Wed, 8 Jan 2025 07:02:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E63FD6B00AA; Wed, 8 Jan 2025 02:02:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DFBA76B00AB; Wed, 8 Jan 2025 02:02:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C18D16B00AC; Wed, 8 Jan 2025 02:02:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9F27A6B00AA for ; Wed, 8 Jan 2025 02:02:40 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 616BDC05F0 for ; Wed, 8 Jan 2025 07:02:40 +0000 (UTC) X-FDA: 82983391680.24.E03751F Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by imf09.hostedemail.com (Postfix) with ESMTP id 746E1140008 for ; Wed, 8 Jan 2025 07:02:38 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=KZtHNFAs; spf=pass (imf09.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.173 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=1736319758; 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=oFL9SGbXxYqRlw6G0JwTVWRijc5/6EOrJfB/UywRwlQ=; b=CmB5Q7bxogNcADrhy8ZtCOEZKGR35gdX3hLaaBVyc4reQ9UnZ1B7HV00r6CVlDxFvdaITM Tdv9f3qeo4b78JAtI6dwPxu89Bwl+iIetx0hzaPcr3DXaFVxQubMFAi0BJULFDoh7DmdDM KEkm/CPYomb9GfH9/SVjJFKgl8AkEZU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736319758; a=rsa-sha256; cv=none; b=hpzXdzTf8L5Rc8L3m13AgzcEb1C8v34Vsp9DyY9X/tEnc65bUJUkwK9kB+eXqSNGR2PK5F /h6rgnsceXjwdTluDhdQtWWnQuZaB7WGI3W0gWbc12Cxw42U4U6Ffrivbe7mimoeZINjE7 IFNDI5jm5Y21uKtiwNzu47P6TTL2/Yc= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=KZtHNFAs; spf=pass (imf09.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.173 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-21636268e43so68037755ad.2 for ; Tue, 07 Jan 2025 23:02:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1736319757; x=1736924557; 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=oFL9SGbXxYqRlw6G0JwTVWRijc5/6EOrJfB/UywRwlQ=; b=KZtHNFAss0K6DS2eHTORNgb79l2bTKqi3AjExEkNTn1BwBUckYz1mAucfYigTixZ58 asLQK5uKvE29/IDrGsKHTvMv4pJdNdZ5qx6HevrFw4GxrwokFgBtKIWQeqsIkO7P3tBy pNC9vruCOV2Tb1ePggYYejUT3WwEdZcINM7KdM9Juh8d5My+dn3M9fr9PC3TkO7ydRAc vC6WXavkxveVUc+bgp9rMBeOY/opddGAwBongW3B94WSgemBkm8IWpxslMkqYzi1n2cC 8FVkzUhdK4zwz9XJxNmBfWpUckuyuLcFA+rBiYn7TpDaX7wzLRysp1VvRGy40A65iibR aMnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736319757; x=1736924557; 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=oFL9SGbXxYqRlw6G0JwTVWRijc5/6EOrJfB/UywRwlQ=; b=xVGIWglkMd2iSSacJQfI65GFfmLkVlCnvBrJARrsKgvYQT9hFSi+FUrKyy+MUcOJa7 gq5c2jjptc5ei3vDPJD+kLQbA0Y/5vTa/oWxR/LyMZvfFrMPA/y9AZIu1shPcOH2xhdD 4cJuprreltGPUpYTAM0eG0Dn6IHIsA7djKjiLuyhylLt402HWf6DGBzK7/Z7peeZfut/ JhoOW3pgUz5bPiZfukUEsb8BGIY5bDvqcq651nGu5NpmLaPzrKgBfnIDL6MvnY4LvZ2K Sz3BvcT6I5R6X4seX9V0rrpFGoyzH955EH9cB9oss2Y68PpkmPWVqvuK+Cbg7OKBzXBY Ap2Q== X-Gm-Message-State: AOJu0YytvDgrcsHrzgJyV2L9vU0QkGDMzsg+tF3acUWjqK/b/84AeSUi G93JPEEy+wWFKJDSvk/VeLbiXR7N9QHAO6OZpvZf8HiSuyYASJsr3ad/NfaqJz0= X-Gm-Gg: ASbGnctHWFkGkXak71fxUfdI94LrVtRmCLdMiFfbKTfxnpI4TKMlntLXgG+9ULueLhR LnF+WQAam5+qCQ4+lDeta+YkHuZQQxVxCOxDQgdBZD62u17LP3STKAv3hTBPIWeeluTsH8GdGrT gpeKtlNEjwQDEGB4bozOK6PMwK3ShLKy5zZJjYZCsaLFd7lkzBp1freI9UWuoWtDQWmJ993TjY+ 5jXEoLmNQyP628CYbgzzZZjxejv2Nu4+tvdDVzSwPWvKNm/ZQo1f9lgnqme4F2Vk8yrayX/m7C8 eaGvEQnTAObRWR4CxYBt1XSonp0= X-Google-Smtp-Source: AGHT+IFBkkoQabtOk36FtfqYc8ZUQnhLYoik+Qreb3ophWoDY5tLIXttH+D63mfzQSCD0xoXOJPU5A== X-Received: by 2002:a17:902:dac8:b0:215:773a:c168 with SMTP id d9443c01a7336-21a83f48cf9mr30903435ad.1.1736319757144; Tue, 07 Jan 2025 23:02:37 -0800 (PST) Received: from C02DW0BEMD6R.bytedance.net ([139.177.225.244]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dca023a3sm320067275ad.250.2025.01.07.23.02.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 23:02:36 -0800 (PST) From: Qi Zheng To: peterz@infradead.org, agordeev@linux.ibm.com, kevin.brodsky@arm.com, alex@ghiti.fr, andreas@gaisler.com, palmer@dabbelt.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 v5 13/17] s390: pgtable: consolidate PxD and PTE TLB free paths Date: Wed, 8 Jan 2025 14:57:29 +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: 746E1140008 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: hp3jme9uts5qwnti7hjcakpz96sqwzbw X-HE-Tag: 1736319758-913625 X-HE-Meta: U2FsdGVkX18GZoTdIOiQxENO6rWwF7cIDf1U4315CXI0lYXt+wGVMwjGKFqcTDrd0NVoOpUIMyAUFt/qHRz9j08bGBavJEwHStucwe+qPJdvGy79CIoONnUXJcmmkvnKpnlGYA3L/sNsRsYSwltdWpejC7xne5cp9eXVQmK9Ta6A2d6SiBCRSsAc6WZ4zdjohQBOUBt1GkClOvJ9QshtE4llUCQiSonJZtckxNezag4OLchvFZj/JNEWL1kR4e+Io72jlYaAHHshKa4P30FpeTJsJA9rfwppEqYPx0HzFPH7PMF56rNXyjuZ4ioYSkyYtBSudnW6K/9ao83Ub9sPzWG5rxA1Yyk02z+EWk3V2CFsLLT4GatzePGadRageZmDmFWqt1XVAmBOKhuyA+g5qet5dC00Z6fwhwSSMzd/YlhvjbULckHwcxhSdZwfDDFIFKoAgcM8pOU0b38gbNziw1PMVlG6CIYtnX9SKINiPOGn3YPuEA1WXwnL5XJqxNq6KVGE8Jc7ZhivdpvNOkl4zh6Jaq59JJMjd1W6+e5pl5QpMjYixlQvmAzliY2+ecHF0oPkI5mDhMBllNXqCj8mCNM6OBFkZO551HlxtQAbIlJXLkoajCyopLiwtqrO4dHtzFQrsGaTF7he/IFNg/9OHrryUkRD3jGZpNZx6SVCkCu5hnnd8HBM5FC/We+OS7ld9CoW82CUsQTVgK1P+pNub0hCuPlcetNABkr2k0cM6dVcNfcQtt7axaBmeWole3G2gm9qC9kFQ2Spqz9bImyw9kXrQIQDuKSpRGiZn4l5JXGu8E/CkU/2X488CJpMaD1qap4pCeNLlKVxgAQ/hu7AH63G6YbV7PyL+096E/VgXvlLxcPsjrG76H6O7CZIJc2LLBcy4ZAbjFJ56NQtc90l4+GL29OYLOpWrFBRNeNFDTwa1Y8Iyz8oJommPROpvjrTtT+XQxEDiBtQfhcD9N/ GSJGbvNM XKaHwPGMqq3BF8cDzVWjdHUfM2o22nLHz1p74tgF4y8M7VscKhlqr1WgEIlsWULiClKGmr60H+v4HuUTxBsgyIsoUnOPMUapyUF2CD84RNPw3nVzWj5336pVmhgSb4+8k/3U1Xowzmoor10Tw14qVei3xoGsrl2RO90AtsnuqIl1m4HmNYZFdSP04wEW1xpbxDZV+KWr1sLjw5glSj5QRdL/4zZSQqezshSHmxHJw2dA7/b81YR9T3LlWdEfp55ZkQtgVvgtDjQW+Q5NwG9KwKueWbBW90OaTnOWTkLyFc+2y7OxEFiM+K9GnS3rHZgsvY6GPkP/f4RNn0eOn3ZlrL4/klLui9ZYYHhlvWr7jkuxzkKH+gy7BnpUtyn/4sb+xtv76OOOTHtu8P0DywnBBVDMonQC+H1jM4KTJ74tA+U14FIGBKdgQtG5brSA8dDh/vI8YpRAKT6tL33qHUJL0apj3mjFeJr4bAEWyq6C8uevb2n8LIFB0HRDvX6ESp1QfZGzAJhwJW64SrdE= 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: List-Subscribe: List-Unsubscribe: Call pagetable_dtor() for PMD|PUD|P4D tables just before ptdesc is freed - same as it is done for PTE tables. That allows consolidating TLB free paths for all table types. Signed-off-by: Qi Zheng Suggested-by: Peter Zijlstra (Intel) Reviewed-by: Kevin Brodsky Cc: linux-s390@vger.kernel.org Acked-by: Alexander Gordeev --- arch/s390/include/asm/tlb.h | 3 --- arch/s390/mm/pgalloc.c | 14 ++++---------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/arch/s390/include/asm/tlb.h b/arch/s390/include/asm/tlb.h index dde847a5be545..d5b27a2445c96 100644 --- a/arch/s390/include/asm/tlb.h +++ b/arch/s390/include/asm/tlb.h @@ -102,7 +102,6 @@ static inline void pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd, { if (mm_pmd_folded(tlb->mm)) return; - pagetable_dtor(virt_to_ptdesc(pmd)); __tlb_adjust_range(tlb, address, PAGE_SIZE); tlb->mm->context.flush_mm = 1; tlb->freed_tables = 1; @@ -122,7 +121,6 @@ static inline void p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d, { if (mm_p4d_folded(tlb->mm)) return; - pagetable_dtor(virt_to_ptdesc(p4d)); __tlb_adjust_range(tlb, address, PAGE_SIZE); tlb->mm->context.flush_mm = 1; tlb->freed_tables = 1; @@ -141,7 +139,6 @@ static inline void pud_free_tlb(struct mmu_gather *tlb, pud_t *pud, { if (mm_pud_folded(tlb->mm)) return; - pagetable_dtor(virt_to_ptdesc(pud)); tlb->mm->context.flush_mm = 1; tlb->freed_tables = 1; tlb->cleared_p4ds = 1; diff --git a/arch/s390/mm/pgalloc.c b/arch/s390/mm/pgalloc.c index 569de24d33761..c73b89811a264 100644 --- a/arch/s390/mm/pgalloc.c +++ b/arch/s390/mm/pgalloc.c @@ -180,7 +180,7 @@ unsigned long *page_table_alloc(struct mm_struct *mm) return table; } -static void pagetable_pte_dtor_free(struct ptdesc *ptdesc) +static void pagetable_dtor_free(struct ptdesc *ptdesc) { pagetable_dtor(ptdesc); pagetable_free(ptdesc); @@ -190,20 +190,14 @@ void page_table_free(struct mm_struct *mm, unsigned long *table) { struct ptdesc *ptdesc = virt_to_ptdesc(table); - pagetable_pte_dtor_free(ptdesc); + pagetable_dtor_free(ptdesc); } void __tlb_remove_table(void *table) { struct ptdesc *ptdesc = virt_to_ptdesc(table); - struct page *page = ptdesc_page(ptdesc); - if (compound_order(page) == CRST_ALLOC_ORDER) { - /* pmd, pud, or p4d */ - pagetable_free(ptdesc); - return; - } - pagetable_pte_dtor_free(ptdesc); + pagetable_dtor_free(ptdesc); } #ifdef CONFIG_TRANSPARENT_HUGEPAGE @@ -211,7 +205,7 @@ static void pte_free_now(struct rcu_head *head) { struct ptdesc *ptdesc = container_of(head, struct ptdesc, pt_rcu_head); - pagetable_pte_dtor_free(ptdesc); + pagetable_dtor_free(ptdesc); } void pte_free_defer(struct mm_struct *mm, pgtable_t pgtable)