Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1323297ybg; Fri, 18 Oct 2019 15:58:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqySos232MYb+HJfa37qBUBWvJDLtJ/vAc/3kH0mHCNHI4jNqtxswilUtcGRFL7pqLdaE7YC X-Received: by 2002:aa7:ce94:: with SMTP id y20mr12516098edv.120.1571439523376; Fri, 18 Oct 2019 15:58:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571439523; cv=none; d=google.com; s=arc-20160816; b=QeYxCGPr19FE/kxJRhFjQRrxb2p3bY+Glkg825zUDqTt5wSIS+aoElQqJ2P5Zdnaaz MOYrWcWrkeqdDCOtB0icje7xuS2AHKNrsHcomuts/nO+gPb+LJVbpAXeAWfB6Tr8O2zG g8V3ugQzIhunC+1Np61bZlgWcJZaIbRv9nITSCatFGxuXhxhofW5IcC1wOgD6JTOWJ0U cRuSf11BzHa4kHFe0HcYs8jSOQbdzmgLhnmo2qX8Wz5d8AR+trft0Yi6HJdOBYVNkVKw Ehf0aKqEEG+kX1tNCKVnueoXTfmYTMsS96NySZViU2e0Spxmb2n1PJ72WLZzPy5psLOa VhFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=xKBYmqBKnM/fTox+DxH/j6jDg0wBrXkD7WU8TmLcePI=; b=e1P8qz4TOFbo5i1ZtMtVg83nFLA3yQ/DeB7RwoHQCUnJGDPD1LFNJ/nZErv5E+Exyr lYXVFFYt0Z1cPVJz0k5yZHuu9ezr4P9e49ZcbXMN46gLy9WURO9ljR1YcReHFGpx9KrD FBziKC7a5HsUAFpuU4v3uHer6InVzi0rYd4nj3ANpL8fbuXkgnPvlgaJaHQYLy74LC4+ i9Ee4lfOkQs91XTvZcV1F6N/yNBj8RsJCPBEWPUx3++wKP/gYkRIlk1WPuIusjr8V6Dn Lmh9QhFXztwcuk6PS6GK4NC/qa98oxGb+hIvcKSurFCjp6xhpLFNkV5XYTAliQkE46me 0mRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=P7b8jX1i; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pk19si4531045ejb.257.2019.10.18.15.58.20; Fri, 18 Oct 2019 15:58:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=P7b8jX1i; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405589AbfJRFxb (ORCPT + 99 others); Fri, 18 Oct 2019 01:53:31 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:54030 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391881AbfJRFxb (ORCPT ); Fri, 18 Oct 2019 01:53:31 -0400 Received: by mail-wm1-f67.google.com with SMTP id i16so4783216wmd.3 for ; Thu, 17 Oct 2019 22:53:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xKBYmqBKnM/fTox+DxH/j6jDg0wBrXkD7WU8TmLcePI=; b=P7b8jX1ijvI/1bRMfMuCiF0DEfoT7NClM6s9cMKR7dPyvouJu3HRaHo0oNEOiIahvW LnPgQ7tzaz6FV2kJQH7KN0daOdPvxM/i8MQyIWUjxhfUwumj9stzNXKAyHHcvFdn4OI/ t8qPLUyAZ+NvrqlrlxFWHnMKvbZHDa0pnlb2cgzexpgcQQzLIjqlxum+EFN5TA1U1mcn wjB+Ni93KTrNJB7Ncrk/ysFSdGxHwows7K8UvOp1offJm7vaxd9gggcXKetxJilyGmE5 y3s8l4JLTbm8cp5/1FfpR+C9aw1JnFbY61P4A8w45w431ia/nPKYBTcieXjzaowvKALO 4JWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xKBYmqBKnM/fTox+DxH/j6jDg0wBrXkD7WU8TmLcePI=; b=bX/t594LAAupm6OVmcIr2zFI2620J+InaDqVieA8N5uhzlzZYWOr3DlaKbkdPpeMAp 1yWhB+zTyeZyguGY4NPxsmYBNnJlgQ8QW/TNX8Qt9xDmj00VTk99zZYGqaCxx3XmxYRO K6sURlAGsykJBHCqxjLklXLDYCaM9apdwsHw7549fZcYPziFRufvU3DfEiSZm1HfHVPg vGlIDiM5EV0yFGgxznyLm31KiTyNZ2idfAezmxZrEwGOATRec/wuGppuvNEzqrCmAWsh Ttyiw99E4DiNtoDEErK/cFyzI7EjP3qVTx6qpqTwuu8KtUPAa3QeJIDpElbojyiJEVvs PLXQ== X-Gm-Message-State: APjAAAV+ypQGon2CvU7MKv12dd/+KvzRyDOi4SJZQMYEOwIO9oGfD+T7 2+LsDbJN8d9bLPwoiR0OA+SZBRLnFWaqv4CIBSJduOHYmvA= X-Received: by 2002:a1c:bc07:: with SMTP id m7mr5449292wmf.103.1571367327709; Thu, 17 Oct 2019 19:55:27 -0700 (PDT) MIME-Version: 1.0 References: <20191017173743.5430-1-hch@lst.de> <20191017173743.5430-8-hch@lst.de> In-Reply-To: <20191017173743.5430-8-hch@lst.de> From: Anup Patel Date: Fri, 18 Oct 2019 08:25:17 +0530 Message-ID: Subject: Re: [PATCH 07/15] riscv: implement remote sfence.i using IPIs To: Christoph Hellwig Cc: Palmer Dabbelt , Paul Walmsley , Damien Le Moal , linux-riscv , "linux-kernel@vger.kernel.org List" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 17, 2019 at 11:08 PM Christoph Hellwig wrote: > > The RISC-V ISA only supports flushing the instruction cache for the > local CPU core. Currently we always offload the remote TLB flushing to > the SBI, which then issues an IPI under the hoods. But with M-mode > we do not have an SBI so we have to do it ourselves. IPI to the > other nodes using the existing kernel helpers instead if we have > native clint support and thus can IPI directly from the kernel. > > Signed-off-by: Christoph Hellwig > --- > arch/riscv/include/asm/sbi.h | 3 +++ > arch/riscv/mm/cacheflush.c | 24 ++++++++++++++++++------ > 2 files changed, 21 insertions(+), 6 deletions(-) > > diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h > index b167af3e7470..0cb74eccc73f 100644 > --- a/arch/riscv/include/asm/sbi.h > +++ b/arch/riscv/include/asm/sbi.h > @@ -94,5 +94,8 @@ static inline void sbi_remote_sfence_vma_asid(const unsigned long *hart_mask, > { > SBI_CALL_4(SBI_REMOTE_SFENCE_VMA_ASID, hart_mask, start, size, asid); > } > +#else /* CONFIG_RISCV_SBI */ > +/* stub to for code is only reachable under IS_ENABLED(CONFIG_RISCV_SBI): */ > +void sbi_remote_fence_i(const unsigned long *hart_mask); > #endif /* CONFIG_RISCV_SBI */ > #endif /* _ASM_RISCV_SBI_H */ > diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c > index 3f15938dec89..794c9ab256eb 100644 > --- a/arch/riscv/mm/cacheflush.c > +++ b/arch/riscv/mm/cacheflush.c > @@ -10,9 +10,17 @@ > > #include > > +static void ipi_remote_fence_i(void *info) > +{ > + return local_flush_icache_all(); > +} > + > void flush_icache_all(void) > { > - sbi_remote_fence_i(NULL); > + if (IS_ENABLED(CONFIG_RISCV_SBI)) > + sbi_remote_fence_i(NULL); > + else > + on_each_cpu(ipi_remote_fence_i, NULL, 1); > } > > /* > @@ -28,7 +36,7 @@ void flush_icache_all(void) > void flush_icache_mm(struct mm_struct *mm, bool local) > { > unsigned int cpu; > - cpumask_t others, hmask, *mask; > + cpumask_t others, *mask; > > preempt_disable(); > > @@ -46,10 +54,7 @@ void flush_icache_mm(struct mm_struct *mm, bool local) > */ > cpumask_andnot(&others, mm_cpumask(mm), cpumask_of(cpu)); > local |= cpumask_empty(&others); > - if (mm != current->active_mm || !local) { > - riscv_cpuid_to_hartid_mask(&others, &hmask); > - sbi_remote_fence_i(hmask.bits); > - } else { > + if (mm == current->active_mm && local) { > /* > * It's assumed that at least one strongly ordered operation is > * performed on this hart between setting a hart's cpumask bit > @@ -59,6 +64,13 @@ void flush_icache_mm(struct mm_struct *mm, bool local) > * with flush_icache_deferred(). > */ > smp_mb(); > + } else if (IS_ENABLED(CONFIG_RISCV_SBI)) { > + cpumask_t hartid_mask; > + > + riscv_cpuid_to_hartid_mask(&others, &hartid_mask); > + sbi_remote_fence_i(cpumask_bits(&hartid_mask)); > + } else { > + on_each_cpu_mask(&others, ipi_remote_fence_i, NULL, 1); > } > > preempt_enable(); > -- > 2.20.1 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv LGTM. Reviewed-by: Anup Patel Regards, Anup