From nobody Mon Feb 9 15:26:07 2026 Received: from canpmsgout03.his.huawei.com (canpmsgout03.his.huawei.com [113.46.200.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD7083BBA05 for ; Wed, 21 Jan 2026 10:15:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768990551; cv=none; b=PEEbJPJ6vnhxj3YsGycJx2PZpCRNyHtDzFDP//m1IK/sQB1uO0wJJNvAd/6qZr+ZeduUJLxze8Sjhp8PXnWfHjmpc4GvyX5XkFcJidQMHSzT3Yk01kH2kWlPwo/fs3w2JCC6r+R9N9AF+UleDCZ7U3OL9sCk+VXaopmqQBz10Ac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768990551; c=relaxed/simple; bh=xERB3rGqRdPSVmkJ9/4cinH0FLt0DO1fhvMdftI4MnA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WtRJ2yibXHJ+Yc5tkonAwMMdaskAXl+wvu/3oWtoFmyXMRg4nmnRlEeciqCi5Js+62sDb7zL3P3q0IOYsW6bu/a2HTUuYnDCm+laeTDwiTPCgS4EvDHMz8/wIhdfkUllMR9NJE9fPxkkJjtobRm4Ti6cTIXR4yGxgAFEzPv8ir4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=QmKS4GXs; arc=none smtp.client-ip=113.46.200.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="QmKS4GXs" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=I3U1Z5r/oJQJ8Swr+0RW6Y6ntVi3pLUWh5uPNAHTjzs=; b=QmKS4GXsphZP8JN1pxgaNj7sGHSyaf1/pHLzvpLk6E6Rm7wrnZ1JAkotE9Lg72yLmPaqQvuC9 y1HR9ctRMIkL6HMc5X4NPPRm8Ms8aMKsCzFNzroHT1HjLNZ6A0lBAa1jBRSHbsLYXsYPEcKI+KW f6EVvlxuE3dtwHa4Y9vhT6Y= Received: from mail.maildlp.com (unknown [172.19.162.197]) by canpmsgout03.his.huawei.com (SkyGuard) with ESMTPS id 4dx0Nc1KF3zpStK; Wed, 21 Jan 2026 18:12:00 +0800 (CST) Received: from dggemv705-chm.china.huawei.com (unknown [10.3.19.32]) by mail.maildlp.com (Postfix) with ESMTPS id 224DD40363; Wed, 21 Jan 2026 18:15:46 +0800 (CST) Received: from kwepemn100008.china.huawei.com (7.202.194.111) by dggemv705-chm.china.huawei.com (10.3.19.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 21 Jan 2026 18:15:45 +0800 Received: from localhost.huawei.com (10.90.31.46) by kwepemn100008.china.huawei.com (7.202.194.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.36; Wed, 21 Jan 2026 18:15:45 +0800 From: Yushan Wang To: , , , , , CC: , , , , , , Subject: [PATCH v5 3/3] coresight: tmc: Decouple the perf buffer allocation from sysfs mode Date: Wed, 21 Jan 2026 18:15:43 +0800 Message-ID: <20260121101543.2017014-4-wangyushan12@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260121101543.2017014-1-wangyushan12@huawei.com> References: <20260121101543.2017014-1-wangyushan12@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To kwepemn100008.china.huawei.com (7.202.194.111) Content-Type: text/plain; charset="utf-8" From: Yicong Yang Currently the perf buffer allocation follows the below logic: - if the required AUX buffer size if larger, allocate the buffer with the required size - otherwise allocate the size reference to the sysfs buffer size This is not useful as we only collect to one AUX data, so just try to allocate the buffer match the AUX buffer size. Suggested-by: Suzuki K Poulose Link: https://lore.kernel.org/linux-arm-kernel/df8967cd-2157-46a2-97d9-a1ae= a883cf63@arm.com/ Signed-off-by: Yicong Yang Signed-off-by: Junhao He --- .../hwtracing/coresight/coresight-tmc-etr.c | 30 ++++++------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtr= acing/coresight/coresight-tmc-etr.c index fc0a946053dd..cee82e52c4ea 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -1367,9 +1367,7 @@ EXPORT_SYMBOL_GPL(tmc_etr_get_buffer); =20 /* * alloc_etr_buf: Allocate ETR buffer for use by perf. - * The size of the hardware buffer is dependent on the size configured - * via sysfs and the perf ring buffer size. We prefer to allocate the - * largest possible size, scaling down the size by half until it + * Allocate the largest possible size, scaling down the size by half until= it * reaches a minimum limit (1M), beyond which we give up. */ static struct etr_buf * @@ -1378,36 +1376,26 @@ alloc_etr_buf(struct tmc_drvdata *drvdata, struct p= erf_event *event, { int node; struct etr_buf *etr_buf; - unsigned long size; + ssize_t size; =20 node =3D (event->cpu =3D=3D -1) ? NUMA_NO_NODE : cpu_to_node(event->cpu); - /* - * Try to match the perf ring buffer size if it is larger - * than the size requested via sysfs. - */ - if ((nr_pages << PAGE_SHIFT) > drvdata->size) { - etr_buf =3D tmc_alloc_etr_buf(drvdata, ((ssize_t)nr_pages << PAGE_SHIFT), - 0, node, NULL); - if (!IS_ERR(etr_buf)) - goto done; - } + + /* Use the minimum limit if the required size is smaller */ + size =3D nr_pages << PAGE_SHIFT; + size =3D max_t(ssize_t, size, TMC_ETR_PERF_MIN_BUF_SIZE); =20 /* - * Else switch to configured size for this ETR - * and scale down until we hit the minimum limit. + * Try to allocate the required size for this ETR, if failed scale + * down until we hit the minimum limit. */ - size =3D drvdata->size; do { etr_buf =3D tmc_alloc_etr_buf(drvdata, size, 0, node, NULL); if (!IS_ERR(etr_buf)) - goto done; + return etr_buf; size /=3D 2; } while (size >=3D TMC_ETR_PERF_MIN_BUF_SIZE); =20 return ERR_PTR(-ENOMEM); - -done: - return etr_buf; } =20 static struct etr_buf * --=20 2.33.0