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: <20140825155914.GB2849@kernel.org>
Date:	Mon, 25 Aug 2014 12:59:14 -0300
From:	Arnaldo Carvalho de Melo <acme@...nel.org>
To:	Jiri Olsa <jolsa@...hat.com>
Cc:	linux-kernel@...r.kernel.org,
	Adrian Hunter <adrian.hunter@...el.com>,
	Corey Ashford <cjashfor@...ux.vnet.ibm.com>,
	David Ahern <dsahern@...il.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Ingo Molnar <mingo@...nel.org>,
	Jean Pihet <jean.pihet@...aro.org>,
	Jiri Olsa <jolsa@...nel.org>,
	Namhyung Kim <namhyung@...nel.org>,
	Paul Mackerras <paulus@...ba.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>
Subject: Re: [PATCH 06/10] perf evlist: Allow growing pollfd on add method

Em Mon, Aug 25, 2014 at 11:47:47AM +0200, Jiri Olsa escreveu:
> On Fri, Aug 22, 2014 at 05:59:46PM -0300, Arnaldo Carvalho de Melo wrote:

> > -static int perf_evlist__alloc_pollfd(struct perf_evlist *evlist)
> > +static int perf_evlist__grow_pollfd(struct perf_evlist *evlist, int hint)
> > +{
> > +	int nr_fds_alloc = evlist->nr_fds_alloc + hint;
> > +	size_t size = sizeof(struct pollfd) * nr_fds_alloc;
> > +	struct pollfd *pollfd = realloc(evlist->pollfd, size);
> > +
> > +	if (pollfd == NULL)
> > +		return -ENOMEM;
> > +
> > +	evlist->nr_fds_alloc = nr_fds_alloc;
> > +	evlist->pollfd	     = pollfd;
> > +	return 0;
> > +}
> > +
> > +int perf_evlist__alloc_pollfd(struct perf_evlist *evlist)
> >  {
> >  	int nr_cpus = cpu_map__nr(evlist->cpus);
> >  	int nr_threads = thread_map__nr(evlist->threads);
> > @@ -416,16 +430,28 @@ static int perf_evlist__alloc_pollfd(struct perf_evlist *evlist)
> >  			nfds += nr_cpus * nr_threads;
> >  	}
> >  
> > -	evlist->pollfd = malloc(sizeof(struct pollfd) * nfds);
> > -	return evlist->pollfd != NULL ? 0 : -ENOMEM;
> > +	if (evlist->nr_fds_alloc - evlist->nr_fds < nfds &&
> > +	    perf_evlist__grow_pollfd(evlist, nfds) < 0)
> > +		return -ENOMEM;
> 
> hum, so do we still need perf_evlist__alloc_pollfd?
> we grow any time we need inside perf_evlist__add_pollfd..

Humm, yeah, it could conceivably be removed and then we would rely
always on add_pollfd() autogrowing it as needed. But then, I thought
that code using this could optimize for the case where it knows in
advance how many entries it will need, just like perf_evlist does.

I.e. the first thing builtin-kvm.c should do would be to grow it by two
more entries, because it knows it wants to add just two more entries, in
advance, etc.

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ