From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f201.google.com (mail-dy1-f201.google.com [74.125.82.201]) (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 00DF923FC41 for ; Mon, 4 May 2026 03:51:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777866701; cv=none; b=DqtgGavYle05gM+mkbIDvuHg08vF6XqHxZJguVBfdsNFfynLVoEvrWYoE2wTE/n9a1B+1whoQfKS1ag3thRcpy8LcrLhlkBpFQeYfvTDDOJy0fQGmjVouWYGpc4mmcWC1t5N5G5vmDFOqvRPxedIrU7/eF5EwcTCcpuRpu/Hltw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777866701; c=relaxed/simple; bh=oO73p1xRPTCaH7zWY9uPtQL6ZrNpPDEb1CrIWcRHrM0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=MXVZVhD9MMwrnxdP4hhN05OwUabajUgczYFjeVLiHjcaRcwo90ty130ZH2t7HJAqoBuiyNuGv77pMbcwkUEzbYWK26tM6zj5cK5sG7j+Q4IC0eywWtBmEMerDOWMbvO8pR5oaK4DesyWcijG1K7fHZCSvpR/qKYOIqmx/NUQJ+w= 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=njgijQdj; arc=none smtp.client-ip=74.125.82.201 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="njgijQdj" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2c0f6593ef5so5228968eec.1 for ; Sun, 03 May 2026 20:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1777866699; x=1778471499; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=hdtzf9eHR5G9u38wQE27Ez1yBHseJb6vJmHAUnBL/S4=; b=njgijQdjeI+S156AYjrQQ0RWaO9hI+kZi9ftc6cIL11QF+PC+O4qVjc2Y9bBt+OtAb xHzQ5H0hu8hgcuYtV1Io2+78YlhS3KznOWyTqOOKwZRgLr+y3W2wpK60ZayHhkETITtg 1QQVTo7KdbnGwbChXGzjsDPuhoO2iHnQ3XGr3fnxSOQnAXZRsm5699kapFbh+jCSQ5eq aYVfghpAAWWi6IY2yRq/5HW0wDES+LMJ2afflzbIBsHuCHyqz8fvIJkgu/9J+AXASJ0b jTe85KyK2kL9JNKBjFP+pW1zR8ij3sNKpcycjPYcVzh5x2/mK40MOgguI/F6bwcbyM2S eA3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777866699; x=1778471499; h=content-transfer-encoding:cc: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=hdtzf9eHR5G9u38wQE27Ez1yBHseJb6vJmHAUnBL/S4=; b=Dwv7sUmIvm2Mo7N8J7684rZp78daDGqMAp712G0dN1nXGjFKNAvbwLsoHMvJ8diIDO 6dmpy9pKLqwf72b7gjAj4T8tZ6OfWtG2/8O7hoYJxvqjJAJymDXPxSql866X9lVmizu0 IJswB39yh5nwvG/8Vidkd6Inzci0LgMyP6uOL6n9xq96b5lh1uEAK9uVnjP9StudO7vH j401Y+k/VUpkwF2MPOKZTupPm9poH8o9M7xOGBHANC895+3Lf1dwvNb0GB/XaQdjqL+e pihI36fTNVXGLAYJvrWK6e3/TpRv0tBkhb9d/zSKT9Mh5q8lf/JPl3aUqyDpYfbnN8FC xNPg== X-Forwarded-Encrypted: i=1; AFNElJ8fdfpcyhAT/hlsde74BbHNVQySclR31b9aDE8y9JQ+BQ5T+dbNhJqXqgpelK4FFFOJwEkzl0V/JaPOSHc=@vger.kernel.org X-Gm-Message-State: AOJu0YzXQ0w7F68htX4OEATdWqEeYPjGpYVa1XCMxM81+Zi0UczNsNLJ mINmpiytdQVFKHAB89apYtwGVbusO0JhPC+Ed/2wiZP93YcQIhy6MjotLmGwM5nYwWIyL+2Trwf Rq+wWiKskVA== X-Received: from dldz12-n1.prod.google.com ([2002:a05:701b:418c:10b0:12c:91ef:91f4]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:e1e:b0:128:d20a:2f40 with SMTP id a92af1059eb24-12dfd79e773mr4170199c88.8.1777866699093; Sun, 03 May 2026 20:51:39 -0700 (PDT) Date: Sun, 3 May 2026 20:51:23 -0700 In-Reply-To: <20260504035125.1851720-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: <20260425020529.3246331-1-irogers@google.com> <20260504035125.1851720-1-irogers@google.com> X-Mailer: git-send-email 2.54.0.545.g6539524ca2-goog Message-ID: <20260504035125.1851720-3-irogers@google.com> Subject: [PATCH v3 2/4] perf tool: Fix missing schedstat delegates and dont_split_sample_group in delegate_tool From: Ian Rogers To: acme@kernel.org, gmx@google.com, namhyung@kernel.org Cc: adrian.hunter@intel.com, james.clark@linaro.org, jolsa@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, Ian Rogers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable delegate_tool was missing the delegate overrides for schedstat_cpu and schedstat_domain. As a result, when allocated with zalloc, these callbacks defaulted to NULL, causing a segmentation fault crash if any schedstat events were delivered during event processing. Fix this by adding delegate_schedstat_cpu and delegate_schedstat_domain via the CREATE_DELEGATE_OP2 macro, and ensuring delegate_tool__init correctly registers them. Additionally, delegate_tool__init completely omitted copying the dont_split_sample_group property from the delegate. This would cause wrapper tools to default the flag to false, which corrupts piped event processing (e.g., in perf inject) by triggering duplicate event deliveries on split sample values in deliver_sample_group(). Similarly, perf_tool__init() omitted the initialization of this boolean field. On stack-allocated tools that rely on this initializer (like intel-tpebs or __cmd_evlist), this could result in uninitialized stack garbage evaluating to true=E2=80=94silently dropping non-leader event members in deliver_sample_group(). Fix both issues by properly copying the field in delegate_tool__init and initializing it to false in perf_tool__init. Assisted-by: Gemini-CLI:Google Gemini 3 Fixes: 6331b2669359 ("perf tool: Add a delegate_tool that just delegates ac= tions to another tool") Fixes: 79bcd34e0f3d ("perf inject: Fix leader sampling inserting additional= samples") Signed-off-by: Ian Rogers --- tools/perf/util/tool.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/perf/util/tool.c b/tools/perf/util/tool.c index 013c7839e2cf..ff2150517b75 100644 --- a/tools/perf/util/tool.c +++ b/tools/perf/util/tool.c @@ -285,6 +285,7 @@ void perf_tool__init(struct perf_tool *tool, bool order= ed_events) tool->no_warn =3D false; tool->show_feat_hdr =3D SHOW_FEAT_NO_HEADER; tool->merge_deferred_callchains =3D true; + tool->dont_split_sample_group =3D false; =20 tool->sample =3D process_event_sample_stub; tool->mmap =3D process_event_stub; @@ -433,6 +434,8 @@ CREATE_DELEGATE_OP2(stat_config); CREATE_DELEGATE_OP2(stat_round); CREATE_DELEGATE_OP2(thread_map); CREATE_DELEGATE_OP2(time_conv); +CREATE_DELEGATE_OP2(schedstat_cpu); +CREATE_DELEGATE_OP2(schedstat_domain); CREATE_DELEGATE_OP2(tracing_data); =20 #define CREATE_DELEGATE_OP3(name) \ @@ -470,6 +473,7 @@ void delegate_tool__init(struct delegate_tool *tool, st= ruct perf_tool *delegate) tool->tool.no_warn =3D delegate->no_warn; tool->tool.show_feat_hdr =3D delegate->show_feat_hdr; tool->tool.merge_deferred_callchains =3D delegate->merge_deferred_callcha= ins; + tool->tool.dont_split_sample_group =3D delegate->dont_split_sample_group; =20 tool->tool.sample =3D delegate_sample; tool->tool.read =3D delegate_read; @@ -516,4 +520,6 @@ void delegate_tool__init(struct delegate_tool *tool, st= ruct perf_tool *delegate) tool->tool.bpf_metadata =3D delegate_bpf_metadata; tool->tool.compressed =3D delegate_compressed; tool->tool.auxtrace =3D delegate_auxtrace; + tool->tool.schedstat_cpu =3D delegate_schedstat_cpu; + tool->tool.schedstat_domain =3D delegate_schedstat_domain; } --=20 2.54.0.545.g6539524ca2-goog