[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <AANLkTik1JumZon9JJcNjQvbTETZPfiBmpsSDdTybLyKb@mail.gmail.com>
Date: Mon, 1 Nov 2010 18:15:46 -0700
From: Tom Herbert <therbert@...gle.com>
To: Eric Dumazet <eric.dumazet@...il.com>
Cc: davem@...emloft.net, netdev@...r.kernel.org
Subject: Re: [PATCH 2/2 v4] xps: Transmit Packet Steering
>> +struct xps_map {
>> + unsigned int len;
>> + unsigned int alloc_len;
>> + struct rcu_head rcu;
>> + u16 queues[0];
>> +};
>
> OK, so its a 'small' structure. And we dont want it to share a cache
> line with an other user in the kernel, or false sharing might happen.
>
> Make sure you allocate big enough ones to fill a full cache line.
>
> alloc_len = (L1_CACHE_BYTES - sizeof(struct xps_map)) / sizeof(u16);
>
> I see you allocate ones with alloc_len = 1. Thats not good.
>
Okay.
>> +
>> +/*
>> + * This structure holds all XPS maps for device. Maps are indexed by CPU.
>> + */
>> +struct xps_dev_maps {
>> + struct rcu_head rcu;
>> + struct xps_map *cpu_map[0];
>
> Hmm... per_cpu maybe, instead of an array ?
>
The cpu_map is an array of pointers to the actual maps, and I wouldn't
expect those pointers to be changing so maybe that's okay for the
cache. We still need the rcu head, and making cpu_map per-cpu (struct
xps_map **) would add another level of indirection. Is there a
compelling reason to use per-cpu here?
> Also make sure this xps_dev_maps use a full cache line, to avoid false
> sharing.
>
Okay.
> Really I am not sure we need this array and smp_processor_id().
> Please consider alloc_percpu().
> Then, use __this_cpu_ptr() and avoid the preempt_disable()/enable()
> thing. Its a hint we want to use, because as soon as we leave
> get_xps_queue() we might migrate to another cpu ?
If we don't use per-cpu, how about raw_smp_processor_id() here?
>> + if (dev_maps) {
>> + for (i = 0; i < num_possible_cpus(); i++) {
>
> The use of num_possible_cpus() seems wrong to me.
> Dont you meant nr_cpu_ids ?
>
Okay, thanks for clarifying.
> Some machines have two possible cpus, numbered 0 and 8 :
> num_possible_cpus = 2
> nr_cpu_ids = 8
>
>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists