mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: K Prateek Nayak <kprateek.nayak@amd.com>
To: Tycho Andersen <tycho@kernel.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, "Ian Rogers" <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	"James Clark" <james.clark@linaro.org>,
	Chun-Tse Shao <ctshao@google.com>,
	<linux-perf-users@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	"Ravi Bangoria" <ravi.bangoria@amd.com>
Subject: Re: [PATCH] perf: fix segfault in `lock contention -b`
Date: Tue, 13 Jan 2026 08:41:24 +0530	[thread overview]
Message-ID: <fb38d19e-f4b4-4f89-a41a-78a845861468@amd.com> (raw)
In-Reply-To: <20260109164417.396138-1-tycho@kernel.org>

Hello Tycho,

On 1/9/2026 10:14 PM, Tycho Andersen wrote:
> @@ -43,19 +43,20 @@ static void check_slab_cache_iter(struct lock_contention *con)
>  	con->btf = btf__load_vmlinux_btf();
>  	if (con->btf == NULL) {
>  		pr_debug("BTF loading failed: %s\n", strerror(errno));
> -		return;
> +		return -errno;
>  	}
>  
>  	ret = btf__find_by_name_kind(con->btf, "bpf_iter__kmem_cache", BTF_KIND_STRUCT);
>  	if (ret < 0) {
>  		bpf_program__set_autoload(skel->progs.slab_cache_iter, false);
>  		pr_debug("slab cache iterator is not available: %d\n", ret);
> -		return;
> +		return ret;
>  	}
>  
>  	has_slab_iter = true;
>  
>  	bpf_map__set_max_entries(skel->maps.slab_caches, con->map_nr_entries);
> +	return 0;
>  }
>  
>  static void run_slab_cache_iter(void)
> @@ -301,7 +302,8 @@ int lock_contention_prepare(struct lock_contention *con)
>  			skel->rodata->use_cgroup_v2 = 1;
>  	}
>  
> -	check_slab_cache_iter(con);
> +	if (check_slab_cache_iter(con) < 0)
> +		return -1;
>  
>  	if (con->filters->nr_slabs && has_slab_iter) {

nit.

Now that lock_contention_prepare() bails out when
check_slab_cache_iter() fails, we no longer need the "has_slab_iter"
global indicator.

Both this, and run_slab_cache_iter() that depend on "has_slab_iter"
will only run if check_slab_cache_iter() succeeded and the global
indicator will be true in both those cases.

Can be separate follow-up cleanup.

>  		skel->rodata->has_slab = 1;
> 
> base-commit: 5572ad8fddecd4a0db19801262072ff5916b7589

-- 
Thanks and Regards,
Prateek


  parent reply	other threads:[~2026-01-13  3:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-09 16:44 Tycho Andersen
2026-01-10  0:49 ` Namhyung Kim
2026-01-12 16:15   ` Tycho Andersen
2026-01-13 21:18     ` Namhyung Kim
2026-02-04 15:20       ` Tycho Andersen
2026-02-04 21:26         ` Namhyung Kim
2026-01-13  3:11 ` K Prateek Nayak [this message]
2026-01-13 15:48   ` Tycho Andersen

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=fb38d19e-f4b4-4f89-a41a-78a845861468@amd.com \
    --to=kprateek.nayak@amd.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=ctshao@google.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=ravi.bangoria@amd.com \
    --cc=tycho@kernel.org \
    /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

all inboxes | Powered by JetHome®