From: "Dong Feng" <middle.fengdong@gmail.com>
To: "Paul Mackerras" <paulus@samba.org>
Cc: ak@suse.de, "Christoph Lameter" <clameter@sgi.com>,
linux-kernel@vger.kernel.org
Subject: Fwd: Unnecessary Relocation Hiding?
Date: Fri, 25 Aug 2006 14:39:33 +0800 [thread overview]
Message-ID: <a2ebde260608242339h3ad6718fg26a00ef56c86a1dc@mail.gmail.com> (raw)
In-Reply-To: <a2ebde260608242329r12259e0k7e798ee1d8737d68@mail.gmail.com>
The mail was rejected by the list because I sent it in HTML format, my
fault. Resend it in plain-text and you can delete the version you do
not like.
I put my understanding below for your confirm or correcting, ...
Once I get a C pointer, say "some_type_t * ptr;" ...
1. If I want to treat it as an ordinary C array and retrieve elements
from it, then plain pointer addition is OK. Like this:
some_type_t * ptr1 = ptr + 2;
2. If I want to add some offset to it (that is, the ptr need to be
converted to _void *_ or _unsigned long_ before manipulated), and the
offset does not exceed sizeof(some_type_t), then plain C addtion is
OK. Like this:
unsigned long raw_addr = (unsigned long)ptr;
int *second_mem = raw_addr + sizeof(int); // as long as the
sizeof(int) less than
// the
sizeof(some_type_t), for example,
//
some_type_t really has two members and the
// the
first is really an integer.
3. If I want to add some offset to it (after converted to _void *_ or
_unsigned long_). However, the offset exceed sizeof(some_type_t). In
this case, gcc still (mis-)assume that I would want to do the same
thing as case 2 (but I am not actually). In this case, I have to use
RELOC_HIDE. And this is exactly what per_cpu() going to do.
== the end of the description of my understanding ==
Thanks.
Feng,Dong
2006/8/25, Paul Mackerras <paulus@samba.org>:
> Dong Feng writes:
>
> > Sorry for perhaps extending the specific question to a more generic
> > one. In which cases shall we, in current or future development,
> > prevent gcc from knowing a pointer-addition in the way RELOC_HIDE? And
> > in what cases shall we just write pure C point addition?
>
> Where you are saying to gcc "you think this variable is at this
> address, but I know it's actually at this other address over here" you
> should use RELOC_HIDE. Where the addition is being used to get the
> address of some part of the object (so the resulting address is still
> within the object) you can just use plain addition.
>
> Paul.
>
next prev parent reply other threads:[~2006-08-25 6:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-23 12:00 Dong Feng
2006-08-23 12:25 ` Dong Feng
2006-08-24 18:26 ` Christoph Lameter
2006-08-24 19:24 ` Andi Kleen
2006-08-24 23:31 ` Paul Mackerras
2006-08-25 1:30 ` Dong Feng
2006-08-25 3:49 ` Paul Mackerras
[not found] ` <a2ebde260608242329r12259e0k7e798ee1d8737d68@mail.gmail.com>
2006-08-25 6:39 ` Dong Feng [this message]
2006-08-25 6:18 ` Andi Kleen
2006-08-25 7:20 ` Paul Mackerras
2006-08-25 7:38 ` Andi Kleen
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=a2ebde260608242339h3ad6718fg26a00ef56c86a1dc@mail.gmail.com \
--to=middle.fengdong@gmail.com \
--cc=ak@suse.de \
--cc=clameter@sgi.com \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®