Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp766742rwb; Wed, 26 Jul 2023 02:30:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlEdQQ2GneH/Pxv6InI84I9nOool/s/+sykWj2d6j7NyUpOK1Oe0q8sVj3t8hBUKA84dj34G X-Received: by 2002:a05:6358:9895:b0:133:4ce:4e8c with SMTP id q21-20020a056358989500b0013304ce4e8cmr1337041rwa.29.1690363811049; Wed, 26 Jul 2023 02:30:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690363811; cv=none; d=google.com; s=arc-20160816; b=qgS0A8VZhvMLmjiRUfNt06WHlnpPA2n9hvm2fIYOQbDceF306bfzTo7KaqwxZ7+d2M 7iqTY7bqd/BdCfvpwq6hp9Vt7ZwE+XPIZjBAxjq/ys9A+8MbHLOQ0ynCqj9Han7jpI3m 1j5VacfBFuKzl+FJhVpMjP91bYKnhLoWBhv8iBQ+3lnGuiZeal3KUszjmeVCiWDb1gcm AmmSwrvGlp49lf6tG5DnZ5JHY6Bi6ZitBEErLWbX1J4FxkU3BJiGF6BnpzapNjod/bK0 UZOMy/bTC8roZii81MyonBfYZBSckDMNhffSWEBRwzX4m7BefAwNa24O7ByeyxSCfY7b H2/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=CIorqVVzQAbHZJUC4BNCOgZhZAEVr+TjS5Zo30Detsc=; fh=AOGxZkvyQJyR8NGd3iiPIU03CDvhNr6/spDLuC8P3pQ=; b=I5z8PK/dxGxyri/5IvxzdOu+g5GIek/WLiN+By0GmSMBzy9sOOyhAfXWP9glwUnMLO qISTMGPuGXv6MR0MfeYXXcsBLu9KeZBCzxlZePF+g0sNCAFCK9u5Ui0ngv19d39A1APU ujYXiVXqKXn+nVs+suSI9JJ3iCu3LTM52nATo20/uIa+OkH9+PN/4ORxv9kk+Yk1jErF mpm3oRtMiuSUjikxM5GJzDyBYi36d9ZHWthCTT9bh33vmFJWLIREt8A51+2eUb/JUMhx XBNZA9mwjU/MVLd8vYgbOKbjhiY2YsCZi3Nm0swKanLeeVMRk57IbpTiHBsDoEyHHyV1 vjYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b="l/NGQ3KM"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t25-20020a639559000000b00563e080a7c9si1041864pgn.759.2023.07.26.02.29.58; Wed, 26 Jul 2023 02:30:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b="l/NGQ3KM"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232909AbjGZIGk (ORCPT + 99 others); Wed, 26 Jul 2023 04:06:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231230AbjGZIGK (ORCPT ); Wed, 26 Jul 2023 04:06:10 -0400 Received: from m12.mail.163.com (m12.mail.163.com [220.181.12.215]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 78CE56181 for ; Wed, 26 Jul 2023 00:57:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=CIorq VVzQAbHZJUC4BNCOgZhZAEVr+TjS5Zo30Detsc=; b=l/NGQ3KMJcSYdMQcAXRCC Kb6LTOmgan9yuAZWYFc9dTLL9qZKqcxiYbCwaWlHrL/AMmUAOxWuem0hy+DtysGH JE/M5DiERCZ5aOjSkXxNpK5IyC5J+iE9QRUmzYacY9FxJ8Vbl7jY/L7h3TQnQDzc xMhBJQRSmJInihcjjR84do= Received: from yw-virtual-machine.localdomain (unknown [180.110.115.47]) by zwqz-smtp-mta-g4-1 (Coremail) with SMTP id _____wDXEzFczsBkuNlkBQ--.45898S2; Wed, 26 Jul 2023 15:42:21 +0800 (CST) From: wang_yang To: palmer@dabbelt.com Cc: aou@eecs.berkeley.edu, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, wang_yang , Wang Yang Subject: [PATCH] RISC-V: Use GCC __builtin_prefetch() to implement prefetch(). GCC's __builtin_prefetch() was introduced a long time ago, all supported GCC versions have it.So this patch is to use it for implementing the prefetch. RISC-V Cache Management Operation instructions has been supported by GCC last year.you can refer to https://github.com/gcc-mirror/gcc/commit/3df3ca9014f94fe4af07444fea19b4ab29ba8e73 It is worth noting that CPU based on RISC-V should support Zicbop extension. This has been already done on other architectures (see the commit: https://github.com/torvalds/linux/commit/0453fb3c528c5eb3483441a466b24a4cb409eec5). Date: Wed, 26 Jul 2023 15:42:18 +0800 Message-Id: <20230726074218.32933-1-wang_yang6662023@163.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: _____wDXEzFczsBkuNlkBQ--.45898S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7Jw4kKr13Xw4DKFWxCw4xCrg_yoW3uwb_Cw 1xJa10grW8ZF48uFy2yw4rtrWjy395tF9rWF4Iy3WYy3srWa1UXa9rGw1UJryUZrs0qFsr uF98Zay8GryakjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUjsXotUUUUU== X-Originating-IP: [180.110.115.47] X-CM-SenderInfo: 5zdqwsp1dqwlawwsijqt6rljoofrz/1tbiYx649VaEP9up8gAAsd X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_BL,RCVD_IN_MSPIKE_L4, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Wang Yang --- arch/riscv/include/asm/processor.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h index c950a8d9edef..f16d4c85ca5b 100644 --- a/arch/riscv/include/asm/processor.h +++ b/arch/riscv/include/asm/processor.h @@ -70,6 +70,17 @@ extern void start_thread(struct pt_regs *regs, extern unsigned long __get_wchan(struct task_struct *p); +#define ARCH_HAS_PREFETCH +static inline void prefetch(const void *ptr) +{ + __builtin_prefetch(ptr, 0, 3); +} + +#define ARCH_HAS_PREFETCHW +static inline void prefetchw(const void *ptr) +{ + __builtin_prefetch(ptr, 1, 3); +} static inline void wait_for_interrupt(void) { -- 2.34.1