From: Andrew Morton <akpm@linux-foundation.org>
To: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
Ingo Molnar <mingo@elte.hu>,
linux-kernel@vger.kernel.org
Subject: Re: kprobes: get rid of distinct type warning
Date: Wed, 30 Dec 2009 13:29:45 -0800 [thread overview]
Message-ID: <20091230132945.f32f49fd.akpm@linux-foundation.org> (raw)
In-Reply-To: <20091221120224.GA4471@osiris.boeblingen.de.ibm.com>
On Mon, 21 Dec 2009 13:02:24 +0100
Heiko Carstens <heiko.carstens@de.ibm.com> wrote:
> Of course the patch wouldn't help for CONFIG_PREEMPT and !CONFIG_SMP since
> we would have a comparison of a signed and and unsigned value again *sigh*.
We should fix that, shouldn't we? Rather than working around it at one
caller site.
: #if NR_CPUS > 1
: #define num_online_cpus() cpumask_weight(cpu_online_mask)
: #define num_possible_cpus() cpumask_weight(cpu_possible_mask)
: #define num_present_cpus() cpumask_weight(cpu_present_mask)
: #define num_active_cpus() cpumask_weight(cpu_active_mask)
: #define cpu_online(cpu) cpumask_test_cpu((cpu), cpu_online_mask)
: #define cpu_possible(cpu) cpumask_test_cpu((cpu), cpu_possible_mask)
: #define cpu_present(cpu) cpumask_test_cpu((cpu), cpu_present_mask)
: #define cpu_active(cpu) cpumask_test_cpu((cpu), cpu_active_mask)
: #else
: #define num_online_cpus() 1
: #define num_possible_cpus() 1
: #define num_present_cpus() 1
: #define num_active_cpus() 1
: #define cpu_online(cpu) ((cpu) == 0)
: #define cpu_possible(cpu) ((cpu) == 0)
: #define cpu_present(cpu) ((cpu) == 0)
: #define cpu_active(cpu) ((cpu) == 0)
: #endif
The num_*() "functions" return unsigned on SMP and int on UP. This is
wrong.
The cpu_*() "functions" got lucky and return int in both cases.
Personally I think it's neatest if a quantity which can never be
negative is held in an unsigned type. Than includes anything starting
with "num". But for expediency's sake we could live with making these
things consistently return "int".
Alas, changing those four num_*() "functions" to return int on SMP is a
pretty wide-reaching change and will probably expose warts.
next prev parent reply other threads:[~2009-12-30 21:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-21 10:15 kprobes: get rid of distinct type warning Heiko Carstens
2009-12-21 11:17 ` Ananth N Mavinakayanahalli
2009-12-21 12:02 ` Heiko Carstens
2009-12-28 10:08 ` [tip:perf/urgent] kprobes: Fix " tip-bot for Heiko Carstens
2009-12-30 21:29 ` Andrew Morton [this message]
2010-01-04 15:57 ` kprobes: get rid of " Heiko Carstens
2010-01-04 22:45 ` Rusty Russell
2010-01-05 8:40 ` Heiko Carstens
2010-01-09 0:18 ` Andrew Morton
2010-01-09 17:45 ` Heiko Carstens
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=20091230132945.f32f49fd.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=ananth@in.ibm.com \
--cc=heiko.carstens@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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