linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: can kfree sleep?
@ 2004-11-21 18:56 Manfred Spraul
  2004-11-21 20:51 ` Peter T. Breuer
  0 siblings, 1 reply; 8+ messages in thread
From: Manfred Spraul @ 2004-11-21 18:56 UTC (permalink / raw)
  To: Peter T. Breuer; +Cc: linux-kernel

Hi Peter,

>Just a question: can kfree sleep?
>
>
>  
>
No, it never sleeps. It's safe to call kfree from arbitrary context. The 
only exception is the NMI oopser and similar arch code.

>I believe so, but slab.c does not enlighten me immediately:
>  
>
Yes, the kfree code is quite long - it must check if freeing one object 
created a freeable page and return it to the page allocator. Together 
with lots of caching and debug checks.

--
    Manfred


^ permalink raw reply	[flat|nested] 8+ messages in thread
* can kfree sleep?
@ 2004-11-21 12:23 Peter T. Breuer
  2004-11-21 21:10 ` Andrew Morton
  0 siblings, 1 reply; 8+ messages in thread
From: Peter T. Breuer @ 2004-11-21 12:23 UTC (permalink / raw)
  To: linux kernel


Just a question: can kfree sleep?

I believe so, but slab.c does not enlighten me immediately:

 void
 kfree (const void *objp)
 {
        kmem_cache_t *c;
        unsigned long flags;

        if (!objp)
                return;
        local_irq_save (flags);
        c = GET_PAGE_CACHE (virt_to_page (objp));
        __cache_free (c, (void *) objp);
        local_irq_restore (flags);
 }

 static inline void __cache_free (kmem_cache_t *cachep, void* objp)
 {
        struct array_cache *ac = ac_data(cachep);

        check_irq_off();
        objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));

        if (likely(ac->avail < ac->limit)) {
                STATS_INC_FREEHIT(cachep);
                ac_entry(ac)[ac->avail++] = objp;
                return;
        } else {
                STATS_INC_FREEMISS(cachep);
                cache_flusharray(cachep, ac);
                ac_entry(ac)[ac->avail++] = objp;
        }
 }

 ...


Peter

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

end of thread, other threads:[~2004-11-22  8:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-21 18:56 can kfree sleep? Manfred Spraul
2004-11-21 20:51 ` Peter T. Breuer
  -- strict thread matches above, loose matches on Subject: below --
2004-11-21 12:23 Peter T. Breuer
2004-11-21 21:10 ` Andrew Morton
2004-11-21 21:14   ` Christoph Hellwig
2004-11-21 22:30     ` Peter T. Breuer
2004-11-22  5:41       ` Christoph Hellwig
2004-11-22  8:18       ` Arjan van de Ven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).