On Sat, 29 Mar 2014 18:10:18 +0100, Jiri Olsa wrote:
> On Mon, Mar 24, 2014 at 03:36:56PM -0400, Don Zickus wrote:
>
> SNIP
>
>>
>> static int perf_c2c__process_load_store(struct perf_c2c *c2c,
>> + struct addr_location *al,
>> struct perf_sample *sample,
>> - struct addr_location *al)
>> + struct perf_evsel *evsel)
>> {
>> - if (c2c->raw_records)
>> - perf_sample__fprintf(sample, ' ', "raw input", al, stdout);
>> + struct mem_info *mi;
>> +
>> + mi = sample__resolve_mem(sample, al);
>> + if (!mi)
>> + return -ENOMEM;
>
> perhaps not directly related to this patchset, but I needed
> attached patch to get resolved data in .bss (static), which
> for some reason happened to be located in executable segment
Wasn't it a read-only/const data?
Hmm.. maybe we could copy the text map and add it to a variable map
group if it has any variables in it..
Thanks,
Namhyung
>
> I wonder why we need this VARIABLE/FUNCTION separation at all,
> I think Arnaldo told me some archs could have same addresses
> for data and functions.. will check ;-)
>
> jirka
>
> ---
> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> index d9d86c6..be6d7cf 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -1220,6 +1220,10 @@ static void ip__resolve_data(struct machine *machine, struct thread *thread,
>
> thread__find_addr_location(thread, machine, m, MAP__VARIABLE, addr,
> &al);
> + if (!al.map)
> + thread__find_addr_location(thread, machine, m, MAP__FUNCTION, addr,
> + &al);
> +
> ams->addr = addr;
> ams->al_addr = al.addr;
> ams->sym = al.sym;
On Tue, Apr 08, 2014 at 04:41:29PM +0900, Namhyung Kim wrote:
> On Sat, 29 Mar 2014 18:10:18 +0100, Jiri Olsa wrote:
> > On Mon, Mar 24, 2014 at 03:36:56PM -0400, Don Zickus wrote:
> >
> > SNIP
> >
> >>
> >> static int perf_c2c__process_load_store(struct perf_c2c *c2c,
> >> + struct addr_location *al,
> >> struct perf_sample *sample,
> >> - struct addr_location *al)
> >> + struct perf_evsel *evsel)
> >> {
> >> - if (c2c->raw_records)
> >> - perf_sample__fprintf(sample, ' ', "raw input", al, stdout);
> >> + struct mem_info *mi;
> >> +
> >> + mi = sample__resolve_mem(sample, al);
> >> + if (!mi)
> >> + return -ENOMEM;
> >
> > perhaps not directly related to this patchset, but I needed
> > attached patch to get resolved data in .bss (static), which
> > for some reason happened to be located in executable segment
>
> Wasn't it a read-only/const data?
I believe it had the 'x' bit set. Or the kernel was not passing any
protection bits, so it defaulted to MAP_FUNCTION?
Cheers,
Don
>
> Hmm.. maybe we could copy the text map and add it to a variable map
> group if it has any variables in it..
>
> Thanks,
> Namhyung
>
> >
> > I wonder why we need this VARIABLE/FUNCTION separation at all,
> > I think Arnaldo told me some archs could have same addresses
> > for data and functions.. will check ;-)
> >
> > jirka
> >
> > ---
> > diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> > index d9d86c6..be6d7cf 100644
> > --- a/tools/perf/util/machine.c
> > +++ b/tools/perf/util/machine.c
> > @@ -1220,6 +1220,10 @@ static void ip__resolve_data(struct machine *machine, struct thread *thread,
> >
> > thread__find_addr_location(thread, machine, m, MAP__VARIABLE, addr,
> > &al);
> > + if (!al.map)
> > + thread__find_addr_location(thread, machine, m, MAP__FUNCTION, addr,
> > + &al);
> > +
> > ams->addr = addr;
> > ams->al_addr = al.addr;
> > ams->sym = al.sym;
On Tue, 8 Apr 2014 10:11:07 -0400, Don Zickus wrote:
> On Tue, Apr 08, 2014 at 04:41:29PM +0900, Namhyung Kim wrote:
>> On Sat, 29 Mar 2014 18:10:18 +0100, Jiri Olsa wrote:
>> > On Mon, Mar 24, 2014 at 03:36:56PM -0400, Don Zickus wrote:
>> >
>> > SNIP
>> >
>> >>
>> >> static int perf_c2c__process_load_store(struct perf_c2c *c2c,
>> >> + struct addr_location *al,
>> >> struct perf_sample *sample,
>> >> - struct addr_location *al)
>> >> + struct perf_evsel *evsel)
>> >> {
>> >> - if (c2c->raw_records)
>> >> - perf_sample__fprintf(sample, ' ', "raw input", al, stdout);
>> >> + struct mem_info *mi;
>> >> +
>> >> + mi = sample__resolve_mem(sample, al);
>> >> + if (!mi)
>> >> + return -ENOMEM;
>> >
>> > perhaps not directly related to this patchset, but I needed
>> > attached patch to get resolved data in .bss (static), which
>> > for some reason happened to be located in executable segment
>>
>> Wasn't it a read-only/const data?
>
> I believe it had the 'x' bit set. Or the kernel was not passing any
> protection bits, so it defaulted to MAP_FUNCTION?
The perf treats a mapping as a data mapping (MAP_VARIABLE) by default if
the 'x' bit is not set. As Jiri said its a static data, I guessed it's
a const data (set to 0?) and moved into .rodata section and then to the
text segment.
Thanks,
Namhyung
On Wed, Apr 09, 2014 at 10:12:32AM +0900, Namhyung Kim wrote:
> On Tue, 8 Apr 2014 10:11:07 -0400, Don Zickus wrote:
> > On Tue, Apr 08, 2014 at 04:41:29PM +0900, Namhyung Kim wrote:
> >> On Sat, 29 Mar 2014 18:10:18 +0100, Jiri Olsa wrote:
> >> > On Mon, Mar 24, 2014 at 03:36:56PM -0400, Don Zickus wrote:
> >> >
> >> > SNIP
> >> >
> >> >>
> >> >> static int perf_c2c__process_load_store(struct perf_c2c *c2c,
> >> >> + struct addr_location *al,
> >> >> struct perf_sample *sample,
> >> >> - struct addr_location *al)
> >> >> + struct perf_evsel *evsel)
> >> >> {
> >> >> - if (c2c->raw_records)
> >> >> - perf_sample__fprintf(sample, ' ', "raw input", al, stdout);
> >> >> + struct mem_info *mi;
> >> >> +
> >> >> + mi = sample__resolve_mem(sample, al);
> >> >> + if (!mi)
> >> >> + return -ENOMEM;
> >> >
> >> > perhaps not directly related to this patchset, but I needed
> >> > attached patch to get resolved data in .bss (static), which
> >> > for some reason happened to be located in executable segment
> >>
> >> Wasn't it a read-only/const data?
> >
> > I believe it had the 'x' bit set. Or the kernel was not passing any
> > protection bits, so it defaulted to MAP_FUNCTION?
>
> The perf treats a mapping as a data mapping (MAP_VARIABLE) by default if
> the 'x' bit is not set. As Jiri said its a static data, I guessed it's
> a const data (set to 0?) and moved into .rodata section and then to the
> text segment.
Unfortunately, his patch will be needed eventually, if not for his reason,
I had a java JAR file example that was pulling data addresses out of a
shared memory region with the protection bits set to 'rwx' (in the
/proc/<pid>/maps area). I was losing lots of samples until I came up with
a more complicated hack.
I will try to dig up my example, so you can see, so it doesn't sound like
I am making this up. :-)
Cheers,
Don
On Tue, Apr 08, 2014 at 09:36:58PM -0400, Don Zickus wrote:
> On Wed, Apr 09, 2014 at 10:12:32AM +0900, Namhyung Kim wrote:
> > On Tue, 8 Apr 2014 10:11:07 -0400, Don Zickus wrote:
> > > On Tue, Apr 08, 2014 at 04:41:29PM +0900, Namhyung Kim wrote:
> > >> On Sat, 29 Mar 2014 18:10:18 +0100, Jiri Olsa wrote:
> > >> > On Mon, Mar 24, 2014 at 03:36:56PM -0400, Don Zickus wrote:
> > >> >
> > >> > SNIP
> > >> >
> > >> >>
> > >> >> static int perf_c2c__process_load_store(struct perf_c2c *c2c,
> > >> >> + struct addr_location *al,
> > >> >> struct perf_sample *sample,
> > >> >> - struct addr_location *al)
> > >> >> + struct perf_evsel *evsel)
> > >> >> {
> > >> >> - if (c2c->raw_records)
> > >> >> - perf_sample__fprintf(sample, ' ', "raw input", al, stdout);
> > >> >> + struct mem_info *mi;
> > >> >> +
> > >> >> + mi = sample__resolve_mem(sample, al);
> > >> >> + if (!mi)
> > >> >> + return -ENOMEM;
> > >> >
> > >> > perhaps not directly related to this patchset, but I needed
> > >> > attached patch to get resolved data in .bss (static), which
> > >> > for some reason happened to be located in executable segment
> > >>
> > >> Wasn't it a read-only/const data?
> > >
> > > I believe it had the 'x' bit set. Or the kernel was not passing any
> > > protection bits, so it defaulted to MAP_FUNCTION?
> >
> > The perf treats a mapping as a data mapping (MAP_VARIABLE) by default if
> > the 'x' bit is not set. As Jiri said its a static data, I guessed it's
> > a const data (set to 0?) and moved into .rodata section and then to the
> > text segment.
it was not initialized static data, .. not sure why it ended up
in text segment, because I dont see it anymore :-)
>
> Unfortunately, his patch will be needed eventually, if not for his reason,
> I had a java JAR file example that was pulling data addresses out of a
> shared memory region with the protection bits set to 'rwx' (in the
> /proc/<pid>/maps area). I was losing lots of samples until I came up with
> a more complicated hack.
also, I think nothing prevents user from mapping memory as 'rwx'
and load/store data there.. we should be able to handle this case
jirka