ANDROID: ring-buffer: Fix rb_page_desc() fast-path

The fast-path for the proper CPU in rb_page_desc() was wrong due to a
missing cast. In practice, we only have trace descriptors with the same
number of pages per CPU, but nonetheless the structure doesn't really
enforce it. Proper support would need a MAGIC in the header of each CPU
as well as a complete struct size in the global header. We do not
anticipate any gain here from this optimization in a first place, so
let's get rid of it entirely.

Bug: 357781595
Fixes: 162c11d25b ("FROMLIST: ring-buffer: Introducing ring-buffer writer")
Change-Id: Idf226cc96e4d1cf5ed959f87c4612f8a24d68cd0
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
This commit is contained in:
Vincent Donnefort
2025-02-03 17:03:01 +00:00
parent 1ded8bfbc0
commit ec9e469a80

View File

@@ -2105,7 +2105,6 @@ static struct rb_page_desc *rb_page_desc(struct trace_page_desc *trace_pdesc,
int cpu)
{
struct rb_page_desc *pdesc;
size_t len;
int i;
if (!trace_pdesc)
@@ -2114,15 +2113,6 @@ static struct rb_page_desc *rb_page_desc(struct trace_page_desc *trace_pdesc,
if (cpu >= trace_pdesc->nr_cpus)
return NULL;
pdesc = __first_rb_page_desc(trace_pdesc);
len = struct_size(pdesc, page_va, pdesc->nr_page_va);
pdesc += len * cpu;
if (pdesc->cpu == cpu)
return pdesc;
/* Missing CPUs, need to linear search */
for_each_rb_page_desc(pdesc, i, trace_pdesc) {
if (pdesc->cpu == cpu)
return pdesc;