Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3883532ybl; Mon, 12 Aug 2019 07:57:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwV1AkdXF/yw324WuSpECBvZJUFK6hXT5hzi1aEV0IswlduKN+OXsqIAaXHC9DZOMDW9nA7 X-Received: by 2002:a17:902:2ae8:: with SMTP id j95mr30662388plb.276.1565621861296; Mon, 12 Aug 2019 07:57:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565621861; cv=none; d=google.com; s=arc-20160816; b=Czlgcgz+TtfY76KLiMUEXeHb1hjBJZZOdFYz6JwNi5jKiD3NRu4SIbKU5/qJVGeCxF mzz+2uizC8LRauLO4c1uP9AEkGba6uc4IxKQchMqyTDHMNFMIF0zHX9ZMvZ8MwYFQLvY WJVQFEU5b+X9LiKyxOE9sKXx51DMAf0/yqVEChSfKdvGNbX/VCpGAmuxrDupkwK45Jj9 5/Nrp7B+u1umvT4bhQ/JJ8Uze2PZZtNZAUehbLblHzh94zQRppwFKXdMP1etX5Oml4k2 QTRwwb1qtRjCGtjvCktvjQQeX4gJIgxtWVvfhPmvDghVkBy3JnKIMqWTWfFk+JNCIxkW p81Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=J7eOk4wkvl1ZRHOqJ/6BItrpvzWshj+n4R5L+gfBXQc=; b=CKFsPvyAF0Xx/utWFDJWQhP1yRy8RNZyfViSIF7DuaRUNVwPXbgu3AxDTDHJuQ+43a BdxKY02KfHlivlzhRP7jiDuahW9SJJWzIladJIHJq+48jAmuUGqMJRFlLR6k5Bkh2v1z +TKcd1cc8jfVphcXcdt2LCBykE3OcnLGODELF3n4oewEAC0WmkW3yW5aaH5+s35tcIBe +YacJs+KRzuISSYt/gBWe7853zMM7YXyPe//WaoCP5nw/75O2Hwk2xbVtbdyHBbf6bHO Ry8iaRGwSlYEqwxH7SgAHiOemm5SNOvzsMqa2/w7ke7/W/tiSateiC9OBrrl9vFEo5/Y XN4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=vCianp2j; 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 p35si62882302pgb.484.2019.08.12.07.57.25; Mon, 12 Aug 2019 07:57:41 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=vCianp2j; 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 S1727100AbfHLO4c (ORCPT + 99 others); Mon, 12 Aug 2019 10:56:32 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:57304 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726831AbfHLO4c (ORCPT ); Mon, 12 Aug 2019 10:56:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=J7eOk4wkvl1ZRHOqJ/6BItrpvzWshj+n4R5L+gfBXQc=; b=vCianp2jMfu2wigM8bEhV1sSx +7uMHMOupRKqQ2TXmJ7ZXiZU+ZrN5Gn8ULUshK26A44BuxVQzaf51pPTMXqgdW3pPK2gz3U0h/h/z g65Xg+s7rxkPHWAg4+T4azezNwWPPz7qWGgJEx4OhvZJPis/nMt5qkR/BeW6Mjv0+2Oj1LmbznMqP 7Wnqb4DcoZhF0lLGZfGw0Paxid9kyuJwpMnxibVwc0I1D02gTdbQWkHigRBNcaaR2UKQ8FQaU30bL n8fPd7VBTNONWW9xtGPGuInnPPWe8HVvOMV1Et1E+g0IR8HfUaFZEGPA8+0XXnySul9uUWlsUObyg 7+XwURRNA==; Received: from hch by bombadil.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1hxBkN-0003Jt-5S; Mon, 12 Aug 2019 14:56:31 +0000 Date: Mon, 12 Aug 2019 07:56:31 -0700 From: Christoph Hellwig To: Atish Patra Cc: linux-kernel@vger.kernel.org, Albert Ou , Alexios Zavras , Greg Kroah-Hartman , Palmer Dabbelt , Anup Patel , Paul Walmsley , linux-riscv@lists.infradead.org, Allison Randal Subject: Re: [PATCH] RISC-V: Issue a local tlb flush if possible. Message-ID: <20190812145631.GC26897@infradead.org> References: <20190810014309.20838-1-atish.patra@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190810014309.20838-1-atish.patra@wdc.com> User-Agent: Mutt/1.11.4 (2019-03-13) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I agree with the comment that we really should move this out of line now, and also that we can simplify it further, which also includes not bothering with the SBI call if we were the only online CPU. I also thing we need to use get_cpu/put_cpu to be preemption safe. Also why would we need to do a local flush if we have a mask that doesn't include the local CPU? How about something like: void __riscv_flush_tlb(struct cpumask *cpumask, unsigned long start, unsigned long size) { unsigned int cpu; if (!cpumask) cpumask = cpu_online_mask; cpu = get_cpu(); if (!cpumask || cpumask_test_cpu(cpu, cpumask) { if ((start == 0 && size == -1) || size > PAGE_SIZE) local_flush_tlb_all(); else if (size == PAGE_SIZE) local_flush_tlb_page(start); cpumask_clear_cpu(cpuid, cpumask); } if (!cpumask_empty(cpumask)) { struct cpumask hmask; riscv_cpuid_to_hartid_mask(cpumask, &hmask); sbi_remote_sfence_vma(hmask.bits, start, size); } put_cpu(); }