[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4873DC10.6030406@sgi.com>
Date: Tue, 08 Jul 2008 14:28:48 -0700
From: Mike Travis <travis@....com>
To: Vegard Nossum <vegard.nossum@...il.com>
CC: Ingo Molnar <mingo@...e.hu>,
"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
mm-commits@...r.kernel.org, Yinghai Lu <yhlu.kernel@...il.com>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/1] x86: Change _node_to_cpumask_ptr to return const
ptr
Vegard Nossum wrote:
> On Tue, Jul 8, 2008 at 10:51 PM, Mike Travis <travis@....com> wrote:
>> Vegard Nossum wrote:
>>> On Tue, Jul 8, 2008 at 8:05 PM, Mike Travis <travis@....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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists