Skip to content

Commit

Permalink
x86, bts: use atomic memory allocation
Browse files Browse the repository at this point in the history
Ds_request_bts() needs to allocate memory. It uses GFP_KERNEL.

Hw-branch-tracer calls ds_request_bts() within on_each_cpu().

Use atomic memory allocation to allow it to be used in that context.

Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
LKML-Reference: <20090318192700.A6038@sedona.ch.intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Markus Metzger authored and Ingo Molnar committed Mar 19, 2009
1 parent 79258a3 commit c78a395
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions arch/x86/kernel/ds.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,13 @@ static inline struct ds_context *ds_get_context(struct task_struct *task)
struct ds_context *new_context = NULL;
unsigned long irq;

/* Chances are small that we already have a context. */
new_context = kzalloc(sizeof(*new_context), GFP_KERNEL);
/*
* Chances are small that we already have a context.
*
* Contexts for per-cpu tracing are allocated using
* smp_call_function(). We must not sleep.
*/
new_context = kzalloc(sizeof(*new_context), GFP_ATOMIC);
if (!new_context)
return NULL;

Expand Down Expand Up @@ -662,8 +667,12 @@ struct bts_tracer *ds_request_bts(struct task_struct *task,
if (ovfl)
goto out;

/*
* Per-cpu tracing is typically requested using smp_call_function().
* We must not sleep.
*/
error = -ENOMEM;
tracer = kzalloc(sizeof(*tracer), GFP_KERNEL);
tracer = kzalloc(sizeof(*tracer), GFP_ATOMIC);
if (!tracer)
goto out;
tracer->ovfl = ovfl;
Expand Down Expand Up @@ -722,8 +731,12 @@ struct pebs_tracer *ds_request_pebs(struct task_struct *task,
if (ovfl)
goto out;

/*
* Per-cpu tracing is typically requested using smp_call_function().
* We must not sleep.
*/
error = -ENOMEM;
tracer = kzalloc(sizeof(*tracer), GFP_KERNEL);
tracer = kzalloc(sizeof(*tracer), GFP_ATOMIC);
if (!tracer)
goto out;
tracer->ovfl = ovfl;
Expand Down

0 comments on commit c78a395

Please sign in to comment.