All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: zhe.he@windriver.com
Cc: peterz@infradead.org, mingo@redhat.com,
	alexander.shishkin@linux.intel.com, jolsa@redhat.com,
	namhyung@kernel.org, kan.liang@linux.intel.com,
	eranian@google.com, alexey.budankov@linux.intel.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] perf: Fix failure to set cpumask when only one cpu
Date: Thu, 8 Aug 2019 10:29:33 -0300	[thread overview]
Message-ID: <20190808132933.GB19444@kernel.org> (raw)
In-Reply-To: <1564734592-15624-1-git-send-email-zhe.he@windriver.com>

Em Fri, Aug 02, 2019 at 04:29:51PM +0800, zhe.he@windriver.com escreveu:
> From: He Zhe <zhe.he@windriver.com>
> 
> The buffer containing string used to set cpumask is overwritten by end of
> string later in cpu_map__snprint_mask due to not enough memory space, when
> there is only one cpu. And thus causes the following failure.
> 
> $ perf ftrace ls
> failed to reset ftrace
> 
> This patch fixes the calculation of cpumask string size.

Please next time add this as well:

Fixes: dc23103278c5 ("perf ftrace: Add support for -a and -C option")

Applied,

- Arnaldo
 
> Signed-off-by: He Zhe <zhe.he@windriver.com>
> ---
>  tools/perf/builtin-ftrace.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
> index 66d5a66..0193128 100644
> --- a/tools/perf/builtin-ftrace.c
> +++ b/tools/perf/builtin-ftrace.c
> @@ -173,7 +173,7 @@ static int set_tracing_cpumask(struct cpu_map *cpumap)
>  	int last_cpu;
>  
>  	last_cpu = cpu_map__cpu(cpumap, cpumap->nr - 1);
> -	mask_size = (last_cpu + 3) / 4 + 1;
> +	mask_size = last_cpu / 4 + 2; /* one more byte for EOS */
>  	mask_size += last_cpu / 32; /* ',' is needed for every 32th cpus */
>  
>  	cpumask = malloc(mask_size);
> -- 
> 2.7.4

-- 

- Arnaldo

  parent reply	other threads:[~2019-08-08 13:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-02  8:29 [PATCH 1/2] perf: Fix failure to set cpumask when only one cpu zhe.he
2019-08-02  8:29 ` [PATCH 2/2] perf: Fix writing to illegal memory in handling cpumap mask zhe.he
2019-08-08 13:36   ` Arnaldo Carvalho de Melo
2019-08-08 20:19   ` [tip:perf/urgent] perf cpumap: " tip-bot for He Zhe
2019-08-02 13:06 ` [PATCH 1/2] perf: Fix failure to set cpumask when only one cpu Jiri Olsa
2019-08-03  5:34   ` He Zhe
2019-08-08 13:29 ` Arnaldo Carvalho de Melo [this message]
2019-08-08 20:18 ` [tip:perf/urgent] perf ftrace: Fix failure to set cpumask when only one cpu is present tip-bot for He Zhe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190808132933.GB19444@kernel.org \
    --to=arnaldo.melo@gmail.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=alexey.budankov@linux.intel.com \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=zhe.he@windriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.