Received: by 2002:ab2:23c8:0:b0:1f2:fdbc:cb93 with SMTP id a8csp77796lqe; Tue, 26 Mar 2024 21:51:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXPVYau87IP7E0MyizjDoMlIlyJwmun7TPAbijC03bDMrFIs9eLYxvqcWs8su8L3WSlDiok3dKy0+0zKCyk4D70Q4YWjw6tVQyJocl6/w== X-Google-Smtp-Source: AGHT+IFYL1jE7B42BSnpSjCBmG4//EUeBy4fKMdHPgBdyUiI3rWIiCrPbJaepJAKX1/hpGPp0ssY X-Received: by 2002:a05:6a20:ce47:b0:1a3:6fe5:7c82 with SMTP id id7-20020a056a20ce4700b001a36fe57c82mr3548861pzb.27.1711515104857; Tue, 26 Mar 2024 21:51:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711515104; cv=pass; d=google.com; s=arc-20160816; b=rse1boDSULrA5UPCMoFIWhEKnifrWoTqvDaKFGeWO/sG/6lm7trX7QV0mrFqRVr1Pr oFStUYvIT0OjQdalrlYmzYNCRVHPv4wq6+Tyo5iTV2bpQCG6U3DoDabqSck/4us7GDJC 8qu1ms9EZemaRGil6GGmRdK+2Btd6NDpMYmZGaOdLHmltQXKvo9zDe/Q/M9FhUsfEBai 7kC2qOUmZmDbpQv7IpcBetGQtKpb5HR3Z9GlpuW2dw6YKMbvHuYR8gr8UqijuIFyf8cD doLYlUbytcbXs4pwlUsmT+BGsZbfqhz8aYI440zQCgv4tJe+MsJzuACpahfUzoGGoifE OuYQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Tmp/TOSalTk1E9Om53lqcGFTwB3eFzfKle7hmp+7bao=; fh=kVMl8kfpA36Ro/3P2bM4CdBKxR/FbbKq3UwoDY1wFDQ=; b=IN185LWW7JKzVjkgeAiE9+PkROpADLHpnvwdtYI8Ad2D6knJGS01YiiEojS+Px/Eci 7yuynkyLemDO3T7+sttKqwYMKXJGLxESO5t3Xo68hL9gDzQBjrxoeuV6TtNmu/skU9V1 Wmr/TfDFggucC4BzQJliOwaHuDUvoDKSczei/ah5ebIFJM1jbBiLItxrf5oz6F+u1La9 R0Dsq0mkvqEO4fgaG5PWgpmF6zXo9p+YMLeTDHYHXFe6+dVtH51r3i0ic2rwyQ6ub2vP KsYneU54wMQfTQIMEYgwKaarCtVffY6QHqN8ioE+V4r/1xlG438LSjN6UOycAUus14Mw cO/g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=FzfRSZqK; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-120305-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120305-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id ob6-20020a17090b390600b002a0857556d5si727188pjb.185.2024.03.26.21.51.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 21:51:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-120305-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=FzfRSZqK; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-120305-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120305-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8C3BDB21842 for ; Wed, 27 Mar 2024 04:51:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5B921F9F0; Wed, 27 Mar 2024 04:50:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="FzfRSZqK" Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) (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 E0EA5B67E for ; Wed, 27 Mar 2024 04:50:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711515045; cv=none; b=RHU5mYl94/tklzMG3cXtdXTWMNKmTaUiU1jV4/e71gsKZ9s1+JbEmQAPj61R4CG7OslO0mYo0KeYEXvGypxfGIDvBulFi395gbsl5xS1YHvjtRBzLSEir1yzr1nnY0OPd26acHTLl4kuLataET72VgUhvKFaOPxBVXweBCwCpK8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711515045; c=relaxed/simple; bh=PNo9fUUIIt9SGGQDqI5YlJUfPkSDmqOPYa4cRVAr/j8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=js/L+gOHhxFwShxfl0xk8zfL1IZYMWv6mgTaeLy/ElRzd2TAGadV6snS7s/i2PCyiRfqQlK2dKKiCrCcK1hOZ3irvxqRVbtx4YMC60zqHgfMsW8v1Iuf29823IyH9cNbuE/SdC8W0G6NaAz2cnLQPWY3LaMuBXoLmUdO1cx249Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=FzfRSZqK; arc=none smtp.client-ip=209.85.210.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-6e50e8dcc72so2629172a34.3 for ; Tue, 26 Mar 2024 21:50:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711515043; x=1712119843; 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=Tmp/TOSalTk1E9Om53lqcGFTwB3eFzfKle7hmp+7bao=; b=FzfRSZqKT+avHlzxgaXIOJ7UUuwHeo6s8whPqrsSsSxvLXFf8geB+CKvZReY1Y3rdt GRLh8KgXYGMjTs9I+cO1mQyEE8z/J2rPCv7r4R1nRen8gPflEX/fdyuZ36y7yJQc8LHu 7LyEEKGYcDch9khG3sdYWwcI90mG8NwYfuWstbevpeKhZga0db2UoZikFcrlmBU/RE1F rperXo4BRTfdyTRhD1EI6aRLivTiWlEdPKL1wq0hKdvURo+15NtwX/l4VEtf/FO04xKk ewcoq2UpHdc7d33F6p6Qx8NSGCnoWK72KlS7HeKnWe0R/FhZsoPnHLiY+T9GE2Snx4W8 ygsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711515043; x=1712119843; 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=Tmp/TOSalTk1E9Om53lqcGFTwB3eFzfKle7hmp+7bao=; b=JmqjEfLuWqB7dqBBKICO0f3VPPhQNCAXxmoRSoPS/cjHYP3b8Mi56VQ3TRQVSC6J9b Db+aepbGMTzvnhzH7zeiH90u4OEp2C7Hfe7Vi+0NXTopzpVXv7KK6eI+2711LGkwK8w1 w7zQNMrswm+53wUnwsqnthehyvlL0mkqUvKgcqx5mwXhcAmSEWdPYIGWYzZVdQ9a/DIU JXCaAtuWboPPkEhPqYvWgYw07mzw2F1yy+0OusgKotxkhONLRQ61yZubxKHcgvbwfVvO tJQrbqYUsknSEMDSfVC4tgVMu/Ts2hy75FnIGSv558tnntF2ElRCBBHpVZ9HBoa0eO0s ntTA== X-Gm-Message-State: AOJu0YwVeOk58dXO7gzwbe0aiBrEgmugyLR9BcGQcGVgmz6j+wILqLjl e7qXnOCdXQiI3ELV5PMg2wx0jHjUM5nKzm1tjJGUPUBfX/WV27NAm8ncbC5o/Ss= X-Received: by 2002:a05:6830:1bd5:b0:6e6:99da:8944 with SMTP id v21-20020a0568301bd500b006e699da8944mr3176474ota.26.1711515043004; Tue, 26 Mar 2024 21:50:43 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id e31-20020a63501f000000b005e4666261besm8351500pgb.50.2024.03.26.21.50.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 21:50:42 -0700 (PDT) From: Samuel Holland To: Palmer Dabbelt , linux-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexandre Ghiti , Jisheng Zhang , Yunhui Cui , Samuel Holland Subject: [PATCH v6 02/13] riscv: Factor out page table TLB synchronization Date: Tue, 26 Mar 2024 21:49:43 -0700 Message-ID: <20240327045035.368512-3-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240327045035.368512-1-samuel.holland@sifive.com> References: <20240327045035.368512-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The logic is the same for all page table levels. See commit 69be3fb111e7 ("riscv: enable MMU_GATHER_RCU_TABLE_FREE for SMP && MMU"). Signed-off-by: Samuel Holland --- Changes in v6: - Move riscv_tlb_remove_ptdesc() definition to fix 32-bit build Changes in v5: - New patch for v5 arch/riscv/include/asm/pgalloc.h | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/arch/riscv/include/asm/pgalloc.h b/arch/riscv/include/asm/pgalloc.h index deaf971253a2..b34587da8882 100644 --- a/arch/riscv/include/asm/pgalloc.h +++ b/arch/riscv/include/asm/pgalloc.h @@ -15,6 +15,14 @@ #define __HAVE_ARCH_PUD_FREE #include +static inline void riscv_tlb_remove_ptdesc(struct mmu_gather *tlb, void *pt) +{ + if (riscv_use_ipi_for_rfence()) + tlb_remove_page_ptdesc(tlb, pt); + else + tlb_remove_ptdesc(tlb, pt); +} + static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte) { @@ -102,10 +110,7 @@ static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud, struct ptdesc *ptdesc = virt_to_ptdesc(pud); pagetable_pud_dtor(ptdesc); - if (riscv_use_ipi_for_rfence()) - tlb_remove_page_ptdesc(tlb, ptdesc); - else - tlb_remove_ptdesc(tlb, ptdesc); + riscv_tlb_remove_ptdesc(tlb, ptdesc); } } @@ -139,12 +144,8 @@ static inline void p4d_free(struct mm_struct *mm, p4d_t *p4d) static inline void __p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d, unsigned long addr) { - if (pgtable_l5_enabled) { - if (riscv_use_ipi_for_rfence()) - tlb_remove_page_ptdesc(tlb, virt_to_ptdesc(p4d)); - else - tlb_remove_ptdesc(tlb, virt_to_ptdesc(p4d)); - } + if (pgtable_l5_enabled) + riscv_tlb_remove_ptdesc(tlb, virt_to_ptdesc(p4d)); } #endif /* __PAGETABLE_PMD_FOLDED */ @@ -176,10 +177,7 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd, struct ptdesc *ptdesc = virt_to_ptdesc(pmd); pagetable_pmd_dtor(ptdesc); - if (riscv_use_ipi_for_rfence()) - tlb_remove_page_ptdesc(tlb, ptdesc); - else - tlb_remove_ptdesc(tlb, ptdesc); + riscv_tlb_remove_ptdesc(tlb, ptdesc); } #endif /* __PAGETABLE_PMD_FOLDED */ @@ -190,10 +188,7 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte, struct ptdesc *ptdesc = page_ptdesc(pte); pagetable_pte_dtor(ptdesc); - if (riscv_use_ipi_for_rfence()) - tlb_remove_page_ptdesc(tlb, ptdesc); - else - tlb_remove_ptdesc(tlb, ptdesc); + riscv_tlb_remove_ptdesc(tlb, ptdesc); } #endif /* CONFIG_MMU */ -- 2.43.1