From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Cc: igt-dev@lists.freedesktop.org, Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Subject: Re: [igt-dev] [PATCH igt] igt/perf_pmu: Disable all cpus
Date: Wed, 21 Feb 2018 09:24:46 +0000 [thread overview]
Message-ID: <3aea4759-6818-222f-df2c-2bd2b603816e@linux.intel.com> (raw)
In-Reply-To: <151920463124.8092.543638866655423103@mail.alporthouse.com>
On 21/02/2018 09:17, Chris Wilson wrote:
> Quoting Tvrtko Ursulin (2018-02-21 09:11:15)
>>
>> On 20/02/2018 21:40, Chris Wilson wrote:
>>> Rather than iteratively disable and then immediately reenable a CPU,
>>> turn off each in turn, forcing the PMU events onto the next CPU without
>>> allowing them to retreat back to CPU0 after the first. If this fails,
>>
>> Hm, interesting and I think it possibly makes sense to test both
>> migration patterns.
>
> Yup.
>
>>> @@ -988,35 +999,43 @@ static void cpu_hotplug(int gem_fd)
>>> */
>>> igt_fork(child, 1) {
>>> int cpu = 0;
>>> + int cpufd;
>>> + int err;
>>>
>>> close(link[0]);
>>>
>>> + /* Offline each cpu in turn */
>>> for (;;) {
>>> - char name[128];
>>> - int cpufd;
>>> -
>>> - igt_assert_lt(snprintf(name, sizeof(name),
>>> - "/sys/devices/system/cpu/cpu%d/online",
>>> - cpu), sizeof(name));
>>> - cpufd = open(name, O_WRONLY);
>>> - if (cpufd == -1) {
>>> - igt_assert(cpu > 0);
>>> - /*
>>> - * Signal parent that we cycled through all
>>> - * CPUs and we are done.
>>> - */
>>> - igt_assert_eq(write(link[1], "*", 1), 1);
>>> + cpufd = open_cpu_online(cpu);
>>> + igt_assert(cpufd != -1);
>>> +
>>> + err = write(cpufd, "0", 2);
>>> + close(cpufd);
>>> + if (err < 0)
>>> break;
>>
>> Keep off-lining until no more CPUs to offline? I had to try it! :) Ok,
>> last one will fail to offline. But I think it needs a comment.
>
> I thought that was a fun trick to try and offline the last cpu :)
>
>>> - }
>>>
>>> - /* Offline followed by online a CPU. */
>>> - igt_assert_eq(write(cpufd, "0", 2), 2);
>>> usleep(1e6);
>>> - igt_assert_eq(write(cpufd, "1", 2), 2);
>>> + cpu++;
>>> + }
>>>
>>> + /* Then bring them back online */
>>> + while (cpu--) {
>>> + cpufd = open_cpu_online(cpu);
>>> + err = write(cpufd, "1", 2);
>>> close(cpufd);
>>
>> Need to online in the same order or the PMU will stay on some higher CPU
>> making the subsequent tests fail. Or I need to improve the helpers to
>> hunt for the correct CPU, as perf tool does.
>
> Ah. I was expecting everytime we onlined a new cpu, the notifier would
> move the pmu. Why do the subsequent tests fail? In my naivety I expected
> one CPU is as good as any other for pmu. Do we need to put a trivial
> test inside the online/offline loops?
It only moves it to the first available CPU once it gets kicked out from
the one it was on.
So with the above pattern of offline all and online in reverse, it will
happily stay on the last CPU. And IGTs only try to open on the first CPU
so it fails to open it from then on.
As I said, it would be easy to support opening our PMU regardless on
which CPU it currently lives on by wrapping the "try the next cpu" logic
in the perf open wrappers. In kernel perf tool for instance does that
already.
I could also change i915 to always try to move to CPU0 if it is
available, on any online events. But I am not sure that's in the spirit
of things.
I think making IGT perf open wrapper more robust makes most sense.
Regards,
Tvrtko
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2018-02-21 9:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-20 21:40 [igt-dev] [PATCH igt] igt/perf_pmu: Disable all cpus Chris Wilson
2018-02-20 22:16 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2018-02-21 7:11 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2018-02-21 9:11 ` [Intel-gfx] [igt-dev] [PATCH igt] " Tvrtko Ursulin
2018-02-21 9:17 ` Chris Wilson
2018-02-21 9:24 ` Tvrtko Ursulin [this message]
2018-02-21 9:30 ` Chris Wilson
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=3aea4759-6818-222f-df2c-2bd2b603816e@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=igt-dev@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=tvrtko.ursulin@intel.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