The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Lin Ming <ming.m.lin@intel.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@elte.hu>,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: [rfc] x86,perf: P4 PMU -- use hash for p4_get_escr_idx
Date: Mon, 10 May 2010 17:10:27 -0400	[thread overview]
Message-ID: <1273525827.22438.4489.camel@gandalf.stny.rr.com> (raw)
In-Reply-To: <20100510152708.GS5104@lenovo>

On Mon, 2010-05-10 at 19:27 +0400, Cyrill Gorcunov wrote:

>  static int p4_get_escr_idx(unsigned int addr)
>  {
> -	unsigned int i;
> +	unsigned int idx = P4_ESCR_MSR_IDX(addr);
>  
> -	for (i = 0; i < ARRAY_SIZE(p4_escr_map); i++) {
> -		if (addr == p4_escr_map[i])
> -			return i;
> -	}
> +	BUG_ON(idx >= P4_ESCR_MSR_TABLE_SIZE);
> +	BUG_ON(!p4_escr_table[idx]);

Is there any softer way to handle this. IOW, must it be a BUG_ON()? or
can you add a WARN_ON() and pass back something that will cause it to
fail a bit nicer.

A BUG_ON() may panic the box and if you are in X on a laptop, all you
see is that your box locked up hard. If this is a WARN_ON() and you can
prevent further damage to the computer (no file corruption or anything)
then the user may notice, "Oh, my dmesg has this nasty error here", and
report something useful.

You could do:

	if (WARN_ON(idx >= P4_ESCR_MSR_TABLE_SIZE))
		return -1;

or whatever.

Thanks,

-- Steve

>  
> -	return -1;
> +	return idx;
>  }
>  


  reply	other threads:[~2010-05-10 21:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-10 15:27 [rfc] x86,perf: P4 PMU -- use hash for p4_get_escr_idx Cyrill Gorcunov
2010-05-10 21:10 ` Steven Rostedt [this message]
2010-05-10 21:57   ` Cyrill Gorcunov
2010-05-11  6:21 ` Lin Ming
2010-05-11  6:30   ` Ingo Molnar
2010-05-11  6:41     ` Ingo Molnar
2010-05-11  6:47       ` Lin Ming
2010-05-11  7:03         ` Ingo Molnar
2010-05-11  7:06         ` Lin Ming
2010-05-11  7:09           ` Cyrill Gorcunov
2010-05-11 15:37           ` Cyrill Gorcunov

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=1273525827.22438.4489.camel@gandalf.stny.rr.com \
    --to=rostedt@goodmis.org \
    --cc=fweisbec@gmail.com \
    --cc=gorcunov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.m.lin@intel.com \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    /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