public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay.com>
To: linux-kernel@vger.kernel.org
Subject: [RFC] : SLAB : Could we have a process context only versions of  kmem_cache_alloc(), and kmem_cache_free()
Date: Thu, 04 Aug 2005 20:23:47 +0200	[thread overview]
Message-ID: <42F25D33.7080607@cosmosbay.com> (raw)
In-Reply-To: <42F25352.8050805@winch-hebergement.net>

Hi

The cost of local_irq_save(flags)/local_irq_restore(flags) in slab functions is very high
  popf, cli, pushf do stress the modern processors.

Maybe we could provide special functions for caches that are known to be used only from process context ?


These functions may use the local_irq_save(flags)/local_irq_restore(flags) only if needed (cache_alloc_refill() or cache_flusharray())

Something like :

void *kmem_cache_alloc_noirq(kmem_cache_t *cachep, unsigned int __nocast flags)
{
         unsigned long save_flags;
         void* objp;
         struct array_cache *ac;

         cache_alloc_debugcheck_before(cachep, flags);
	check_irq_on();
         preempt_disable();
         ac = ac_data(cachep);
         if (likely(ac->avail)) {
                 STATS_INC_ALLOCHIT(cachep);
                 ac->touched = 1;
                 objp = ac_entry(ac)[--ac->avail];
         } else {
                 STATS_INC_ALLOCMISS(cachep);
		local_irq_save(save_flags);
                 objp = cache_alloc_refill(cachep, flags);
		local_irq_restore(save_flags);
         }
         preempt_enable();
         objp = cache_alloc_debugcheck_after(cachep, flags, objp, __builtin_return_address(0));
	prefetchw(objp);
         return objp;
}


void kmem_cache_free_noirq(kmem_cache_t *cachep, void *objp)
{
         struct array_cache *ac;

	check_irq_on();
	preempt_disable();
	ac  = ac_data(cachep);

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

         if (likely(ac->avail < ac->limit)) {
                 STATS_INC_FREEHIT(cachep);
         } else {
		unsigned long flags;
                 STATS_INC_FREEMISS(cachep);
		local_irq_save(flags);
                 cache_flusharray(cachep, ac);
		local_irq_restore(flags);
         }
         ac_entry(ac)[ac->avail++] = objp;
	preempt_disable();
}

Thank you

Eric Dumazet


  reply	other threads:[~2005-08-04 18:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-01  8:33 2.6.13-rc4 - kernel panic - BUG at net/ipv4/tcp_output.c:918 Guillaume Pelat
2005-08-04  3:33 ` Herbert Xu
2005-08-04 10:35   ` Herbert Xu
2005-08-04 17:41     ` Guillaume Pelat
2005-08-04 18:23       ` Eric Dumazet [this message]
2005-08-04 23:58       ` Andrew Morton
2005-08-05  0:57         ` [TCP]: Fix TSO cwnd caching bug Herbert Xu
2005-08-05  1:08           ` Andrew Morton
2005-08-05  8:33           ` David S. Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42F25D33.7080607@cosmosbay.com \
    --to=dada1@cosmosbay.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox