From patchwork Thu Jan 23 13:26:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13948264 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 5F888C02182 for ; Thu, 23 Jan 2025 13:29:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA127280003; Thu, 23 Jan 2025 08:29:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E5161280001; Thu, 23 Jan 2025 08:29:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF209280003; Thu, 23 Jan 2025 08:29:01 -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 AD1FA280001 for ; Thu, 23 Jan 2025 08:29:01 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6D805B1086 for ; Thu, 23 Jan 2025 13:29:01 +0000 (UTC) X-FDA: 83038797282.17.5E4B6E9 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf27.hostedemail.com (Postfix) with ESMTP id 9F8B24000F for ; Thu, 23 Jan 2025 13:28:59 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=SDDrF5Wg; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf27.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737638939; a=rsa-sha256; cv=none; b=JpVb+l3Piq+0N2kFVe17FzT0IeySvhFqZqMB67CcEo7gUOSe4nQLfZJXepkvSDc9DHFjaJ iFHpcfRZe+sexCZad5/iLvYDkV+hBXP9D97rvZWPRGjp31ZPJ8Kwj9qUtFAaAL2uP3877a 0fwn2JjQKNWY9IQqlgSiwzc4vFUwkgs= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=SDDrF5Wg; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf27.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737638939; 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=bSVoet4BIZh93xV/DLydReH1JogDWuAFDaImcbetZJc=; b=Fx3kTzIEDztvLVkMfi4nmNerkACXnL0wmcagnZwJopj73CXPlpw39IUiullOXjfyES7jNB pLsdiYEiShFHio8mKFXo+s4a5wyh6SuH3ETJlbU4vIai/9kv6/pBwg1qB8ksDkBzBmzz1v /yonANURMujIfcYxcvxj2XMg7UlyZcs= Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-21619108a6bso14158435ad.3 for ; Thu, 23 Jan 2025 05:28:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1737638938; x=1738243738; 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=bSVoet4BIZh93xV/DLydReH1JogDWuAFDaImcbetZJc=; b=SDDrF5WgvUL9IC26GtbkrW15cJ2iWPRcV60E/ReZJon1TKocBiigF9E/Ap6W7jHvkY GFz1UX0QsEytdrEJ87SluPkI3B2N9PIxAOo1MtVaJhRW5da4UPS6FuWGGYPOp5Mz+baN mF8FQLP1UwENNzqFicfb8Ny9oAewGod6v5ZGLKqF6A5r3GmweA2ID6vNcxhaa4l1kcp5 zFQVpZR6NWm8lB3LMnGhuTAxf9xD6iuleDQ0vJx61QtfsXxnj97l0Jw9IjtptSnfjaew HfCrtLY7TJ4so8fFt9VVgUENqcRUp9FnqpLN7HbwJbycmJAehv4f76StG7q1N8wrQOgj 8K8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737638938; x=1738243738; 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=bSVoet4BIZh93xV/DLydReH1JogDWuAFDaImcbetZJc=; b=oG7IH9Q86PZ7LgLHC/bviEWvrVSWYhiw3+o5pXsx0KEdEHHGX0cFkxiska4gSryNwm 5c7a1kNroHgBQKYdpzjuA8qTbZOMxEITZOrF4gKjIQNPS/w7ZP4biX2m/KSsBNCmyIkc DAWt5p3QAdY0clvwNWw+cDUknr3qtxQyYWgoGo7K+Q3AytUkLy5UunWx8t1hrymuGmhP uKIylYu6NmQCgxkPlzJtTnkq7Q7ERxLgqCqQhBJ4nzAhoc0TxC+WkyRGO6y9tZD8U0I/ 06xlixgGmnpw8hEKtAXIR952TauNl/N7sFcXJOeBOhrlWhkOYISkBxmdMsK8zSLWdDe2 IO2Q== X-Gm-Message-State: AOJu0Yy1mEapFI2n8I1wY22YRROIRhQqZJVVYRyOTttfTBZ+zibK8bJx zS5cOuQsc/n2Ppv71zGWbzCo/wJbkVhpDrjwohGJLXzDToqGLuAdnnuIzNx9ywk= X-Gm-Gg: ASbGnctSTCHbBpuu40oCvernDo/YKc6O6Pc7d2M2Koz6CnceIOsdH/Jx/KcbAuZq9j/ DTIqW0TxuSeoK2bOClkxuH7DX4DyYqAeBo58p6jUh9vGZY9HFYwPXsYxKuPqNo8uig2kR3jfafA 84b7dwgMZ9v/UUD/CDcwIThQpiSZ7LEclvzhzX1GJCeNC/m8iASe7Dp3ZJTmQikTsDdsMtzTCHv t0O+x+p81VrCvlYAVFFtj76bZzuFTBNiJ2zH3GzpqMAFAYIN9/tUW9LcoQQPmq3YAxZ1XnIpeEB pt9iCnhOODraE1fsIkzDeJZzEux0xHCYzLC5bylkw5J8 X-Google-Smtp-Source: AGHT+IE9ITT+lxW4q5ku2WHS5AYNu8WFWCG+wILMASo2spfcLUt1T5YAi0clrsTLRCDPofgLk2+QPw== X-Received: by 2002:a17:902:e5ce:b0:216:6590:d472 with SMTP id d9443c01a7336-21c3551ae48mr419794535ad.21.1737638938491; Thu, 23 Jan 2025 05:28:58 -0800 (PST) Received: from C02DW0BEMD6R.bytedance.net ([63.216.146.178]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21c2d3ac3e2sm111583655ad.139.2025.01.23.05.28.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2025 05:28:57 -0800 (PST) From: Qi Zheng To: peterz@infradead.org, kevin.brodsky@arm.com, riel@surriel.com, vishal.moola@gmail.com, david@redhat.com, jannh@google.com, hughd@google.com, willy@infradead.org, yuzhao@google.com, muchun.song@linux.dev, akpm@linux-foundation.org, will@kernel.org, aneesh.kumar@kernel.org, npiggin@gmail.com, arnd@arndb.de, dave.hansen@linux.intel.com, rppt@kernel.org, alexghiti@rivosinc.com Cc: linux-mm@kvack.org, linux-kernel@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, x86@kernel.org, linux-riscv@lists.infradead.org, Qi Zheng Subject: [PATCH 4/5] x86: pgtable: unconditionally use tlb_remove_table() Date: Thu, 23 Jan 2025 21:26:17 +0800 Message-Id: <00bf7935d65826eee547ac195d7854b1c946dbc5.1737637631.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-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 9F8B24000F X-Stat-Signature: mf86dhe4bx1ggpc1pty8doem5fjt1kcz X-HE-Tag: 1737638939-506167 X-HE-Meta: U2FsdGVkX196nFC0SsJhuign0r8SaHnQrhqyMza4VriGQbgslzTnNQ//ybEe+VKdOSK6oK+Cm7KdPuSKDK1rkod98sWvwm3lhf8DHZtjXstV7FLaqS7baaYL7gM2sO2G76fm+rC9LjCkfUBc5oaUwVKiBjExAGdI9PoT6a2CEHoDAFqvpIT3+ZC3NV2ueYapPCN/6UMd4hfI5Toj3Cqsw9EihImEc008mySUbKh6DogDjM6eKjxPBMp7tg1mv3kDxSZUmWFHqFdkF1qIUU/bgaFSwO9aJ+Yr+fO3W1OBTlPWRzyt1jEtvx+CF4gVGnO7ga8x2NxcZMSCbETmzf3TS68LIijkIyw64humadFCLKimpTYjrFWmvsYDiZ0iWDlDvdlCkKa6qP91VHT56CTDNyd6royM5uD1+DiJHhgG7bAAGnhxXm21OwuaDQdAUDABId1s9b/wgw7ttOH7YzdxH2TqR47POpkruTGYpLXIgcPiSuUOgcbUa7gXpItJzAdd00a3BVqw1xHyiUdRR9G4lMbGVGi98WiPZ1HExd5uPYrZOzl0KJTdZBUwGpJwZaTb6uQFw0jjjHTO7oaXbEV6dQ+Tk2IEtjJ5iDtxtdpX+7wxWbX7P01L+pE04Uk4bgKRmyhhS+cvDEm8cogrneGfAp3vRjghwBp1xitjsplt5yAo1ot5yTuFMfhVTE+8Qd2Vj5cIdkhkaplCyWkcjlQEWpT6+p222Ws9LR0Ix//lDXWMwxJAIETq87aYjiVMHP3lpvO/jufj9sOMCKpLB/Pydtq69/1vjV54njgEHHowTNm3eUQ8jin5AA3gpwsELwSi7IfAiQhJy7syi2BvGPZ2T+uSdlBpLFARRewfmTHJqdki1/bCcTiknSMVTKhPeDrcP0OUqqSsgoqjSuJfkKvqwzNp1hB6fxojuYjWpNsc6v3VIY30oJ1u+LFMYBrq4YQdAmdLraxeiKzbFthozQc BHuaxZ+I GtjrOiV3EJHSf27jUW/sjiuNDohc+KgLDmywvHN2jkaV9Bn9es/qtbhReokyw3WgCS0n52qB8mI05rRc3QcKInaRo6fzjUo226BSP2gBHvZw5RJDUwi/0gCJ5fJ1oRs3pjX6Z3rAa9kCELouHaR+ZZzq2eX7OMG2CWIJ+tKaOdkTg/UI5GvuYnfUdQx717mtJJN8jYa53BS1nclZUIOnSXzyDy0Xw4JhubnjUVCLgLLi3AG4PUKX/QMFlbSi19G69oHebIrw6g7AbXUxhZkK0xTtDK+SFpkESqXyWojQk5QOTZC8cYMZMgSK73oxH6+PTRG1d7/G48dMhGjXseoQJEgYg/9aVD8fjq4GwSzz/YqzP4g9e5IqW6QeLSDhgbccaVpwSZskhCU17Q+KOYLY0jCjlagl+PK3euf/ow3W20Nth4+xjF6z2HrNDHsogqtYhdL4wrSMifM2tVrfo1OXWwvFeHLmqQ+bV4wFKEECfA5tAc1E= 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: If the CONFIG_MMU_GATHER_TABLE_FREE is disabled, the tlb_remove_table() will fall back to pagetable_dtor() + tlb_remove_page(). So let's use tlb_remove_table() unconditionally to free page table pages. Signed-off-by: Qi Zheng Suggested-by: Peter Zijlstra (Intel) --- arch/x86/kernel/paravirt.c | 17 +---------------- arch/x86/mm/pgtable.c | 11 ----------- 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index 1ccaa3397a670..527f5605aa3e5 100644 --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c @@ -59,21 +59,6 @@ void __init native_pv_lock_init(void) static_branch_enable(&virt_spin_lock_key); } -#ifndef CONFIG_PT_RECLAIM -static void native_tlb_remove_table(struct mmu_gather *tlb, void *table) -{ - struct ptdesc *ptdesc = (struct ptdesc *)table; - - pagetable_dtor(ptdesc); - tlb_remove_page(tlb, ptdesc_page(ptdesc)); -} -#else -static void native_tlb_remove_table(struct mmu_gather *tlb, void *table) -{ - tlb_remove_table(tlb, table); -} -#endif - struct static_key paravirt_steal_enabled; struct static_key paravirt_steal_rq_enabled; @@ -195,7 +180,7 @@ struct paravirt_patch_template pv_ops = { .mmu.flush_tlb_kernel = native_flush_tlb_global, .mmu.flush_tlb_one_user = native_flush_tlb_one_user, .mmu.flush_tlb_multi = native_flush_tlb_multi, - .mmu.tlb_remove_table = native_tlb_remove_table, + .mmu.tlb_remove_table = tlb_remove_table, .mmu.exit_mmap = paravirt_nop, .mmu.notify_page_enc_status_changed = paravirt_nop, diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c index 1fef5ad32d5a8..3bc8ad282b272 100644 --- a/arch/x86/mm/pgtable.c +++ b/arch/x86/mm/pgtable.c @@ -19,22 +19,11 @@ EXPORT_SYMBOL(physical_mask); #endif #ifndef CONFIG_PARAVIRT -#ifndef CONFIG_PT_RECLAIM -static inline -void paravirt_tlb_remove_table(struct mmu_gather *tlb, void *table) -{ - struct ptdesc *ptdesc = (struct ptdesc *)table; - - pagetable_dtor(ptdesc); - tlb_remove_page(tlb, ptdesc_page(ptdesc)); -} -#else static inline void paravirt_tlb_remove_table(struct mmu_gather *tlb, void *table) { tlb_remove_table(tlb, table); } -#endif /* !CONFIG_PT_RECLAIM */ #endif /* !CONFIG_PARAVIRT */ gfp_t __userpte_alloc_gfp = GFP_PGTABLE_USER | PGTABLE_HIGHMEM;