From patchwork Tue Jan 2 22:00:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13509532 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 B4CCFC47074 for ; Tue, 2 Jan 2024 22:01:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B408D6B02B9; Tue, 2 Jan 2024 17:01:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AED2C6B02BB; Tue, 2 Jan 2024 17:01:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93FF46B02BA; Tue, 2 Jan 2024 17:01:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7A04B6B02B5 for ; Tue, 2 Jan 2024 17:01:45 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4B1D11607CE for ; Tue, 2 Jan 2024 22:01:45 +0000 (UTC) X-FDA: 81635743770.23.5A4B299 Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by imf30.hostedemail.com (Postfix) with ESMTP id 6F4EB8000F for ; Tue, 2 Jan 2024 22:01:43 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=sifive.com header.s=google header.b=RCOFjuHn; spf=pass (imf30.hostedemail.com: domain of samuel.holland@sifive.com designates 209.85.216.46 as permitted sender) smtp.mailfrom=samuel.holland@sifive.com; dmarc=pass (policy=reject) header.from=sifive.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704232903; 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=LtzHkWRF5gALofCSRDnlYgSzHUyaPaF++esfIcBOkBw=; b=NlfigpamL3YP5W3rx6flYSUVdmFYNhwBGnKyoyjY8lX5IwVbPS9HvQuIYbjGcb8ByYbLHb k/Rdj9q/maoYZu3Yd96x/1XBs+qLv+Wo9qs0Rv/mU1I3136RCKlDkXLmEj7NWTwhLsEYNR h9ZUuXW/vTBsBrZ9jJvpEWn9kYWsxow= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=sifive.com header.s=google header.b=RCOFjuHn; spf=pass (imf30.hostedemail.com: domain of samuel.holland@sifive.com designates 209.85.216.46 as permitted sender) smtp.mailfrom=samuel.holland@sifive.com; dmarc=pass (policy=reject) header.from=sifive.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704232903; a=rsa-sha256; cv=none; b=5/SzWf0NDBPctuTo2EXivVGua6wtvJxEvL4utvJo1okEGk/zEZ88gW8HuSuqgXyQJQi+bO V5GhrQnirjLxm8lJtfTHr0Hq44pcf8+zU0+E2a8awTf5rDAulh9quQy0l/jK90QgMYD5wj 9dclo1GkGVY+Pq/6oMnpDc/FT2uO074= Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-28be024282bso4981174a91.3 for ; Tue, 02 Jan 2024 14:01:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1704232902; x=1704837702; 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=LtzHkWRF5gALofCSRDnlYgSzHUyaPaF++esfIcBOkBw=; b=RCOFjuHnCIMUTiauTxg/k8LlgYvNiEHqLW3ihkVQz+nrPSRgjpwkEjKCwNwOCxXuB+ ZML4H5oi7V2Oky06wZLpTyZZKPSjXCltN5n7LicpQaEbxOUGbQyEXI+lhfufr2yJ1nc7 FFFXrUiGXJQaUGRbMqQ/xpKf+EKu5ThHS/OwMfx1xGhIjhbh/v24h30nPQqjXhnXG1wC 0TFHoYCD9Xwg108+4uVg9Q7QEl4cglGSZsxVUuZx6exdjtdpmmLQs+mTtP+SfD9bbzFX 9zh1t3gdCxTqcA8sXlem64HaknXS9+Dk5GGjVXZYzqRbEl27y6YGtCNwlkCiQFmuw10F Jplg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704232902; x=1704837702; 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=LtzHkWRF5gALofCSRDnlYgSzHUyaPaF++esfIcBOkBw=; b=vXdj3XSTeNss62kf2PomC1x4IjRp9qltbPCFIIHhUN3fNYI9wag+6cDDVzSa/8ez6L lu0Wnjg1xeanPlgsyJr1Ji3tIM+IoH11ZR7fM6bvkx3OgA6dJ2NlKboQ0/n1sNsIX3Fe tdvmoMz2tCeTq4lR0KfmWwwXAfWBjTHypZqxjP+c2jzF2btnBE3RBj0o8AG/97/d6anm ONoQORdd2L9fAIw25/pwGcSzdp8GaIXlNdI7mi1iRPoMOmYYMDfdK+Iala1FY7SVrDMa 1/o2fvR1qgA0xRzoiw78UzBrl7WMrQGgEp5GQVY84nk+yYhyp+FhautPo8d9NfzyhgFG rmuQ== X-Gm-Message-State: AOJu0YzlrnU+yoMOMdyDzojBDDF9FkEb+JpeWe3zz44D5zEMn3/mkyky vTdSZ3C4qB3OmetK6JV8M4rYIrF8Sg5VT9a0jMxNTF6nAwk= X-Google-Smtp-Source: AGHT+IExkJSZEsbRdHGUNd8kiI0pICSa1vMynIFUPWzzc2fqMiijvWM2jfH6XllBTjKhdLtvimrjxg== X-Received: by 2002:a17:90a:740a:b0:286:7f0d:6254 with SMTP id a10-20020a17090a740a00b002867f0d6254mr6006468pjg.63.1704232902374; Tue, 02 Jan 2024 14:01:42 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id r59-20020a17090a43c100b0028ce507cd7dsm101724pjg.55.2024.01.02.14.01.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 14:01:42 -0800 (PST) From: Samuel Holland To: Palmer Dabbelt , linux-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexandre Ghiti , Samuel Holland Subject: [PATCH v4 05/12] riscv: mm: Combine the SMP and UP TLB flush code Date: Tue, 2 Jan 2024 14:00:42 -0800 Message-ID: <20240102220134.3229156-6-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240102220134.3229156-1-samuel.holland@sifive.com> References: <20240102220134.3229156-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 6F4EB8000F X-Rspam-User: X-Stat-Signature: z6iimzwyqk4jppz3qo8bz9xs65q175ez X-Rspamd-Server: rspam01 X-HE-Tag: 1704232903-532830 X-HE-Meta: U2FsdGVkX19x+prQkUcMp9qujcnSdNmYbQh4kbNRsjrTLOQ7q7yizek8Y/ftpx6fLpxjmGRyiosF4FeRH3d3efKtc5SR1cW+q/xBViUsL6YjkPw+bGj3Z5Zrrv1Bbk0HqrJvI6LA3W+JXdhc9MQQmUkJrY/OV7lrB/5iGrchvn8vSPJRURrbOmoZuHgQ4eupK9uhVIkHQyT1Z4gPJ+d2LlYpOkaYfQU7dnFTNhyj6UWXXdHrCxCv04XUb8zw6GZwsYfe18rp34GGcA7LE2F4vhB7QVfiwSLDrrodAC0Gl97BJvrgNK2HS2e2PLmHKMSQs7oMSvYXP31NYmguccIUp+xPcpOCKOoG+ixNCJgJ95kgwL+0wIataNb4x/Va57k0ZrgQDWbzhGrR5vvPBwXHtn5PGhQmhZbQHEMa4inaQ+uqCp5jb7WCcihBOn03qZQy5oX0hoRr7+RXgUrwjr71tPenC8fHrQ2VUeACBZ51wkyr0oKJcRxgFxwFenmJvTRrrGyTltwamJXEUj3OKINYl2oDNh4qyj2UgeF4Zmx6eT7SjsEQNNNDjj3QBgO4eYlmFLQLMRqQNO5rDH96swX08DPQ0tG4IK7XpYk6PZKWUSxXZ/6gwKNPHhD0odPNLQwcrsRxN3ob1DLQjZooyj/06ZZwwDwHKfMfe0na2Q0IR1KhoPinN7RLXA4qquAWFbOU0u8I0+MW7YWPm7AVI+eOxer+seX+Bgx0XMOZCvh7HK0DJ3xrNmBcFcNZaWayS5ofzTqiNnd4czJl4MzPbZdNtcQaDklIG52o3AdXCdeW1A4AIkgS5AMtSWVDtskYwaHZG4MYZUhgZ4j3x7YiNCSrcAdzhkVrc+/XZ8zDSduARINMrLOBODChZGGhtw7OaI3Fj9fGH9pIB/C0s7u9fdbd0Fu/pf66Jo7D38eqyjvHLD5cLzalDRF4yvGCpUcAnTeyzwAKmO4Agf7hj4OGK/1 +4+87HhY otAf9RxuiNfskrIbXMleyZ/c43LuWIiht3288NuxRNd0na7UE4yNvHs/q/BnbByiJiUqfeC338/5A2hNn5GBPVShxCp6gjTFhkmhaPBeO8pLuapkhHY7NqnZmB0ZDW49iZeGzLiGKeZUrrYkuKNC4GgSJhKuGR5MzH19ahj584N76uVS9tpyaMwHk69ck9OOE1DTPJjvNQ/SkKn5QAu60rR1njW9YR9DXfmkCLl1bggnZcqKFOSrJmdv+Jhtu8ObqgV1EeNLOlZZjK/Ierqzt73iAGb0OjzumdPOxw7S85pYcxqYCTecPLjOj83ylkADrFFoyAVl0sQoXURkaG2HlVCTk9p9EkOABii0BoSU1m0fNCkG5q9TUzfSgrDHSt82p50hxDAbevvxBsaI= 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: In SMP configurations, all TLB flushing narrower than flush_tlb_all() goes through __flush_tlb_range(). Do the same in UP configurations. This allows UP configurations to take advantage of recent improvements to the code in tlbflush.c, such as support for huge pages and flushing multiple-page ranges. Signed-off-by: Samuel Holland Reviewed-by: Alexandre Ghiti --- Changes in v4: - Merge the two copies of __flush_tlb_range() and rely on the compiler to optimize out the broadcast path (both clang and gcc do this) - Merge the two copies of flush_tlb_all() and rely on constant folding Changes in v2: - Move the SMP/UP merge earlier in the series to avoid build issues - Make a copy of __flush_tlb_range() instead of adding ifdefs inside - local_flush_tlb_all() is the only function used on !MMU (smpboot.c) arch/riscv/include/asm/tlbflush.h | 29 +++-------------------------- arch/riscv/mm/Makefile | 5 +---- 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/arch/riscv/include/asm/tlbflush.h b/arch/riscv/include/asm/tlbflush.h index 8f3418c5f172..7712ffe2f6c4 100644 --- a/arch/riscv/include/asm/tlbflush.h +++ b/arch/riscv/include/asm/tlbflush.h @@ -27,12 +27,7 @@ static inline void local_flush_tlb_page(unsigned long addr) { ALT_FLUSH_TLB_PAGE(__asm__ __volatile__ ("sfence.vma %0" : : "r" (addr) : "memory")); } -#else /* CONFIG_MMU */ -#define local_flush_tlb_all() do { } while (0) -#define local_flush_tlb_page(addr) do { } while (0) -#endif /* CONFIG_MMU */ -#if defined(CONFIG_SMP) && defined(CONFIG_MMU) void flush_tlb_all(void); void flush_tlb_mm(struct mm_struct *mm); void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start, @@ -46,26 +41,8 @@ void flush_tlb_kernel_range(unsigned long start, unsigned long end); void flush_pmd_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end); #endif -#else /* CONFIG_SMP && CONFIG_MMU */ - -#define flush_tlb_all() local_flush_tlb_all() -#define flush_tlb_page(vma, addr) local_flush_tlb_page(addr) - -static inline void flush_tlb_range(struct vm_area_struct *vma, - unsigned long start, unsigned long end) -{ - local_flush_tlb_all(); -} - -/* Flush a range of kernel pages */ -static inline void flush_tlb_kernel_range(unsigned long start, - unsigned long end) -{ - local_flush_tlb_all(); -} - -#define flush_tlb_mm(mm) flush_tlb_all() -#define flush_tlb_mm_range(mm, start, end, page_size) flush_tlb_all() -#endif /* !CONFIG_SMP || !CONFIG_MMU */ +#else /* CONFIG_MMU */ +#define local_flush_tlb_all() do { } while (0) +#endif /* CONFIG_MMU */ #endif /* _ASM_RISCV_TLBFLUSH_H */ diff --git a/arch/riscv/mm/Makefile b/arch/riscv/mm/Makefile index 3a4dfc8babcf..96e65c571ce8 100644 --- a/arch/riscv/mm/Makefile +++ b/arch/riscv/mm/Makefile @@ -13,15 +13,12 @@ endif KCOV_INSTRUMENT_init.o := n obj-y += init.o -obj-$(CONFIG_MMU) += extable.o fault.o pageattr.o +obj-$(CONFIG_MMU) += extable.o fault.o pageattr.o tlbflush.o obj-y += cacheflush.o obj-y += context.o obj-y += pgtable.o obj-y += pmem.o -ifeq ($(CONFIG_MMU),y) -obj-$(CONFIG_SMP) += tlbflush.o -endif obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o obj-$(CONFIG_PTDUMP_CORE) += ptdump.o obj-$(CONFIG_KASAN) += kasan_init.o