lkml.org 
[lkml]   [2011]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/2] perf, x86: Fix event scheduler for constraints with
From
Date
On Sat, 2011-09-10 at 16:49 +0200, Robert Richter wrote:
> struct perf_sched {
> int max_weight;
> int max_events;
> struct event_constraint **constraints;
> struct sched_state state;
> +
> + int saved_states;

This creates an ugly hole in the structure

> + struct sched_state saved[SCHED_STATES_MAX];
> };
>
> static void perf_sched_init(struct perf_sched *sched, struct event_constraint **c,
> @@ -817,7 +849,30 @@ static void perf_sched_init(struct perf_sched *sched, struct event_constraint **
> sched->state.unassigned = num;
> }
>
> -static struct sched_state *perf_sched_find_counter(struct perf_sched *sched)
> +static void perf_sched_save_state(struct perf_sched *sched)
> +{
> + if (sched->saved_states >= SCHED_STATES_MAX)
> + return;
> +
> + sched->saved[sched->saved_states] = sched->state;
> + sched->saved_states++;
> +}

Shouldn't we fail the save_state when we're out of states? the restore
code doesn't check to see if --saved_states is within range and simply
derefs the array.




\
 
 \ /
  Last update: 2011-09-14 16:47    [W:0.063 / U:0.264 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site