* [PATCH] coresight: catu: Fix number of pages while using 64k pages
@ 2025-01-09 21:53 Ilkka Koskinen
2025-01-10 10:44 ` Suzuki K Poulose
2025-02-21 16:11 ` Suzuki K Poulose
0 siblings, 2 replies; 6+ messages in thread
From: Ilkka Koskinen @ 2025-01-09 21:53 UTC (permalink / raw)
To: Suzuki K Poulose, Mike Leach, James Clark, Alexander Shishkin
Cc: coresight, linux-arm-kernel, linux-kernel, Ilkka Koskinen
Trying to record a trace on kernel with 64k pages resulted in -ENOMEM.
This happens due to a bug in calculating the number of table pages, which
returns zero. Fix the issue by rounding up.
$ perf record --kcore -e cs_etm/@tmc_etr55,cycacc,branch_broadcast/k --per-thread taskset --cpu-list 1 dd if=/dev/zero of=/dev/null
failed to mmap with 12 (Cannot allocate memory)
Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
---
drivers/hwtracing/coresight/coresight-catu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c
index 275cc0d9f505..3378bb77e6b4 100644
--- a/drivers/hwtracing/coresight/coresight-catu.c
+++ b/drivers/hwtracing/coresight/coresight-catu.c
@@ -269,7 +269,7 @@ catu_init_sg_table(struct device *catu_dev, int node,
* Each table can address upto 1MB and we can have
* CATU_PAGES_PER_SYSPAGE tables in a system page.
*/
- nr_tpages = DIV_ROUND_UP(size, SZ_1M) / CATU_PAGES_PER_SYSPAGE;
+ nr_tpages = DIV_ROUND_UP(size, CATU_PAGES_PER_SYSPAGE * SZ_1M);
catu_table = tmc_alloc_sg_table(catu_dev, node, nr_tpages,
size >> PAGE_SHIFT, pages);
if (IS_ERR(catu_table))
--
2.47.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] coresight: catu: Fix number of pages while using 64k pages
2025-01-09 21:53 [PATCH] coresight: catu: Fix number of pages while using 64k pages Ilkka Koskinen
@ 2025-01-10 10:44 ` Suzuki K Poulose
2025-01-10 21:32 ` Ilkka Koskinen
2025-02-21 16:11 ` Suzuki K Poulose
1 sibling, 1 reply; 6+ messages in thread
From: Suzuki K Poulose @ 2025-01-10 10:44 UTC (permalink / raw)
To: Ilkka Koskinen, Mike Leach, James Clark, Alexander Shishkin
Cc: coresight, linux-arm-kernel, linux-kernel
On 09/01/2025 21:53, Ilkka Koskinen wrote:
> Trying to record a trace on kernel with 64k pages resulted in -ENOMEM.
> This happens due to a bug in calculating the number of table pages, which
> returns zero. Fix the issue by rounding up.
>
> $ perf record --kcore -e cs_etm/@tmc_etr55,cycacc,branch_broadcast/k --per-thread taskset --cpu-list 1 dd if=/dev/zero of=/dev/null
> failed to mmap with 12 (Cannot allocate memory)
>
Needs a Fixes tag.
Fixes : 8ed536b1e283 ("coresight: catu: Add support for scatter gather
tables")
> Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
> ---
> drivers/hwtracing/coresight/coresight-catu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c
> index 275cc0d9f505..3378bb77e6b4 100644
> --- a/drivers/hwtracing/coresight/coresight-catu.c
> +++ b/drivers/hwtracing/coresight/coresight-catu.c
> @@ -269,7 +269,7 @@ catu_init_sg_table(struct device *catu_dev, int node,
> * Each table can address upto 1MB and we can have
> * CATU_PAGES_PER_SYSPAGE tables in a system page.
> */
> - nr_tpages = DIV_ROUND_UP(size, SZ_1M) / CATU_PAGES_PER_SYSPAGE;
> + nr_tpages = DIV_ROUND_UP(size, CATU_PAGES_PER_SYSPAGE * SZ_1M);
> catu_table = tmc_alloc_sg_table(catu_dev, node, nr_tpages,
> size >> PAGE_SHIFT, pages);
> if (IS_ERR(catu_table))
Looks good to me, I will queue this later for v6.15.
Suzuki
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] coresight: catu: Fix number of pages while using 64k pages
2025-01-10 10:44 ` Suzuki K Poulose
@ 2025-01-10 21:32 ` Ilkka Koskinen
2025-01-13 16:49 ` Suzuki K Poulose
0 siblings, 1 reply; 6+ messages in thread
From: Ilkka Koskinen @ 2025-01-10 21:32 UTC (permalink / raw)
To: Suzuki K Poulose
Cc: Ilkka Koskinen, Mike Leach, James Clark, Alexander Shishkin,
coresight, linux-arm-kernel, linux-kernel
Hi Suzuko,
On Fri, 10 Jan 2025, Suzuki K Poulose wrote:
> On 09/01/2025 21:53, Ilkka Koskinen wrote:
>> Trying to record a trace on kernel with 64k pages resulted in -ENOMEM.
>> This happens due to a bug in calculating the number of table pages, which
>> returns zero. Fix the issue by rounding up.
>>
>> $ perf record --kcore -e cs_etm/@tmc_etr55,cycacc,branch_broadcast/k
>> --per-thread taskset --cpu-list 1 dd if=/dev/zero of=/dev/null
>> failed to mmap with 12 (Cannot allocate memory)
>>
>
> Needs a Fixes tag.
>
> Fixes : 8ed536b1e283 ("coresight: catu: Add support for scatter gather
> tables")
That's a good point
>
>> Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
>> ---
>> drivers/hwtracing/coresight/coresight-catu.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/hwtracing/coresight/coresight-catu.c
>> b/drivers/hwtracing/coresight/coresight-catu.c
>> index 275cc0d9f505..3378bb77e6b4 100644
>> --- a/drivers/hwtracing/coresight/coresight-catu.c
>> +++ b/drivers/hwtracing/coresight/coresight-catu.c
>> @@ -269,7 +269,7 @@ catu_init_sg_table(struct device *catu_dev, int node,
>> * Each table can address upto 1MB and we can have
>> * CATU_PAGES_PER_SYSPAGE tables in a system page.
>> */
>> - nr_tpages = DIV_ROUND_UP(size, SZ_1M) / CATU_PAGES_PER_SYSPAGE;
>> + nr_tpages = DIV_ROUND_UP(size, CATU_PAGES_PER_SYSPAGE * SZ_1M);
>> catu_table = tmc_alloc_sg_table(catu_dev, node, nr_tpages,
>> size >> PAGE_SHIFT, pages);
>> if (IS_ERR(catu_table))
>
> Looks good to me, I will queue this later for v6.15.
>
> Suzuki
Sounds great. Just to confirm, are you ok to add the fixes line or would
you prefer me to submit v2 with it?
Cheers, Ilkka
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] coresight: catu: Fix number of pages while using 64k pages
2025-01-10 21:32 ` Ilkka Koskinen
@ 2025-01-13 16:49 ` Suzuki K Poulose
2025-01-14 0:28 ` Ilkka Koskinen
0 siblings, 1 reply; 6+ messages in thread
From: Suzuki K Poulose @ 2025-01-13 16:49 UTC (permalink / raw)
To: Ilkka Koskinen
Cc: Mike Leach, James Clark, Alexander Shishkin, coresight,
linux-arm-kernel, linux-kernel
On 10/01/2025 21:32, Ilkka Koskinen wrote:
>
> Hi Suzuko,
>
> On Fri, 10 Jan 2025, Suzuki K Poulose wrote:
>> On 09/01/2025 21:53, Ilkka Koskinen wrote:
>>> Trying to record a trace on kernel with 64k pages resulted in -ENOMEM.
>>> This happens due to a bug in calculating the number of table pages,
>>> which
>>> returns zero. Fix the issue by rounding up.
>>>
>>> $ perf record --kcore -e cs_etm/@tmc_etr55,cycacc,branch_broadcast/k
>>> --per-thread taskset --cpu-list 1 dd if=/dev/zero of=/dev/null
>>> failed to mmap with 12 (Cannot allocate memory)
>>>
>>
>> Needs a Fixes tag.
>>
>> Fixes : 8ed536b1e283 ("coresight: catu: Add support for scatter gather
>> tables")
>
> That's a good point
>
>>
>>> Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
>>> ---
>>> drivers/hwtracing/coresight/coresight-catu.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/
>>> hwtracing/coresight/coresight-catu.c
>>> index 275cc0d9f505..3378bb77e6b4 100644
>>> --- a/drivers/hwtracing/coresight/coresight-catu.c
>>> +++ b/drivers/hwtracing/coresight/coresight-catu.c
>>> @@ -269,7 +269,7 @@ catu_init_sg_table(struct device *catu_dev, int
>>> node,
>>> * Each table can address upto 1MB and we can have
>>> * CATU_PAGES_PER_SYSPAGE tables in a system page.
>>> */
>>> - nr_tpages = DIV_ROUND_UP(size, SZ_1M) / CATU_PAGES_PER_SYSPAGE;
>>> + nr_tpages = DIV_ROUND_UP(size, CATU_PAGES_PER_SYSPAGE * SZ_1M);
>>> catu_table = tmc_alloc_sg_table(catu_dev, node, nr_tpages,
>>> size >> PAGE_SHIFT, pages);
>>> if (IS_ERR(catu_table))
>>
>> Looks good to me, I will queue this later for v6.15.
>>
>> Suzuki
>
> Sounds great. Just to confirm, are you ok to add the fixes line or would
> you prefer me to submit v2 with it?
No, not required. I have picked this up for v6.15, and will push it out
once v6.14-rc is out.
Suzuki
>
> Cheers, Ilkka
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] coresight: catu: Fix number of pages while using 64k pages
2025-01-13 16:49 ` Suzuki K Poulose
@ 2025-01-14 0:28 ` Ilkka Koskinen
0 siblings, 0 replies; 6+ messages in thread
From: Ilkka Koskinen @ 2025-01-14 0:28 UTC (permalink / raw)
To: Suzuki K Poulose
Cc: Ilkka Koskinen, Mike Leach, James Clark, Alexander Shishkin,
coresight, linux-arm-kernel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2154 bytes --]
On Mon, 13 Jan 2025, Suzuki K Poulose wrote:
> On 10/01/2025 21:32, Ilkka Koskinen wrote:
>>
>> Hi Suzuko,
>>
>> On Fri, 10 Jan 2025, Suzuki K Poulose wrote:
>>> On 09/01/2025 21:53, Ilkka Koskinen wrote:
>>>> Trying to record a trace on kernel with 64k pages resulted in -ENOMEM.
>>>> This happens due to a bug in calculating the number of table pages, which
>>>> returns zero. Fix the issue by rounding up.
>>>>
>>>> $ perf record --kcore -e cs_etm/@tmc_etr55,cycacc,branch_broadcast/k
>>>> --per-thread taskset --cpu-list 1 dd if=/dev/zero of=/dev/null
>>>> failed to mmap with 12 (Cannot allocate memory)
>>>>
>>>
>>> Needs a Fixes tag.
>>>
>>> Fixes : 8ed536b1e283 ("coresight: catu: Add support for scatter gather
>>> tables")
>>
>> That's a good point
>>
>>>
>>>> Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
>>>> ---
>>>> drivers/hwtracing/coresight/coresight-catu.c | 2 +-
>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/
>>>> hwtracing/coresight/coresight-catu.c
>>>> index 275cc0d9f505..3378bb77e6b4 100644
>>>> --- a/drivers/hwtracing/coresight/coresight-catu.c
>>>> +++ b/drivers/hwtracing/coresight/coresight-catu.c
>>>> @@ -269,7 +269,7 @@ catu_init_sg_table(struct device *catu_dev, int node,
>>>> * Each table can address upto 1MB and we can have
>>>> * CATU_PAGES_PER_SYSPAGE tables in a system page.
>>>> */
>>>> - nr_tpages = DIV_ROUND_UP(size, SZ_1M) / CATU_PAGES_PER_SYSPAGE;
>>>> + nr_tpages = DIV_ROUND_UP(size, CATU_PAGES_PER_SYSPAGE * SZ_1M);
>>>> catu_table = tmc_alloc_sg_table(catu_dev, node, nr_tpages,
>>>> size >> PAGE_SHIFT, pages);
>>>> if (IS_ERR(catu_table))
>>>
>>> Looks good to me, I will queue this later for v6.15.
>>>
>>> Suzuki
>>
>> Sounds great. Just to confirm, are you ok to add the fixes line or would
>> you prefer me to submit v2 with it?
>
> No, not required. I have picked this up for v6.15, and will push it out
> once v6.14-rc is out.
Perfect, thanks!
--Ilkka
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] coresight: catu: Fix number of pages while using 64k pages
2025-01-09 21:53 [PATCH] coresight: catu: Fix number of pages while using 64k pages Ilkka Koskinen
2025-01-10 10:44 ` Suzuki K Poulose
@ 2025-02-21 16:11 ` Suzuki K Poulose
1 sibling, 0 replies; 6+ messages in thread
From: Suzuki K Poulose @ 2025-02-21 16:11 UTC (permalink / raw)
To: Mike Leach, Alexander Shishkin, James Clark, Ilkka Koskinen
Cc: Suzuki K Poulose, linux-arm-kernel, linux-kernel, coresight
On Thu, 9 Jan 2025 21:53:48 +0000, Ilkka Koskinen wrote:
> Trying to record a trace on kernel with 64k pages resulted in -ENOMEM.
> This happens due to a bug in calculating the number of table pages, which
> returns zero. Fix the issue by rounding up.
>
> $ perf record --kcore -e cs_etm/@tmc_etr55,cycacc,branch_broadcast/k --per-thread taskset --cpu-list 1 dd if=/dev/zero of=/dev/null
> failed to mmap with 12 (Cannot allocate memory)
>
> [...]
Applied, thanks!
[1/1] coresight: catu: Fix number of pages while using 64k pages
https://git.kernel.org/coresight/c/0e14e062f5ff
Best regards,
--
Suzuki K Poulose <suzuki.poulose@arm.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-02-21 16:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-09 21:53 [PATCH] coresight: catu: Fix number of pages while using 64k pages Ilkka Koskinen
2025-01-10 10:44 ` Suzuki K Poulose
2025-01-10 21:32 ` Ilkka Koskinen
2025-01-13 16:49 ` Suzuki K Poulose
2025-01-14 0:28 ` Ilkka Koskinen
2025-02-21 16:11 ` Suzuki K Poulose
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).