From: Tiwei Bie <tiwei.bie@linux.dev>
To: richard@nod.at, anton.ivanov@cambridgegreys.com,
johannes@sipsolutions.net
Cc: linux-um@lists.infradead.org, tiwei.btw@antgroup.com,
tiwei.bie@linux.dev
Subject: [RFC PATCH 3/4] um: vdso: Implement __vdso_getcpu() via syscall
Date: Mon, 14 Jul 2025 01:25:35 +0800 [thread overview]
Message-ID: <20250713172536.404809-4-tiwei.bie@linux.dev> (raw)
In-Reply-To: <20250713172536.404809-1-tiwei.bie@linux.dev>
From: Tiwei Bie <tiwei.btw@antgroup.com>
We are going to support SMP in UML, so we can not hard code
the CPU and NUMA node in __vdso_getcpu() anymore.
Signed-off-by: Tiwei Bie <tiwei.btw@antgroup.com>
---
arch/x86/um/vdso/um_vdso.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/arch/x86/um/vdso/um_vdso.c b/arch/x86/um/vdso/um_vdso.c
index cbae2584124f..ee40ac446c1c 100644
--- a/arch/x86/um/vdso/um_vdso.c
+++ b/arch/x86/um/vdso/um_vdso.c
@@ -17,7 +17,7 @@
int __vdso_clock_gettime(clockid_t clock, struct __kernel_old_timespec *ts);
int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz);
__kernel_old_time_t __vdso_time(__kernel_old_time_t *t);
-long __vdso_getcpu(unsigned int *cpu, unsigned int *node, struct getcpu_cache *unused);
+long __vdso_getcpu(unsigned int *cpu, unsigned int *node, struct getcpu_cache *tcache);
int __vdso_clock_gettime(clockid_t clock, struct __kernel_old_timespec *ts)
{
@@ -60,18 +60,16 @@ __kernel_old_time_t __vdso_time(__kernel_old_time_t *t)
__kernel_old_time_t time(__kernel_old_time_t *t) __attribute__((weak, alias("__vdso_time")));
long
-__vdso_getcpu(unsigned int *cpu, unsigned int *node, struct getcpu_cache *unused)
+__vdso_getcpu(unsigned int *cpu, unsigned int *node, struct getcpu_cache *tcache)
{
- /*
- * UML does not support SMP, we can cheat here. :)
- */
+ long ret;
- if (cpu)
- *cpu = 0;
- if (node)
- *node = 0;
+ asm volatile("syscall"
+ : "=a" (ret)
+ : "0" (__NR_getcpu), "D" (cpu), "S" (node), "d" (tcache)
+ : "rcx", "r11", "memory");
- return 0;
+ return ret;
}
long getcpu(unsigned int *cpu, unsigned int *node, struct getcpu_cache *tcache)
--
2.34.1
next prev parent reply other threads:[~2025-07-13 17:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-13 17:25 [RFC PATCH 0/4] um: Add SMP support Tiwei Bie
2025-07-13 17:25 ` [RFC PATCH 1/4] um: Stop tracking virtual CPUs via mm_cpumask() Tiwei Bie
2025-07-13 17:25 ` [RFC PATCH 2/4] um: Remove unused cpu_data and current_cpu_data macros Tiwei Bie
2025-07-13 17:25 ` Tiwei Bie [this message]
2025-07-13 17:25 ` [RFC PATCH 4/4] um: Add SMP support Tiwei Bie
2025-07-14 12:37 ` [RFC PATCH 0/4] " Benjamin Berg
2025-07-14 14:56 ` Tiwei Bie
2025-07-24 21:21 ` Richard Weinberger
2025-07-25 11:42 ` Tiwei Bie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250713172536.404809-4-tiwei.bie@linux.dev \
--to=tiwei.bie@linux.dev \
--cc=anton.ivanov@cambridgegreys.com \
--cc=johannes@sipsolutions.net \
--cc=linux-um@lists.infradead.org \
--cc=richard@nod.at \
--cc=tiwei.btw@antgroup.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).