Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3854187rdb; Mon, 11 Dec 2023 01:44:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IE7ZYYjJNJ81oYxR+DMN0bzx1iuVLvCq0ow65OkAcbvO9aUGILk/e1GeUXuDdNA/Uuta2qn X-Received: by 2002:a05:6870:568a:b0:1fb:75b:2fad with SMTP id p10-20020a056870568a00b001fb075b2fadmr5370956oao.68.1702287896081; Mon, 11 Dec 2023 01:44:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702287896; cv=none; d=google.com; s=arc-20160816; b=VbA8N8P2agYx2mD0a9e0nIP9PNi+f3dM5KuIblqVts8WdzDmJsGAcfaPQKJ/XRG7WE wdk54T6uvPY+mN9K/0/Keqh0aZHvTQLJYaXGqgwhSgtlyvM66OYlq3pXrL2dDE2Wh5WY 6vJPu1cJQWR+/+7PmCDlorhr/h8P6G1EzIug2rbU5UtXUYZ88EPFCJimYLIxp4JydzSQ FVwGwMRLhSanNqIvvM9u/EbRoyiXMVB6KMD2NvP0Pd5nyiTyEb4jDbv71Ezpwyqe8zBM AbZa6oZIYKIAGHGVXHOljR/4VVyFgTh29mTPLhK44XMm7VJ7XIQiSv2/NLK+tMhKVIKU 3PTw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mfT6yTigw0JL9rPQ3RLVTHss5/tTMRXlGfMsOm5hiBA=; fh=6I8UF0n155JlUMKXPHZEdVXaDDfdWw9idVSmXg1+KEE=; b=PIiLdGA191667sI5NJNDJUx+6VI5oKUuOR2mDIRB8w5GDkgJLiFBEx9DWDfEfW7F/Z d8ox/Z6cHwSKpbB0nbqJ9/9TL79QiWtZuxC+ndpju4CUEkuiD9OpoBp9KxFsJUQWH4OE 8tV9lI+ZO49gWtXV++KuZMCtpnFgYoIbwyTeINf0nHHAVGsguXs/Wv9tZbhc20oG0wN5 kkbVGy+630zV73WJYeN8n65j5h95m2SmaYVjkJR9CBHi02RIr9Y141Czur0pLaxEJDGE +BYSpB4tEIo8pNcYYKES3cJyBGBgBsJIMALA4KdNd2FlKKOkYJl1d5tUAj9pom9Ah6fn jiNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=LxX+NeJm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id y3-20020a636403000000b005c6b4e190a3si5649772pgb.552.2023.12.11.01.44.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 01:44:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=LxX+NeJm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 48D6C80752AD; Mon, 11 Dec 2023 01:44:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234655AbjLKJob (ORCPT + 99 others); Mon, 11 Dec 2023 04:44:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234619AbjLKJo1 (ORCPT ); Mon, 11 Dec 2023 04:44:27 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EBC5CE for ; Mon, 11 Dec 2023 01:44:33 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-54da61eb366so5658441a12.3 for ; Mon, 11 Dec 2023 01:44:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702287872; x=1702892672; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mfT6yTigw0JL9rPQ3RLVTHss5/tTMRXlGfMsOm5hiBA=; b=LxX+NeJmku4hhfwrCuLd7Y4EmSUJY/rWF4dkOk0wtCBLRLkUdksgBUIQT/wywyFOiW Ikm6SeMjQX2C/WuocV9tTcrHLtlvFC+zCdsqHQVofwfmntMnxLXnjPhYlOsLJn7rQQ5J MQNXYs1+GQQ6yLePwB5ukueLn4vCbBJPjKTaMmZmRXRCQLLnYQfrIB9HQKxAvUouOAJx NERDYxemmIj9ObiiDjfRn4EluEb/Xlw5nAo5oB1ZkiOxzpriI0MZYTN+U7p0rn+pEhTj ogqsXa/+W2dnuzPl1qe6sM0nLLDS9xJo0Uxiv0TWK5Kn+AvHnk0Fnxx5gfL5vworcrCo emag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702287872; x=1702892672; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mfT6yTigw0JL9rPQ3RLVTHss5/tTMRXlGfMsOm5hiBA=; b=BH3tTKaQQnnmfJaJcqyXsh3njcIqqBBimppTZ4C0Z2T1koobDg1TrWSg+HJz8ujjsI ICQ9KcSc37boEnV21wKj6cw6xnxF0mKc4w+tpy5dJMWG0gVGFaDEbon4O7lzcKli15Z7 oai255l0CeHC+lYsBO2DcnSP4cquKIkF8gBd3TX38OJqzL/yPnuTAxFnN1JCvZ1DY9cr 4LcxCp0hTyHqBQpdOa41AqwmWhkspklAujITN+yFFqlnxpeW9iJpV2WKCQZqkZlywuLm kIKh/i0z/WF4BMFlCGHVx0yHfrnF40oXq3JTX1NOF3iVnhUqs3hXAc5gvYzcokSOKcly 6jmA== X-Gm-Message-State: AOJu0YzilyW7ffo4LQUXiO/t1Xj1UfUhkvGYe1FK/MhoQVoFqgC6U15D A5kRX4bq69GiZkhzkhageoQ= X-Received: by 2002:a50:fb8b:0:b0:54c:4837:93f7 with SMTP id e11-20020a50fb8b000000b0054c483793f7mr2864378edq.62.1702287871520; Mon, 11 Dec 2023 01:44:31 -0800 (PST) Received: from andrea.wind3.hub ([31.189.124.152]) by smtp.gmail.com with ESMTPSA id if3-20020a0564025d8300b0054afcab0af2sm3463505edb.59.2023.12.11.01.44.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 01:44:31 -0800 (PST) From: Andrea Parri To: mathieu.desnoyers@efficios.com, paulmck@kernel.org, palmer@dabbelt.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu Cc: mmaas@google.com, hboehm@google.com, striker@us.ibm.com, charlie@rivosinc.com, rehn@rivosinc.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Andrea Parri Subject: [PATCH v2 2/4] locking: Introduce prepare_sync_core_cmd() Date: Mon, 11 Dec 2023 10:44:12 +0100 Message-Id: <20231211094414.8078-3-parri.andrea@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231211094414.8078-1-parri.andrea@gmail.com> References: <20231211094414.8078-1-parri.andrea@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 11 Dec 2023 01:44:53 -0800 (PST) Introduce an architecture function that architectures can use to set up ("prepare") SYNC_CORE commands. The function will be used by RISC-V to update its "deferred icache- flush" data structures (icache_stale_mask). Architectures defining prepare_sync_core_cmd() static inline need to select ARCH_HAS_PREPARE_SYNC_CORE_CMD. Suggested-by: Mathieu Desnoyers Signed-off-by: Andrea Parri Reviewed-by: Mathieu Desnoyers --- include/linux/sync_core.h | 16 +++++++++++++++- init/Kconfig | 3 +++ kernel/sched/membarrier.c | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/linux/sync_core.h b/include/linux/sync_core.h index 013da4b8b3272..67bb9794b8758 100644 --- a/include/linux/sync_core.h +++ b/include/linux/sync_core.h @@ -17,5 +17,19 @@ static inline void sync_core_before_usermode(void) } #endif -#endif /* _LINUX_SYNC_CORE_H */ +#ifdef CONFIG_ARCH_HAS_PREPARE_SYNC_CORE_CMD +#include +#else +/* + * This is a dummy prepare_sync_core_cmd() implementation that can be used on + * all architectures which provide unconditional core serializing instructions + * in switch_mm(). + * If your architecture doesn't provide such core serializing instructions in + * switch_mm(), you may need to write your own functions. + */ +static inline void prepare_sync_core_cmd(struct mm_struct *mm) +{ +} +#endif +#endif /* _LINUX_SYNC_CORE_H */ diff --git a/init/Kconfig b/init/Kconfig index 9ffb103fc927b..87daf50838f02 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1972,6 +1972,9 @@ source "kernel/Kconfig.locks" config ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE bool +config ARCH_HAS_PREPARE_SYNC_CORE_CMD + bool + config ARCH_HAS_SYNC_CORE_BEFORE_USERMODE bool diff --git a/kernel/sched/membarrier.c b/kernel/sched/membarrier.c index 2ad881d07752c..58f801e013988 100644 --- a/kernel/sched/membarrier.c +++ b/kernel/sched/membarrier.c @@ -320,6 +320,7 @@ static int membarrier_private_expedited(int flags, int cpu_id) MEMBARRIER_STATE_PRIVATE_EXPEDITED_SYNC_CORE_READY)) return -EPERM; ipi_func = ipi_sync_core; + prepare_sync_core_cmd(mm); } else if (flags == MEMBARRIER_FLAG_RSEQ) { if (!IS_ENABLED(CONFIG_RSEQ)) return -EINVAL; -- 2.34.1