From nobody Sun Dec 14 19:14:05 2025 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (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 D71FF233145 for ; Fri, 18 Apr 2025 06:04:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.35 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744956295; cv=none; b=o8oo2JiJ4h+uSBZateo+PX4TEYJqW71tnu2oKEIkFKKyBqierip/s2hSjNQVlzlF07hI6da/3VMIFcitrCIqdaymrGtxiqRMgAtw4ECvO1ymFKwdsPMHopAz7rvEXmakxfv1eXxrGjWmexGtSU8W10nUIRYceGgo/xRKkIbQLaA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744956295; c=relaxed/simple; bh=TewKLJ0Nr8qIwc2SY/X3J5h3C4hj0NdcKTMbOBGE3Ls=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=R291KsW2Vzbv0KplZlLikicvopu3Gq35pzY7sCOtF0ZwJesG48AKSrq4Tx4R4+2EjEXqpWKVEXHVpiyV6SumJpfMvvu+ONuQle9Wxf0sBgpObpr9szOZFn4LcLBZnBmZF+DV2EhzdXzI1EDsbApamFIfD+7uGXRa/zIO0mqo0dE= 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; arc=none smtp.client-ip=45.249.212.35 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 Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Zf43N69tHzsSp7; Fri, 18 Apr 2025 14:04:32 +0800 (CST) Received: from dggemv705-chm.china.huawei.com (unknown [10.3.19.32]) by mail.maildlp.com (Postfix) with ESMTPS id 784571402CA; Fri, 18 Apr 2025 14:04:43 +0800 (CST) Received: from kwepemn500004.china.huawei.com (7.202.194.145) 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; Fri, 18 Apr 2025 14:04:43 +0800 Received: from localhost.localdomain (10.90.30.45) by kwepemn500004.china.huawei.com (7.202.194.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 18 Apr 2025 14:04:42 +0800 From: Junhao He To: , , , , CC: , , , , , , Subject: [PATCH 4/4] coresight: tmc-etr: Decouple the perf buffer allocation from sysfs mode Date: Fri, 18 Apr 2025 13:58:20 +0800 Message-ID: <20250418055820.3689408-5-hejunhao3@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20250418055820.3689408-1-hejunhao3@huawei.com> References: <20250418055820.3689408-1-hejunhao3@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: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemn500004.china.huawei.com (7.202.194.145) 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 | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtr= acing/coresight/coresight-tmc-etr.c index 3d94d64cacaa..26b56cb91bad 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -1254,9 +1254,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 * @@ -1268,33 +1266,24 @@ alloc_etr_buf(struct tmc_drvdata *drvdata, struct p= erf_event *event, unsigned long 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 (unsigned long)nr_pages << PAGE_SHIFT; + if (size < TMC_ETR_PERF_MIN_BUF_SIZE) + size =3D 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