Re: [PATCH 05/18] perf evlist: Do not use hard coded value for a mmap_pages default

From: Arnaldo Carvalho de Melo
Date: Wed Dec 17 2014 - 09:01:01 EST


Em Wed, Dec 17, 2014 at 02:23:30PM +0100, Jiri Olsa escreveu:
> On Tue, Dec 16, 2014 at 01:57:07PM -0300, Arnaldo Carvalho de Melo wrote:
> > + if (pages == UINT_MAX) {
> > + int max;
> > +
> > + if (sysctl__read_int("kernel/perf_event_mlock_kb", &max) < 0) {
> > + /*
> > + * Pick a once upon a time good value, i.e. things look
> > + * strange since we can't read a sysctl value, but lets not
> > + * die yet...
> > + */
> > + max = 512;
> > + } else {
> > + max -= (page_size / 1024);
> > + }

> so this way you depend on value in perf_event_mlock_kb being power 2,
> otherwise:

> # echo 1000 > /proc/sys/kernel/perf_event_mlock_kb
> $ perf record ls
> failed to mmap with 22 (Invalid argument)

Right, I thought that perf_event_mlock_kb input was validated, realized
that it is not, see the following patchkit that makes it validate that
after reading, using rounddown_pow_of_two if not.

- Arnaldo

> maybe you could use the logic/code from parse_pages_arg function
>
> jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/