From nobody Tue Dec 2 01:36:13 2025 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B5F12F6919 for ; Sat, 22 Nov 2025 08:19:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763799595; cv=none; b=H53H94lMlK5RLgXxW+7F93wzXnM5MGl9JWpZ4nOj2Zpx994dg6qQ1O0rFqSwvuOvmL8rfXzXk5kjr/p4q/xJqW2vn+jJ4/ed/GzjkAiLBk5A10QhMHfRR8x+h97UBPgxvkprUCGfj5uKIj6yhpwpx/b7yCkn/j0KvyYohI/CSew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763799595; c=relaxed/simple; bh=hokyhNCY+MHNMohzynNm3sybgVsho518d99UEKSGFb8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=k5BbGudZA4MaZI1dChla1bk1vIwm1Zkgd7n1vGqRafWff2K1QEI2xhRSjQjmY9E0/foESK+TUJIN/U8OdokW+bbf107qnqIG0I8NQyj+zK724eWIoBQ6V5iZOR9oD83qoBc2mqz1V0vfmbo8jvVGtCm1K96Tnjdrzi+NpH9GIcc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=4bzLQWK9; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="4bzLQWK9" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-7b80de683efso5255086b3a.3 for ; Sat, 22 Nov 2025 00:19:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1763799593; x=1764404393; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=26FhnXWE4Dsn0zAV9ZwtQIoSpCE1XR4rqqIzFCKLx+o=; b=4bzLQWK9V1y3LL6p/vsbw1TuSha2y/QHPJr1spge2EKXv5wxXQnZ4LHd9tMuDb862v gId/QVHOawkCNE81WZ0zWUBokBNsN6LWT9+zKfwk1hC12Nm8lm8fB5dQ5vUbuLX1m+fL pbAN31xm8kW4CshkNPRIZQ8+b83IQ4Vlw+OAFh7RK1efCzQkdarAikGtizv+vsGmSOc8 3c+BoxIltvlK4dYtxz9+LjR0jxBgAt5iRyndRjhajYUbkPCJZzSCwOFBWySiiw+V8/dW rOTxTu1hWA9JzuVt80J2AkRatAvOsyNtuSxLww2cTBpR9LMwEL5fqKJ6VvsZBm0HbDxI 0QUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763799593; x=1764404393; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=26FhnXWE4Dsn0zAV9ZwtQIoSpCE1XR4rqqIzFCKLx+o=; b=C/6/k6UySS8Txu6j265f1HuG8NrIClQkkZyG2KxyaRLi/xV6UOdljNUGvHn9hDEAMB NLTvxzHRGgaxTqUm/UELxL5iPJt4n4uy16ffrOUG4qfplLwim1gEyHPZRa0aRVAc1xbX 1Y6sEHhICbr1LKxoFEtye2gyurfU1qqe362PoRoVwydNttZnbwwzCZCwFQCaS3Mgt/1R +pLXNTz3gswKikBDUQz4vYvJIzKNIYLba4B/8ppDLvol71eAH2fDaumauTV2bfM+P5/Z nbVSlEvUBmeQf1bnmN3UWQPVqddlxHN/JTHnaOKGJRxEtaORLoGFUDa0+Jb1w5iqGDAB CH8Q== X-Forwarded-Encrypted: i=1; AJvYcCWjSoLVdIoQKQPOQ5eSdQKJu3ogE8P+V7XTXAFr4yifNKyo0S0WIf1rQZ6TUtDPbF8U4MZvQVsQwBFn/DI=@vger.kernel.org X-Gm-Message-State: AOJu0YwBLed3OT/TfYaluux9wiY/kDTiJkQaEOmSINpAU5k3XNkuiInQ Zy9gVd9N4RXK/6DmiNaEn9jKz674Vlr7tvsCrTcaVaPim/Zbs7rDIwDNMoLnaZJhmuu8yklzxHq WbkPQL1kbwQ== X-Google-Smtp-Source: AGHT+IF30nRtHoEub+YkqFq2fygrJaHFjXNsptZmI4tghtBxkzV5nNyD0cEO4D+YMpyWWt86zI9LwysnHYJE X-Received: from dlbvt2.prod.google.com ([2002:a05:7022:3f82:b0:119:49ca:6b8c]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:b903:b0:11b:d990:1de1 with SMTP id a92af1059eb24-11c9d865e98mr2048215c88.39.1763799593123; Sat, 22 Nov 2025 00:19:53 -0800 (PST) Date: Sat, 22 Nov 2025 00:19:21 -0800 In-Reply-To: <20251122081929.7588-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251122081929.7588-1-irogers@google.com> X-Mailer: git-send-email 2.52.0.rc2.455.g230fcf2819-goog Message-ID: <20251122081929.7588-10-irogers@google.com> Subject: [PATCH v1 09/17] perf c2c: Clean up some defensive gets and make asan clean From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Collin Funk , Dmitry Vyukov , Andi Kleen , Thomas Falcon , Leo Yan , Yicong Yang , Greg Kroah-Hartman , "Masami Hiramatsu (Google)" , Stephen Brennan , Haibo Xu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" To deal with histogram code that had missing gets the c2c code had some defensive gets. Those other issues were cleaned up by the reference count checker, clean them up for the c2c command here. Signed-off-by: Ian Rogers Reviewed-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-c2c.c | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 14c3823f8fed..d390ae4e3ec8 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -322,7 +322,7 @@ static int process_sample_event(const struct perf_tool = *tool __maybe_unused, struct c2c_stats stats =3D { .nr_entries =3D 0, }; struct hist_entry *he; struct addr_location al; - struct mem_info *mi, *mi_dup; + struct mem_info *mi =3D NULL; struct callchain_cursor *cursor; int ret; =20 @@ -349,20 +349,15 @@ static int process_sample_event(const struct perf_too= l *tool __maybe_unused, goto out; } =20 - /* - * The mi object is released in hists__add_entry_ops, - * if it gets sorted out into existing data, so we need - * to take the copy now. - */ - mi_dup =3D mem_info__get(mi); - c2c_decode_stats(&stats, mi); =20 he =3D hists__add_entry_ops(&c2c_hists->hists, &c2c_entry_ops, &al, NULL, NULL, mi, NULL, sample, true); - if (he =3D=3D NULL) - goto free_mi; + if (he =3D=3D NULL) { + ret =3D -ENOMEM; + goto out; + } =20 c2c_he =3D container_of(he, struct c2c_hist_entry, he); c2c_add_stats(&c2c_he->stats, &stats); @@ -393,17 +388,19 @@ static int process_sample_event(const struct perf_too= l *tool __maybe_unused, int cpu =3D sample->cpu =3D=3D (unsigned int) -1 ? 0 : sample->cpu; int node =3D c2c.cpu2node[cpu]; =20 - mi =3D mi_dup; - c2c_hists =3D he__get_c2c_hists(he, c2c.cl_sort, 2, machine->env); - if (!c2c_hists) - goto free_mi; + if (!c2c_hists) { + ret =3D -ENOMEM; + goto out; + } =20 he =3D hists__add_entry_ops(&c2c_hists->hists, &c2c_entry_ops, &al, NULL, NULL, mi, NULL, sample, true); - if (he =3D=3D NULL) - goto free_mi; + if (he =3D=3D NULL) { + ret =3D -ENOMEM; + goto out; + } =20 c2c_he =3D container_of(he, struct c2c_hist_entry, he); c2c_add_stats(&c2c_he->stats, &stats); @@ -421,14 +418,9 @@ static int process_sample_event(const struct perf_tool= *tool __maybe_unused, } =20 out: + mem_info__put(mi); addr_location__exit(&al); return ret; - -free_mi: - mem_info__put(mi_dup); - mem_info__put(mi); - ret =3D -ENOMEM; - goto out; } =20 static const char * const c2c_usage[] =3D { --=20 2.52.0.rc2.455.g230fcf2819-goog