From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B95BC4332F for ; Tue, 22 Nov 2022 20:41:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234980AbiKVUlf (ORCPT ); Tue, 22 Nov 2022 15:41:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234468AbiKVUkW (ORCPT ); Tue, 22 Nov 2022 15:40:22 -0500 Received: from smtpout.efficios.com (unknown [IPv6:2607:5300:203:b2ee::31e5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED9EA7721A; Tue, 22 Nov 2022 12:39:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1669149595; bh=RT5zTNt+b0dcxGolKxL6wWKrezXmEB7dqcTheMOw884=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ujG03NqI1iqdY873NCE8qMSNYp+S7TvN7gPDH9xMjAKgZG0HHocfuyjQFJKyJQczV QdRCwTfba90an/tkqpcLObr9pDFP4+kXLzrKqSgXPafh6kKjq0Ib1bBXTt//Zo2+AL ai+/d95qVuXlJ9lmksS1AvY3iyPamfvI2zFBpOND5mZX9kkKkPAHycGC2WXrDg4WAK DmZdSP1rhyuXAOA9F2v8n8QSYaDscDAdfy7GSTTFt7kT1kD67CT54HmA5eJTBlCnsV JDGW8CdEXCzjXxsCASQH5AzAqFV1P2MfGQAp9RZiQw54JWbS/QZJt9UKqgWliUJNvj BoN02AJN98SOQ== Received: from localhost.localdomain (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4NGx2f5MY3zXJc; Tue, 22 Nov 2022 15:39:54 -0500 (EST) From: Mathieu Desnoyers To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , "Paul E . McKenney" , Boqun Feng , "H . Peter Anvin" , Paul Turner , linux-api@vger.kernel.org, Christian Brauner , Florian Weimer , David.Laight@ACULAB.COM, carlos@redhat.com, Peter Oskolkov , Alexander Mikhalitsyn , Chris Kennelly , Mathieu Desnoyers Subject: [PATCH 25/30] rseq: Extend struct rseq with per-memory-map NUMA-aware Concurrency ID Date: Tue, 22 Nov 2022 15:39:27 -0500 Message-Id: <20221122203932.231377-26-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221122203932.231377-1-mathieu.desnoyers@efficios.com> References: <20221122203932.231377-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-api@vger.kernel.org Expose a per-memory-map NUMA-aware concurrency ID to userspace. Each concurrency ID stays associated with the same NUMA node except in case of NUMA topology reconfiguration. Signed-off-by: Mathieu Desnoyers --- include/uapi/linux/rseq.h | 9 +++++++++ kernel/rseq.c | 10 +++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/rseq.h b/include/uapi/linux/rseq.h index c233aae5eac9..5779249ed37f 100644 --- a/include/uapi/linux/rseq.h +++ b/include/uapi/linux/rseq.h @@ -148,6 +148,15 @@ struct rseq { */ __u32 mm_cid; + /* + * Restartable sequences mm_numa_cid field. Updated by the kernel. + * Read by user-space with single-copy atomicity semantics. This field + * should only be read by the thread which registered this data + * structure. Aligned on 32-bit. Contains the current thread's + * NUMA-aware concurrency ID (allocated uniquely within a memory map). + */ + __u32 mm_numa_cid; + /* * Flexible array member at end of structure, after last feature field. */ diff --git a/kernel/rseq.c b/kernel/rseq.c index cb2512ab3256..58b09de0de47 100644 --- a/kernel/rseq.c +++ b/kernel/rseq.c @@ -91,14 +91,17 @@ static int rseq_update_cpu_node_id(struct task_struct *t) u32 cpu_id = raw_smp_processor_id(); u32 node_id = cpu_to_node(cpu_id); u32 mm_cid = task_mm_cid(t); + u32 mm_numa_cid = task_mm_numa_cid(t); WARN_ON_ONCE((int) mm_cid < 0); + WARN_ON_ONCE((int) mm_numa_cid < 0); if (!user_write_access_begin(rseq, t->rseq_len)) goto efault; unsafe_put_user(cpu_id, &rseq->cpu_id_start, efault_end); unsafe_put_user(cpu_id, &rseq->cpu_id, efault_end); unsafe_put_user(node_id, &rseq->node_id, efault_end); unsafe_put_user(mm_cid, &rseq->mm_cid, efault_end); + unsafe_put_user(mm_numa_cid, &rseq->mm_numa_cid, efault_end); /* * Additional feature fields added after ORIG_RSEQ_SIZE * need to be conditionally updated only if @@ -117,7 +120,7 @@ static int rseq_update_cpu_node_id(struct task_struct *t) static int rseq_reset_rseq_cpu_node_id(struct task_struct *t) { u32 cpu_id_start = 0, cpu_id = RSEQ_CPU_ID_UNINITIALIZED, node_id = 0, - mm_cid = 0; + mm_cid = 0, mm_numa_cid = 0; /* * Reset cpu_id_start to its initial state (0). @@ -141,6 +144,11 @@ static int rseq_reset_rseq_cpu_node_id(struct task_struct *t) */ if (put_user(mm_cid, &t->rseq->mm_cid)) return -EFAULT; + /* + * Reset mm_numa_cid to its initial state (0). + */ + if (put_user(mm_numa_cid, &t->rseq->mm_numa_cid)) + return -EFAULT; /* * Additional feature fields added after ORIG_RSEQ_SIZE * need to be conditionally reset only if -- 2.25.1