From patchwork Tue Jan 9 14:45:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangyu Chen X-Patchwork-Id: 186428 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp156130dyi; Tue, 9 Jan 2024 06:47:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IFpdnLyYa4+tzYSfCVv8gdki3qPleqihClKT7h5B2hf29u31F2p46v+ff+7BppTdKgUy62U X-Received: by 2002:a05:6e02:1b8c:b0:35f:f1a9:8149 with SMTP id h12-20020a056e021b8c00b0035ff1a98149mr7707295ili.30.1704811623450; Tue, 09 Jan 2024 06:47:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704811623; cv=none; d=google.com; s=arc-20160816; b=XZfq+zixb3rODujZ3YP0C3feQ17NN2CutE6A6GENqS8TlSNNb12PWXnvidgty7cye9 VvpTSSXeVrAjyivs+hKI23EbOn5KnC00YAmzalArZXGWLpe3Day23cjnnNg1pOvGkesV soijeMnlNWYaLyF2i6njkU3hLpHEH+UPP8+W/coJsgZQD7LEDnLGzUbsJQUxupR+Rd2A pcJERjbTLF0p4+DiHT9ufL3m+WUF1440Tb1nZKE1QQKbOpcA0MJO8OuXnu8HyLEJEHkZ U10240Ex/scL9fojPj7sB+J6AmXOqh2PIK95ji9Or1Z/NXpbVha/GZ9LOQt1eFLJV9vb f2lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:subject:cc:to:from :message-id:dkim-signature; bh=kW1dPczTH04Crl0tbFUCfcQMkxib/V9/fWFO15vd0ac=; fh=ULehVswrx0HvtseSytkkx5fFO85YAQYSlb+4+2Qixi4=; b=ImH6daulE0Wj1K0Qtf52Gvi3mWyfm7+N+9wvI+hiu74OvveF3wKk7lyBrfrdPx6Dyr wAWVWYnWfSRkfTbh31vPGbtYNSfXfgmFtdZoaA+s0qYRVHMyDsd/gtkSeLsDp8BFJlYI VEGpf2EWe9UvKWJHoYP+gNdZYzR9v2JTDXY+wX7cqeUt7/tGY7tLc4pEDijB3EiPrHuF arhKNGi/5FrtYTDHG8FRYpRYSRVm0jwpBAIf0jmNuQY//euJq1IApRzfWyAyuztoKjdD dr8fh4Yzp/tNgyX8mwxSShjZzuFfUFly02uwVHPSxz9BjT46anR3GeZihrngxYiJWxLy nzKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@qq.com header.s=s201512 header.b=roCY5IWt; spf=pass (google.com: domain of linux-kernel+bounces-21009-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21009-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h191-20020a636cc8000000b005c626072edfsi1461969pgc.773.2024.01.09.06.47.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 06:47:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-21009-ouuuleilei=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=@qq.com header.s=s201512 header.b=roCY5IWt; spf=pass (google.com: domain of linux-kernel+bounces-21009-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21009-ouuuleilei=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 992A12871F1 for ; Tue, 9 Jan 2024 14:47:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CF50439FE5; Tue, 9 Jan 2024 14:46:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=qq.com header.i=@qq.com header.b="roCY5IWt" Received: from out162-62-57-49.mail.qq.com (out162-62-57-49.mail.qq.com [162.62.57.49]) (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 CC36039AC0; Tue, 9 Jan 2024 14:46:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=cyyself.name Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=cyyself.name DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1704811582; bh=kW1dPczTH04Crl0tbFUCfcQMkxib/V9/fWFO15vd0ac=; h=From:To:Cc:Subject:Date; b=roCY5IWtGteTzczcJ6Rg5jYCIT2mgvePdtxbY/m+xxSpnwzFi+pnsyBqdLsBvAyCp vpsfKa/TnPiX9K2O1LLNTDqCHGKbhkUdgIT7i/h2EG43+3eUKlfimWPQ5P/uSolojh 8GCX0wl1jLQ99XCyTmwkdPWatoLOSjUf+J45nRNk= Received: from cyy-pc.lan ([2001:da8:c800:d084:c65a:644a:13d7:e72c]) by newxmesmtplogicsvrszb9-1.qq.com (NewEsmtp) with SMTP id B8806A65; Tue, 09 Jan 2024 22:46:08 +0800 X-QQ-mid: xmsmtpt1704811568tjhw333a7 Message-ID: X-QQ-XMAILINFO: MJf32pulH481N5+721FHDLNIsCPMMppGeNjz2u6HG63swzGmnY8jwl7oe52Ui6 DZcnWAjXa93Z9dClvHOMcvdpYU5C73qTscOBPb3nCL/w9utGbUUuPUOZzN7MBkVXkpCd+qPRy7N+ irGWHzeIRxFpPzCzCCqN6rbJbQWqUt4zsAtXXTtH6sj+iWXDlCaIAvWx2qBogRRIkReNvy47Ytbq 7YE8wVeEMrTifNQx6S+aLlKdrdAyRu0lTDnt1tGsUzhXW31UtyDk6pydzCyL8ic+wvpmnrttyJ7o XOnL3gRCVw6c2ZdxZdVrvQbgSeUhAY2dwhCAPbAuz3ft+BwYa+UJHiUtuNu1jKJNvMg+QNeCP9Qa H0znsWzWa+9/WAQFFQYTxmCnaEPqQQB/XbUilTf9ZioykuQ/HrIctj/bOyJGQSgHcikt9D4SJS7N whidKdbYGiFGMnHT32hV4yHMsLC2NBSG/P5rv4FtdSA4W2HJfultP74sQthjUFzAWULP2f1jYtXl 6FMToImFWmp7EValb6ILd5wxCgjv4nK3O6jYk11qDRpP5i6Y8Ns1SlIdH7APxo+uMSBeTRfzV6OL 7iU1KQ1nm9N75RU9mj1dax4MIAe8c3+3dQQkOdd6Usre6DmnwihTaLiFTh19ZsrebEYDf76PGNgx 8GtW3LzRINoW1QRZ5vCy0UUUNayOVFUGa2QsCG2/0PGZygcn7K+tQ4ZNnPQvlE5ySZrG027YkkeT xnDvThWzmaEgBCmS5IGwU/bxkZv3BUH6OJ0X1kvR8xbsDGdzL29M0CdLYHUh7V3naGdTSJ4YZvXu ThgkA8V0QZeVBCI+YqNDjf1a1S3RC28HiDGZ795GmtQBoQGcENZdg6Wk0Ybe9Q/Jd+I97sOOzX57 NykiS9ynUeeg6cNSHZnEc2g8o6cWALxP2/2+rHdZ6rgUxuxdyIQmBQeD98nFQNQ5dgtmZE0FPcSc DCT1M/3VHEzZbo4g1ElO1o5YBlLJQ6uMp8ZjrhA9K048YtOv733gr1Jf4l6ebq X-QQ-XMRINFO: MSVp+SPm3vtS1Vd6Y4Mggwc= From: Yangyu Chen To: Arnd Bergmann Cc: Christoph Hellwig , Alexander Potapenko , Mike Frysinger , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Yangyu Chen Subject: [PATCH] asm-generic: flush icache only when vma->vm_flags has VM_EXEC set Date: Tue, 9 Jan 2024 22:45:59 +0800 X-OQ-MSGID: <20240109144559.315476-1-cyy@cyyself.name> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787624552315121712 X-GMAIL-MSGID: 1787624552315121712 For some ISAs like RISC-V, which may not support bus broadcast-based icache flushing instructions, it's necessary to send IPIs to all of the CPUs in the system to flush the icache. This process can be expensive for these ISAs and introduce disturbances during performance profiling. Limiting the icache flush to occur only when the vma->vm_flags has VM_EXEC can help minimize the frequency of these operations. Signed-off-by: Yangyu Chen --- include/asm-generic/cacheflush.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/asm-generic/cacheflush.h b/include/asm-generic/cacheflush.h index 84ec53ccc450..729d51536575 100644 --- a/include/asm-generic/cacheflush.h +++ b/include/asm-generic/cacheflush.h @@ -102,7 +102,8 @@ static inline void flush_cache_vunmap(unsigned long start, unsigned long end) do { \ instrument_copy_to_user((void __user *)dst, src, len); \ memcpy(dst, src, len); \ - flush_icache_user_page(vma, page, vaddr, len); \ + if (vma->vm_flags & VM_EXEC) \ + flush_icache_user_page(vma, page, vaddr, len); \ } while (0) #endif