Re: [PATCH] SLUB use cmpxchg_local

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Mathieu Desnoyers
Date: Monday, August 27, 2007 - 1:39 pm

* Christoph Lameter (clameter@sgi.com) wrote:

Not exactly. What I propose is:

- Running slab_alloc and slab_free fast paths in preempt_disable
  context, using cmpxchg_local.
- Running slab_alloc and slab_free slow paths with irqs disabled.
- Running __alloc_pages in preemptible context, not tied to any CPU.

In this scheme, calling __alloc_pages from slab_alloc would reenable
interrupts and potentially migrate us to a different CPU. We would
therefore have to get once again our per-cpu data structure once we get
back into irq disabled code, because we may be running on a different
CPU. This is actually what the __slab_alloc slow path does:


new_slab:
        new = get_partial(s, gfpflags, node);
        if (new) {
                c->page = new;
                goto load_freelist;
        }

        new = new_slab(s, gfpflags, node);

          ----> within new_slab, we can reenable interrupts for the
                __slab_alloc call.

        if (new) {
                c = get_cpu_slab(s, smp_processor_id());
                if (c->page) {
                        /*
                         * Someone else populated the cpu_slab while we
                         * enabled interrupts, or we have gotten scheduled
                         * on another cpu. The page may not be on the
                         * requested node even if __GFP_THISNODE was
                         * specified. So we need to recheck.
                         */
                        if (node_match(c, node)) {
                                /*
                                 * Current cpuslab is acceptable and we
                                 * want the current one since its cache hot
                                 */
                                discard_slab(s, new);
                                slab_lock(c->page);
                                goto load_freelist;
                        }
                        /* New slab does not fit our expectations */
                        flush_slab(s, c);
                }
                slab_lock(new);
                SetSlabFrozen(new);
                c->page = new;
                goto load_freelist;

So the idea would be to split the code in O(1)
preempt_disable/irq_disable sections and to enable interrupt and check
for current per-cpu data structure when re-entering in irq disabled
code.

Mathieu

-- 
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch 01/23] Fall back on interrupt disable in cmpxchg8b ..., Mathieu Desnoyers, (Mon Aug 20, 1:15 pm)
Re: [patch 01/23] Fall back on interrupt disable in cmpxch ..., Christoph Lameter, (Mon Aug 20, 1:32 pm)
Re: [patch 01/23] Fall back on interrupt disable in cmpxch ..., Mathieu Desnoyers, (Mon Aug 20, 1:41 pm)
Re: [patch 01/23] Fall back on interrupt disable in cmpxch ..., Christoph Lameter, (Mon Aug 20, 1:46 pm)
Re: [patch 01/23] Fall back on interrupt disable in cmpxch ..., Mathieu Desnoyers, (Mon Aug 20, 2:29 pm)
Re: [patch 01/23] Fall back on interrupt disable in cmpxch ..., Christoph Lameter, (Mon Aug 20, 2:49 pm)
Re: [patch 01/23] Fall back on interrupt disable in cmpxch ..., Mathieu Desnoyers, (Mon Aug 20, 2:54 pm)
Re: [patch 01/23] Fall back on interrupt disable in cmpxch ..., Christoph Lameter, (Mon Aug 20, 3:07 pm)
Re: [patch 01/23] Fall back on interrupt disable in cmpxch ..., Mathieu Desnoyers, (Mon Aug 20, 3:29 pm)
[PATCH] SLUB Use cmpxchg() everywhere, Mathieu Desnoyers, (Tue Aug 21, 10:38 am)
[PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Tue Aug 21, 10:38 am)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Tue Aug 21, 10:44 am)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Tue Aug 21, 1:41 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Tue Aug 21, 2:08 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Tue Aug 21, 2:10 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Tue Aug 21, 2:36 pm)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Tue Aug 21, 4:12 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Tue Aug 21, 4:14 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Tue Aug 21, 4:17 pm)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Tue Aug 21, 4:21 pm)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Tue Aug 21, 4:23 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Tue Aug 21, 4:35 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Tue Aug 21, 4:38 pm)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Tue Aug 21, 4:39 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Tue Aug 21, 4:41 pm)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Tue Aug 21, 4:47 pm)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Tue Aug 21, 4:50 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Tue Aug 21, 4:51 pm)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Tue Aug 21, 5:03 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Tue Aug 21, 5:11 pm)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Tue Aug 21, 5:26 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Tue Aug 21, 5:34 pm)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Tue Aug 21, 5:38 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Tue Aug 21, 6:06 pm)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Tue Aug 21, 6:12 pm)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Tue Aug 21, 6:18 pm)
Re: [PATCH] SLUB use cmpxchg_local, Andi Kleen, (Tue Aug 21, 6:28 pm)
Re: [PATCH] SLUB use cmpxchg_local, Andi Kleen, (Wed Aug 22, 2:39 am)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Wed Aug 22, 6:45 am)
Re: [PATCH] SLUB use cmpxchg_local, Andi Kleen, (Wed Aug 22, 6:46 am)
[PATCH] define have_arch_cmpxchg(), Mathieu Desnoyers, (Wed Aug 22, 8:00 am)
[PATCH] SLUB: use have_arch_cmpxchg(), Mathieu Desnoyers, (Wed Aug 22, 8:02 am)
Re: [PATCH] SLUB: use have_arch_cmpxchg(), Pekka Enberg, (Wed Aug 22, 9:24 am)
Re: [PATCH] define have_arch_cmpxchg(), Christoph Lameter, (Wed Aug 22, 11:50 am)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Wed Aug 22, 11:54 am)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Wed Aug 22, 12:25 pm)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Wed Aug 22, 1:09 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Wed Aug 22, 1:19 pm)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Wed Aug 22, 1:29 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Wed Aug 22, 1:33 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Wed Aug 22, 1:38 pm)
Re: [PATCH] SLUB use cmpxchg_local, Peter Zijlstra, (Sun Aug 26, 11:52 pm)
Re: [PATCH] SLUB: use have_arch_cmpxchg(), Mathieu Desnoyers, (Mon Aug 27, 7:56 am)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Mon Aug 27, 12:39 pm)
Re: [PATCH] SLUB: use have_arch_cmpxchg(), Christoph Lameter, (Mon Aug 27, 12:43 pm)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Mon Aug 27, 1:22 pm)
Re: [PATCH] SLUB: use have_arch_cmpxchg(), Mathieu Desnoyers, (Mon Aug 27, 1:25 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Mon Aug 27, 1:26 pm)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Mon Aug 27, 1:39 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Mon Aug 27, 2:04 pm)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Mon Aug 27, 2:10 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Mon Aug 27, 2:23 pm)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Mon Aug 27, 2:38 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Mon Aug 27, 3:12 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Mon Aug 27, 3:15 pm)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Mon Aug 27, 3:27 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Mon Aug 27, 3:29 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Mon Aug 27, 6:26 pm)
Re: [PATCH] SLUB use cmpxchg_local, Peter Zijlstra, (Tue Aug 28, 12:12 am)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Tue Aug 28, 5:07 am)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Tue Aug 28, 12:36 pm)
Re: [PATCH] SLUB use cmpxchg_local, Christoph Lameter, (Tue Aug 28, 12:42 pm)
Re: [PATCH] SLUB use cmpxchg_local, Peter Zijlstra, (Tue Aug 28, 12:46 pm)
Re: [PATCH] SLUB use cmpxchg_local, Mathieu Desnoyers, (Tue Sep 4, 1:02 pm)
[PATCH] local_t protection (critical section), Mathieu Desnoyers, (Tue Sep 4, 1:03 pm)
[PATCH] slub - Use local_t protection, Mathieu Desnoyers, (Tue Sep 4, 1:04 pm)
Re: [PATCH] slub - Use local_t protection, Christoph Lameter, (Tue Sep 4, 1:45 pm)
Re: [PATCH] slub - Use local_t protection, Mathieu Desnoyers, (Wed Sep 5, 6:03 am)
[PATCH] local_t protection (critical section), Mathieu Desnoyers, (Wed Sep 5, 6:04 am)
Re: [PATCH] slub - Use local_t protection, Mathieu Desnoyers, (Wed Sep 5, 6:06 am)
Re: [PATCH] slub - Use local_t protection, Christoph Lameter, (Wed Sep 12, 3:28 pm)
Re: [PATCH] local_t protection (critical section), Christoph Lameter, (Wed Sep 12, 3:33 pm)
Re: [PATCH] local_t protection (critical section), Mathieu Desnoyers, (Wed Sep 12, 4:00 pm)