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: <20190101182852.GA13760@krava>
Date:   Tue, 1 Jan 2019 19:28:52 +0100
From:   Jiri Olsa <jolsa@...hat.com>
To:     Adrian Hunter <adrian.hunter@...el.com>
Cc:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 6/8] perf thread-stack: Allocate an array of thread stacks

On Fri, Dec 21, 2018 at 02:06:18PM +0200, Adrian Hunter wrote:
> In preparation for fixing thread stack processing for the idle task,
> allocate an array of thread stacks.
> 
> Signed-off-by: Adrian Hunter <adrian.hunter@...el.com>
> ---
>  tools/perf/util/thread-stack.c | 30 ++++++++++++++++++------------
>  1 file changed, 18 insertions(+), 12 deletions(-)
> 
> diff --git a/tools/perf/util/thread-stack.c b/tools/perf/util/thread-stack.c
> index 4340381d54c2..a896d89fe5f7 100644
> --- a/tools/perf/util/thread-stack.c
> +++ b/tools/perf/util/thread-stack.c
> @@ -114,20 +114,26 @@ static int thread_stack__init(struct thread_stack *ts, struct thread *thread,
>  static struct thread_stack *thread_stack__new(struct thread *thread,
>  					      struct call_return_processor *crp)
>  {
> -	struct thread_stack *ts;
> -
> -	ts = zalloc(sizeof(struct thread_stack));
> -	if (!ts)
> -		return NULL;
> -
> -	ts->arr_sz = 1;
> -
> -	if (thread_stack__init(ts, thread, crp)) {
> -		free(ts);
> -		return NULL;
> +	struct thread_stack *ts = thread->ts, *new_ts;
> +	unsigned int old_sz = ts ? ts->arr_sz : 0;
> +	unsigned int new_sz = 1;
> +
> +	if (!ts || new_sz > old_sz) {
> +		new_ts = calloc(new_sz, sizeof(*ts));
> +		if (!new_ts)
> +			return NULL;
> +		if (ts)
> +			memcpy(new_ts, ts, old_sz * sizeof(*ts));
> +		new_ts->arr_sz = new_sz;
> +		if (thread->ts)
> +			zfree(&thread->ts);

you don't need to check for thread->ts,
anyway it looks all good, for the patchset:

Acked-by: Jiri Olsa <jolsa@...nel.org>

jirka

> +		thread->ts = new_ts;
> +		ts = new_ts;
>  	}
>  
> -	thread->ts = ts;
> +	if (!ts->stack &&
> +	    thread_stack__init(ts, thread, crp))
> +		return NULL;
>  
>  	return ts;
>  }
> -- 
> 2.17.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ