From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (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 7C5281DDC35 for ; Mon, 15 Jun 2026 00:28:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781483304; cv=none; b=gtbcQALwBYGoEOK5L+ZXM8NeK6qosndCNjDuLgiAhN1I88fTmkpR3coFHiLtXaIdFTB7JdETblJLyFn8ir41NnV4pDee/R3Ee1htSWiUXu+Ixsz15d7RPsDX/e4gd25S6FOjnpJKRrwioWPzsb3WDsLc3ktNm+YiY8AiOoF+faM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781483304; c=relaxed/simple; bh=BmN+uIK2KozJ/CmJ6jybIyW1ngHuqgsLL5Q2oJs/n+Y=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=hjtfqjVBLv6GBCHRLDLGj+afITUadBeruKlL32j4DMlDG+iwx877D8j/G0tjHJLnQWMpGPdtVhpg8mKrQ1P8U3sjFc19/YAjUdZGv4bPU4mXRzlcC4f7Uuvgh61ckaXBCv1jbYUoEAcdiLHC2ALlY3OP1+VDLWZz2JZUquRWMJ4= 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=V1ySdmgO; arc=none smtp.client-ip=74.125.82.74 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="V1ySdmgO" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-13967c19ac6so3745530c88.0 for ; Sun, 14 Jun 2026 17:28:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1781483303; x=1782088103; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=VvL9FN3niBRwopfeT8jFF2/cj8/ZhVUpeFaQcjlgPs4=; b=V1ySdmgO40tqgc37XYbifuIUl+E2FWAlGwRouAPP9EWHaHMM8MRRkHI82nbtOAWW3w +ztFi8Pn/m6Ue9N4BWNMHBzBLtdU7zlVoV1y1x5xp56lfZj0O65qAMHnmqagvAERizx+ fktmMW809WtwlvQISaCS7vvG68mJy9T8wJ7WioCBSEviSQPpuiP2mFk31CXWBSuZmChI dr8KBRLqpIAgrWraJQS5eWtT8RZlLqCmkij2F4Qk2X/AEAIzpbCwP1xXsx18UVaGkGzo ROQDJMJlhHDFNTB4SqS/dDtOlI9jl7wV/ezlEY4AG5YlEsOpAPwIygWtunED+0eD6He5 /Oew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781483303; x=1782088103; h=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=VvL9FN3niBRwopfeT8jFF2/cj8/ZhVUpeFaQcjlgPs4=; b=X+mZuzzdXP36ougIgQhJXV2kRDIAlxaJZvcbBbrml80EWds7SKhaazL2JV+JnC6X4g 2ESiZubQiPLhY9hkONBYA+cHKvV3wHjjpC7aNca8Xsf4mJjPXoT7CnlMVa7FWwcTbIIS TTU+WQ0bVkZIPBWgltcceDX1Sui71gqpHldlrQGZQ9hnSFcBUfKqltyqEwuI2wEMvTSb Dlk5wMtytDK5PgpLChwTIun+HIkIsWty3ipQdFhAXuv5TSVd3lZAS0nPXQ1YN1YDF2In UwpcIzeCipqW5inRajaj7JfOAIgFu+eFI8MbgWRYnnIfBlFDMcpuSm+kk5MHpa0/DLnp cdnw== X-Forwarded-Encrypted: i=1; AFNElJ8iE7zoEE4G2zjYwITMamgDoHpYBxgkTauDO+5yevyu8RTatTTu0+Bp143CauteG15CzGOzRCLXvS/4ldc=@vger.kernel.org X-Gm-Message-State: AOJu0YxLeKNh1YRpSGlcSQh1tZoZY6+xZ5iwjJxQBQ4dKBt6KDAVNvzS WNp/jqZAHzE0609Xd8WQ79G9k9WzqSyVHGw+N9BK/ck9yd8Wu+IsppqCeiuHCvUC+PktIiPecyF EgumfRrK03A== X-Received: from dlbcj30.prod.google.com ([2002:a05:7022:699e:b0:135:b432:37dc]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:250a:b0:137:d08e:e5b1 with SMTP id a92af1059eb24-1386f34a1femr4089185c88.16.1781483302288; Sun, 14 Jun 2026 17:28:22 -0700 (PDT) Date: Sun, 14 Jun 2026 17:27:54 -0700 In-Reply-To: <20260615002812.2234795-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: <20260613071100.1508192-1-irogers@google.com> <20260615002812.2234795-1-irogers@google.com> X-Mailer: git-send-email 2.54.0.1136.gdb2ca164c4-goog Message-ID: <20260615002812.2234795-3-irogers@google.com> Subject: [PATCH v18 02/20] perf python: Add missed explicit dependencies From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: adrian.hunter@intel.com, alice.mei.rogers@gmail.com, dapeng1.mi@linux.intel.com, james.clark@linaro.org, leo.yan@linux.dev, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, tmricht@linux.ibm.com Content-Type: text/plain; charset="UTF-8" Fix missing #include of pmus.h found while cleaning the evsel/evlist header files. Also define PY_SSIZE_T_CLEAN before including Python.h to comply with modern Python 3 C-API requirements, and introduce CHECK_INITIALIZED and CHECK_INITIALIZED_INT safety macros to be used by subsequent patches. Signed-off-by: Ian Rogers --- tools/perf/util/python.c | 41 +++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index cc1019d29a5d..98a8dd9b673d 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -1,30 +1,37 @@ // SPDX-License-Identifier: GPL-2.0 +#define PY_SSIZE_T_CLEAN #include -#include + #include -#include + #include +#include + +#include #include -#ifdef HAVE_LIBTRACEEVENT -#include -#endif #include +#include + #include "callchain.h" #include "counts.h" +#include "event.h" #include "evlist.h" #include "evsel.h" -#include "event.h" #include "expr.h" +#include "metricgroup.h" +#include "mmap.h" +#include "pmus.h" #include "print_binary.h" #include "record.h" #include "strbuf.h" #include "thread_map.h" #include "tp_pmu.h" #include "trace-event.h" -#include "metricgroup.h" -#include "mmap.h" #include "util/sample.h" -#include + +#ifdef HAVE_LIBTRACEEVENT +#include +#endif PyMODINIT_FUNC PyInit_perf(void); @@ -38,6 +45,22 @@ PyMODINIT_FUNC PyInit_perf(void); offsetof(struct pyrf_event, sample) + offsetof(struct perf_sample, member), \ 0, help } +#define CHECK_INITIALIZED(ptr, msg) \ + do { \ + if (!(ptr)) { \ + PyErr_SetString(PyExc_ValueError, msg " not initialized"); \ + return NULL; \ + } \ + } while (0) + +#define CHECK_INITIALIZED_INT(ptr, msg) \ + do { \ + if (!(ptr)) { \ + PyErr_SetString(PyExc_ValueError, msg " not initialized"); \ + return -1; \ + } \ + } while (0) + struct pyrf_event { PyObject_HEAD struct evsel *evsel; -- 2.54.0.1136.gdb2ca164c4-goog