Commit 90583af6 authored by Alexander Shishkin's avatar Alexander Shishkin Committed by Ingo Molnar

perf/x86/intel/pt: Clean up ToPA allocation path

Some of the allocation parameters are passed as function arguments,
while the CPU number for per-cpu allocation is passed via the buffer
object. There's no reason for this.

Pass the CPU as a function argument instead.
Signed-off-by: default avatarAlexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Link: http://lkml.kernel.org/r/20190821124727.73310-2-alexander.shishkin@linux.intel.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 8db5957b
...@@ -670,7 +670,7 @@ static bool topa_table_full(struct topa *topa) ...@@ -670,7 +670,7 @@ static bool topa_table_full(struct topa *topa)
* *
* Return: 0 on success or error code. * Return: 0 on success or error code.
*/ */
static int topa_insert_pages(struct pt_buffer *buf, gfp_t gfp) static int topa_insert_pages(struct pt_buffer *buf, int cpu, gfp_t gfp)
{ {
struct topa *topa = buf->last; struct topa *topa = buf->last;
int order = 0; int order = 0;
...@@ -681,7 +681,7 @@ static int topa_insert_pages(struct pt_buffer *buf, gfp_t gfp) ...@@ -681,7 +681,7 @@ static int topa_insert_pages(struct pt_buffer *buf, gfp_t gfp)
order = page_private(p); order = page_private(p);
if (topa_table_full(topa)) { if (topa_table_full(topa)) {
topa = topa_alloc(buf->cpu, gfp); topa = topa_alloc(cpu, gfp);
if (!topa) if (!topa)
return -ENOMEM; return -ENOMEM;
...@@ -1061,20 +1061,20 @@ static void pt_buffer_fini_topa(struct pt_buffer *buf) ...@@ -1061,20 +1061,20 @@ static void pt_buffer_fini_topa(struct pt_buffer *buf)
* @size: Total size of all regions within this ToPA. * @size: Total size of all regions within this ToPA.
* @gfp: Allocation flags. * @gfp: Allocation flags.
*/ */
static int pt_buffer_init_topa(struct pt_buffer *buf, unsigned long nr_pages, static int pt_buffer_init_topa(struct pt_buffer *buf, int cpu,
gfp_t gfp) unsigned long nr_pages, gfp_t gfp)
{ {
struct topa *topa; struct topa *topa;
int err; int err;
topa = topa_alloc(buf->cpu, gfp); topa = topa_alloc(cpu, gfp);
if (!topa) if (!topa)
return -ENOMEM; return -ENOMEM;
topa_insert_table(buf, topa); topa_insert_table(buf, topa);
while (buf->nr_pages < nr_pages) { while (buf->nr_pages < nr_pages) {
err = topa_insert_pages(buf, gfp); err = topa_insert_pages(buf, cpu, gfp);
if (err) { if (err) {
pt_buffer_fini_topa(buf); pt_buffer_fini_topa(buf);
return -ENOMEM; return -ENOMEM;
...@@ -1124,13 +1124,12 @@ pt_buffer_setup_aux(struct perf_event *event, void **pages, ...@@ -1124,13 +1124,12 @@ pt_buffer_setup_aux(struct perf_event *event, void **pages,
if (!buf) if (!buf)
return NULL; return NULL;
buf->cpu = cpu;
buf->snapshot = snapshot; buf->snapshot = snapshot;
buf->data_pages = pages; buf->data_pages = pages;
INIT_LIST_HEAD(&buf->tables); INIT_LIST_HEAD(&buf->tables);
ret = pt_buffer_init_topa(buf, nr_pages, GFP_KERNEL); ret = pt_buffer_init_topa(buf, cpu, nr_pages, GFP_KERNEL);
if (ret) { if (ret) {
kfree(buf); kfree(buf);
return NULL; return NULL;
......
...@@ -53,7 +53,6 @@ struct pt_pmu { ...@@ -53,7 +53,6 @@ struct pt_pmu {
/** /**
* struct pt_buffer - buffer configuration; one buffer per task_struct or * struct pt_buffer - buffer configuration; one buffer per task_struct or
* cpu, depending on perf event configuration * cpu, depending on perf event configuration
* @cpu: cpu for per-cpu allocation
* @tables: list of ToPA tables in this buffer * @tables: list of ToPA tables in this buffer
* @first: shorthand for first topa table * @first: shorthand for first topa table
* @last: shorthand for last topa table * @last: shorthand for last topa table
...@@ -71,7 +70,6 @@ struct pt_pmu { ...@@ -71,7 +70,6 @@ struct pt_pmu {
* @topa_index: table of topa entries indexed by page offset * @topa_index: table of topa entries indexed by page offset
*/ */
struct pt_buffer { struct pt_buffer {
int cpu;
struct list_head tables; struct list_head tables;
struct topa *first, *last, *cur; struct topa *first, *last, *cur;
unsigned int cur_idx; unsigned int cur_idx;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment