From: Michael Ellerman <mpe@ellerman.id.au>
To: Benjamin Gray <bgray@linux.ibm.com>, linuxppc-dev@lists.ozlabs.org
Cc: Benjamin Gray <bgray@linux.ibm.com>
Subject: Re: [PATCH 2/5] selftests/powerpc/dscr: Add lockstep test cases to DSCR explicit tests
Date: Tue, 07 Mar 2023 20:59:37 +1100 [thread overview]
Message-ID: <87h6uw286u.fsf@mpe.ellerman.id.au> (raw)
In-Reply-To: <20230307005515.174362-3-bgray@linux.ibm.com>
Benjamin Gray <bgray@linux.ibm.com> writes:
> Add new cases to the relevant tests that use explicitly synchronized
> threads to test the behaviour across context switches with less
> randomness. By locking the participants to the same CPU we guarantee a
> context switch occurs each time they make progress, which is a likely
> failure point if the kernel is not tracking the thread local DSCR
> correctly.
>
> The random case is left in to keep exercising potential edge cases.
>
> Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
> ---
> tools/testing/selftests/powerpc/dscr/Makefile | 1 +
> tools/testing/selftests/powerpc/dscr/dscr.h | 23 +++++
> .../powerpc/dscr/dscr_default_test.c | 87 ++++++++++++++++---
> .../powerpc/dscr/dscr_explicit_test.c | 87 ++++++++++++++++++-
> 4 files changed, 183 insertions(+), 15 deletions(-)
...
> diff --git a/tools/testing/selftests/powerpc/dscr/dscr.h b/tools/testing/selftests/powerpc/dscr/dscr.h
> index 2c54998d4715..903ee0c83fac 100644
> --- a/tools/testing/selftests/powerpc/dscr/dscr.h
> +++ b/tools/testing/selftests/powerpc/dscr/dscr.h
> @@ -90,4 +92,25 @@ double uniform_deviate(int seed)
> {
> return seed * (1.0 / (RAND_MAX + 1.0));
> }
> +
> +int restrict_to_one_cpu(void)
> +{
> + cpu_set_t cpus;
> + int cpu;
> +
> + FAIL_IF(sched_getaffinity(0, sizeof(cpu_set_t), &cpus));
> +
> + for (cpu = 0; cpu < CPU_SETSIZE; cpu++)
> + if (CPU_ISSET(cpu, &cpus))
> + break;
> +
> + FAIL_IF(cpu == CPU_SETSIZE);
> +
> + CPU_ZERO(&cpus);
> + CPU_SET(cpu, &cpus);
> + FAIL_IF(sched_setaffinity(0, sizeof(cpu_set_t), &cpus));
> +
> + return 0;
> +}
We have pick_online_cpu() in utils.c, can you use that?
You probably also need to move bind_to_cpu() from pmu/lib.c to utils.c
so you can use it.
cheers
next prev parent reply other threads:[~2023-03-07 10:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-07 0:55 [PATCH 0/5] Update DSCR tests Benjamin Gray
2023-03-07 0:55 ` [PATCH 1/5] selftests/powerpc/dscr: Correct typos Benjamin Gray
2023-03-07 0:55 ` [PATCH 2/5] selftests/powerpc/dscr: Add lockstep test cases to DSCR explicit tests Benjamin Gray
2023-03-07 9:59 ` Michael Ellerman [this message]
2023-03-07 0:55 ` [PATCH 3/5] selftests/powerpc/dscr: Improve DSCR explicit random test case Benjamin Gray
2023-03-07 0:55 ` [PATCH 4/5] selftests/powerpc/dscr: Speed up DSCR sysfs tests Benjamin Gray
2023-03-07 0:55 ` [PATCH 5/5] selftests/powerpc/dscr: Restore timeout to DSCR selftests Benjamin Gray
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=87h6uw286u.fsf@mpe.ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=bgray@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
/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