Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7681393rdb; Thu, 4 Jan 2024 04:36:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IG7L6GkKHaAu0KKA761e7ZWCDnv6Q7scVr6YeMgSEAZ+5v3qdAGdwzirWZT9fYdgAdI6n93 X-Received: by 2002:aa7:83d1:0:b0:6d9:c788:bef2 with SMTP id j17-20020aa783d1000000b006d9c788bef2mr372724pfn.17.1704371817779; Thu, 04 Jan 2024 04:36:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704371817; cv=none; d=google.com; s=arc-20160816; b=XY+DIjWgABmTHnDI3/pij7Y1SXuy5NfM3UyNEfdgRryydZNnzEV28HhBkBXAgZ6d3O R3EBToi/K19tbDTVla1awPu538bu4mMbt4qiDzlWzJc3L/txo2Io5PvlI0Ad8dbXWhtg xXKPpptGfSsvek/gV0Z3DM1st7nMfR+BWqehzaxhAT3glnE2VtuhwOj+ccHP+t/GEbPv yMEpBLFFVV+sXDfshSycfWAnYyTz7UcNpKSaKDhgX5RFxZ/PzRj12Zm+XhWKC3Z3yU4w KmxiBeYyjx1Ym02cw1LeEM9edlyarHYe6o7MNMoHO8efS/8Lnj4zaIO173rLZtkqjlrD DGuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=0rbdo4C/X6bEIX/A1ZdBX4InlDHJmGdJuXNskE1V/Lk=; fh=jKTs+9BUHPZxCmyb5dF9Er/fPaYRhA3WUfhb/jpFMpk=; b=wslGy2qIYm3OLmjYxJRnEtySwOTqJIu7zViTNJLjPEPgL+II00H/jnvXZspKGHRtH+ Edbr31zZsj770Sgsh4ETaONxCn/KjdNbFGTT/5pSiKm9F2egpi59m+eZxmtb9e00lUid dj3DYJnoo8R08NE4VWgv1DAMm9V8AP95wjrKBbB5vy5CnZ6X+fFEPRXPp1hImqeYlefr fEKD1zrfgxe2UsI85utU24DSAp1GQkdbokNttBmO0Rktc9ixR08NemeX0uwZmk47OH6o maL57UYaPvyQufnV9OtJTQd7riK6N+MzByKVwQMRfk/3pM5QDQobu1uuRvcvbvpcQC57 UUtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=KWWVr+ot; spf=pass (google.com: domain of linux-kernel+bounces-16646-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16646-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id a12-20020a056a000c8c00b006da94231494si5673424pfv.156.2024.01.04.04.36.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 04:36:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16646-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=KWWVr+ot; spf=pass (google.com: domain of linux-kernel+bounces-16646-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16646-linux.lists.archive=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 4500D286B9B for ; Thu, 4 Jan 2024 12:36:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 99E512137F; Thu, 4 Jan 2024 12:36:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="KWWVr+ot" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (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 2306C2111E for ; Thu, 4 Jan 2024 12:36:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a28bd9ca247so48861966b.1 for ; Thu, 04 Jan 2024 04:36:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1704371808; x=1704976608; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0rbdo4C/X6bEIX/A1ZdBX4InlDHJmGdJuXNskE1V/Lk=; b=KWWVr+otSCFrIjJ5IAAYiDUw23+7hTLRq7+8i+85YqYjzmHgFrkP9dR0mBNlR+tYPA OqjHfvHxMZQAfDaLd9hASLQk1lgnHqtH6t9V/4hjwLcK/ZEE8rinqZJSGsPCTA5ucO1X n0mAHZ7qJpuwbzIduPpcEiblqbYaXuHHesUjFJQ8k0Mn3hpV6/D07VdsfCPpFlm8LHZY sIEUev7RHRlH5A+Ltz9YX4JpQOE5qfTBG6WUUbI2ksK83bplNm3/r8HsXd8MtDyfd1X2 j+nFIEEgokJd/M+uU6jYYnBz96RYuPxXcYcmmdNAtnZg6M3cjcHM4LHqyJ2B9gyklcSh ZWRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704371808; x=1704976608; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0rbdo4C/X6bEIX/A1ZdBX4InlDHJmGdJuXNskE1V/Lk=; b=Uh30sFknFHaAApwNhE7cpJx67NMeVuMHRnv3MqhgRVTdeTDxBnkQ7PQe2BbH85QG4E lnHuD95kzZmOodcdAVILI8U1Ljpe1yFd1zAXun7/LRfNSPdMZ4sSHdJLrmRvBVTbuxc/ 90TA6c+gXyCmOvkhRTux+lUe3Zuwtoj+EOGQrRal+XJqddouAPtM0haqwvOwlLCymxwq +7yLsH3dVYrrL7JQn9/DxRa4/CJafRMp9HybQw0y2ise5h1yAQpNtBV9M/q52i1cgGlH k4xZgVe6ANshgGvEIpLyfyIJahE+pLHxWZL1OBsUn5KLkVCdehzKDVNQhGg0UgnaJvJ1 myPQ== X-Gm-Message-State: AOJu0YxVPByP7Dm7Su3DmtiHwvny8Ur5r1exTRKqZHsSjv+kzdQ+T71t 80m0mXpjCgPvHnjXFczK47yfocxkQpf8APBhtmo6/bhW3CPtDw== X-Received: by 2002:a17:906:58d:b0:a28:893:64a8 with SMTP id 13-20020a170906058d00b00a28089364a8mr336250ejn.85.1704371808415; Thu, 04 Jan 2024 04:36:48 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240102220134.3229156-1-samuel.holland@sifive.com> <20240102220134.3229156-6-samuel.holland@sifive.com> In-Reply-To: <20240102220134.3229156-6-samuel.holland@sifive.com> From: Alexandre Ghiti Date: Thu, 4 Jan 2024 13:36:37 +0100 Message-ID: Subject: Re: [PATCH v4 05/12] riscv: mm: Combine the SMP and UP TLB flush code To: Samuel Holland Cc: Palmer Dabbelt , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jan 2, 2024 at 11:01=E2=80=AFPM Samuel Holland wrote: > > 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 > --- > > 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/t= lbflush.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, unsig= ned 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 :=3D n > > obj-y +=3D init.o > -obj-$(CONFIG_MMU) +=3D extable.o fault.o pageattr.o > +obj-$(CONFIG_MMU) +=3D extable.o fault.o pageattr.o tlbflush.o > obj-y +=3D cacheflush.o > obj-y +=3D context.o > obj-y +=3D pgtable.o > obj-y +=3D pmem.o > > -ifeq ($(CONFIG_MMU),y) > -obj-$(CONFIG_SMP) +=3D tlbflush.o > -endif > obj-$(CONFIG_HUGETLB_PAGE) +=3D hugetlbpage.o > obj-$(CONFIG_PTDUMP_CORE) +=3D ptdump.o > obj-$(CONFIG_KASAN) +=3D kasan_init.o > -- > 2.42.0 > Nice one, you can add: Reviewed-by: Alexandre Ghiti Thanks, Alex