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]
Date:	Mon, 25 Aug 2014 11:47:47 +0200
From:	Jiri Olsa <jolsa@...hat.com>
To:	Arnaldo Carvalho de Melo <acme@...nel.org>
Cc:	linux-kernel@...r.kernel.org,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	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

On Fri, Aug 22, 2014 at 05:59:46PM -0300, Arnaldo Carvalho de Melo wrote:

SNIP

>  
> -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..

jirka
--
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