Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3626619ybl; Mon, 27 Jan 2020 07:27:20 -0800 (PST) X-Google-Smtp-Source: APXvYqyh/ckbmpOkN8pBTgR3RnbtYZ3uKvYxDrrN1i+UNfFEVZwJVdDD32h8bTjyhciQnlQ4Ve2y X-Received: by 2002:aca:815:: with SMTP id 21mr8067560oii.52.1580138840484; Mon, 27 Jan 2020 07:27:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580138840; cv=none; d=google.com; s=arc-20160816; b=qe80OD/oq6S0dCf9kLx73wTRPeM7Vv8JwifMMjJpGUQS6wQpsHPnoKksNCQ4gylPYC jcYnfQN5Qrc3IUNYGtQM8iQSCHIye4NrEYlKaDV0pXrVRUQRyG13kqVj7j6XmIqUf7CD CVk9qqV+GQ6RiLssGeGFrqXtoM5KYQLAAIsKzQwFnV3mDGb3ot8n/dCyP6OOig2Ie2qN aOKxghm6wBPKbhSHPbeYxaE73NwAh0oJBdO9XqVXQU0ClmLm46xd1GY/7k33s73r9NeZ gdvitLgXj6yPyGPQFbUoEO7xjaKuxZsiF3lHqjxD422kojOXni9SqraT+qDd4XR/9O2N GrYQ== 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; bh=H6geSFx+S+IgHqUf4VcaZNtH+08l5FRugbxfs8MuzRM=; b=qEQJnqs5c3qNd1sTLKbhxBYOg3Mmu7pGPGG/KoE6txrfc+KL4gjhAVByWyX8gkm4Pm aT1rlE64QdNtT/nstFoIGL4oAwCALdI4J9Ql7u0mCP/mFRN1iyNpvb5eRajU4jAyZN9j y5jYKVji/e72Xj8SzWdKxRYEu6h+CdhFSZ67Y6qg7fkcJOtgpBoTAd3Dp3GVni2TBqKy wRRdqliZk9bEU/LSGqzbIBODdGmltZVZI4hWC+yuZISPDiWvpqlRmZjTlJQCgxO2U5VN x5ZTSCf8nZXtL1ukfYsrMkb9sXRXg0Hhfgxi9s1M13Orzc4jz6VBYnN7/icB+dPlgn+z XsoQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q9si3193961oij.125.2020.01.27.07.27.07; Mon, 27 Jan 2020 07:27:20 -0800 (PST) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729505AbgA0P0M (ORCPT + 99 others); Mon, 27 Jan 2020 10:26:12 -0500 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:36216 "EHLO out30-133.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729146AbgA0P0M (ORCPT ); Mon, 27 Jan 2020 10:26:12 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07488;MF=guoren@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0TociXAZ_1580138757; Received: from localhost(mailfrom:guoren@linux.alibaba.com fp:SMTPD_---0TociXAZ_1580138757) by smtp.aliyun-inc.com(127.0.0.1); Mon, 27 Jan 2020 23:25:57 +0800 Date: Mon, 27 Jan 2020 23:25:57 +0800 From: Guo Ren To: paul.walmsley@sifive.com, andrew@sifive.com, palmer@dabbelt.com Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-csky@vger.kernel.org, Albert Ou Subject: Re: [PATCH V2] riscv: Use flush_icache_mm for flush_icache_user_range Message-ID: <20200127152557.GA8980@parallels-Parallels-Virtual-Platform> References: <20200127145008.2850-1-guoren@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200127145008.2850-1-guoren@linux.alibaba.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, No ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1 in this patch, I'll remove it in V3. The update_mmu_cache() is wrong with sfence.vma and I'll give another patch to fixup it with ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1. Best Regards Guo Ren On Mon, Jan 27, 2020 at 10:50:08PM +0800, Guo Ren wrote: > The patch is the fixup for the commit 08f051eda33b by Andrew. > > For copy_to_user_page, the only call path is: > __access_remote_vm -> copy_to_user_page -> flush_icache_user_range > > Seems it's ok to use flush_icache_mm instead of flush_icache_all and > it could reduce flush_icache_all called on other harts. > > Add (vma->vm_flags & VM_EXEC) condition to flush icache only for > executable vma area. > > ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE is used in a lot of fs/block codes. > We need it to make their pages dirty and defer sync i/dcache in > update_mmu_cache(). > > Signed-off-by: Guo Ren > Cc: Paul Walmsley > Cc: Andrew Waterman > Cc: Palmer Dabbelt > Cc: Albert Ou > > --- > Changelog V2: > - Add VM_EXEC condition. > - Remove flush_icache_user_range definition. > - define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1 > --- > arch/riscv/include/asm/cacheflush.h | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/arch/riscv/include/asm/cacheflush.h b/arch/riscv/include/asm/cacheflush.h > index b69aecbb36d3..ae57d6ce63a9 100644 > --- a/arch/riscv/include/asm/cacheflush.h > +++ b/arch/riscv/include/asm/cacheflush.h > @@ -8,7 +8,7 @@ > > #include > > -#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 > +#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1 > > /* > * The cache doesn't need to be flushed when TLB entries change when > @@ -62,7 +62,8 @@ static inline void flush_cache_vunmap(unsigned long start, unsigned long end) > #define copy_to_user_page(vma, page, vaddr, dst, src, len) \ > do { \ > memcpy(dst, src, len); \ > - flush_icache_user_range(vma, page, vaddr, len); \ > + if (vma->vm_flags & VM_EXEC) \ > + flush_icache_mm(vma->vm_mm, 0); \ > } while (0) > #define copy_from_user_page(vma, page, vaddr, dst, src, len) \ > memcpy(dst, src, len) > @@ -85,7 +86,6 @@ static inline void flush_dcache_page(struct page *page) > * so instead we just flush the whole thing. > */ > #define flush_icache_range(start, end) flush_icache_all() > -#define flush_icache_user_range(vma, pg, addr, len) flush_icache_all() > > void dma_wbinv_range(unsigned long start, unsigned long end); > void dma_wb_range(unsigned long start, unsigned long end); > -- > 2.17.0