Re: DEFINE_IDA causing memory leaks? (was Re: [PATCH 1/2] virtio: fix memory leak of virtio ida cache layers)

2015-09-17 Thread Suman Anna
On 09/17/2015 01:51 AM, Hannes Reinecke wrote: > On 09/17/2015 07:33 AM, Michael S. Tsirkin wrote: >> On Wed, Sep 16, 2015 at 07:29:17PM -0500, Suman Anna wrote: >>> The virtio core uses a static ida named virtio_index_ida for >>> assigning index numbers to virtio devices during registration. >>> T

Re: DEFINE_IDA causing memory leaks? (was Re: [PATCH 1/2] virtio: fix memory leak of virtio ida cache layers)

2015-09-17 Thread Tejun Heo
Hello, James. On Thu, Sep 17, 2015 at 10:58:29AM -0700, James Bottomley wrote: > The argument is that we shouldn't have to explicitly destroy a > statically initialized object, so > > DEFINE_IDA(someida); > > Should just work without having to explicitly do > > ida_destory(someida); > > somew

Re: DEFINE_IDA causing memory leaks? (was Re: [PATCH 1/2] virtio: fix memory leak of virtio ida cache layers)

2015-09-17 Thread James Bottomley
On Thu, 2015-09-17 at 13:15 -0400, Tejun Heo wrote: > Hello, > > On Thu, Sep 17, 2015 at 09:48:37AM -0700, James Bottomley wrote: > > Well, there's an easy fix for that. We could have ida_remove() actually > > free the bitmap and not cache it if it's the last layer. That way ida > > would natura

Re: DEFINE_IDA causing memory leaks? (was Re: [PATCH 1/2] virtio: fix memory leak of virtio ida cache layers)

2015-09-17 Thread Tejun Heo
Hello, On Thu, Sep 17, 2015 at 09:48:37AM -0700, James Bottomley wrote: > Well, there's an easy fix for that. We could have ida_remove() actually > free the bitmap and not cache it if it's the last layer. That way ida > would naturally empty and we wouldn't need a destructor. Tejun, would > th

Re: DEFINE_IDA causing memory leaks? (was Re: [PATCH 1/2] virtio: fix memory leak of virtio ida cache layers)

2015-09-17 Thread James Bottomley
On Thu, 2015-09-17 at 19:06 +0300, Michael S. Tsirkin wrote: > On Thu, Sep 17, 2015 at 07:15:44AM -0700, James Bottomley wrote: > > On Thu, 2015-09-17 at 08:33 +0300, Michael S. Tsirkin wrote: > > > On Wed, Sep 16, 2015 at 07:29:17PM -0500, Suman Anna wrote: > > > > The virtio core uses a static id

Re: DEFINE_IDA causing memory leaks? (was Re: [PATCH 1/2] virtio: fix memory leak of virtio ida cache layers)

2015-09-17 Thread Michael S. Tsirkin
On Thu, Sep 17, 2015 at 07:15:44AM -0700, James Bottomley wrote: > On Thu, 2015-09-17 at 08:33 +0300, Michael S. Tsirkin wrote: > > On Wed, Sep 16, 2015 at 07:29:17PM -0500, Suman Anna wrote: > > > The virtio core uses a static ida named virtio_index_ida for > > > assigning index numbers to virtio

Re: DEFINE_IDA causing memory leaks? (was Re: [PATCH 1/2] virtio: fix memory leak of virtio ida cache layers)

2015-09-17 Thread Tejun Heo
Hello, On Thu, Sep 17, 2015 at 07:15:44AM -0700, James Bottomley wrote: > I don't understand why you'd want to forbid DEFINE_IDA ... all it does I guess to require the use of explicit init / creation so that it's clear the data structure needs to be destroyed? > is pre-initialise a usually stati

Re: DEFINE_IDA causing memory leaks? (was Re: [PATCH 1/2] virtio: fix memory leak of virtio ida cache layers)

2015-09-17 Thread James Bottomley
On Thu, 2015-09-17 at 08:33 +0300, Michael S. Tsirkin wrote: > On Wed, Sep 16, 2015 at 07:29:17PM -0500, Suman Anna wrote: > > The virtio core uses a static ida named virtio_index_ida for > > assigning index numbers to virtio devices during registration. > > The ida core may allocate some internal

Re: DEFINE_IDA causing memory leaks? (was Re: [PATCH 1/2] virtio: fix memory leak of virtio ida cache layers)

2015-09-16 Thread Hannes Reinecke
On 09/17/2015 07:33 AM, Michael S. Tsirkin wrote: > On Wed, Sep 16, 2015 at 07:29:17PM -0500, Suman Anna wrote: >> The virtio core uses a static ida named virtio_index_ida for >> assigning index numbers to virtio devices during registration. >> The ida core may allocate some internal idr cache laye

DEFINE_IDA causing memory leaks? (was Re: [PATCH 1/2] virtio: fix memory leak of virtio ida cache layers)

2015-09-16 Thread Michael S. Tsirkin
On Wed, Sep 16, 2015 at 07:29:17PM -0500, Suman Anna wrote: > The virtio core uses a static ida named virtio_index_ida for > assigning index numbers to virtio devices during registration. > The ida core may allocate some internal idr cache layers and > an ida bitmap upon any ida allocation, and all

[PATCH 1/2] virtio: fix memory leak of virtio ida cache layers

2015-09-16 Thread Suman Anna
The virtio core uses a static ida named virtio_index_ida for assigning index numbers to virtio devices during registration. The ida core may allocate some internal idr cache layers and an ida bitmap upon any ida allocation, and all these layers are truely freed only upon the ida destruction. The vi