From nobody Sun Feb 8 07:51:09 2026 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.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 D2FF021ADAE for ; Mon, 21 Apr 2025 21:58:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745272709; cv=none; b=j7rAqK6M9SDX2rp2dhtigNQO0I9kghRHwpnNx457C15ipuHZZ8jKk6B4OjrRqlhqceFK9SKvvJnX3wTX/0c2TvYJ2gSlM8gKngwjtyJFUQCztZtty0c0zWqkD2UGmvhBkwK+dWzJT6N21xWAQJi/sJWKE2yfWkJIij/p2HJlzdg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745272709; c=relaxed/simple; bh=hS1o3wNFKx2vnmveTMX3eCOlsgwQBYcrENQJm+49WtU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=TKprhkaGlkqPrXPW3qSFYdoF0MrA7+AX8OiUpLjcDv7KsV5axysJPxIhYkb1wOffZl5dL9S2l+8GyUCI6gC+3yoZiAWR5uzmdoQhS0Z8qynvaRYEAPwXtqDAzD6xkq5of2EcQuZ1KkErIPpBp4gGSuWXwHMf5K06crAq0Zt8hVI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--yabinc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=IJJRQavT; arc=none smtp.client-ip=209.85.215.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--yabinc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="IJJRQavT" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-896c1845cb9so3995691a12.1 for ; Mon, 21 Apr 2025 14:58:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1745272707; x=1745877507; 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=ppEhzGTJ1895vVIrd/yxk1GkqcslORwV/iBHx5nBBw0=; b=IJJRQavTTaWcA4u71k/5b+Sv5G+y/pC/QpGYF59x38bP9aSfNSd6Sbxey6g6O7Drsk jHpwvJt9mVPB1ClRtUKfA7OTzX3a/cbsx1y4XJdSVRNVV6hh2wkXxCp4dV0Ve60tGGqu we2rFn7bOpKSCVDzd4CmPv3RHihMt+l0ZS/42xuL9kvd/+hc83BMpzreqtZA+UafCUaj Pru82iBeDE+0BGL6jMigR6B6MvQTs4FgZIMapo6j99n/864PEDcwGp5tt5M4yQPs0MRP wdx6SAACdbbb0WLoyGyoLkukfdGmv3V7cVOa4XvLlT65p7zunJwZI3kuYDn/5AKWCkCU ikVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745272707; x=1745877507; 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=ppEhzGTJ1895vVIrd/yxk1GkqcslORwV/iBHx5nBBw0=; b=sJN4FNJF/uEO8vdFTMtUkEIdxlZiqh+nCjJYFEDQoR2NsTCg0zEWqz1K4O+niTrmBL 0eA/gmwPc2fGYzz1/Crdf2tkS8fH1lL1Pb6/TR41dDyK+Z2il6CMWPgzLlaBpmN+zX1b XYCi1oBlVwMSy3DGL7/mLU2VQBbcey2zPcbVlewgUHozsIt6vaYaCDaOwqNvr0i2/GWA fiUuc5/b41ajLXoB4adE545JRQH++Mtee3yd7CJNLkDjhJ3Rp5WpMSEDZusQIObaEGpi CU+SFxT21Za9Houcn9lV8HO0B98p54Io9WVl2/1KOUtx867jKfsOvbRtYfpRAysP95sB MR3A== X-Forwarded-Encrypted: i=1; AJvYcCV/4csvFs8B2BJ+8GXet0m8RvdjXgNkzQkP/+ChxzdRCWyFR+qqAAkmk5ddf6ZUSji9ffP6Ql396trZEyw=@vger.kernel.org X-Gm-Message-State: AOJu0Yx3IRLS4bZoGCHrJyKPpmS3UydRgM8qbbSHJrSFsBM6z91ufKHL VPvc5+5OKZbSgJrZInFr6P3F4a1lqJ6fU0+Q4te6xZlHhoLT3VjMsYU2hN8tGMLxqgHLs/G5LJK z X-Google-Smtp-Source: AGHT+IEUjbbR7dOsTbPRk4tKnHc0lJD5Lp9uelQGasXEqv+mLjMNCHnAVBHz9WrQmMThkR2ExG51pC8JdTg= X-Received: from pjbnb11.prod.google.com ([2002:a17:90b:35cb:b0:2fc:201d:6026]) (user=yabinc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:5826:b0:2fe:93be:7c9d with SMTP id 98e67ed59e1d1-3087c2ca5a2mr18673508a91.7.1745272707042; Mon, 21 Apr 2025 14:58:27 -0700 (PDT) Date: Mon, 21 Apr 2025 14:58:17 -0700 In-Reply-To: <20250421215818.3800081-1-yabinc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250421215818.3800081-1-yabinc@google.com> X-Mailer: git-send-email 2.49.0.805.g082f7c87e0-goog Message-ID: <20250421215818.3800081-2-yabinc@google.com> Subject: [PATCH 1/2] perf: Allow non-contiguous AUX buffer pages via PMU capability From: Yabin Cui To: Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Jiri Olsa , Ian Rogers , Adrian Hunter , Liang Kan Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Yabin Cui Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For PMUs like ARM ETM/ETE, contiguous AUX buffers are unnecessary and increase memory fragmentation. This patch introduces PERF_PMU_CAP_AUX_NON_CONTIGUOUS_PAGES, allowing PMUs to request non-contiguous pages for their AUX buffers. Signed-off-by: Yabin Cui --- include/linux/perf_event.h | 1 + kernel/events/ring_buffer.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 0069ba6866a4..26ca35d6a9f2 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -301,6 +301,7 @@ struct perf_event_pmu_context; #define PERF_PMU_CAP_AUX_OUTPUT 0x0080 #define PERF_PMU_CAP_EXTENDED_HW_TYPE 0x0100 #define PERF_PMU_CAP_AUX_PAUSE 0x0200 +#define PERF_PMU_CAP_AUX_NON_CONTIGUOUS_PAGES 0x0400 =20 /** * pmu::scope diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c index 5130b119d0ae..87f42f4e8edc 100644 --- a/kernel/events/ring_buffer.c +++ b/kernel/events/ring_buffer.c @@ -710,6 +710,12 @@ int rb_alloc_aux(struct perf_buffer *rb, struct perf_e= vent *event, max_order =3D ilog2(nr_pages); watermark =3D 0; } + /* + * When the PMU doesn't prefer contiguous AUX buffer pages, favor + * low-order allocations to reduce memory fragmentation. + */ + if (event->pmu->capabilities & PERF_PMU_CAP_AUX_NON_CONTIGUOUS_PAGES) + max_order =3D 0; =20 /* * kcalloc_node() is unable to allocate buffer if the size is larger --=20 2.49.0.805.g082f7c87e0-goog From nobody Sun Feb 8 07:51:09 2026 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.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 B703E21B9F0 for ; Mon, 21 Apr 2025 21:58:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745272713; cv=none; b=NnRBzq+RfldJc9Mt1i2W3e3pQsAISyPvxKCJuHlWH33AlzmrF8fT5JXRB2ftynR/LzB2HkdOt99/nt3+SssHuJQEqR1UKhVRUt0OiAUgaAMbI9WWs87tNMQgPCap4tB2TAE5EyQQ50WHeaDAy21FTwUmhIGX6SdMmUpSRQ8HQ8o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745272713; c=relaxed/simple; bh=nMgu5glmK3F7QNbIg1QfyS3VbDIbwgjVcwChkm+gctQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=En4V6mjL3puhYifGLJtWI9YFCyt7Uo6gVrkkQB2tZYS9iv/2ht5FOB7vjMIs2zoFh1nO7JkcL+lmSd3QNyPE/VrlUSNUNhU898btVxF8xRW0yM5ehBGwA0CQlNOmJjyL5cK3+5RvEV2u1P+Eft4Wl4KXMiGyOIRLBvenk/3Q+gY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--yabinc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=M6uXK9wq; arc=none smtp.client-ip=209.85.215.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--yabinc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="M6uXK9wq" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-af98c8021b5so4461655a12.2 for ; Mon, 21 Apr 2025 14:58:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1745272711; x=1745877511; 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=EcpcuD7anqMhhZmchi1Jj15ct5OGdKXSmJ/UTKESh3w=; b=M6uXK9wqqNfx8zKsUY4mjCLKP5aUKmT/hawDTTKj3/diZcsikN1kXlUFxHLKNsrNr6 kk6rF5zWUZzDZIl7vCbSASDNtOu5xqmQWgRCQamKnLLyDEhaEbmLrc+lS785ZyFIHQ14 42mYE7AFg2VLJ+RuJiqzSnf0fgkujYp9Fve7WTs5OMmMyO41jjoi4IIJjbwGehaGMKpR tuFPfNoYZzeR+TTvO2ikWACA6yHYBhlxWvxeWhSA3Ft2nXIgBgg1rIG4SjJ4Z7tOjyz0 L5JJ3SiyYHQ5RxqRTJEWjjgBMdpb/7Pigh/x6XkMJ+3J5TI7x5Qvkvms3q9fErVF1S3H wYow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745272711; x=1745877511; 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=EcpcuD7anqMhhZmchi1Jj15ct5OGdKXSmJ/UTKESh3w=; b=VA4HPui9fr+Qs2ytUbMrHh2JCFypFhwnW45T8plmqAcn/sG9FeLBO5wf6wkyskl8wQ sY49P9e0RoS45Jvbuc34a21z2LXVssn0tu9K+kP0+8FlyGV8BZZKcV/gUOEFrg3LjPPV sNDq3M7o3bSYPjfz63C3Adgt//73f/RZBcKrCFTd10ADeo6wSgWc3Pl++lviBTFm1qQZ WtDnEkp2rT2i92Uh0KwDJWc6lef25JyqQSl9CxDKLqo55ZO+Ztejb0u7Owgrbxmxn1PN ndYQQfQyTxvVf05lKic2wO4RFg3f375AMH9cOQTiYxxLqW+HLJYV/p95MghgS6qfm0EB re1A== X-Forwarded-Encrypted: i=1; AJvYcCXfQmKeWweUYezTd6iUfFgHEIUs2GwM20MGZ/6Ql3l3E/70p0eJ1lEzGcNyVM7fvhxqProZmAGJyhldJgQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyGOZakXSdOnr9CZA6semjhpWUhO0zPaWAuydjnSxfQVW8hqalr nyOB1Gml9oOTi+Qtq3+5m3k6EDZ/NDrzAs8p0btXzKUi2dna/cK2JVM+ktQUj+qaj6TvfjiT+iS G X-Google-Smtp-Source: AGHT+IHXIs/Ogd7Xy1uFo5InHHYWM0p69glnRQCeqAR959OOyLerqEP0Pnb8KTz0VXSe5vCiUYWbcDZdU/s= X-Received: from plsr14.prod.google.com ([2002:a17:902:be0e:b0:223:8233:a96c]) (user=yabinc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:ce84:b0:224:24d3:6103 with SMTP id d9443c01a7336-22c5361988bmr204811505ad.35.1745272711001; Mon, 21 Apr 2025 14:58:31 -0700 (PDT) Date: Mon, 21 Apr 2025 14:58:18 -0700 In-Reply-To: <20250421215818.3800081-1-yabinc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250421215818.3800081-1-yabinc@google.com> X-Mailer: git-send-email 2.49.0.805.g082f7c87e0-goog Message-ID: <20250421215818.3800081-3-yabinc@google.com> Subject: [PATCH 2/2] coresight: etm-perf: Add AUX_NON_CONTIGUOUS_PAGES to cs_etm PMU From: Yabin Cui To: Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Jiri Olsa , Ian Rogers , Adrian Hunter , Liang Kan Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Yabin Cui Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The cs_etm PMU, regardless of the underlying trace sink (ETF, ETR or TRBE), doesn't require contiguous pages for its AUX buffer. This patch adds the PERF_PMU_CAP_AUX_NON_CONTIGUOUS_PAGES capability to the cs_etm PMU. This allows the kernel to allocate non-contiguous pages for the AUX buffer, reducing memory fragmentation when using cs_etm. Signed-off-by: Yabin Cui --- drivers/hwtracing/coresight/coresight-etm-perf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwt= racing/coresight/coresight-etm-perf.c index f4cccd68e625..c98646eca7f8 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -899,7 +899,8 @@ int __init etm_perf_init(void) int ret; =20 etm_pmu.capabilities =3D (PERF_PMU_CAP_EXCLUSIVE | - PERF_PMU_CAP_ITRACE); + PERF_PMU_CAP_ITRACE | + PERF_PMU_CAP_AUX_NON_CONTIGUOUS_PAGES); =20 etm_pmu.attr_groups =3D etm_pmu_attr_groups; etm_pmu.task_ctx_nr =3D perf_sw_context; --=20 2.49.0.805.g082f7c87e0-goog