public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Robert Richter <robert.richter@amd.com>
Cc: Ingo Molnar <mingo@elte.hu>,
	Stephane Eranian <eranian@google.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] perf, x86: Fix event scheduler for constraints with
Date: Wed, 14 Sep 2011 16:45:47 +0200	[thread overview]
Message-ID: <1316011547.5040.22.camel@twins> (raw)
In-Reply-To: <1315666143-7106-3-git-send-email-robert.richter@amd.com>

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.



      reply	other threads:[~2011-09-14 14:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-10 14:49 [PATCH 0/2] perf, x86: handle overlapping counters Robert Richter
2011-09-10 14:49 ` [PATCH 1/2] perf, x86: Implement event scheduler helper functions Robert Richter
2011-09-14 14:43   ` Peter Zijlstra
2011-09-10 14:49 ` [PATCH 2/2] perf, x86: Fix event scheduler for constraints with Robert Richter
2011-09-14 14:45   ` Peter Zijlstra [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1316011547.5040.22.camel@twins \
    --to=peterz@infradead.org \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=robert.richter@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox