From nobody Fri Dec 19 20:37:55 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 3E3861DED53 for ; Fri, 28 Feb 2025 22:23:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740781435; cv=none; b=SEmqasZVjgkpcTEIRpkqt8pyjxOODDRO8zerdXQuQdQedsKashWjU57oiM5oYEOQ74cSHv5Qbx8i2IIZUZ+SkYa/AA/pM+mY7ph0KvGDZiE9uulVEnp49oTvLpv6qWOKrmK0t6gYNJoaWLMMj1tb9thH/LM0Q+olHoBaSoshZIA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740781435; c=relaxed/simple; bh=txn0P05cQCFrXxSXwvz56otvn2hrpJG2Johc1iskpbc=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=VqIH+WohADTmRQa4QJWnfVSqIHwEYtUzBGPMuFEMekDor0DIeEPU9DicoJIHw0VWwzptTBX/+lJNF3jfPHrC3SdB1fMYEEBK0Ax/8mBoYbOfcjcY3m1o+IK9fjzJuFeMqzgQh2HnqLoX0vNxu0hPsWVGITTqxbNO7Ss7T5tVrZY= 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=qPSipR7P; arc=none smtp.client-ip=209.85.128.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="qPSipR7P" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6fd4e4c7e02so16470767b3.2 for ; Fri, 28 Feb 2025 14:23:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1740781433; x=1741386233; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=HT+nPv2tYgupeaKy7eqEuPRMTJ57BlbBsuhS7nbNqeE=; b=qPSipR7P2rgdkG/kWz8lod+lLspE/S7IGk14hKCkvsVvAe5ibXNIPErRHX7GkOGb5i 4+521Vrrt9YYIMgJVCV7Oq7ujgz9mk6unRvIs+fcDAgCQfWfXWmrC5Pkjqb66eZCW+TS lv40dFw87VKaSmuGZgbGoQaZ2VjubNCicn7xYq+wQWwLT+Muv/VEwV8NypRwm6tNDgxq qo6Cq6o8GkmtnmQm4xL2RiiNxGiMWs9W9lG8oVEBzS0GINenKctMvVq8BEU1e8QsLrD8 85Mn2/zNUtbZbqIXglL9QUKA04UsOvV+jOraPd17aUGzxtZ/QnWMKB2gsx7hYrk2qbfy Atfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740781433; x=1741386233; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HT+nPv2tYgupeaKy7eqEuPRMTJ57BlbBsuhS7nbNqeE=; b=m3uIa/xdPMnAosFvav4Q0mr/oFA+9ZDDSHuD6s/B3oaGJhMG3SYzwWgNaI0Q1BQ4LD AAIhRuCf6FpIGbSLvDNqhnE1GjuhlQRVYdG/bur/JosHwK3ctxhIX+en4A17swCVygT5 T7nuaFXAbIgENxrtWBH+PdoUwLCBoNXQlX22/nqi852t/jCkOO7LH/oCf6bCWXpissVO YEF9D15y1IixJvq97erexeGjOMVIZ2++VwMZwIHh98Y6m9s4h/IR660oPBC2UpxWdUqG W2gfQOARcN4IHs9LymzCxaVYW27AAJ8F3tpUkZszInNHV/LJgiqCpSwStS3f8p3panjo I29A== X-Forwarded-Encrypted: i=1; AJvYcCUCVf6btGIWJhxJPkQejXwtXPeJqSkYM0vgKJWBxsvSQay9puknsR+h3POJkehGTWjG2L1mcEb8ZtSk4JA=@vger.kernel.org X-Gm-Message-State: AOJu0YxABwpJvtsjWDoe0nQekCRXBaHP5i0prNJy+0hgndMs0boJcaVS JgiCFpnc+ImNzM+LVsLFJ+GY84iuVlzBy5EHklJr72lmgFnmJBXF76uSGNbY5vifR4P+/c3wAPi NzdVJKg== X-Google-Smtp-Source: AGHT+IGMXYRBfiYKFmm/2HsXNIce5dF6aVnsil7+fnx7h+OYMmaozsXrjJsnVHcWdb0mTBHmTv3e3OdlQMjP X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:23a3:4d43:890f:dfd7]) (user=irogers job=sendgmr) by 2002:a25:aa90:0:b0:e60:a52a:377a with SMTP id 3f1490d57ef6-e60b2e817edmr57514276.2.1740781433136; Fri, 28 Feb 2025 14:23:53 -0800 (PST) Date: Fri, 28 Feb 2025 14:22:58 -0800 In-Reply-To: <20250228222308.626803-1-irogers@google.com> Message-Id: <20250228222308.626803-2-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250228222308.626803-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.711.g2feabab25a-goog Subject: [PATCH v2 01/11] perf debug: Avoid stack overflow in recursive error message From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , Yicong Yang , James Clark , "Dr. David Alan Gilbert" , Levi Yun , Ze Gao , Weilin Wang , Xu Yang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Howard Chu Cc: Ian Rogers Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In debug_file, pr_warning_once is called on error. As that function calls debug_file the function will yield a stack overflow. Switch the location of the call so the recursion is avoided. Reviewed-by: Howard Chu Signed-off-by: Ian Rogers Reviewed-by: Arnaldo Carvalho de Melo --- tools/perf/util/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 995f6bb05b5f..f9ef7d045c92 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c @@ -46,8 +46,8 @@ int debug_type_profile; FILE *debug_file(void) { if (!_debug_file) { - pr_warning_once("debug_file not set"); debug_set_file(stderr); + pr_warning_once("debug_file not set"); } return _debug_file; } --=20 2.48.1.711.g2feabab25a-goog From nobody Fri Dec 19 20:37:55 2025 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.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 7B8261DEFE6 for ; Fri, 28 Feb 2025 22:23:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740781438; cv=none; b=OneygU8MapOJnRn2B9MdTXa4R/sVfAwkEITrCTH/VqiLN8mEKCsXvDMl6g+soN64o5QxKvGPVyvgKtME8x87s9gmgIE2WLXQMcI0usUv6UkbwLgVo6rEUScWd7EUO5pSQi8/c2dpVCJmZwtTDqoW7HQ1C5sG0fWOtzjqToVFMu4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740781438; c=relaxed/simple; bh=jw2JvCMwh40S1sqr4HtAsdcBJhtA5W1IjdOGgQVIXGU=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=LhFuaxxxrCvivttA2cUDWh69c7bOm05zgqZ8PdmfBuHQ7Gsuo0R86tYISQ8G9w4Q3xFWepiwVmF632GqqBYE0Z95gGUB8sphy8ZXY206KaoWpQ5isiF67g5yRoWsNS/DE8gxWVOqLGl8hBzrSGZlLRX1bfxtaEsKRMa+KxCPqno= 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=z1wq6nRt; arc=none smtp.client-ip=209.85.128.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="z1wq6nRt" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6f2bdb560ecso37496087b3.1 for ; Fri, 28 Feb 2025 14:23:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1740781435; x=1741386235; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=deGH2VjmLT83Kk+l97C6+20x9ip/iQR0QehEJSDELbI=; b=z1wq6nRtNA9tyaDFtU95Xm6NvOZ/3VfqHXJVgl/GIcv4N6UNZPeFJNfWlfkO6uiyuI aEiIWtCHHO38azHEwAa8JMjPU6TqcOzi138EsoVWikJR94uaynb08ZT2nF38eX0QptZx hBEVl0OiIKvOsFJQx/sI3NaBSxPkxKAFiTiEvuyEXt3awMSAmrd8BviudIiE/4cfYjV9 IUGM+g3UDh8fFRtlLxF65WZK6LhJsh+PIxJ8Y3BJ6stoD9//FPrBgy/3eUl5sydqXt+R XctqMJVdn22Rj2ptqtDWxuECEjp6ayYv7J6yURYUlz1WnQAY4jXezzuV8aAgG88s5vd3 Iybg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740781435; x=1741386235; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=deGH2VjmLT83Kk+l97C6+20x9ip/iQR0QehEJSDELbI=; b=uTFRHoLEAvEBnKXpflWF7TsyK9ggQyf51w8aUCyGfjOX7pGoCOM8KI97q6+iko/cYg TlW9I00bhtfTzoy+gdsQOQ3CZCaqo8CVIFQOXFEGMINFrdpcX1g04RawcE/0nm0Q7t/Z VSZ+Uo17GxlN+n88zHd/5WFWrF9lDopEWT4LZtOXmqrGBVcXEH8/pF4VYcldJuxDy/1N 396bThKtw07p+Y66ANaHWY7+QYV5E7s2Hy0QOqqJ0ofaEfwMP60sUkrRPYv4kmzO1jd+ czkS3ho6BOfkll5JAxoSX2KC/9Exs58v8P1OJj3hlJVrIJJvgTOuqOKvWGWGY8z/v9ZP Q+Vw== X-Forwarded-Encrypted: i=1; AJvYcCXZHl5hOFIAcTc7ztz05x4w9oCdh8sY7krNaFnmVmSbwxxl2kXLlw8tcHdw7027jANUtQuItI/ZvyzBFZQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzfGslv8H/qwobBnToVZqLy55l2J+yHRe90AT7nVfdnZmCFcePc T/TBOBiHkqyE8TwklUuKngJglx/URMp1ROpG7dyQu37HWXlRTBgNxJ5+ZX82Xb36InsDz0MkuJg g7N2eJg== X-Google-Smtp-Source: AGHT+IFE7d3v320fruJZDyKQRPxtYcFs1S4WGsj03GrTm6oN1eMjN5dQCeQksAPTYLlZWWAXkO95dI7pXbC2 X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:23a3:4d43:890f:dfd7]) (user=irogers job=sendgmr) by 2002:a05:690c:528a:b0:6fb:78b2:8b70 with SMTP id 00721157ae682-6fd4a10fda2mr5924667b3.7.1740781435497; Fri, 28 Feb 2025 14:23:55 -0800 (PST) Date: Fri, 28 Feb 2025 14:22:59 -0800 In-Reply-To: <20250228222308.626803-1-irogers@google.com> Message-Id: <20250228222308.626803-3-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250228222308.626803-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.711.g2feabab25a-goog Subject: [PATCH v2 02/11] perf evlist: Add success path to evlist__create_syswide_maps From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , Yicong Yang , James Clark , "Dr. David Alan Gilbert" , Levi Yun , Ze Gao , Weilin Wang , Xu Yang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Howard Chu Cc: Ian Rogers Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Over various refactorings evlist__create_syswide_maps has been made to only ever return with -ENOMEM. Fix this so that when perf_evlist__set_maps is successfully called, 0 is returned. Reviewed-by: Howard Chu Signed-off-by: Ian Rogers Reviewed-by: Arnaldo Carvalho de Melo --- tools/perf/util/evlist.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index f0dd174e2deb..633df7d9204c 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -1373,19 +1373,18 @@ static int evlist__create_syswide_maps(struct evlis= t *evlist) */ cpus =3D perf_cpu_map__new_online_cpus(); if (!cpus) - goto out; + return -ENOMEM; =20 threads =3D perf_thread_map__new_dummy(); - if (!threads) - goto out_put; + if (!threads) { + perf_cpu_map__put(cpus); + return -ENOMEM; + } =20 perf_evlist__set_maps(&evlist->core, cpus, threads); - perf_thread_map__put(threads); -out_put: perf_cpu_map__put(cpus); -out: - return -ENOMEM; + return 0; } =20 int evlist__open(struct evlist *evlist) --=20 2.48.1.711.g2feabab25a-goog From nobody Fri Dec 19 20:37:55 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 8C8D61DF277 for ; Fri, 28 Feb 2025 22:23:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740781441; cv=none; b=r55ToqN6ToLcPOlpJuIn1Zicb9fBkbKKKfP+TVauZt+xN6bebrYjUpSjJRmUEB08Llegz+8ndRTdiH5JO48PJAF7wl/rKqrgjIb4S/CbmIF3usH77qgfxAUj6+Ui2aQxNdjYaVjyCfXsyVNkR/+Bttajn650w2aVT8rYh0FMIYE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740781441; c=relaxed/simple; bh=1QIgufyKX//dArN5ELC42cSlOnJMqn/N6xXRUEwesp8=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=CNV9LuOTM6Hh76TjE5jSF+sTMDYljedEnPC7CLlu6e9BHQTUpx4UOjo81aBJn79N0vcSs8ontyvIwlVSiw4MMXpFhGVEbgoxQ7KY+6C8CoomY6C9tOUPHv72O4dunNiL45QNqYzcXHNclc0Wccu8lWynAk7q1zosQS9Z6XXLXTs= 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=3ZpqNINu; arc=none smtp.client-ip=209.85.128.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="3ZpqNINu" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6fd010df0f4so41552237b3.3 for ; Fri, 28 Feb 2025 14:23:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1740781438; x=1741386238; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=NsPMBkH69637TTeUcT12GL6mDYxITCSmP/v5bZ3zoSc=; b=3ZpqNINuMmRm+VsPbvi8OGKHitqQN41gkBY1nEg8eRsD1t7CRThVgfL5hXe36UVmB+ T7X7oFEc63iFCzhrw31UOk+qTVyd5pGeOhcm/7juHGUikaUnw2+7DIRSp+gap5+rFYJL Pc80K6EKPt6jCMDHOtE5unJTScgHKAHJeEVduwMYos8GMTcCYCCK77dFqPYV0cqjrcdQ IueALOZdHH/B9kaC8PK8n5fTUbWC0VHQQ2BJ+kxkNqjDuH7a4SWvceN9jSGjmg2zJOcu J52Rcs/UdOYj3wLaJTi8Jq2K8nOoAkNUzn+OAMIJ0q/sIJ0mAueYk/Mglr+2gc87s308 wgJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740781438; x=1741386238; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NsPMBkH69637TTeUcT12GL6mDYxITCSmP/v5bZ3zoSc=; b=CzVASbjm92odGoXxKxYXMTFDEdmHpyzBeBPci0gUteMM+OdyBNgose8zUcuBRF9Si2 K1QldxW5twFZ55FdUjNCeb2eCadeDAaSMAWtcDbY5mEzJ6EtLqEyKCS5uFkRPWuQ3nPF g5Rd6PGYUdfxtU5pwUS9jVRGgLw6FZYKl53MHLLVGb/XvDCzCyKCyWGxuQTMAd+jk+iC gL+TpwOUfwmSYhLduqEtGm0v+M7vNeTAk8G3X0lrhc+NxFvksLPOYJH2KmiKOmAUQgXq muJTI08NT5UH3DYTCRoalyeun3pVhPAfNfO9vkzrNiiEyFnq++dK10lUyRyjR8+qjgK0 HTQg== X-Forwarded-Encrypted: i=1; AJvYcCXD/BaK/8c1ik/LvO5PEa2AnELDGgAk1+U2f/hCz0/OTFOVxMcYfFGnvG9kXN8TfpxA0lxwSvkX45vPLso=@vger.kernel.org X-Gm-Message-State: AOJu0Yzsrm41vQlVNRLucZjfaQDYshQBfJh661o9D1RBuJdjsDqG2xpM +DkHkzTtdgPNMbGmpZtH+7OqkjgsLCIaX2E93SPnKHmmyf7lzuDjPZuahX2YUyKQcp1VFlOnxu/ NLX+1Mg== X-Google-Smtp-Source: AGHT+IGZdRCkerahb9c4wxk645+PM+BR2jUS+KgFNjUrlkGATtsekS5Ap18M/puYq5Y6YdfL36FIgTPIx/hT X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:23a3:4d43:890f:dfd7]) (user=irogers job=sendgmr) by 2002:a05:690c:8e06:b0:6ef:7372:10f8 with SMTP id 00721157ae682-6fd4a0f729fmr6305367b3.5.1740781437790; Fri, 28 Feb 2025 14:23:57 -0800 (PST) Date: Fri, 28 Feb 2025 14:23:00 -0800 In-Reply-To: <20250228222308.626803-1-irogers@google.com> Message-Id: <20250228222308.626803-4-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250228222308.626803-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.711.g2feabab25a-goog Subject: [PATCH v2 03/11] perf evsel: tp_format accessing improvements From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , Yicong Yang , James Clark , "Dr. David Alan Gilbert" , Levi Yun , Ze Gao , Weilin Wang , Xu Yang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Howard Chu Cc: Ian Rogers Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Ensure evsel__clone copies the tp_sys and tp_name variables. In evsel__tp_format, if tp_sys isn't set, use the config value to find the tp_format. This succeeds in python code where pyrf__tracepoint has already found the format. Reviewed-by: Howard Chu Signed-off-by: Ian Rogers Reviewed-by: Arnaldo Carvalho de Melo --- tools/perf/util/evsel.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 4a0ef095db92..1974395492d7 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -521,6 +521,16 @@ struct evsel *evsel__clone(struct evsel *dest, struct = evsel *orig) } evsel->cgrp =3D cgroup__get(orig->cgrp); #ifdef HAVE_LIBTRACEEVENT + if (orig->tp_sys) { + evsel->tp_sys =3D strdup(orig->tp_sys); + if (evsel->tp_sys =3D=3D NULL) + goto out_err; + } + if (orig->tp_name) { + evsel->tp_name =3D strdup(orig->tp_name); + if (evsel->tp_name =3D=3D NULL) + goto out_err; + } evsel->tp_format =3D orig->tp_format; #endif evsel->handler =3D orig->handler; @@ -644,7 +654,11 @@ struct tep_event *evsel__tp_format(struct evsel *evsel) if (evsel->core.attr.type !=3D PERF_TYPE_TRACEPOINT) return NULL; =20 - tp_format =3D trace_event__tp_format(evsel->tp_sys, evsel->tp_name); + if (!evsel->tp_sys) + tp_format =3D trace_event__tp_format_id(evsel->core.attr.config); + else + tp_format =3D trace_event__tp_format(evsel->tp_sys, evsel->tp_name); + if (IS_ERR(tp_format)) { int err =3D -PTR_ERR(evsel->tp_format); =20 --=20 2.48.1.711.g2feabab25a-goog From nobody Fri Dec 19 20:37:55 2025 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.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 8BAEB1DF747 for ; Fri, 28 Feb 2025 22:24:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740781443; cv=none; b=adop6VNKeRxbjNiL8Y3fLNPYJXte8gFOtAMPcSvnoCJR+Dsee2Tc75Kr2GtDj1NLzfJHxj+C+SOFqSP0gnQqLp00Y6rIwwPO62u/4X/TX6JriK4yeaftf5vw0kC38R+OjrMreD1rWD1lp2x+/oJKjqbzSH7HcDzlFjnRSYv+D+o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740781443; c=relaxed/simple; bh=yPSgF/Erg7nRVre+x5Jz1gkXcw2ww+rcY64bedQyBeo=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=HCVq4c2LJxZFoGNyGD+RMyXYTNaZSsEAo375JS+BW7221PGeC3Fr+nBNSIq8S1vogAmtZGRFKzi2eFVwz2S0vKFt/ikozkOoZ3LwYIvsEgZfbvAd72Ug2SVCQjTLSTSzY5I7HrU/2u8yPoMRecsTPWsE7uCH7ZshN/AnjE2PDJg= 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=aBpFtRv8; arc=none smtp.client-ip=209.85.128.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="aBpFtRv8" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6f2bdb560ecso37496967b3.1 for ; Fri, 28 Feb 2025 14:24:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1740781440; x=1741386240; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ZRqlQ5/wrup7zltecqprA1SHOUOVYQRpzhsxUmWzkao=; b=aBpFtRv8oY7yXEVjyoNb64mwugQuQienTuggR1er+tcWIHCYFRCWyoDaKzdC71iO0l tiMzTspA/I73JR9dPEpLdy6R4+NBEbP2qK1xSIXJ1E4wU28x6gQM7AoyEUmKYQXeDAbj PHLlMQabRXeZJJwa8JxHR/BeE2U3/FkIeP+L1qEWyPHmp7jjA4d4ftrA6TUgss/iDs7Z wDyEx7emTReeICv19lAQrVxWk7RfuaGXVLf8dZinu3zZBkd9a5dnY9ovdrghmEZR5i6J KfWwWRiAP47P3hKTKUPFk3EhazYNiFIiW1veuU3RNPrYlMnLSKp8w/N2T9m7Tq/bqpzL RKbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740781440; x=1741386240; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZRqlQ5/wrup7zltecqprA1SHOUOVYQRpzhsxUmWzkao=; b=TMVvE/9RH2iC7TcR53HtMVfRyrk3knWCaCNI/6yfe4Rkf+vJ3Atr98HPcrLZd63OQy 9s+MEZThdhmYnarKmrzBSpvGpSCKKrkn8wrHFxg+1DCeOlH3lZts256Dy+xE3bJajb9T dybLharkvgrjD6DHtyYmmjKB/nhYU9oS3/xOxVmQ4OGUfsY4hulvvbmqhYnzyjuTamtC QY7eWFhEtzFapQnLmX5315ZnAL/aSph2MSgcst8pl7a8+0HBLT3qPpYSYLUmnQkj/p5f oZe9Dkqvjni9NF9RvCjRA37+Gr0vooORqK0WJwJghb5CnoZ0YB8X/8Eg7R1mOutBo+V1 zI4g== X-Forwarded-Encrypted: i=1; AJvYcCW4jE4+rNuyEg12t5qhK3jXmfQj0DO+wuH41tZZPyo7A25OIcvz4l+tNNMB9qMf3y3ZbKqWqbYwNnW4Ckg=@vger.kernel.org X-Gm-Message-State: AOJu0YyvjpXRysdSAu5dy4q381f7r81AwjHa7bUchev4KXEPIHyTMrfc KNYEwM+cw9gvle5gcMVv8sTwcOo+nQg2OAlrsRVdChwa1kUfoSoTzox4dXDPoAG9/SFF3H8zxnR VZOA0jw== X-Google-Smtp-Source: AGHT+IFcqOiYt0+71v9S4XyEHFuM+CO4XG+qN8q+YtwMhGrGlLxJrG5VKdr4sB09eQOhiDBfxPmzyBgBIHRd X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:23a3:4d43:890f:dfd7]) (user=irogers job=sendgmr) by 2002:a05:690c:528a:b0:6fb:78b2:8b70 with SMTP id 00721157ae682-6fd4a10fda2mr5924717b3.7.1740781440633; Fri, 28 Feb 2025 14:24:00 -0800 (PST) Date: Fri, 28 Feb 2025 14:23:01 -0800 In-Reply-To: <20250228222308.626803-1-irogers@google.com> Message-Id: <20250228222308.626803-5-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250228222308.626803-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.711.g2feabab25a-goog Subject: [PATCH v2 04/11] perf python: Add evlist enable and disable methods From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , Yicong Yang , James Clark , "Dr. David Alan Gilbert" , Levi Yun , Ze Gao , Weilin Wang , Xu Yang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Howard Chu Cc: Ian Rogers Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" By default the evsels from parse_events will be disabled. Add access to the evlist functions so they can be enabled/disabled. Reviewed-by: Howard Chu Signed-off-by: Ian Rogers Reviewed-by: Arnaldo Carvalho de Melo --- tools/perf/util/python.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index e2b9032c1311..0cf81cfcfafb 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -1028,6 +1028,20 @@ static PyObject *pyrf_evlist__open(struct pyrf_evlis= t *pevlist, return Py_None; } =20 +static PyObject *pyrf_evlist__disable(struct pyrf_evlist *pevlist) +{ + evlist__disable(&pevlist->evlist); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *pyrf_evlist__enable(struct pyrf_evlist *pevlist) +{ + evlist__enable(&pevlist->evlist); + Py_INCREF(Py_None); + return Py_None; +} + static PyMethodDef pyrf_evlist__methods[] =3D { { .ml_name =3D "mmap", @@ -1065,6 +1079,18 @@ static PyMethodDef pyrf_evlist__methods[] =3D { .ml_flags =3D METH_VARARGS | METH_KEYWORDS, .ml_doc =3D PyDoc_STR("reads an event.") }, + { + .ml_name =3D "disable", + .ml_meth =3D (PyCFunction)pyrf_evlist__disable, + .ml_flags =3D METH_NOARGS, + .ml_doc =3D PyDoc_STR("Disable the evsels in the evlist.") + }, + { + .ml_name =3D "enable", + .ml_meth =3D (PyCFunction)pyrf_evlist__enable, + .ml_flags =3D METH_NOARGS, + .ml_doc =3D PyDoc_STR("Enable the evsels in the evlist.") + }, { .ml_name =3D NULL, } }; =20 --=20 2.48.1.711.g2feabab25a-goog From nobody Fri Dec 19 20:37:55 2025 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.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 00F251DF99D for ; Fri, 28 Feb 2025 22:24:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740781445; cv=none; b=cm5Q5eEyqQoVm4L/JZ6NG8/ZS2k1JNKiEIGmr0xvh/kLhGjHQHCtM6QicaeLtV3Pz0oNkL+FH8HxISLpST/Kz6Px3w5qTK28zfMJHdg+QGtsrMglOITy2qkhXQIBLuyWcVsYhGXLf/sXy9paojrpK2dc0yrZrVGs5/QNUoOgNBQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740781445; c=relaxed/simple; bh=tODv7690hqlZb2xriWhDrFPwKVoBHpGvviDIDK71V8M=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=kDP4F25CnZnOn0qGVn2op6JB/xSGrmLmIyZBxbyHJec4KwbYgzZlIuIUswO4QYwCFxBh8h93r9jApKWHuHGBLP+PtgJNrgHNqdgLzPvk6cLwNESaDP5FfFQgtWDqUBpKGWIDhthH0u5bTllLgqg9M7i8qpBUIc869Ju0H/CxjtE= 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=F+AdoSmw; arc=none smtp.client-ip=209.85.219.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="F+AdoSmw" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e3a1bc0c875so3434023276.2 for ; Fri, 28 Feb 2025 14:24:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1740781443; x=1741386243; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=/Di4fYvOp7GLM6eylwf5YJrXliWR6y7W6n5lGa1rECA=; b=F+AdoSmwn0g9MBvq/q2zVSXxElar8BladO98PgPlF2c4+rVlvM+D6TXVKvKClSBk+J aLygZmIHtIi+hK0TZKStdBMo6dhJmk8tbsYbVq4L9ZXwcJP6dptHfX63G8rQ9eF8tXnM bA8FcASCBQCPOTjUuFJ4Sr2qeq3Dh50r13bqhXT2yme846mmhQrHn6sXnR9hKTBnk699 RMrUZszM6a4bjMm7fqKOJtkKYx2eP9Tu2Uh3nWEuhojltHzZz6WU5C8z0r4pg59MC8Q8 bUhR8UZDzR0OKYZNndIhGKJI+mEiVaBiHv8YO5ocSFswl1srhJpfT4Kmx77Z4/VKFMV7 Dmtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740781443; x=1741386243; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/Di4fYvOp7GLM6eylwf5YJrXliWR6y7W6n5lGa1rECA=; b=fB+LG3wHTBwMUbUYFNT4+jR7Kfly1kvISzhmIaPokxcX1pZCm2g7nhDzCuy2+WJaIt x9ORPw4AFXzwM7iy9mdVGT5dBQU87xxyXPlcmLBCkOu52DZ9ja8id+jOujs7MeUcPxs2 xBt4o3reqYel/W1t6d/z+ZGSWa56xBqz0ZZciUd1ZWzoi/EcOw/sr+tZSZzEozTVdvoq TMOoR9I5GHMvUKtdDJchJ8PV2iO8w+ZkHpyda6aBoOXxoWiriDtAP+TBpHn0kR6dRiC/ 7/NNc/ujZSyZ+23H/NV/OEC6y5kIshQ2ellmaKqIVf/g00rJMiLG8Y7Z3ZcXMUx5EJfa /F+A== X-Forwarded-Encrypted: i=1; AJvYcCVE+92lao9EhaU0p4vvNjrXYkKyPJ395CzTmJ3zAb/Rq+MV6Q8NHa+VKmyUnkHtPQ9uIg8GaqBya4jQLrQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyT10Q9ATLHHG4e4Si9tzCPT1HDPuQ3yawClqYKwghITrnZ8oyn WooK1Sn8xm9Z30hewwsDzDjkyM76P13PguUWn2MTeaYXrgz0OeB7ZKd48Bbj+0Zw5aZ3TzRX3CP HEJqSig== X-Google-Smtp-Source: AGHT+IHb+kaR2q+Vsn7L10Sd0q8KHqsewLN7g4KXEvWyOLV1BrwdPWHrXjjjKQ4YL5gZahx3JWH5VBpZXYlu X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:23a3:4d43:890f:dfd7]) (user=irogers job=sendgmr) by 2002:a25:aae3:0:b0:e60:9fda:1ba4 with SMTP id 3f1490d57ef6-e60b2f7d2b0mr31270276.9.1740781442950; Fri, 28 Feb 2025 14:24:02 -0800 (PST) Date: Fri, 28 Feb 2025 14:23:02 -0800 In-Reply-To: <20250228222308.626803-1-irogers@google.com> Message-Id: <20250228222308.626803-6-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250228222308.626803-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.711.g2feabab25a-goog Subject: [PATCH v2 05/11] perf python: Add member access to a number of evsel variables From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , Yicong Yang , James Clark , "Dr. David Alan Gilbert" , Levi Yun , Ze Gao , Weilin Wang , Xu Yang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Howard Chu Cc: Ian Rogers Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Most variables are part of the perf_event_attr, so that they may be queried and modified. Reviewed-by: Howard Chu Signed-off-by: Ian Rogers Acked-by: Arnaldo Carvalho de Melo --- tools/perf/util/python.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 0cf81cfcfafb..b600b6379b4e 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -811,6 +811,28 @@ static PyMethodDef pyrf_evsel__methods[] =3D { { .ml_name =3D NULL, } }; =20 +#define evsel_member_def(member, ptype, help) \ + { #member, ptype, \ + offsetof(struct pyrf_evsel, evsel.member), \ + 0, help } + +#define evsel_attr_member_def(member, ptype, help) \ + { #member, ptype, \ + offsetof(struct pyrf_evsel, evsel.core.attr.member), \ + 0, help } + +static PyMemberDef pyrf_evsel__members[] =3D { + evsel_member_def(tracking, T_BOOL, "tracking event."), + evsel_attr_member_def(type, T_UINT, "attribute type."), + evsel_attr_member_def(size, T_UINT, "attribute size."), + evsel_attr_member_def(config, T_ULONGLONG, "attribute config."), + evsel_attr_member_def(sample_period, T_ULONGLONG, "attribute sample_perio= d."), + evsel_attr_member_def(sample_type, T_ULONGLONG, "attribute sample_type."), + evsel_attr_member_def(read_format, T_ULONGLONG, "attribute read_format."), + evsel_attr_member_def(wakeup_events, T_UINT, "attribute wakeup_events."), + { .name =3D NULL, }, +}; + static const char pyrf_evsel__doc[] =3D PyDoc_STR("perf event selector lis= t object."); =20 static PyTypeObject pyrf_evsel__type =3D { @@ -820,6 +842,7 @@ static PyTypeObject pyrf_evsel__type =3D { .tp_dealloc =3D (destructor)pyrf_evsel__delete, .tp_flags =3D Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, .tp_doc =3D pyrf_evsel__doc, + .tp_members =3D pyrf_evsel__members, .tp_methods =3D pyrf_evsel__methods, .tp_init =3D (initproc)pyrf_evsel__init, .tp_str =3D pyrf_evsel__str, --=20 2.48.1.711.g2feabab25a-goog From nobody Fri Dec 19 20:37:55 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 404731DFE0F for ; Fri, 28 Feb 2025 22:24:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740781447; cv=none; b=Oec+sF1QIv6Dz8sUrks8dqlUAQOWuzhsz3ZO8Y3m9U6A57I8xtVvkZrHK5wIoOpKX1/h0nBGiMorQUlbiBHG5dPrE6Kx5HOMWACeyOYKNpy32AFMHJg4QXTjDwYQCVaPGSwTnA/ACcByOBUvMLhZfuPKepsT/Ka3Owq+4J9JVso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740781447; c=relaxed/simple; bh=c20W4Lu/yCFUCIff1Ju7FoRwzLs1VC3M4seD1jUrq3E=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=aSFkn5thGSt8caw66wlPYIZSkoHnMA4x7zVu7wFFxeP3PnQ8Ulmp2cctGWuijz6On272DhwnEN7RA07xjJVGKbwZgah2aJwJVOPeRUT/usUsTSufv1x1yiFIWop+Bndv5cIuFx8vfrQceeMqjCCBW9l6/RFMSmbc6yN2ZCWXmKs= 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=hGEtrz0w; arc=none smtp.client-ip=209.85.128.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="hGEtrz0w" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6fcfa304ef4so40514457b3.0 for ; Fri, 28 Feb 2025 14:24:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1740781445; x=1741386245; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=DUsOhiF32RtA3rdS/vMtgZcfTtdyvQ+DyGJcYbuYksQ=; b=hGEtrz0wEox6rzvuO6NpBDVqctkakMf1cHnYjdbymY13S1De23RW5kyCd2RRR5prpI BD4jhAVQQa3cPF8NE1Zb3ERsesmbIjmsTJaLw2WW4WoCxYgKPBggzO/E4QsLVxqlYKq9 BUkO7+6swLDpE4bl/aLNl51D0KrjnePMPeOsThVKdWU9Jlefy1+2d35kIS1zIDjzlc4g 5/1H7c4KszCNoztpgabDIYQmNBZ6b/mc0od7INWWuLyYDmKknQZM+rNZcsCayJ2RD/xr 8JcjytiFPcTVlAHidc8sTYZiu8s9h+s+IpSW+a2e1iszEpTEBmw2Qfs7WG0/f83jQKHg 1S+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740781445; x=1741386245; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DUsOhiF32RtA3rdS/vMtgZcfTtdyvQ+DyGJcYbuYksQ=; b=PunxrGYX8/s+x4cKV4yA8ZYlwVW/C8ElgJAck8xR2sM5zhG0JVF9ouOSbg8xTjomOC +LMBVmBrYZotO9DbNCch7ZW7S1zBAtHdO/k7q0VEcH4vi3fIEkm+yxtc2akYFG/NXLLy k1UQ/mu9pdCwivjdivbLOB6ZDWs6ua3Wnuo6mjvmXZpE+IKqxGr/yCuFXqjbTK/q3YBG LoQajfxEw5Ex0SQNwb3YJ4kdL2woHT83yYOGpgFscGqiMV6G/G7BIqz9m+LTG8DMQWoh JaUKDvXfHBi2LE0Y5JnvCC+TsF0yD9Sv30C4gkoCFDYoB02WZD9Yf2Eu1iJ5lG9g12iR kHHw== X-Forwarded-Encrypted: i=1; AJvYcCVnhnTfOiW8PKljfhV/y7G97KcM7HOcS1+2ZmJdLGgzgtBghmVrTG4Va3z6j3+1brKrucRroHJu8r+z2aM=@vger.kernel.org X-Gm-Message-State: AOJu0YzG+rxwlDkCov7H+f9pRdWgI7/VKGAHQn4dTd8kegQiokiM9pu/ OEFxoqAbUBlGzOpx+TSjIIwaIBK8eUT308Ae6C0XP6LH/KTleiUQ1JG0Sbi/QqnhwPAB7J/q2NG XlKqorQ== X-Google-Smtp-Source: AGHT+IHfd7GrwJfhb+MWua2bx3vtIpV6EB15tYflsFx+umvkBji+DSYZmokYAdQCo0ENr+WPX3hvXcndIKmZ X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:23a3:4d43:890f:dfd7]) (user=irogers job=sendgmr) by 2002:a05:690c:5c16:b0:6f9:d2ce:45e4 with SMTP id 00721157ae682-6fd394641c2mr11001607b3.1.1740781445317; Fri, 28 Feb 2025 14:24:05 -0800 (PST) Date: Fri, 28 Feb 2025 14:23:03 -0800 In-Reply-To: <20250228222308.626803-1-irogers@google.com> Message-Id: <20250228222308.626803-7-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250228222308.626803-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.711.g2feabab25a-goog Subject: [PATCH v2 06/11] perf python: Add optional cpus and threads arguments to parse_events From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , Yicong Yang , James Clark , "Dr. David Alan Gilbert" , Levi Yun , Ze Gao , Weilin Wang , Xu Yang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Howard Chu Cc: Ian Rogers Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Used for the evlist initialization. Reviewed-by: Howard Chu Signed-off-by: Ian Rogers Reviewed-by: Arnaldo Carvalho de Melo --- tools/perf/util/python.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index b600b6379b4e..4a3015e7dc83 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -1339,12 +1339,18 @@ static PyObject *pyrf__parse_events(PyObject *self,= PyObject *args) struct evlist evlist =3D {}; struct parse_events_error err; PyObject *result; + PyObject *pcpus =3D NULL, *pthreads =3D NULL; + struct perf_cpu_map *cpus; + struct perf_thread_map *threads; =20 - if (!PyArg_ParseTuple(args, "s", &input)) + if (!PyArg_ParseTuple(args, "s|OO", &input, &pcpus, &pthreads)) return NULL; =20 + threads =3D pthreads ? ((struct pyrf_thread_map *)pthreads)->threads : NU= LL; + cpus =3D pcpus ? ((struct pyrf_cpu_map *)pcpus)->cpus : NULL; + parse_events_error__init(&err); - evlist__init(&evlist, NULL, NULL); + evlist__init(&evlist, cpus, threads); if (parse_events(&evlist, input, &err)) { parse_events_error__print(&err, input); PyErr_SetFromErrno(PyExc_OSError); --=20 2.48.1.711.g2feabab25a-goog From nobody Fri Dec 19 20:37:55 2025 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.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 3FBFB1E0086 for ; Fri, 28 Feb 2025 22:24:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740781449; cv=none; b=J+XyoAOrqNTQMaFnwSQZKOZImPB2NMxsNbwkyRLnN5COpZ2n2uP4wv743g7tV/jx1SE3XEiJLqDYMzhyVIabQ29MpI4a+aCZTKmTFkkwtQ4v9Vzw9O9mrdgFE8iMHKQNbS8GeZ2oSXJKIt8MUhX+YhRIPqLyKfOO7mC1oYKzjpc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740781449; c=relaxed/simple; bh=3U/cYgmD6vAgcdgCcDMxQT27dA1CrOHmVEkNQlnQDdI=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=C/bpxpLoPuHea88utuIfe/v9s/LbAQOvMpAAasKtPU7GAkkw8VoU7exavbdvyjMs6Ww979ljA2izREZLT8o0qTdeIvUU364UU/xxfZg1ur80L3/3HySK+Zhr7QKof1Jiqyw67Z3s/e0xZDYLpXpbvtYwbiZtdiyJwcNtSr3nmp8= 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=B/yhMBqA; arc=none smtp.client-ip=209.85.219.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="B/yhMBqA" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e60b18e8e7aso2160133276.2 for ; Fri, 28 Feb 2025 14:24:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1740781447; x=1741386247; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=zWmfzvWfvxhIoKLCku8WgoqMCrsFvtRSiOtbgh4saZ8=; b=B/yhMBqACBFJJh24GUEWT+8YU919pbVBSUrdp3A5B+UzucdXmKjRAS57PYTAx9CVFk 3fdAokpTSCoGnwY8exCYr/Ixs0FcXyHfQegaaz69lFkjsFA6OTpYs2Rly2NpLxF4hxdO qFnYZeQ7V9MJXepFyGtnVBD7GJCF5tHwznmflyghTb5ntqyM2oJtM4UDWBQVE9IPWCu6 G4clIQy/aXNPiJagG4MUwOxKxvfMSm5keFmcBZVEOmGdmVo50SV6oCjf8rioyOjRkfmM xxK6SwaX+GY+MHO7ez+JMIO9aL6ZZZxgVvQ8D4qymdbsc4eKhQDpoBaACs7Lc7M7Evh0 nmhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740781447; x=1741386247; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zWmfzvWfvxhIoKLCku8WgoqMCrsFvtRSiOtbgh4saZ8=; b=HlXAjdzNdqzuCi1YwnnB1GmLew7CpRgf8Uz28PQBOZvpvD8FISr7Xt4AZGAHdQc/we NbRYWHyT8VDvZeEB8aZJHz8+QlrUgB6vQSukTNu49harRH674Yo3wvmVrUNv8JFTYjVl u21GBNmFYAdBQi7noVhEws0iWuUMX1MNEpPr8NsFgcNJsvU7e7Ex70v+KCP5FnJAPIBt e20DrtixmDnlSzQ+gr27fBh6HlomCjDKglzlR4UgVwI+He7VqR0rClFePZTgys3PU9Ji oQRu8wbTQFL/JqKnU3A9C/gpas45lvp03gAZMZ1NTNNMoFgUtMnDJ13/fEmJh/3LLnef nTHg== X-Forwarded-Encrypted: i=1; AJvYcCXskcUkX1VOM9GvJUOhrEGRox+CsXv97LVP8TSiMQodh+EnufUsYt2mK6PbuhES+EQoUARNEUzVMmvC7+8=@vger.kernel.org X-Gm-Message-State: AOJu0Yw7Vhw+MT0/dSM47nicJT0FUnTCpCuEIul2bVt7jY280D0wlknx 2bSzRJP5BnwXp2e/919Z5Rr8d3XViIc1XBxT6Hf8xvk4AqqfN54mGC9JVH10G46K0dPe0GqHmFa 18X7/uw== X-Google-Smtp-Source: AGHT+IH/nPjC9NzM/le3+8wxGvd2HBBDieU4nncgkyyZl5u9QM2UhIqdpSklmjOPeDgwQUJFXpb0phg9zS0z X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:23a3:4d43:890f:dfd7]) (user=irogers job=sendgmr) by 2002:a5b:b43:0:b0:e5e:fdc:88e1 with SMTP id 3f1490d57ef6-e60b2f347b6mr514013276.4.1740781447186; Fri, 28 Feb 2025 14:24:07 -0800 (PST) Date: Fri, 28 Feb 2025 14:23:04 -0800 In-Reply-To: <20250228222308.626803-1-irogers@google.com> Message-Id: <20250228222308.626803-8-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250228222308.626803-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.711.g2feabab25a-goog Subject: [PATCH v2 07/11] perf python: Update ungrouped evsel leader in clone From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , Yicong Yang , James Clark , "Dr. David Alan Gilbert" , Levi Yun , Ze Gao , Weilin Wang , Xu Yang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Howard Chu Cc: Ian Rogers Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" evsels are cloned in the python code as they form part of the Python object pyrf_evsel. The cloning doesn't update the evsel's leader, do this for the case of an evsel being ungrouped. Reviewed-by: Howard Chu Signed-off-by: Ian Rogers Reviewed-by: Arnaldo Carvalho de Melo --- tools/perf/util/python.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 4a3015e7dc83..e244cc74f16d 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -1312,6 +1312,8 @@ static PyObject *pyrf_evsel__from_evsel(struct evsel = *evsel) evsel__init(&pevsel->evsel, &evsel->core.attr, evsel->core.idx); =20 evsel__clone(&pevsel->evsel, evsel); + if (evsel__is_group_leader(evsel)) + evsel__set_leader(&pevsel->evsel, &pevsel->evsel); return (PyObject *)pevsel; } =20 --=20 2.48.1.711.g2feabab25a-goog From nobody Fri Dec 19 20:37:55 2025 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.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 A60571E0B96 for ; Fri, 28 Feb 2025 22:24:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740781452; cv=none; b=ZwOZAGSe/t0s5sQ8oUP0ldjmFfOP4tKI7wMPcXdXV4s+L83r44Pc4G6lYBAy5Bx21i5xIm0ArHZbyMFQtEkDIfo0XSS8N3ZyPW4M5gRNERly73nJ4wZ81tiysrt9A0wsQkItSYWu2pAVXY1Q3tJW2c8iJSx0aVHdbFo4p63A/SM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740781452; c=relaxed/simple; bh=SMz5hMAzgWKP7lTvIai1pMYw2CR0WUilsImxdukqyKc=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=Xpfypbum4JfiGZB/FbwgK1nxgv7j2NSXxr44N//kOvMkP4Y83VeNnikUgsxD4Xqdzttr1H9HgEiGIe7b1Fb+DmL3R2TQMX4VgUO4BREIVByuXUGGvqW8RYC1UjzMn3HDJFeCj/vQ+8t2dnBDiYQr8G+jyCWIVDUBY/jeZ+O57lU= 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=4vjc+zr1; arc=none smtp.client-ip=209.85.219.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="4vjc+zr1" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e3a109984a5so2962944276.3 for ; Fri, 28 Feb 2025 14:24:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1740781449; x=1741386249; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=G/Ck10qS4AIVni+TJE8pJGK1gpI9LtVGv/HWjv7OGFQ=; b=4vjc+zr13Dtlbxf+Nk/7DSapnrCHFwSJ8sbCYkZVgJnSRgvK+AjQAt0XR6V5bV1o/i f6TDU6wH3SJefurO7rLWlBwUUqT74VG0MsPULJEazYZbc8G1uzBNlWXUlEbbJhtpFGHe XsX7LO61+9z5y+OtJ3OikoJ04vtKEnkk5z7cXBB7xEGD5NsuRpRzc0x+8S/PJyR2cJIX gx+67HT+bc5afjJrtZZCb+u/cfOyAf2z4DWXYbtBdoQ2hkkn1Jqo+z7iLa1N2YNGZx2A +Yw75BN8Wvw3jNGvI76vRp1JNbXZGrkVNQDKqBYigBsi2LdE79TxLc9Xx9SrtBdK/z2W DPlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740781449; x=1741386249; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=G/Ck10qS4AIVni+TJE8pJGK1gpI9LtVGv/HWjv7OGFQ=; b=gike3GviayNuK9dRY8g+BdEXHyBzfG3lLQ24YIhMxzbt5dl/GHj9KWtcaTUlGRiTdU vIfb3wgjO+9FYdxMsBU8c+/AcqT/8Kaqdxaz1ySGvnzWozBSXmxIQfQRiyrTeVZay6Mo OTg/5jGCy5cR5E1QNH0UtrofcQMnD1gKLpYN137bXN66Z3qNJIZnF8kn6GzcXvBulqnI 69AhMIhMUeJ7eg8akXtfaAhkNFStWyi3nmVqioUhxZPbtWszYmNFS4siefZR7Rpm+hHp NGEvoHM4GoS834lupkNDzInCGp3CVJJgLacP5R0CnswY8mlRVLgQ6HOV3SYOYYyLjwpc sizw== X-Forwarded-Encrypted: i=1; AJvYcCVtsr48EKHvckjDnLJzMK3xKEkLdr+yy0z9UzGEfzNoHIdyam+QfUbOJjSDi2fT/2FIdSs2+zJXywXolAs=@vger.kernel.org X-Gm-Message-State: AOJu0YzBvRmpQIol2abIc53ye60aV80B+OY0bJDY1JdYvRXhrs3Bug0m C+i1xcsDNhEIUeWOyMBhg+nRCYL4QFz/rx2FinHz1pBp5l0SXBjp2QMIlaJ+XlY94gzxiHSc2V7 04oZKEQ== X-Google-Smtp-Source: AGHT+IEfAgbSFD2GZxEPGDtfX9Wvdb3Knr+OFfhlJnykxtIBlfOzAQ+++VosFQ1ujFxqWDc9HGj4dSXR8grf X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:23a3:4d43:890f:dfd7]) (user=irogers job=sendgmr) by 2002:a25:a126:0:b0:e5b:1032:bc4f with SMTP id 3f1490d57ef6-e60b2e8e35emr32930276.1.1740781449510; Fri, 28 Feb 2025 14:24:09 -0800 (PST) Date: Fri, 28 Feb 2025 14:23:05 -0800 In-Reply-To: <20250228222308.626803-1-irogers@google.com> Message-Id: <20250228222308.626803-9-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250228222308.626803-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.711.g2feabab25a-goog Subject: [PATCH v2 08/11] perf python: Avoid duplicated code in get_tracepoint_field From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , Yicong Yang , James Clark , "Dr. David Alan Gilbert" , Levi Yun , Ze Gao , Weilin Wang , Xu Yang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Howard Chu Cc: Ian Rogers Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The code replicates computations done in evsel__tp_format, reuse evsel__tp_format to simplify the python C code. Reviewed-by: Howard Chu Signed-off-by: Ian Rogers Reviewed-by: Arnaldo Carvalho de Melo --- tools/perf/util/python.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index e244cc74f16d..7f2513ffe866 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -342,23 +342,14 @@ get_tracepoint_field(struct pyrf_event *pevent, PyObj= ect *attr_name) { const char *str =3D _PyUnicode_AsString(PyObject_Str(attr_name)); struct evsel *evsel =3D pevent->evsel; + struct tep_event *tp_format =3D evsel__tp_format(evsel); struct tep_format_field *field; =20 - if (!evsel->tp_format) { - struct tep_event *tp_format; - - tp_format =3D trace_event__tp_format_id(evsel->core.attr.config); - if (IS_ERR_OR_NULL(tp_format)) - return NULL; - - evsel->tp_format =3D tp_format; - } - - field =3D tep_find_any_field(evsel->tp_format, str); - if (!field) + if (IS_ERR_OR_NULL(tp_format)) return NULL; =20 - return tracepoint_field(pevent, field); + field =3D tep_find_any_field(tp_format, str); + return field ? tracepoint_field(pevent, field) : NULL; } #endif /* HAVE_LIBTRACEEVENT */ =20 --=20 2.48.1.711.g2feabab25a-goog From nobody Fri Dec 19 20:37:55 2025 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.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 0DDED1E0E14 for ; Fri, 28 Feb 2025 22:24:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740781454; cv=none; b=I54/1Xnd9XWKGRDnUOV1WWjjpwSE9behYBHbtvVpfE3/V9s2NXjCQoxipP4QmYQI7YzxQeT7uExic00Hh91JF5/bQbhaVLqwT+hA5E5KYk1ETh2hGNM3OIUOA2pR8JC7lGXpgYUGx9+o+LgKVmgj9w5lmOZnToXaeJfqvfTrENc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740781454; c=relaxed/simple; bh=wrht3Ck1Kuq4sobgfeJPBu1XYS24mA6fKpUErZdwyt0=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=EMHSSEpBiBnS5HN1nv5uWA/KOuswOZIeU1FTrf/KjBOJwNjHhTPwtZHqgSgmNBfeTfcgQZgQ4mDd9lhG5EYBhhaNU3R21p218isfG7I2GWJpGczHbUzUelXAZDGx14aAypnhzY4aOw5w265pfPlJoLU8e7lo1wNG1ZFGvKyadHw= 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=cySwLqlk; arc=none smtp.client-ip=209.85.128.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="cySwLqlk" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6fd409170c7so23177157b3.1 for ; Fri, 28 Feb 2025 14:24:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1740781452; x=1741386252; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Vlh6ybn/t9Eio4NDtMpr3RQAX90AF4f82uyAhhltD3A=; b=cySwLqlkj5aew/DtHv/aObb7sGos68TjBzav8F25UXieR/XsnETPEhp5QoqV3yn/8Z 4pxg89LFuJRD3ZLA+udxJ4JLMzjyW/99AMdznwXj5j252zQ8OcQohrlima8yZKD1wfeW Cf2rMFCmMZ/ao7eELjUYnlQ0o4JOh1k/J9AGSp6S8Zw6Skdoz9M1aWgMhMRhx0w2CeM2 Xd9GH10DoTkiWtZakUuvFYGNwi0N7M8iaymVzMWfRhnVHBe425Jw15yGTvSkdktTFX/y obJu/TszoQK5vUPInX/xq0Ldlv4an88fOdY2Cy5xlYrJf/3J+qHN3LOGJLHkKJhCdR2Y C+Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740781452; x=1741386252; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Vlh6ybn/t9Eio4NDtMpr3RQAX90AF4f82uyAhhltD3A=; b=fTJBiilHPI+dI9wCC/zFY+BNeUxTrXi3OzqM25YyXGZiXrfIa3LwVouZaul3SceIZv EhSJlOMJeMgWzXqPIaYRttQgvIAHkC6augSmYV/M6NJbGDpps4Ctgi/H42dY9bdqTvYT zQxk7sXu3uvtf+HWS8p0d2DTBdd7LtKPhMgwg8lqDnPPedcnXvG9l4POd/dRx4xl9g/q ynXKE9VX3+mppYTqfKlOyW2V3Q0Dr7fyWumtvruyUn9RNV8UxZ4WbsZEAS7HsKXzom3p 8cdbKc6DcBbLt7Pw5vNe62AjDhJscD9LzLLBzeIiwXWD2qpKNn4AJCxQFMDEkLLxLqNh 215w== X-Forwarded-Encrypted: i=1; AJvYcCWAqmQpho1LG+lOfAnwhY3hrih4LdAg2PxEQclcEciZ6gVT3O+vze4tTpg1Dbugx/Dl3qOlvHMXBjHl3v8=@vger.kernel.org X-Gm-Message-State: AOJu0YwJqwUuCWyUWqG/QfGQVLTTzUlbJ5LC7MEOL93KiV2Jb4SfheyA fC9yRgFmIJtYgMbSx+QE/ouhJ5IEtW2LatNFOZxFpQWtKV0ZT3zCCQuQ6LVFzGtuiKe+oHUINOx KxF4qDg== X-Google-Smtp-Source: AGHT+IGS9PUiVd2wbpTmw0ubEIttIIVjgmvg2lVbKCLsqMOnkXdig84FL8BYfckMna/3eucCQ4JlVoCn2p+F X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:23a3:4d43:890f:dfd7]) (user=irogers job=sendgmr) by 2002:a05:690c:c18:b0:6fb:8461:e7f4 with SMTP id 00721157ae682-6fd4a0d3b59mr3420887b3.3.1740781451797; Fri, 28 Feb 2025 14:24:11 -0800 (PST) Date: Fri, 28 Feb 2025 14:23:06 -0800 In-Reply-To: <20250228222308.626803-1-irogers@google.com> Message-Id: <20250228222308.626803-10-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250228222308.626803-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.711.g2feabab25a-goog Subject: [PATCH v2 09/11] perf python: Add evlist all_cpus accessor From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , Yicong Yang , James Clark , "Dr. David Alan Gilbert" , Levi Yun , Ze Gao , Weilin Wang , Xu Yang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Howard Chu Cc: Ian Rogers Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a means to get the reference counted all_cpus CPU map from an evlist in its python form. Reviewed-by: Howard Chu Signed-off-by: Ian Rogers Reviewed-by: Arnaldo Carvalho de Melo --- tools/perf/util/python.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 7f2513ffe866..c55c8392bc07 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -874,6 +874,16 @@ static void pyrf_evlist__delete(struct pyrf_evlist *pe= vlist) Py_TYPE(pevlist)->tp_free((PyObject*)pevlist); } =20 +static PyObject *pyrf_evlist__all_cpus(struct pyrf_evlist *pevlist) +{ + struct pyrf_cpu_map *pcpu_map =3D PyObject_New(struct pyrf_cpu_map, &pyrf= _cpu_map__type); + + if (pcpu_map) + pcpu_map->cpus =3D perf_cpu_map__get(pevlist->evlist.core.all_cpus); + + return (PyObject *)pcpu_map; +} + static PyObject *pyrf_evlist__mmap(struct pyrf_evlist *pevlist, PyObject *args, PyObject *kwargs) { @@ -1057,6 +1067,12 @@ static PyObject *pyrf_evlist__enable(struct pyrf_evl= ist *pevlist) } =20 static PyMethodDef pyrf_evlist__methods[] =3D { + { + .ml_name =3D "all_cpus", + .ml_meth =3D (PyCFunction)pyrf_evlist__all_cpus, + .ml_flags =3D METH_NOARGS, + .ml_doc =3D PyDoc_STR("CPU map union of all evsel CPU maps.") + }, { .ml_name =3D "mmap", .ml_meth =3D (PyCFunction)pyrf_evlist__mmap, --=20 2.48.1.711.g2feabab25a-goog From nobody Fri Dec 19 20:37:55 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 418031E1A23 for ; Fri, 28 Feb 2025 22:24:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740781456; cv=none; b=PMfraEMHZspx8NWpZw7Kjz1mQcAJroASA1nQNR04iPcTm6ZYQ6HFoZriv7VGsD1gpxbBlq5TleGJOk+GgCZUrVN00ryTWWS3DHAiRWQl/4JW/ffbvFADHf31sLQ5aqNkg70a2VDVWjlKrdyD79tgkZnxQ1GYz8ylCC6a7N08e9o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740781456; c=relaxed/simple; bh=jARGiuOKFpE7ttUiyi3nXCy1dRKbqXYHUbF5NHjb0bQ=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=hXgez61mbVIDWaQv5QgWPBzBPqVE56USxfJXAgC2axeDqjNuGiQTECVxxizlP1wK06kpKttdwlb+PihyJwDU4c9CcRaIybFbWQVLuYC5JOQvxgZHfvwIhjUT6BcNyjjCA6Xoz3pm7uYTJVf2m7N86XtodJClhjzvjybHzzw/zaA= 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=PYxO0cH2; arc=none smtp.client-ip=209.85.128.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="PYxO0cH2" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6f788a1de55so34660217b3.3 for ; Fri, 28 Feb 2025 14:24:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1740781454; x=1741386254; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=enmPSmBHYN1yp2Q+rHUZdMzy5YlY4bNvK33F83dFzQM=; b=PYxO0cH264RH1PhhlGubyv9U+IHcFdJGk9690ga/wLCIWccjmucqtnvWOCok5aRTTC /vaeW3mhGYNttXgjocC98Gv/geClz5zMufi+wqKRfMGVsv0YaEAj60fs7wPxL+osIDFO HAqNPM89T4WOC/OkXhSDRlqknWAfzeDMgmO106gFVJgFupZSTCvUFGbonXVrDZod3hfG h8HXzW6Ttetkl0Mi4S1TCuFRrAKLLRkFeoZ9oW0+VPLQGmIq47vdGfq2Byds30JRqzys sB+4tSTnH1w+JSQESQaZkwaEGYOA66ezFrGNw18he5M25plmjmzOiifIP+fm+4e05T9x jSVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740781454; x=1741386254; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=enmPSmBHYN1yp2Q+rHUZdMzy5YlY4bNvK33F83dFzQM=; b=vGyxEVeEoavSfEKrt54evKgzdvisSQaHnzvzwk8jwtQM8uYwFhxEfgc31xAHj8Opus O+echUUvYa7s5h/CG0McIYfFFTwXQVzyTIIBPmHD6nqGuH0OOvFNXh8mrNsE1HjJHLlP xEDPTZa54Y4W5iKnpj5doaqmTKzJaelLwJwa/frb5GD+bO08CNuu4IxzNX6BmLjAQCPK kWPRk21HudLWf3gX4/dr1ckiBDZaF457XvyracU/XoR2o2zKr9dKjcOBcp2INPTbW8Vy HZjk37L+WUc5gXNu8f/HaSmiEp21+dpILjI7R+hWHTUQUR4wGFqYNFDFl5GDafxKwmFY I0/A== X-Forwarded-Encrypted: i=1; AJvYcCW+pK7aFSZF0k4Jp+AlOWb3As+KbvUS4UCcahMzreImxfUDIeXehAvPwGmt/Na5uQoA6oxxqwhY2PDxNFU=@vger.kernel.org X-Gm-Message-State: AOJu0Yzu5stBrFtC/Jwjm28JizgEf5LOAHpURY5QDejmsy5C7vbQ7a1y xapXYJon08SW0GQdHmmgyoJMhlfpHjLSwyu/5krzU4rTC67N8iR0lbVBlwuySHwKM/JnGJGhGo5 tJzVXxg== X-Google-Smtp-Source: AGHT+IF5Ht5Zx7YaRV6uVmPiWZ2hPFfsxIko0UkgE1lrkUhapRpqms48maTlHe7yM9CQdUCAckPuCsM5tclE X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:23a3:4d43:890f:dfd7]) (user=irogers job=sendgmr) by 2002:a05:690c:6e10:b0:6fb:51bb:bb6 with SMTP id 00721157ae682-6fd4a0f3ac6mr4933897b3.3.1740781454138; Fri, 28 Feb 2025 14:24:14 -0800 (PST) Date: Fri, 28 Feb 2025 14:23:07 -0800 In-Reply-To: <20250228222308.626803-1-irogers@google.com> Message-Id: <20250228222308.626803-11-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250228222308.626803-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.711.g2feabab25a-goog Subject: [PATCH v2 10/11] perf python: Add evlist.config to set up record options From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , Yicong Yang , James Clark , "Dr. David Alan Gilbert" , Levi Yun , Ze Gao , Weilin Wang , Xu Yang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Howard Chu Cc: Ian Rogers Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add access to evlist__config that is used to configure an evlist with record options. Reviewed-by: Howard Chu Signed-off-by: Ian Rogers Acked-by: Arnaldo Carvalho de Melo --- tools/perf/util/python.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index c55c8392bc07..69ec2ad60d98 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -9,10 +9,12 @@ #include #endif #include +#include "callchain.h" #include "evlist.h" #include "evsel.h" #include "event.h" #include "print_binary.h" +#include "record.h" #include "strbuf.h" #include "thread_map.h" #include "trace-event.h" @@ -1052,6 +1054,31 @@ static PyObject *pyrf_evlist__open(struct pyrf_evlis= t *pevlist, return Py_None; } =20 +static PyObject *pyrf_evlist__config(struct pyrf_evlist *pevlist) +{ + struct record_opts opts =3D { + .sample_time =3D true, + .mmap_pages =3D UINT_MAX, + .user_freq =3D UINT_MAX, + .user_interval =3D ULLONG_MAX, + .freq =3D 4000, + .target =3D { + .uses_mmap =3D true, + .default_per_cpu =3D true, + }, + .nr_threads_synthesize =3D 1, + .ctl_fd =3D -1, + .ctl_fd_ack =3D -1, + .no_buffering =3D true, + .no_inherit =3D true, + }; + struct evlist *evlist =3D &pevlist->evlist; + + evlist__config(evlist, &opts, &callchain_param); + Py_INCREF(Py_None); + return Py_None; +} + static PyObject *pyrf_evlist__disable(struct pyrf_evlist *pevlist) { evlist__disable(&pevlist->evlist); @@ -1109,6 +1136,12 @@ static PyMethodDef pyrf_evlist__methods[] =3D { .ml_flags =3D METH_VARARGS | METH_KEYWORDS, .ml_doc =3D PyDoc_STR("reads an event.") }, + { + .ml_name =3D "config", + .ml_meth =3D (PyCFunction)pyrf_evlist__config, + .ml_flags =3D METH_NOARGS, + .ml_doc =3D PyDoc_STR("Apply default record options to the evlist.") + }, { .ml_name =3D "disable", .ml_meth =3D (PyCFunction)pyrf_evlist__disable, --=20 2.48.1.711.g2feabab25a-goog From nobody Fri Dec 19 20:37:55 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 C5EAB1E25EA for ; Fri, 28 Feb 2025 22:24:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740781459; cv=none; b=YSmyPc6UQxg/836qJZYwfUSzMG+kE+cuf5W+zID0HETM6yaqtMnDFNMuO9Z7g6w28mDmr7PdtGypxxdW4q8uDQ+lICdjV6OX27yAKAF0M8//K96ekiXoCvLMJrRxqNYf30ftD2fomL5V86xbQYKKAYHDX6MPSjh0oNkxzBfeZGo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740781459; c=relaxed/simple; bh=rex2as/EnuXYCks18MkDmVUBXz3F9t2JAEg7XMf2fWQ=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=UgKhbRWSbbIHpNVE7wiBQW3qzUKYqeu7Jt2V4mauJ4XShF/0Ixtjqd+J3e86Ba2ffAgH9JI9pAxa/vK/Utz8HgA00iZw259rnnB3yctpqV6PDiJtXAZceHmVYrML7koVs0+1A4aftx7w0U+GWtAGXMKohnNiCQqCQ5R8bIt7oPo= 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=yqglsY3B; arc=none smtp.client-ip=209.85.128.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="yqglsY3B" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6fb518ad1e4so29037457b3.1 for ; Fri, 28 Feb 2025 14:24:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1740781457; x=1741386257; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=0RU/+DqotUTg+8ru2ruiECPIkRiWWFRT5gNEZToh78w=; b=yqglsY3B/iEIDP9/RKZL7Wl1NcqXkKwqrvw3FG5XC/UfK5ENGCeY+AFKra79AH841b VDJ6Y275ypvLF/teWBKePbnjnndUygloAQ17Jvk3zvHQD+FUfKWyeQTtRCjJEzQjXKKo YPrIbI6c6vNsD6z9adDGb1Jg1KtBdbza54MpNncbkZ4kgdumoAquTx/BXcZwAcDfQBFT Qf6vWmRUBVX1iL6OEXWQ3y9VTxYZXf0ZPL+y6o9OpQh5BhLHIsxnGntukkYPqBQf6IWi KrMHVgjavq2RTC+32vDaDO4aLW659kwz9OqputgxLAEwcVGIU/4iSOscI3kWHKnw3STt /0jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740781457; x=1741386257; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=0RU/+DqotUTg+8ru2ruiECPIkRiWWFRT5gNEZToh78w=; b=N9Rhf2lLjEr/piW4wpZ68vzriIo3Z2JBjUR14WPKhFb+pQcEXS2MQIc/dA6xeJrq26 OhpoD6ziu4P7ccPU8KrGzNxJL7pBZPZnX5jHA85wdtcNnNFa/PCOG/BWtqIUICIydgW3 UOFBZ+4u6mYj6p5zsQ548xWsQsfdHRN+UP7j2rm8lNsfIAnULi+kRdYmXNy7SzyfswBr PZsOpaIScskFFS5NeiZVEeWVUcyN5PFupjEkREDsR9ha3JSMRDla+jaOp8ZoxtLTP75f 6/aoNxkpQUUWvoikWa3hWjy1kfihspyKtVdeqBXk6osbUrKAwUndeUtfXAJQUexI2gP4 OcBQ== X-Forwarded-Encrypted: i=1; AJvYcCX4g5f9CDODoOdyVCmkuDBOQYqkih3WUyishW3EnjZDH8z1wg5Vh5Otp1TWnOTmKsHOVKev+tIAlU6z96w=@vger.kernel.org X-Gm-Message-State: AOJu0Yw/+Uk6RV5dYun7VWJ0GNnFJWRsMkiGT6Jd5aaFvCqYeZxGerL9 hW7j5NF+dnbZqgvagMZAFKpBNVWezcePughj7qJ1v804roXMvJx3cLdPtLuAGyPJRIcdy5+zS1/ XJumBnA== X-Google-Smtp-Source: AGHT+IHRV+YnNTUs6kh7Q7NpG8hvARodfZBeKR3CohIJAv7l0VaH42fhATH5xGQ/HIF4iWzdguHHMKEDTZpl X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:23a3:4d43:890f:dfd7]) (user=irogers job=sendgmr) by 2002:a05:690c:6303:b0:6fb:afe0:f186 with SMTP id 00721157ae682-6fd49fa7cefmr4574187b3.2.1740781456425; Fri, 28 Feb 2025 14:24:16 -0800 (PST) Date: Fri, 28 Feb 2025 14:23:08 -0800 In-Reply-To: <20250228222308.626803-1-irogers@google.com> Message-Id: <20250228222308.626803-12-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250228222308.626803-1-irogers@google.com> X-Mailer: git-send-email 2.48.1.711.g2feabab25a-goog Subject: [PATCH v2 11/11] perf python tracepoint: Switch to using parse_events From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , Yicong Yang , James Clark , "Dr. David Alan Gilbert" , Levi Yun , Ze Gao , Weilin Wang , Xu Yang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Howard Chu Cc: Ian Rogers Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rather than manually configuring an evsel, switch to using parse_events for greater commonality with the rest of the perf code. Reviewed-by: Howard Chu Signed-off-by: Ian Rogers Tested-by: Arnaldo Carvalho de Melo --- tools/perf/python/tracepoint.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/tools/perf/python/tracepoint.py b/tools/perf/python/tracepoint= .py index bba68a6d4515..38b2b6d11f64 100755 --- a/tools/perf/python/tracepoint.py +++ b/tools/perf/python/tracepoint.py @@ -5,24 +5,23 @@ =20 import perf =20 -class tracepoint(perf.evsel): - def __init__(self, sys, name): - config =3D perf.tracepoint(sys, name) - perf.evsel.__init__(self, - type =3D perf.TYPE_TRACEPOINT, - config =3D config, - freq =3D 0, sample_period =3D 1, wakeup_events= =3D 1, - sample_type =3D perf.SAMPLE_PERIOD | perf.SAMP= LE_TID | perf.SAMPLE_CPU | perf.SAMPLE_RAW | perf.SAMPLE_TIME) - def main(): - tp =3D tracepoint("sched", "sched_switch") cpus =3D perf.cpu_map() threads =3D perf.thread_map(-1) + evlist =3D perf.parse_events("sched:sched_switch", cpus, threads) + # Disable tracking of mmaps and similar that are unnecessary. + for ev in evlist: + ev.tracking =3D False + # Configure evsels with default record options. + evlist.config() + # Simplify the sample_type and read_format of evsels + for ev in evlist: + ev.sample_type =3D ev.sample_type & ~perf.SAMPLE_IP + ev.read_format =3D 0 =20 - evlist =3D perf.evlist(cpus, threads) - evlist.add(tp) evlist.open() evlist.mmap() + evlist.enable(); =20 while True: evlist.poll(timeout =3D -1) --=20 2.48.1.711.g2feabab25a-goog