From: Mike Travis <travis@sgi.com>
To: Vegard Nossum <vegard.nossum@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
mm-commits@vger.kernel.org, Yinghai Lu <yhlu.kernel@gmail.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] x86: Change _node_to_cpumask_ptr to return const ptr
Date: Tue, 08 Jul 2008 14:28:48 -0700 [thread overview]
Message-ID: <4873DC10.6030406@sgi.com> (raw)
In-Reply-To: <19f34abd0807081421j67771dbclfae1fcfaa9ad4bcd@mail.gmail.com>
Vegard Nossum wrote:
> On Tue, Jul 8, 2008 at 10:51 PM, Mike Travis <travis@sgi.com> wrote:
>> Vegard Nossum wrote:
>>> On Tue, Jul 8, 2008 at 8:05 PM, Mike Travis <travis@sgi.com> wrote:
>>>>>> Note: I did not change node_to_cpumask_ptr() in include/asm-generic/topology.h
>>>>>> as node_to_cpumask_ptr_next() does change the cpumask value.
>>>>> Hmmm. Does it really?
>>>>>
>>>>> #define node_to_cpumask_ptr_next(v, node) \
>>>>> _##v = node_to_cpumask(node)
>>>>>
>>>>> This doesn't seem to modify it?
>>>> Well I thought about it. The pointer (*v) does not change
>>>> but the underlying cpumask variable is updated with the
>>>> cpumask for the (supposedly) new node number. You can see
>>>> that in this code snippet from kernel/sched.c:
>>>>
>>>> for (i = 1; i < SD_NODES_PER_DOMAIN; i++) {
>>>> int next_node = find_next_best_node(node, &used_nodes);
>>>>
>>>> node_to_cpumask_ptr_next(nodemask, next_node);
>>>> cpus_or(*span, *span, *nodemask);
>>>> }
>>>>
>>>> In the optimized (x86_64) case, the pointer is simply modified
>>>> to point to the new node_to_cpumask_map[node] entry. It remains
>>>> a pointer to a const value.
>>>>
>>>> But the non-optimized version replaces the const cpumask value
>>>> with the new cpumask value. Isn't this breaking the const
>>>> attribute?
>>> No, I think the pointer really should be const. This doesn't guarantee
>>> that the value doesn't change behind our backs, it only prevents us
>>> from modifying it ourselves.
>>>
>>>
>>> Vegard
>>>
>> Is this what you had in mind:
>>
>>
>> --- linux-2.6.tip.orig/include/asm-generic/topology.h
>> +++ linux-2.6.tip/include/asm-generic/topology.h
>> @@ -60,7 +60,7 @@
>> #ifndef node_to_cpumask_ptr
>>
>> #define node_to_cpumask_ptr(v, node) \
>> - cpumask_t _##v = node_to_cpumask(node), *v = &_##v
>> + const cpumask_t _##v = node_to_cpumask(node), *v = &_##v
>>
>> #define node_to_cpumask_ptr_next(v, node) \
>> _##v = node_to_cpumask(node)
>>
>>
>> (It's taking a while as now I need to do some cross-compile testing.)
>
> Actually, no.
>
> We don't want the _##v to be const, do we? What do you think about
> this? (Watch out for whitespace munges)
>
> diff --git a/include/asm-generic/topology.h b/include/asm-generic/topology.h
> index a6aea79..56957f2 100644
> --- a/include/asm-generic/topology.h
> +++ b/include/asm-generic/topology.h
> @@ -60,7 +60,8 @@
> #ifndef node_to_cpumask_ptr
>
> #define node_to_cpumask_ptr(v, node)
> - cpumask_t _##v = node_to_cpumask(node), *v = &_##v
> + cpumask_t _##v = node_to_cpumask(node); \
> + const cpumask_t *v = &_##v;
>
> #define node_to_cpumask_ptr_next(v, node) \
> _##v = node_to_cpumask(node)
>
>
> Vegard
>
Thanks. That was my alternative though I was hoping to confirm that
the compiler detected the overwrite by node_to_cpumask_ptr_next().
Unfortunately every non-x86 cross-compile that I have for a machine
that has NUMA is failing in some other way.
I'll resubmit with that change.
Mike
next prev parent reply other threads:[~2008-07-08 21:28 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200806090918.m599Ib0G012837@imap1.linux-foundation.org>
[not found] ` <19f34abd0806090420r4100241cgb4b828441de3b102@mail.gmail.com>
[not found] ` <20080609113547.GA1534@elte.hu>
[not found] ` <484D54F2.4070603@sgi.com>
[not found] ` <20080626113229.GB29619@elte.hu>
2008-06-26 16:26 ` [PATCH 1/1] x86: Add check for node passed to node_to_cpumask Mike Travis
2008-06-27 2:39 ` [PATCH 1/1] x86: Add check for node passed to node_to_cpumask V2 Mike Travis
2008-06-27 17:10 ` [PATCH 1/1] x86: Add check for node passed to node_to_cpumask V3 Mike Travis
2008-06-27 17:24 ` Vegard Nossum
2008-06-27 18:03 ` Mike Travis
2008-06-29 11:34 ` Vegard Nossum
2008-06-29 12:40 ` Mike Travis
2008-07-03 8:44 ` Ingo Molnar
2008-07-03 8:55 ` Vegard Nossum
2008-07-03 9:01 ` Ingo Molnar
2008-07-08 17:06 ` [PATCH 1/1] x86: Change _node_to_cpumask_ptr to return const ptr Mike Travis
2008-07-08 17:35 ` Vegard Nossum
2008-07-08 18:05 ` Mike Travis
2008-07-08 18:22 ` Vegard Nossum
2008-07-08 20:51 ` Mike Travis
2008-07-08 21:21 ` Vegard Nossum
2008-07-08 21:28 ` Mike Travis [this message]
2008-07-08 21:35 ` Mike Travis
2008-07-08 21:52 ` Vegard Nossum
2008-07-13 17:12 ` Ingo Molnar
2008-07-07 17:23 ` [PATCH 1/1] x86: Add check for node passed to node_to_cpumask V3 Mike Travis
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=4873DC10.6030406@sgi.com \
--to=travis@sgi.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mm-commits@vger.kernel.org \
--cc=vegard.nossum@gmail.com \
--cc=yhlu.kernel@gmail.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