Sashiko discussions
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: sashiko@lists.linux.dev
Cc: Ian Rogers <irogers@google.com>, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v10 07/29] perf lock: Only pass sample to handlers
Date: Sun, 12 Apr 2026 13:16:55 -0700	[thread overview]
Message-ID: <adv9t-BRXA4tSZ0g@google.com> (raw)
In-Reply-To: <20260412022538.830B4C116C6@smtp.kernel.org>

On Sun, Apr 12, 2026 at 02:25:37AM +0000, sashiko-bot@kernel.org wrote:
> Sashiko AI review found 1 potential issue(s):
> - [Medium] Out-of-memory errors from get_callstack() are silently swallowed.
> --
> 
> commit 4d8eb4c521b8cbbd581b94a51ae57655ebd7ab69
> Author: Ian Rogers <irogers@google.com>
> perf lock: Only pass sample to handlers
> 
> This commit removes the unused evsel parameter from lock event handlers and
> adds a NULL check for sample->callchain in get_callstack().
> 
> > diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
> > index e2b585e528aca..fcc33089b9455 100644
> > --- a/tools/perf/builtin-lock.c
> > +++ b/tools/perf/builtin-lock.c
> [ ... ]
> > @@ -948,9 +938,16 @@ static u64 *get_callstack(struct perf_sample *sample, int max_stack)
> >  	u64 i;
> >  	int c;
> >  
> > +	if (!sample->callchain) {
> > +		pr_debug("Sample unexpectedly missing callchain\n");
> > +		return NULL;
> > +	}
> > +
> >  	callstack = calloc(max_stack, sizeof(*callstack));
> > -	if (callstack == NULL)
> > +	if (callstack == NULL) {
> > +		pr_debug("Failed to allocate callstack\n");
> >  		return NULL;
> > +	}
> >  
> >  	for (i = 0, c = 0; i < sample->callchain->nr && c < max_stack; i++) {
> >  		u64 ip = sample->callchain->ips[i];
> [ ... ]
> > @@ -1070,7 +1066,7 @@ static int report_lock_contention_begin_event(struct evsel *evsel __maybe_unused
> >  	if (needs_callstack()) {
> >  		u64 *callstack = get_callstack(sample, max_stack_depth);
> >  		if (callstack == NULL)
> > -			return -ENOMEM;
> > +			return 0;
> 
> Does this inadvertently swallow the memory allocation failure from
> get_callstack()?
> 
> Since get_callstack() returns NULL both when the callchain is missing and
> when calloc() fails, changing this return from -ENOMEM to 0 means the tool
> will now silently drop events when memory is exhausted instead of propagating
> the error.

I've removed this part for now.

Thanks,
Namhyung


           reply	other threads:[~2026-04-12 20:16 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <20260412022538.830B4C116C6@smtp.kernel.org>]

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=adv9t-BRXA4tSZ0g@google.com \
    --to=namhyung@kernel.org \
    --cc=irogers@google.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox