From patchwork Mon Oct 21 11:01:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tengda Wu X-Patchwork-Id: 13843916 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0183B39FD6; Mon, 21 Oct 2024 11:13:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729509190; cv=none; b=ABrqkeYsWh1mTtmlCIdZjqEtX+CRoBXHmC5FZeTBh/LpQ1tKjB9NXh/iALSVCcziY9VEZqTZWAvrkFxDtcngXPIUgmI9nZGU3ZPv/faO9KwbZw4g3fodvZ7bqv46cwqT9Z6lbonIRzxyl8V7EfSl/JnkMGKOWrUGsC2TBbhu0z4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729509190; c=relaxed/simple; bh=748EsHOhz8UoHb/gUJssuAMhbGWRk9glST+m3EqvEps=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=bY7T82pZjmcu85NYg4hWwpDmK883Y9fJnDY1LUp/J+PcKlRoRvb+Lsy0px4BxqSzsunRrhWPazjVRRaxPbicjhzytGNOtHbN1WQftIDQBazImmZHEUbCt3QWJQnMpUSTphjzf9/PSqAVF2KQrZsxRjYAK/LO7uGzpWLLAT7AqXI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4XXCMd27fRz4f3nJv; Mon, 21 Oct 2024 19:12:45 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.75]) by mail.maildlp.com (Postfix) with ESMTP id 6D3621A0359; Mon, 21 Oct 2024 19:13:03 +0800 (CST) Received: from huawei.com (unknown [10.67.174.45]) by APP2 (Coremail) with SMTP id Syh0CgC3NlwxNxZn5mXIEg--.38372S2; Mon, 21 Oct 2024 19:13:01 +0800 (CST) From: Tengda Wu To: Peter Zijlstra , song@kernel.org, Namhyung Kim Cc: Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , kan.liang@linux.intel.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH -next v5 0/2] perf stat: Support inherit events for bperf Date: Mon, 21 Oct 2024 11:01:59 +0000 Message-Id: <20241021110201.325617-1-wutengda@huaweicloud.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: Syh0CgC3NlwxNxZn5mXIEg--.38372S2 X-Coremail-Antispam: 1UD129KBjvJXoW7KF1xur1UJF4fuFyDGFW3ZFb_yoW8ZF4DpF 4Skr90kwn0gFy5KwnxAanru3WYvr1rGFy5WFn7tr4fAF4qvr17uFWIgFy5tF13ZryxGry0 yrnFgr13urZ5A3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9Sb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x 0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG 6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFV Cjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4IIrI8v6xkF7I0E8cxan2IY04v7MxkF7I0E n4kS14v26r1q6r43MxkF7I0Ew4C26cxK6c8Ij28IcwCF04k20xvY0x0EwIxGrwCFx2IqxV CFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r10 6r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxV WUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG 6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr 1UYxBIdaVFxhVjvjDU0xZFpf9x07jeLvtUUUUU= X-CM-SenderInfo: pzxwv0hjgdqx5xdzvxpfor3voofrz/ Hello, Here is the 5th version of the series to support inherit events for bperf. This version added the `inherit` flag for struct `target` instead of `bpf_stat_opts`, and also fixed the logic when TGID w/o inherit. bperf (perf-stat --bpf-counter) has not supported inherit events during fork() since it was first introduced. This patch series tries to add this support by: 1) adding two new bpf programs to monitor task lifecycle; 2) recording new tasks in the filter map dynamically; 3) reusing `accum_key` of parent task for new tasks. Thanks, Tengda Changelog: --------- v5: (Address comments from Namhyung, thanks) * Add the `inherit` flag for struct `target` instead of `bpf_stat_opts` * Fix the logic when TGID w/o inherit v4: https://lore.kernel.org/all/20241012023225.151084-1-wutengda@huaweicloud.com/ * Add an `inherit` flag to bperf to control inherit behavior v3: https://lore.kernel.org/all/20240916014318.267709-1-wutengda@huaweicloud.com/ * Use pid or tgid based on filter type in new_task prog * Add comments to explain pid usage for TGID type in exit_task prog v2: https://lore.kernel.org/all/20240905115918.772234-1-wutengda@huaweicloud.com/ * Remove the unused init_filter_entries in follower bpf, declare a global filter_entry_count in bpf_counter instead * Attach on_newtask and on_exittask progs only if the filter type is either PID or TGID v1: https://lore.kernel.org/all/20240904123103.732507-1-wutengda@huaweicloud.com/ Tengda Wu (2): perf stat: Support inherit events during fork() for bperf perf test: Use sqrtloop workload to test bperf event tools/perf/builtin-stat.c | 1 + tools/perf/tests/shell/stat_bpf_counters.sh | 2 +- tools/perf/util/bpf_counter.c | 35 +++++-- tools/perf/util/bpf_skel/bperf_follower.bpf.c | 98 +++++++++++++++++-- tools/perf/util/bpf_skel/bperf_u.h | 5 + tools/perf/util/target.h | 1 + 6 files changed, 127 insertions(+), 15 deletions(-)