From: Petr Vorel <pvorel@suse.cz>
To: Edward Liaw <edliaw@google.com>
Cc: kernel-team@android.com, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2] sched/starvation: Choose from available cpus
Date: Thu, 6 Jun 2024 09:40:59 +0200 [thread overview]
Message-ID: <20240606074059.GA463883@pevik> (raw)
In-Reply-To: <20240606014022.1425928-1-edliaw@google.com>
Hi Edward, Wei,
> Use the first available cpu in the sched_getaffinity set.
> This test was failing as a 32bit test for some arm architectures where
> cpu 0 does not support 32bit applications.
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
> Signed-off-by: Edward Liaw <edliaw@google.com>
> ---
> .../kernel/sched/cfs-scheduler/starvation.c | 19 +++++++++++++++++--
> 1 file changed, 17 insertions(+), 2 deletions(-)
> diff --git a/testcases/kernel/sched/cfs-scheduler/starvation.c b/testcases/kernel/sched/cfs-scheduler/starvation.c
> index eb9fd6ff5..0fd45e281 100644
> --- a/testcases/kernel/sched/cfs-scheduler/starvation.c
> +++ b/testcases/kernel/sched/cfs-scheduler/starvation.c
> @@ -49,12 +49,27 @@ again:
> static void setup(void)
> {
> cpu_set_t mask;
> + int cpu = 0;
> + long ncpus = tst_ncpus_conf();
> CPU_ZERO(&mask);
> - CPU_SET(0, &mask);
> + /* Restrict test to a single cpu */
> + TST_EXP_PASS(sched_getaffinity(0, sizeof(mask), &mask));
> - TST_EXP_POSITIVE(sched_setaffinity(0, sizeof(mask), &mask));
Yeah, Wei was correct that both sched_getaffinity() and sched_setaffinity()
should use TST_EXP_PASS() because return only 0 on success (non-zero value is in
the mask, thus using TST_EXP_POSITIVE() was wrong. Ideally this would be in a
separate commit (before your changes), but I'm ok just to note it in the commit
message.
I was also thinking why test macros are used in setup() function (completely
unrelated to the change), I would just use plain code:
if (!sched_getaffinity(0, sizeof(mask), &mask))
tst_brk(TBROK | TERRNO, "sched_getaffinity() failed");
> + if (CPU_COUNT(&mask) == 0)
> + tst_brk(TBROK, "No cpus available");
I was thinking a while and looking in other software which uses CPU_COUNT().
And agree this should be probably tst_brk(TBROK)
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
> +
> + while (CPU_ISSET(cpu, &mask) == 0 && cpu < ncpus)
> + cpu++;
> +
> + CPU_ZERO(&mask);
> +
> + CPU_SET(cpu, &mask);
> +
> + TST_EXP_PASS(sched_setaffinity(0, sizeof(mask), &mask));
> +
> + tst_res(TINFO, "Set affinity to CPU %d", cpu);
> if (tst_parse_long(str_loop, &loop, 1, LONG_MAX))
> tst_brk(TBROK, "Invalid number of loop number '%s'", str_loop);
--
Mailing list info: https://lists.linux.it/listinfo/ltp
prev parent reply other threads:[~2024-06-06 7:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-06 1:40 [LTP] [PATCH v2] sched/starvation: Choose from available cpus Edward Liaw via ltp
2024-06-06 7:40 ` Petr Vorel [this message]
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=20240606074059.GA463883@pevik \
--to=pvorel@suse.cz \
--cc=edliaw@google.com \
--cc=kernel-team@android.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.