Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp795672rdd; Tue, 9 Jan 2024 22:48:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IEFJBySCjj9QlRba6OOafr8J+rHdBzHC9zpemgSsDkm3VOx4E/i+Ujacw8f7frZg8HiiuxO X-Received: by 2002:a05:622a:18a2:b0:429:9e25:1d48 with SMTP id v34-20020a05622a18a200b004299e251d48mr735069qtc.20.1704869288898; Tue, 09 Jan 2024 22:48:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704869288; cv=none; d=google.com; s=arc-20160816; b=HcBLK6PoMvsYWwbjEiYSF1hxxxHRP6T8HzjgIMeMmg84gB6VP5ofB1gSZwqny9xYCt 7nskI86kwReByqUV4KU7NsTbSR9ImCntysx3iuUpa7xAAScX2FxzKKEzIWw2jIvp7VHD R9o2+i8/ALClpMV/L/AaRaWZ8OFxeH+ouIN6mTES4kvwiY7DgMWbm68KRncIyqWTJsS3 neN7zkyCW4GfxfTWyXzEgIkgrfE3mDMBa2unmPH9nLYEx3EERFZalOogrTeJw868TUA+ nHh7o84LWDr94zVWWWQEN/RKkxmfG3VG/1OOXt8ccZ10e434F6Zfia3mxn2XIYRft3xt HWWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=lmeGXnF4o8j5ykm1E896xUJ2Ikyqqwp145FRyyzmn8I=; fh=KtroLETqZu38x5Q1Ybr1HwpaJ8A38CnOnSwyl0tT2E4=; b=TMaa9+kZI85cAHrLjutr4kZSs0N3atw7tsFlZcGQzFyoN83Aqu6HYKoHiu+tWMkWpN /3mFt5um1ExoIh7SI2wo77d2pB+fuBaiKv0ZOwL/DweYg/jz+1/eSFMh5R/Zoi8LBm3V eifXS5aXeeledSiTyMYg7zx1Oh7HyKRzcgS+6S5LTTtNH/dx+Dawx2+dwQ7JiOXMqvKt MCsRrlSBMsgr36XuA7i7bJ+Zgt4dlYZYVoU5wzvVcjPpa9vO0/F2dp0hRN9O8kWprD/+ tx6y935AQgBrOQgQt0bVQgAuXKGvlRoYl4bbnc2mvOuAJtwGbOA6r1MDZBFgrcbway3n bFtg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-21755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21755-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id i13-20020ac85c0d000000b00428142a90a9si3662986qti.450.2024.01.09.22.48.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 22:48:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-21755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-21755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21755-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A7CDB1C256B4 for ; Wed, 10 Jan 2024 06:48:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E898D364CF; Wed, 10 Jan 2024 06:48:02 +0000 (UTC) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75AD5364A9 for ; Wed, 10 Jan 2024 06:48:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ghiti.fr Received: by mail.gandi.net (Postfix) with ESMTPSA id 3D475E0003; Wed, 10 Jan 2024 06:47:48 +0000 (UTC) Message-ID: Date: Wed, 10 Jan 2024 07:47:48 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] RISC-V: only flush icache when it has VM_EXEC set Content-Language: en-US To: Yangyu Chen , linux-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Conor Dooley , Jisheng Zhang , Andrew Waterman References: From: Alexandre Ghiti In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-GND-Sasl: alex@ghiti.fr Hi Yangyu, On 09/01/2024 19:48, Yangyu Chen wrote: > As I-Cache flush on current RISC-V needs to send IPIs to every CPU cores > in the system is very costly, limiting flush_icache_mm to be called only > when vma->vm_flags has VM_EXEC can help minimize the frequency of these > operations. It improves performance and reduces disturbances when Which platform did you test this patchset? Do you have any measurement of the performance improvements? > copy_from_user_page is needed such as profiling with perf. > > For I-D coherence concerns, it will not fail if such a page adds VM_EXEC > flags in the future since we have checked it in the __set_pte_at function. > > Signed-off-by: Yangyu Chen > --- > arch/riscv/include/asm/cacheflush.h | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/arch/riscv/include/asm/cacheflush.h b/arch/riscv/include/asm/cacheflush.h > index 3cb53c4df27c..915f532dc336 100644 > --- a/arch/riscv/include/asm/cacheflush.h > +++ b/arch/riscv/include/asm/cacheflush.h > @@ -33,8 +33,11 @@ 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_page(vma, pg, addr, len) \ > - flush_icache_mm(vma->vm_mm, 0) > +#define flush_icache_user_page(vma, pg, addr, len) \ > +do { \ > + if (vma->vm_flags & VM_EXEC) \ > + flush_icache_mm(vma->vm_mm, 0); \ > +} while (0) > > #ifdef CONFIG_64BIT > #define flush_cache_vmap(start, end) flush_tlb_kernel_range(start, end) Otherwise, it looks good to me, so you can add: Reviewed-by: Alexandre Ghiti Thanks, Alex