From: Rusty Russell <rusty@rustcorp.com.au>
To: davidm@hpl.hp.com
Cc: linux-kernel@vger.kernel.org, torvalds@transmeta.com, ak@suse.de
Subject: Re: per_cpu fixes
Date: Thu, 10 Jul 2003 11:41:07 +1000 [thread overview]
Message-ID: <20030710015208.1E7A22C44B@lists.samba.org> (raw)
In-Reply-To: Your message of "Wed, 09 Jul 2003 14:20:29 MST." <200307092120.h69LKTBH002759@napali.hpl.hp.com>
In message <200307092120.h69LKTBH002759@napali.hpl.hp.com> you write:
> Rusty,
>
> Care needs to be taken when taking the address of a CPU-local
> variable, because otherwise things may break when comparing addresses
> on a platform which uses virtual remapping to implement such
> variables. In particular, it's almost always unsafe to use the
> address of a per-CPU variable which contains a "struct list", because
> the list-manipulation routines use the list-head address to detect the
> end of the list etc.
The horror. Such rules are entirely too much problem to push on the
poor programmer 8(
When I implemented this, I imagined archs putting their per-cpu offset
inside a register, so they could get to their vars in one instruction,
but not the IA64 remapping thing. We are now suffering because of my
limited imagination (which David has commented on before 8).
A compromise is possible. I believe that the address of a per-cpu
variable *must* be the same everywhere, but we can provide get & set
macros which never expose an lvalue, and on IA64 could use the pinned
TLB thing:
/* Usage: set_cpu_local(myint, = 1), or set_cpu_local(mystruct,.member = 1) */
#define set_cpu_local(var, assign) ...
/* Usage: get_cpu_local(myint), or get_cpu_local(mystruct).member */
#define get_cpu_local(var) ...
I rejected such an approach before when Andi Kleen asked for it (IIRC
he wanted to use %gs as the per-cpu ptr, but couldn't easily produce
an lvalue), because I wanted a nice, clean interface. However, recent
gcc handles the struct result of the statement expression flawlessly
AFAICT, so I'm less inclined to resist.
Thoughts?
Rusty.
PS. David, this is your revenge for making more work for you, isn't it?
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
next prev parent reply other threads:[~2003-07-10 1:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-09 21:20 David Mosberger
2003-07-09 21:56 ` David Mosberger
2003-07-10 1:41 ` Rusty Russell [this message]
2003-07-10 9:37 ` Andi Kleen
2003-07-10 17:55 ` David Mosberger
2003-07-10 18:15 ` Linus Torvalds
2003-07-10 18:22 ` David Mosberger
2003-07-11 2:01 ` Rusty Russell
2003-07-11 2:08 ` David Mosberger
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=20030710015208.1E7A22C44B@lists.samba.org \
--to=rusty@rustcorp.com.au \
--cc=ak@suse.de \
--cc=davidm@hpl.hp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.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
all inboxes | Powered by JetHome®