public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* duplicate entry check in kmem_cache_create
@ 2003-06-18 23:08 Steve French
  2003-06-18 23:46 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Steve French @ 2003-06-18 23:08 UTC (permalink / raw)
  To: linux-kernel

Is there a recommended way to check to see if a slab cache with
a specific name exists before calling kmem_cache_create?

I was able to force it into the BUG() at about line 1160 of slab.c by 
removing my
module (rmmod -f) while some of my slab cache objects (e.g. private inode
info) were still in use, and then reloading my module which called
kmem_cache_create with a name that already existed.   I would
like to exit module init code with a more graceful error if I  
could easily detect that my slab cache objects were not deleted  
(since if I proceed farther in my module init code it will hit the  
BUG statement on 1160 of slab.c)

Any easy way to check? 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: duplicate entry check in kmem_cache_create
  2003-06-18 23:08 duplicate entry check in kmem_cache_create Steve French
@ 2003-06-18 23:46 ` Andrew Morton
  2003-06-19  0:08   ` Steve French
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2003-06-18 23:46 UTC (permalink / raw)
  To: Steve French; +Cc: linux-kernel

Steve French <smfrench@austin.rr.com> wrote:
>
> Is there a recommended way to check to see if a slab cache with
> a specific name exists before calling kmem_cache_create?
> 
> I was able to force it into the BUG() at about line 1160 of slab.c by 
> removing my
> module (rmmod -f) while some of my slab cache objects (e.g. private inode
> info) were still in use, and then reloading my module which called
> kmem_cache_create with a name that already existed.

errr, why on earth was the filesystem unloadable when it still had live
objects floating about?

At the very least, if the slab code tries to call a destructor it will ruin
your whole day.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: duplicate entry check in kmem_cache_create
  2003-06-18 23:46 ` Andrew Morton
@ 2003-06-19  0:08   ` Steve French
  0 siblings, 0 replies; 3+ messages in thread
From: Steve French @ 2003-06-19  0:08 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel

Just trying to be paranoid safe in module init code.  You can't unload a 
module with live objects
easily but in at least the case of force unloading of modules (in this 
case the cifs filesystem) is
apparently permitted by the kernel if you specify force and unless there 
is a way to autounmount
when someone forces you into your module exit routine (i.e. on rmmod 
<filesystemname.o> -f)
before all associated mounts are unmounted, I was thinking about whether 
the filesystem's module
init code should check if the filesystem module unloaded (from a slab 
perspective) cleanly but
couldn't think of an easy way to check unless I intentionally leave some 
/proc/fs/ entry around
when module unloading fails (and use the /proc/fs/cifs entry as a hint 
that module unloading was
not clean so don't even think about trying to do a module init on this 
filesystem).

Andrew Morton wrote:

>Steve French <smfrench@austin.rr.com> wrote:
>  
>
>>Is there a recommended way to check to see if a slab cache with
>>a specific name exists before calling kmem_cache_create?
>>
>>I was able to force it into the BUG() at about line 1160 of slab.c by 
>>removing my
>>module (rmmod -f) while some of my slab cache objects (e.g. private inode
>>info) were still in use, and then reloading my module which called
>>kmem_cache_create with a name that already existed.
>>    
>>
>
>errr, why on earth was the filesystem unloadable when it still had live
>objects floating about?
>
>At the very least, if the slab code tries to call a destructor it will ruin
>your whole day.
>
>
>
>  
>



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-06-18 23:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-18 23:08 duplicate entry check in kmem_cache_create Steve French
2003-06-18 23:46 ` Andrew Morton
2003-06-19  0:08   ` Steve French

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox