Messages in this thread | | | Subject | Re: [PATCH 2/2] perf, x86: Fix event scheduler for constraints with | From | Peter Zijlstra <> | Date | Wed, 14 Sep 2011 16:45:47 +0200 |
| |
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.
| |