Re: [PATCH V2 19/30] coresight: etb10: implementing the setup_aux() API

From: Alexander Shishkin
Date: Tue Oct 20 2015 - 07:40:38 EST


Mathieu Poirier <mathieu.poirier@xxxxxxxxxx> writes:

> /**
> + * struct cs_buffer - keep track of a recording session' specifics
> + * @cur: index of the current buffer
> + * @nr_pages: max number of pages granted to us
> + * @nr_bufs: number of clustered pages
> + * @offset: offset within the current buffer
> + * @size: how much space we have for this run
> + * @data_size: how much we collected in this run
> + * @head: head of the ring buffer
> + * @lost: other than zero if we had a HW buffer wrap around
> + * @snapshot: is this run in snapshot mode
> + * @addr: virtual address this buffer starts at
> + */
> +struct cs_buffers {
> + unsigned int cur;
> + unsigned int nr_pages;
> + unsigned int nr_bufs;

This one is not really used.

> + unsigned long offset;
> + unsigned long size;

And this one seems to be only set in one place.

> + local_t data_size;
> + local_t head;

And so is this one.

> + local_t lost;
> + bool snapshot;
> + void *addr[0];

And this one seems to be a copy of what perf's ring buffer gives us.

> +static void *etb_setup_aux(struct coresight_device *csdev, int cpu,
> + void **pages, int nr_pages, bool overwrite)
> +{
> + int node, pg;
> + struct cs_buffers *buf;
> +
> + if (cpu == -1)
> + cpu = smp_processor_id();
> + node = cpu_to_node(cpu);
> +
> + buf = kzalloc_node(offsetof(struct cs_buffers, addr[nr_pages]),
> + GFP_KERNEL, node);
> + if (!buf)
> + return NULL;
> +
> + buf->snapshot = overwrite;
> + buf->nr_pages = nr_pages;
> +
> + /* Record information about buffers */
> + for (pg = 0; pg < buf->nr_pages; pg++)
> + buf->addr[pg] = pages[pg];

Yes, buf::addr is a copy of @pages. You could save some space by just
saving @pages, it's going to be around until pmu::free_aux().

Regards,
--
Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/