Re: [PATCH 7/7] perf tools: Remove prot field in mmap param
On Mon, Nov 13, 2017 at 01:38:09AM +, Wang Nan wrote: > After removing the concept of 'overwrite' in code level, now the > prot is determinated by write_backward. There's no need to pass > prot from perf_evlist__mmap_ex(). > > Signed-off-by: Wang Nan> --- > tools/perf/util/evlist.c | 17 ++--- > tools/perf/util/mmap.c | 4 ++-- > tools/perf/util/mmap.h | 4 ++-- > 3 files changed, 10 insertions(+), 15 deletions(-) > > diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c > index 4948d3d..0d713e0 100644 > --- a/tools/perf/util/evlist.c > +++ b/tools/perf/util/evlist.c > @@ -799,28 +799,23 @@ perf_evlist__should_poll(struct perf_evlist *evlist > __maybe_unused, > } > > static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, > -struct mmap_params *_mp, int cpu_idx, > +struct mmap_params *mp, int cpu_idx, > int thread, int *_output, int > *_output_backward) > { > struct perf_evsel *evsel; > int revent; > int evlist_cpu = cpu_map__cpu(evlist->cpus, cpu_idx); > - struct mmap_params *mp; > > evlist__for_each_entry(evlist, evsel) { > struct perf_mmap *maps = evlist->mmap; > - struct mmap_params rdonly_mp; > int *output = _output; > int fd; > int cpu; > + int prot = PROT_READ; > > - mp = _mp; > if (evsel->attr.write_backward) { > output = _output_backward; > maps = evlist->backward_mmap; > - rdonly_mp = *_mp; > - rdonly_mp.prot &= ~PROT_WRITE; > - mp = _mp; I dont think we need the first patch, you're reverting it in here jirka
Re: [PATCH 7/7] perf tools: Remove prot field in mmap param
On Mon, Nov 13, 2017 at 01:38:09AM +, Wang Nan wrote: > After removing the concept of 'overwrite' in code level, now the > prot is determinated by write_backward. There's no need to pass > prot from perf_evlist__mmap_ex(). > > Signed-off-by: Wang Nan > --- > tools/perf/util/evlist.c | 17 ++--- > tools/perf/util/mmap.c | 4 ++-- > tools/perf/util/mmap.h | 4 ++-- > 3 files changed, 10 insertions(+), 15 deletions(-) > > diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c > index 4948d3d..0d713e0 100644 > --- a/tools/perf/util/evlist.c > +++ b/tools/perf/util/evlist.c > @@ -799,28 +799,23 @@ perf_evlist__should_poll(struct perf_evlist *evlist > __maybe_unused, > } > > static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, > -struct mmap_params *_mp, int cpu_idx, > +struct mmap_params *mp, int cpu_idx, > int thread, int *_output, int > *_output_backward) > { > struct perf_evsel *evsel; > int revent; > int evlist_cpu = cpu_map__cpu(evlist->cpus, cpu_idx); > - struct mmap_params *mp; > > evlist__for_each_entry(evlist, evsel) { > struct perf_mmap *maps = evlist->mmap; > - struct mmap_params rdonly_mp; > int *output = _output; > int fd; > int cpu; > + int prot = PROT_READ; > > - mp = _mp; > if (evsel->attr.write_backward) { > output = _output_backward; > maps = evlist->backward_mmap; > - rdonly_mp = *_mp; > - rdonly_mp.prot &= ~PROT_WRITE; > - mp = _mp; I dont think we need the first patch, you're reverting it in here jirka
Re: [PATCH 7/7] perf tools: Remove prot field in mmap param
On Mon, Nov 13, 2017 at 01:38:09AM +, Wang Nan wrote: > After removing the concept of 'overwrite' in code level, now the > prot is determinated by write_backward. There's no need to pass > prot from perf_evlist__mmap_ex(). > > Signed-off-by: Wang Nan> --- > tools/perf/util/evlist.c | 17 ++--- > tools/perf/util/mmap.c | 4 ++-- > tools/perf/util/mmap.h | 4 ++-- > 3 files changed, 10 insertions(+), 15 deletions(-) > > diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c > index 4948d3d..0d713e0 100644 > --- a/tools/perf/util/evlist.c > +++ b/tools/perf/util/evlist.c > @@ -799,28 +799,23 @@ perf_evlist__should_poll(struct perf_evlist *evlist > __maybe_unused, > } > > static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, > -struct mmap_params *_mp, int cpu_idx, > +struct mmap_params *mp, int cpu_idx, > int thread, int *_output, int > *_output_backward) > { > struct perf_evsel *evsel; > int revent; > int evlist_cpu = cpu_map__cpu(evlist->cpus, cpu_idx); > - struct mmap_params *mp; > > evlist__for_each_entry(evlist, evsel) { > struct perf_mmap *maps = evlist->mmap; > - struct mmap_params rdonly_mp; > int *output = _output; > int fd; > int cpu; > + int prot = PROT_READ; can't you set the PROT_READ in struct mmap_params *mp as its default value? mp->prot = PROT_READ; > > - mp = _mp; > if (evsel->attr.write_backward) { > output = _output_backward; > maps = evlist->backward_mmap; > - rdonly_mp = *_mp; > - rdonly_mp.prot &= ~PROT_WRITE; > - mp = _mp; > > if (!maps) { > maps = perf_evlist__alloc_mmap(evlist); > @@ -830,6 +825,8 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist > *evlist, int idx, > if (evlist->bkw_mmap_state == BKW_MMAP_NOTREADY) > perf_evlist__toggle_bkw_mmap(evlist, > BKW_MMAP_RUNNING); > } > + } else { > + prot |= PROT_WRITE; > } > > if (evsel->system_wide && thread) > @@ -844,7 +841,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist > *evlist, int idx, > if (*output == -1) { > *output = fd; > > - if (perf_mmap__mmap([idx], mp, *output) < 0) > + if (perf_mmap__mmap([idx], mp, prot, *output) < 0) so there's no need for the extra 'prot' param in here jirka
Re: [PATCH 7/7] perf tools: Remove prot field in mmap param
On Mon, Nov 13, 2017 at 01:38:09AM +, Wang Nan wrote: > After removing the concept of 'overwrite' in code level, now the > prot is determinated by write_backward. There's no need to pass > prot from perf_evlist__mmap_ex(). > > Signed-off-by: Wang Nan > --- > tools/perf/util/evlist.c | 17 ++--- > tools/perf/util/mmap.c | 4 ++-- > tools/perf/util/mmap.h | 4 ++-- > 3 files changed, 10 insertions(+), 15 deletions(-) > > diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c > index 4948d3d..0d713e0 100644 > --- a/tools/perf/util/evlist.c > +++ b/tools/perf/util/evlist.c > @@ -799,28 +799,23 @@ perf_evlist__should_poll(struct perf_evlist *evlist > __maybe_unused, > } > > static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, > -struct mmap_params *_mp, int cpu_idx, > +struct mmap_params *mp, int cpu_idx, > int thread, int *_output, int > *_output_backward) > { > struct perf_evsel *evsel; > int revent; > int evlist_cpu = cpu_map__cpu(evlist->cpus, cpu_idx); > - struct mmap_params *mp; > > evlist__for_each_entry(evlist, evsel) { > struct perf_mmap *maps = evlist->mmap; > - struct mmap_params rdonly_mp; > int *output = _output; > int fd; > int cpu; > + int prot = PROT_READ; can't you set the PROT_READ in struct mmap_params *mp as its default value? mp->prot = PROT_READ; > > - mp = _mp; > if (evsel->attr.write_backward) { > output = _output_backward; > maps = evlist->backward_mmap; > - rdonly_mp = *_mp; > - rdonly_mp.prot &= ~PROT_WRITE; > - mp = _mp; > > if (!maps) { > maps = perf_evlist__alloc_mmap(evlist); > @@ -830,6 +825,8 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist > *evlist, int idx, > if (evlist->bkw_mmap_state == BKW_MMAP_NOTREADY) > perf_evlist__toggle_bkw_mmap(evlist, > BKW_MMAP_RUNNING); > } > + } else { > + prot |= PROT_WRITE; > } > > if (evsel->system_wide && thread) > @@ -844,7 +841,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist > *evlist, int idx, > if (*output == -1) { > *output = fd; > > - if (perf_mmap__mmap([idx], mp, *output) < 0) > + if (perf_mmap__mmap([idx], mp, prot, *output) < 0) so there's no need for the extra 'prot' param in here jirka