From: Ingo Molnar <mingo@elte.hu>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
Fr??d??ric Weisbecker <fweisbec@gmail.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Tejun Heo <tj@kernel.org>,
Christoph Lameter <cl@linux-foundation.org>,
linux-next@vger.kernel.org, linux-kernel@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: linux-next: percpu tree build warning
Date: Wed, 25 Nov 2009 12:58:56 +0100 [thread overview]
Message-ID: <20091125115856.GA17856@elte.hu> (raw)
In-Reply-To: <200911252144.08686.rusty@rustcorp.com.au>
(Cc:-ed Linus and Andrew)
* Rusty Russell <rusty@rustcorp.com.au> wrote:
> On Wed, 25 Nov 2009 09:20:04 pm Ingo Molnar wrote:
> > If yes then that needs to be fixed in the percpu tree. per-cpu variables
> > used to have a __per_cpu prefix and that should be maintained - the two
> > namespaces are obviously separate on the logical space, so they should
> > never overlap in the implementational space either.
>
> No, we've been through this.
>
> sparse annotations replace the per_cpu prefix now per-cpu vars can be
> used withn other than per-cpu ops (ie. their address can be usefully
> taken).
>
> The prefix crutch predated sparse. And it was certainly never
> supposed to let people write confusing and crap code like this.
What's confusing and crap about the code below? I dont think it is
confusing, nor crap:
int arch_install_hw_breakpoint(struct perf_event *bp)
{
struct arch_hw_breakpoint *info = counter_arch_bp(bp);
unsigned long *dr7;
int i;
for (i = 0; i < HBP_NUM; i++) {
struct perf_event **slot = &__get_cpu_var(bp_per_reg[i]);
if (!*slot) {
*slot = bp;
break;
}
}
if (WARN_ONCE(i == HBP_NUM, "Can't find any breakpoint slot"))
return -EBUSY;
set_debugreg(info->address, i);
__get_cpu_var(cpu_debugreg[i]) = info->address;
dr7 = &__get_cpu_var(dr7);
*dr7 |= encode_dr7(i, info->len, info->type);
set_debugreg(*dr7, 7);
return 0;
}
This is basically equivalent to:
pid = task->pid;
the 'dr7' in the local scope is clearly different from the
__get_cpu_var(dr7) variable.
percpu variables are basically in a special struct. It's not like you
can _ever_ access 'dr7' the percpu variable like that - it _always_ has
to go via a proper percpu wrapper construct. So this change is
needlessly obtrusive.
Really, guys, while the workaround is easy (a rename), this might be
going a bit too far. I already think that the recently introduced
limitation to name local percpu symbols globally sucked - but i'm not
sure whether this new rule of not allowing such clear and clean looking
code is acceptable.
Percpu variables now pollute _both_ the global and the local namespace -
i dont think you can have it both ways.
Ingo
next prev parent reply other threads:[~2009-11-25 11:59 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-25 10:42 linux-next: percpu tree build warning Stephen Rothwell
2009-11-25 10:50 ` Ingo Molnar
2009-11-25 11:14 ` Rusty Russell
2009-11-25 11:58 ` Ingo Molnar [this message]
2009-11-25 12:39 ` Tejun Heo
2009-11-25 12:31 ` Tejun Heo
2009-11-25 13:40 ` Ingo Molnar
2009-11-25 15:12 ` Tejun Heo
2009-11-26 22:16 ` Rusty Russell
2009-11-27 5:41 ` Ingo Molnar
2009-11-27 5:57 ` Tejun Heo
2009-11-27 6:20 ` Ingo Molnar
2009-11-27 6:31 ` Tejun Heo
2009-11-27 6:32 ` Tejun Heo
2009-11-28 9:51 ` Rusty Russell
2009-11-29 6:40 ` Ingo Molnar
2009-11-30 0:31 ` Rusty Russell
2009-11-25 13:24 ` [PATCH] x86: rename global percpu symbol dr7 to cpu_dr7 Tejun Heo
-- strict thread matches above, loose matches on Subject: below --
2009-11-12 6:45 linux-next: percpu tree build warning Stephen Rothwell
2009-11-12 15:16 ` Christoph Lameter
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=20091125115856.GA17856@elte.hu \
--to=mingo@elte.hu \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=cl@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=sfr@canb.auug.org.au \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).