From: Cyril Hrubis <chrubis@suse.cz>
To: Haifeng Xu <haifeng.xu@shopee.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] ht_affinity.c: fix ht_affinity test failure
Date: Fri, 20 Sep 2024 10:58:06 +0200 [thread overview]
Message-ID: <Zu05HskauxnYheRd@yuki.lan> (raw)
In-Reply-To: <20240920083036.87291-1-haifeng.xu@shopee.com>
Hi!
> The type of cpumask pointer used in set_affinity() is unsigned long, but
> ht_affinity used a unsigned int pointer. When kernel copy cpumask from
> user-space pointer, the high 32bit of cpumask is a random value. So the
> process can't be bind to the cpu specified by users.
Good catch, however it would be better if we used sizeof on the mask
instead of sizeof(unsigned long) in the sched_setaffinity() as well:
diff --git a/testcases/kernel/sched/hyperthreading/ht_affinity/ht_affinity.c b/testcases/kernel/sched/hyperthreading/ht_affinity/ht_affinity.c
index f6e9f2745..3c2fe1bf1 100644
--- a/testcases/kernel/sched/hyperthreading/ht_affinity/ht_affinity.c
+++ b/testcases/kernel/sched/hyperthreading/ht_affinity/ht_affinity.c
@@ -67,7 +67,7 @@ int HT_SetAffinity(void)
tst_resm(TINFO, "Set test process affinity.");
printf("mask: %x\n", mask);
- sched_setaffinity(pid, sizeof(unsigned long), &mask);
+ sched_setaffinity(pid, sizeof(mask), &mask);
for (j = 0; j < 10; j++) {
for (k = 0; k < 10; k++) {
@@ -95,7 +95,7 @@ int HT_SetAffinity(void)
tst_resm(TINFO, "Set test process affinity.");
printf("mask: %x\n", mask);
- sched_setaffinity(pid, sizeof(unsigned long), &mask);
+ sched_setaffinity(pid, sizeof(mask), &mask);
for (j = 0; j < 10; j++) {
for (k = 0; k < 10; k++) {
Most of the code does that already which makes it impossible to pass
different size than the actual size.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2024-09-20 8:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-20 8:30 [LTP] [PATCH] ht_affinity.c: fix ht_affinity test failure Haifeng Xu via ltp
2024-09-20 8:58 ` Cyril Hrubis [this message]
2024-09-20 10:52 ` Haifeng Xu via ltp
2024-09-20 12:22 ` Cyril Hrubis
2024-09-21 4:17 ` Haifeng Xu via ltp
2024-09-21 4:38 ` [LTP] [PATCH v2] " Haifeng Xu via ltp
2024-09-23 12:25 ` Cyril Hrubis
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=Zu05HskauxnYheRd@yuki.lan \
--to=chrubis@suse.cz \
--cc=haifeng.xu@shopee.com \
--cc=ltp@lists.linux.it \
/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