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 CC3C73C76BB for ; Mon, 18 May 2026 06:29:10 +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=1779085754; cv=none; b=CYKWpMDLUv4jY2hh2/9idPAMd+fvT1UMd1dSSOQ7tt3VSncb4UVMKI0Hm2w2d+0mKSkytiXt1ctl+wuklay4xIdfr6I7flx7yMeYAg979FFbTdi5PWQ5+G89zC9vrl+UkWpwcIuFnk+2jtY6+65r0zA1j7ikmmEchcbWBj1kSDI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779085754; c=relaxed/simple; bh=ZMJcLPonl5Fjt6Kl9dyStnZ+/a9xfPxAKm8hoUribt4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=k8rBKOvTM74T6l3SQfMqDqgVNgzdVysmv5NvOYmTfo8Rtn/jGSGsFNV3rkFvUWuH4GVaKKyo8pGSvMzbBPwRy7zB8xUhNFouoOMgMb/KxGzxfJ4rrF518dxmU29Gkc0/uYLxXKNXb+cj1H3Z679qA0D05jTB1nzK4WuGt4uwNiY= 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=fq9xu8t7; 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="fq9xu8t7" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2ee1da7a13fso2373309eec.1 for ; Sun, 17 May 2026 23:29:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779085748; x=1779690548; 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=QAUuUriJFfl0tWxGycaguzlNA3FAkEjcZ0ZaxCBBpfI=; b=fq9xu8t7xn3qKlI7rPvYeGft1enkkBVLvBNS6bknkV5QWW9vjb9gQhM+L+rhZHoWuY EiWhbOKKO2k3GF6UL0AhLtiHKYc1njWjIxWWVmV4y0Mr44G+ztm3Kd/wJMr6K6KelQCB d19Yn6Un5Yg0IS1t8oKTV5WTdzCV4czPIQKrJQ+EEagE6YBx53wzKCQQ8nlfANr0WekY Gg3wwzN8kKL5y57HaMb2c+M9t0+z4sxr9jwwZ8LHlwmhtfoFz90QdZGLxuzR7jnnYLbN IvZKyYs/05b3sj4Jxh3sJ+zpgKG54Q37CX5ccpWelEL1OJmFSZsFERsxpDs3Y8x/CZBM Noog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779085748; x=1779690548; 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=QAUuUriJFfl0tWxGycaguzlNA3FAkEjcZ0ZaxCBBpfI=; b=Uy1neGAg+3B/z9yIS1LRr8DrbFo4JLa7FM+W9SFArVoNPTDnTu+qsbyHylBR3GaROm lXvA42M4IhVPDy590e1K9Eli4ekSN4RqdIcXtMThIvwC+e05xrnx2rA6cShi1k08C8TN 7dBOMS3EOoPZEs0Wgfhe8rAhUI+yXQUy4iGGQpTN9LK0qxprOcI43xlTKyfNVT/n6amH 0Feyj9hGafddNup4t3bGOR8uCGDuuEo66HMKR1akONK0Avo1wDw3hl+1MNy19oU6nMvS jPSsWjtYdM9i28hdE3Miym+3Ymm5HAvs1Y1ZdmMVcLyKRV9qA96mgkQFqmKKiJMS5mGs hVhQ== X-Forwarded-Encrypted: i=1; AFNElJ9taWYRyQnAAF2qEgFNGkSV76jJPkCdUT7kWKd5k/4GXQhH41FdEF/gicOb2ZguI0SR2GujOhH3mcdlpGY=@vger.kernel.org X-Gm-Message-State: AOJu0YzmhFP1FyVXMeeAvYHKU/bYZoUMCvouS//3oEDS5xSE9M2S55Oa 9v+IkneFAS/l/gpPh6WZrCjx5g1qMI4BQpaIJ+QUPrdVKhQTo8WNE4JsKD7VvDa0Pp/43aCL+cK zMouhdej9Fw== X-Received: from dygg14.prod.google.com ([2002:a05:693c:80ce:b0:2ee:3abb:9c9]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:478f:b0:2e1:e3e6:2909 with SMTP id 5a478bee46e88-30398167fccmr5374992eec.9.1779085747893; Sun, 17 May 2026 23:29:07 -0700 (PDT) Date: Sun, 17 May 2026 23:29:02 -0700 In-Reply-To: <20260518043140.2522141-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: <20260518043140.2522141-1-irogers@google.com> X-Mailer: git-send-email 2.54.0.563.g4f69b47b94-goog Message-ID: <20260518062904.2591616-1-irogers@google.com> Subject: [PATCH v8 0/2] perf tests: Add uncore and x86 topdown event sorting tests From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 9erthalion6@gmail.com, adrian.hunter@intel.com, alexander.shishkin@linux.intel.com, collin.funk1@gmail.com, german.gomez@arm.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, zide.chen@intel.com Content-Type: text/plain; charset="UTF-8" A patch thread changing event sorting highlighted a lack of testing for the more complicated uncore and x86 perf metric event sorting: https://lore.kernel.org/linux-perf-users/CAP-5=fWRgDo7UnJAD4C--d=mVPRhOEWZVyU7nVM1YEp3jncAgg@mail.gmail.com/ v8: Simplify event_cb in the uncore event sorting test by removing the unreachable dead-code else block (reported by Sashiko). v7: - Prevent double-free of m.event1 and dangling pointer access upon PMU scanning loop termination or early continue in the uncore event sorting test by utilizing standard perf zfree() helpers (reported by Sashiko). - Document Intel Hybrid CPU architectural invariants in the x86 topdown test to clarify why instructions correctly leads a group of 2 on E-cores (cpu_atom) where slots is unsupported and filtered out (reported by Sashiko). v6: - Ensure robust error initialization and resource cleanup in both uncore and topdown tests by initializing evlist to NULL and parse_events_error at function entry, preventing uninitialized stack access or resource leaks on early return paths (reported by Sashiko). - Prevent double evaluation and duplicate debug logging upon test assertion failure in the x86 topdown test by caching test_sort() return values into local variables (reported by Sashiko). v5: - Strengthen uncore event sorting test assertions to require at least 4 total events (>= 2 groups of 2 events) instead of > 0 events, guaranteeing that multi-PMU wildcard expansion is genuinely exercised across multiple sibling PMUs (reported by Sashiko). - Fix memory leaks on assertion failure across both uncore and topdown test suites by replacing standard TEST_ASSERT macros with local CHECK macros that correctly branch to out_err cleanup handlers (reported by Sashiko). - Fix test_sort() in the x86 topdown test to correctly return TEST_FAIL (-1) instead of parse_events() internal error codes (e.g., -EINVAL) when event parsing fails (reported by Namhyung). v4: Fix malformed event group string formatting in the uncore event sorting test when running on AMD systems (where sysfs event aliases lack JSON descriptions - reported by Namhyung). Added a helper to strip redundant PMU prefixes and trailing slashes to ensure parse_events() receives valid syntax across all architectures. v3: Address sashiko nits on using evsel__name and ensuring slots is injected. https://lore.kernel.org/linux-perf-users/20260331185419.4085479-1-irogers@google.com/ v2: Address indentation and other nits from Namhyung. Add Zide Chen's tested-by tags. https://lore.kernel.org/lkml/20260331165207.4016392-1-irogers@google.com/ v1: https://lore.kernel.org/lkml/20260325183045.1229502-1-irogers@google.com/ Ian Rogers (2): perf tests: Add test for uncore event sorting perf arch x86 tests: Add test for topdown event sorting tools/perf/arch/x86/tests/topdown.c | 166 +++++++++++++++++++++- tools/perf/tests/Build | 1 + tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/tests.h | 1 + tools/perf/tests/uncore-event-sorting.c | 176 ++++++++++++++++++++++++ 5 files changed, 344 insertions(+), 1 deletion(-) create mode 100644 tools/perf/tests/uncore-event-sorting.c -- 2.54.0.563.g4f69b47b94-goog