lkml.org 
[lkml]   [2008]   [Feb]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/4] x86 mmiotrace: fix relay-buffer-full flag for SMP
Pekka Paalanen a écrit :
> On Tue, 05 Feb 2008 21:44:07 +0100
> Eric Dumazet <dada1@cosmosbay.com> wrote:
>
>> Pekka Paalanen a écrit :
>>> diff --git a/arch/x86/kernel/mmiotrace/mmio-mod.c b/arch/x86/kernel/mmiotrace/mmio-mod.c
>>> index 82ae920..f492b65 100644
>>> --- a/arch/x86/kernel/mmiotrace/mmio-mod.c
>>> +++ b/arch/x86/kernel/mmiotrace/mmio-mod.c
>>> @@ -47,9 +48,13 @@ struct trap_reason {
>>> int active_traces;
>>> };
>>>
>>> +/* Accessed per-cpu. */
>>> static struct trap_reason pf_reason[NR_CPUS];
>>> static struct mm_io_header_rw cpu_trace[NR_CPUS];
>>>
>>> +/* Access to this is not per-cpu. */
>>> +static atomic_t dropped[NR_CPUS];
>>> +
>> Please dont introduce NR_CPUS new arrays, since people are working hard to zap
>> them from kernel.
>>
>> You probably can use a per_cpu variable ?
>
> Yes, it would probably be more appropriate to use DEFINE_PER_CPU()
> for 'pf_reason' and 'cpu_trace', but I wasn't sure since the examples
> of DEFINE_PER_CPU I saw always had integers or pointers, not
> whole structs. Is it okay for whole structs?

yes you can use a structure, you can check for example :

net/ipv4/route.c:static DEFINE_PER_CPU(struct rt_cache_stat, rt_cache_stat);

>
> 'dropped' on the other hand is not accessed in per-cpu style, any cpu
> may access any element. DEFINE_PER_CPU is not valid here, is it?

It is valid, you can use per_cpu() accessor to get a pointer to a particular
cpu data.

check net/ipv4/route.c for an example :

return &per_cpu(rt_cache_stat, cpu);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2008-02-05 22:49    [W:0.052 / U:1.996 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site