Re: [PATCH] module: struct module_ref should contains long fields

From: Eric Dumazet
Date: Fri Dec 16 2011 - 11:01:30 EST


Le vendredi 16 dÃcembre 2011 Ã 07:54 -0800, Tejun Heo a Ãcrit :
> Hello, Eric.
>
> On Fri, Dec 16, 2011 at 06:07:37AM +0100, Eric Dumazet wrote:
> > +struct module_ref {
> > + unsigned long incs;
> > + unsigned long decs;
> > +} __attribute((aligned(2 * sizeof(unsigned long))));
>
> Why not ____cacheline_aligned? Another thing is that for percpu
> memory, packing could be better or at least shouldn't be worse.
> Percpu area usages are likely to be local so one major benefit of
> cacheline alignment - avoiding cacheline pingpong - goes away. The
> constant is called SMP_CACHE_BYTES after all.

Its percpu data, there is no need to waste a full cache line per cpu for
this.

This is only a hint to make sure one single cache line is touched if a
thread increments/decrements a module refcount, with no memory extra
cost : We play with the alignement of this 8 or 16 bytes block.



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