lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f877cfa6-9b25-6445-3806-ca44a4042eaf@arm.com>
Date:   Tue, 5 Oct 2021 11:06:12 +0100
From:   German Gomez <german.gomez@....com>
To:     Leo Yan <leo.yan@...aro.org>, James Clark <james.clark@....com>
Cc:     Namhyung Kim <namhyung@...nel.org>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Jiri Olsa <jolsa@...hat.com>, Ingo Molnar <mingo@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Andi Kleen <ak@...ux.intel.com>,
        Ian Rogers <irogers@...gle.com>,
        Stephane Eranian <eranian@...gle.com>,
        Adrian Hunter <adrian.hunter@...el.com>
Subject: Re: [RFC] perf arm-spe: Track task context switch for cpu-mode events

Hi Leo,

On 04/10/2021 07:26, Leo Yan wrote:
> Hi James,
>
> On Thu, Sep 30, 2021 at 04:08:52PM +0100, James Clark wrote:
>> On 23/09/2021 15:23, Leo Yan wrote:
>>> On Thu, Sep 16, 2021 at 02:01:21PM -0700, Namhyung Kim wrote:
> [...]
> I'd like to use the comparison method for the test:
> We should enable PID tracing and capture in the perf.data, when decode
> the trace data, we can based on context packet and based on the switch
> events to generate out two results, so we can check how the difference
> between these results.

Yesterday we did some testing and found that there seems to be an exact
match between using context packets and switch events. However this only
applies when tracing in userspace (by adding the 'u' suffix to the perf
event). Otherwise we still see as much as 2% of events having the wrong
PID around the time of the switch.

In order to measure this I applied Namhyung's patch and James's patch
from [1]. Then added a printf line to the function arm_spe_prep_sample
where I have access to both PID values, as a quick way to compare them
later in a perf-report run. This is the diff of the printf patch:

diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
index 41385ab96fbc..591985c66ac4 100644
--- a/tools/perf/util/arm-spe.c
+++ b/tools/perf/util/arm-spe.c
@@ -247,6 +247,8 @@ static void arm_spe_prep_sample(struct arm_spe *spe,
    event->sample.header.type = PERF_RECORD_SAMPLE;
    event->sample.header.misc = sample->cpumode;
    event->sample.header.size = sizeof(struct perf_event_header);
+
+       printf(">>>>>> %d / %lu\n", speq->tid, record->context_id & 0x7fff);
 }

The differences obtained as error % were obtained by running the
following perf-record commands for different configurations:

$ sudo ./perf record -e arm_spe/ts_enable=1,load_filter=1,store_filter=1/u -a -- sleep 60
$ sudo ./perf report --stdio \
    | grep ">>>>>>" \
    | awk '{total++; if($2!=$4) miss++} END {print "Error: " (100*miss/total) "% out of " total " samples"}'

Error: 0% out of 11839328 samples

$ sudo ./perf record -e arm_spe/ts_enable=1,load_filter=1,store_filter=1/ -a -- sleep 10
$ sudo ./perf report --stdio \
    | grep ">>>>>>" \
    | awk '{total++; if($2!=$4) miss++} END {print "Error: " (100*miss/total) "% out of " total " samples"}'

Error: 1.30624% out of 3418731 samples

>> German Gomez actually starting looking into the switch events for SPE at the
>> same time, so I've CCd him and maybe he can do some testing of the patch.
> Cool!  German is welcome to continue the related work; since I am in
> holiday this week, I will try this as well, if I have any conclusion
> will get back to you guys.
>
> If the test result shows good enough, I personally think we need finish
> below items:
>
> - Enable PID tracing and decode with context packets;
> - Provide interface to user space so perf tool knows if should use
>   hardware PID or rollback to context switch events;
> - Merge Namhyung's patch for using switch events for samples.
>
> Thanks,
> Leo

I think the fallback to using switch when we can't use the CONTEXTIDR
register is a viable option for userspace events, but maybe not so much
for non-userspace.

Thanks,
German

[1] https://www.spinics.net/lists/linux-perf-users/msg12543.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ