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] [day] [month] [year] [list]
Message-ID: <20200907081747.GC25511@leoy-ThinkPad-X240s>
Date:   Mon, 7 Sep 2020 16:17:47 +0800
From:   Leo Yan <leo.yan@...aro.org>
To:     Jiri Olsa <jolsa@...hat.com>
Cc:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Adrian Hunter <adrian.hunter@...el.com>,
        Andi Kleen <ak@...ux.intel.com>,
        Ian Rogers <irogers@...gle.com>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        "Naveen N. Rao" <naveen.n.rao@...ux.vnet.ibm.com>,
        Kemeng Shi <shikemeng@...wei.com>,
        James Clark <james.clark@....com>,
        Wei Li <liwei391@...wei.com>, Al Grant <Al.Grant@....com>,
        Will Deacon <will@...nel.org>,
        Mathieu Poirier <mathieu.poirier@...aro.org>,
        Mike Leach <mike.leach@...aro.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 02/14] perf mem: Introduce weak function
 perf_mem_events__ptr()

On Fri, Sep 04, 2020 at 05:52:51PM +0200, Jiri Olsa wrote:
> On Fri, Sep 04, 2020 at 08:34:47AM +0800, Leo Yan wrote:
> > Hi Jiri,
> > 
> > On Thu, Sep 03, 2020 at 03:50:54PM +0200, Jiri Olsa wrote:
> > > On Tue, Sep 01, 2020 at 09:38:03AM +0100, Leo Yan wrote:
> > > 
> > > SNIP
> > > 
> > > > @@ -2941,30 +2942,38 @@ static int perf_c2c__record(int argc, const char **argv)
> > > >  	rec_argv[i++] = "record";
> > > >  
> > > >  	if (!event_set) {
> > > > -		perf_mem_events[PERF_MEM_EVENTS__LOAD].record  = true;
> > > > -		perf_mem_events[PERF_MEM_EVENTS__STORE].record = true;
> > > > +		e = perf_mem_events__ptr(PERF_MEM_EVENTS__LOAD);
> > > > +		e->record = true;
> > > > +
> > > > +		e = perf_mem_events__ptr(PERF_MEM_EVENTS__STORE);
> > > > +		e->record = true;
> > > >  	}
> > > >  
> > > > -	if (perf_mem_events[PERF_MEM_EVENTS__LOAD].record)
> > > > +	e = perf_mem_events__ptr(PERF_MEM_EVENTS__LOAD);
> > > > +	if (e->record)
> > > >  		rec_argv[i++] = "-W";
> > > >  
> > > >  	rec_argv[i++] = "-d";
> > > >  	rec_argv[i++] = "--phys-data";
> > > >  	rec_argv[i++] = "--sample-cpu";
> > > >  
> > > > -	for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
> > > > -		if (!perf_mem_events[j].record)
> > > > +	j = 0;
> > > > +	while ((e = perf_mem_events__ptr(j)) != NULL) {
> > > > +		if (!e->record) {
> > > 
> > > you could keep the above 'for loop' in here, it seems better
> > > than taking care of j++
> > 
> > Actually in patch v1 I did this way :)  I followed James' suggestion to
> > encapsulate PERF_MEM_EVENTS__MAX into perf_mem_events__ptr(), thus
> > builtin-mem.c and buildin-c2c.c are not necessary to use
> > PERF_MEM_EVENTS__MAX in the loop and only needs to detect if the
> > pointer is NULL or not when return from perf_mem_events__ptr().
> 
> ah because u added that load_store event

Yes.

> > 
> > How about change as below?
> > 
> >         for (j = 0; (e = perf_mem_events__ptr(j)) != NULL; j++) {
> >                 [...]
> 
> will this work? e will be NULL for first iteration no?
> 
> there are still other for loops with PERF_MEM_EVENTS__MAX used
> in the patch.. you overload the perf_mem_events access for arm,
> and add missing load_store NULL item to generic version, so there's
> always PERF_MEM_EVENTS__MAX items in the array

Yes, exactly.

> can we just use the current for loop and check for e->tag != NULL
> or any other field

Understood.  This would be directive, will keep current code and will
check 'e->record' field.

Thanks,
Leo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ