From: Michael Ellerman <michael@ellerman.id.au>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: linuxppc-dev list <linuxppc-dev@ozlabs.org>,
Ingo Molnar <mingo@elte.hu>, Paul Mackerras <paulus@samba.org>,
David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH] powerpc/perfctr: Check oprofile_cpu_type for NULL before using it
Date: Thu, 06 Aug 2009 21:03:06 +1000 [thread overview]
Message-ID: <1249556586.4800.79.camel@concordia> (raw)
In-Reply-To: <1249531356.18245.73.camel@pasglop>
On Thu, 2009-08-06 at 14:02 +1000, Benjamin Herrenschmidt wrote:
> If the current CPU doesn't support performance counters,
> cur_cpu_spec->oprofile_cpu_type can be NULL. The current
> perfctr modules don't test for that case and would thus
> crash.
> + if (!cur_cpu_spec->oprofile_cpu_type ||
..
> + if (!cur_cpu_spec->oprofile_cpu_type ||
..
> + if (!cur_cpu_spec->oprofile_cpu_type ||
..
> + if (!cur_cpu_spec->oprofile_cpu_type ||
..
> + if (!cur_cpu_spec->oprofile_cpu_type ||
..
> + if (!cur_cpu_spec->oprofile_cpu_type ||
..
> + if (!cur_cpu_spec->oprofile_cpu_type ||
Typing it seven times didn't make you think "how about a helper?" :)
Perhaps:
diff --git a/arch/powerpc/include/asm/cputable.h b/arch/powerpc/include/asm/cput
index 80f315e..956cbc3 100644
--- a/arch/powerpc/include/asm/cputable.h
+++ b/arch/powerpc/include/asm/cputable.h
@@ -123,6 +123,11 @@ struct cpu_spec {
extern struct cpu_spec *cur_cpu_spec;
+static inline int oprofile_cpu_type_matches(const char *s)
+{
+ return s && (strcmp(cur_cpu_spec->oprofile_cpu_type, s) == 0);
+}
+
extern unsigned int __start___ftr_fixup, __stop___ftr_fixup;
extern struct cpu_spec *identify_cpu(unsigned long offset, unsigned int pvr);
And then callsites become:
static int init_mpc7450_pmu(void)
{
if (!oprofile_cpu_type_matches("ppc/7450"))
return -ENODEV;
cheers
next prev parent reply other threads:[~2009-08-06 11:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-06 4:02 [PATCH] powerpc/perfctr: Check oprofile_cpu_type for NULL before using it Benjamin Herrenschmidt
2009-08-06 6:41 ` David Woodhouse
2009-08-06 6:48 ` Benjamin Herrenschmidt
2009-08-06 11:03 ` Michael Ellerman [this message]
2009-08-06 12:26 ` Benjamin Herrenschmidt
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=1249556586.4800.79.camel@concordia \
--to=michael@ellerman.id.au \
--cc=benh@kernel.crashing.org \
--cc=dwmw2@infradead.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.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