Re: [patch 6/13] signal/timer/event fds v7 - timerfd core ...

From: Davide Libenzi
Date: Mon Mar 19 2007 - 21:37:43 EST


On Tue, 20 Mar 2007, Eric Dumazet wrote:

> Davide Libenzi a écrit :
>
> > +struct timerfd_ctx {
> > + struct hrtimer tmr;
> > + ktime_t tintv;
> > + spinlock_t lock;
> > + wait_queue_head_t wqh;
> > + unsigned long ticks;
> > +};
>
> > +static struct kmem_cache *timerfd_ctx_cachep;
>
> > + timerfd_ctx_cachep = kmem_cache_create("timerfd_ctx_cache",
> > + sizeof(struct timerfd_ctx),
> > + 0, SLAB_PANIC, NULL, NULL);
>
>
> Do we really expect thousands of active timerfd_ctx ?
>
> If not, using kmalloc()/kfree() would be fine, because sizeof(struct
> timerfd_ctx) is so small.
>
> on SMP / NUMA platforms, each new kmem_cache is rather expensive. (memory
> allocated at kmem_cache_create(), but also memory used when cache is not
> empty, with slabs in freelist for each cpu/node)
>
> Using a general cache might be cheaper : No memory overhead for yet another
> kmem_cache.
>
> I know individual caches are good to spot memory leaks, but in timerfd case,
> you dont have mem leaks, do you ? :)

Silly you, of course not :)
Yes, I gues I can use kmalloc/kfree for those fds ...



- Davide