Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6440836rwb; Tue, 22 Nov 2022 13:28:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf6LLFjl8YpGD0XttGEWq9GMasOO0TnZV2LuSMprkpb8GUiES5Sz6j2F/BrL6re7IpRYCtU3 X-Received: by 2002:aa7:d358:0:b0:467:6847:1ea7 with SMTP id m24-20020aa7d358000000b0046768471ea7mr8090726edr.237.1669152526597; Tue, 22 Nov 2022 13:28:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669152526; cv=none; d=google.com; s=arc-20160816; b=kt4LteeDvtk+RAploytrxrG4Ha1lBti8aYAJZDGDhpSNVmIkRkbxbhhsOKRtaPn9Vi L4srQJobLvZG8scfzP7zT/0YFS665Ylhdz+u4tpPO9tSzmRVG1KwxwsFKLQTTab1w2hs SmdIHr6IPLLC/Cf7sGgkfoobPdhZq0UKarTBgfRArNIFvUy7UW1hMCR9t9F/gjJuWaPs 9IiPdTQScPEXmq0yXDXLYy00Zeaa/mYQcdVO+wyPjsat9mbvTx+QHQ9lulqgvXvfykdc f+cNwi7OjPWYJGMUU61j1bOXPKLyB/taKmtPikkK5/p3Ypgdg2Hqa7K791q4o29ccreL 6Zmg== 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=og6C6YoMceJ6GySewx9oEcq7qqrTCPmKC9Zm8VuwjQU=; b=LtTy7if5HUvWqj72faWUzcYDnSqnUNuQogXOsPmDeV7NH2V2xb4RaRqCb85+A+mx4t Bc2gQo/6LdxM1K/YIr52bSJxXG4m7xdM7khsFNFD2Y5gmYKtrxJTk2Euh3QB/JW+vsUf aOEN12q98/NZqBuooPvZdk4p6/nad34RD3CEGQjJNXHKM+oQEjNS45qSE6czLTithv71 n7+ZolFmoeZqHc8tk72E9SDyVljXXRtK3PubZz7I6ljnShAs9Nz4GRh9gQR9Pu4p2JEy QM7DNomuG0kCX8xMdan12hQRy6u6HuVtOM/3XmFl4zcTPqhd49DOeBpuBiJPmWg5znjc vg6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=ujG03NqI; 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=efficios.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hz5-20020a1709072ce500b0078c2c22d6cesi2945880ejc.70.2022.11.22.13.28.24; Tue, 22 Nov 2022 13:28:46 -0800 (PST) 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=@efficios.com header.s=smtpout1 header.b=ujG03NqI; 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=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235031AbiKVUmF (ORCPT + 90 others); Tue, 22 Nov 2022 15:42:05 -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 X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RDNS_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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 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