26 Mar, 2006

1 commit

  • Implement /proc/slab_allocators. It produces output like:

    idr_layer_cache: 80 idr_pre_get+0x33/0x4e
    buffer_head: 2555 alloc_buffer_head+0x20/0x75
    mm_struct: 9 mm_alloc+0x1e/0x42
    mm_struct: 20 dup_mm+0x36/0x370
    vm_area_struct: 384 dup_mm+0x18f/0x370
    vm_area_struct: 151 do_mmap_pgoff+0x2e0/0x7c3
    vm_area_struct: 1 split_vma+0x5a/0x10e
    vm_area_struct: 11 do_brk+0x206/0x2e2
    vm_area_struct: 2 copy_vma+0xda/0x142
    vm_area_struct: 9 setup_arg_pages+0x99/0x214
    fs_cache: 8 copy_fs_struct+0x21/0x133
    fs_cache: 29 copy_process+0xf38/0x10e3
    files_cache: 30 alloc_files+0x1b/0xcf
    signal_cache: 81 copy_process+0xbaa/0x10e3
    sighand_cache: 77 copy_process+0xe65/0x10e3
    sighand_cache: 1 de_thread+0x4d/0x5f8
    anon_vma: 241 anon_vma_prepare+0xd9/0xf3
    size-2048: 1 add_sect_attrs+0x5f/0x145
    size-2048: 2 journal_init_revoke+0x99/0x302
    size-2048: 2 journal_init_revoke+0x137/0x302
    size-2048: 2 journal_init_inode+0xf9/0x1c4

    Cc: Manfred Spraul
    Cc: Alexander Nyberg
    Cc: Pekka Enberg
    Cc: Christoph Lameter
    Cc: Ravikiran Thirumalai
    Signed-off-by: Al Viro
    DESC
    slab-leaks3-locking-fix
    EDESC
    From: Andrew Morton

    Update for slab-remove-cachep-spinlock.patch

    Cc: Al Viro
    Cc: Manfred Spraul
    Cc: Alexander Nyberg
    Cc: Pekka Enberg
    Cc: Christoph Lameter
    Cc: Ravikiran Thirumalai
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Al Viro
     

24 Mar, 2006

3 commits

  • The hook in the slab cache allocation path to handle cpuset memory
    spreading for tasks in cpusets with 'memory_spread_slab' enabled has a
    modest performance bug. The hook calls into the memory spreading handler
    alternate_node_alloc() if either of 'memory_spread_slab' or
    'memory_spread_page' is enabled, even though the handler does nothing
    (albeit harmlessly) for the page case

    Fix - drop PF_SPREAD_PAGE from the set of flag bits that are used to
    trigger a call to alternate_node_alloc().

    The page case is handled by separate hooks -- see the calls conditioned on
    cpuset_do_page_mem_spread() in mm/filemap.c

    Signed-off-by: Paul Jackson
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Paul Jackson
     
  • The hooks in the slab cache allocator code path for support of NUMA
    mempolicies and cpuset memory spreading are in an important code path. Many
    systems will use neither feature.

    This patch optimizes those hooks down to a single check of some bits in the
    current tasks task_struct flags. For non NUMA systems, this hook and related
    code is already ifdef'd out.

    The optimization is done by using another task flag, set if the task is using
    a non-default NUMA mempolicy. Taking this flag bit along with the
    PF_SPREAD_PAGE and PF_SPREAD_SLAB flag bits added earlier in this 'cpuset
    memory spreading' patch set, one can check for the combination of any of these
    special case memory placement mechanisms with a single test of the current
    tasks task_struct flags.

    This patch also tightens up the code, to save a few bytes of kernel text
    space, and moves some of it out of line. Due to the nested inlines called
    from multiple places, we were ending up with three copies of this code, which
    once we get off the main code path (for local node allocation) seems a bit
    wasteful of instruction memory.

    Signed-off-by: Paul Jackson
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Paul Jackson
     
  • Provide the slab cache infrastructure to support cpuset memory spreading.

    See the previous patches, cpuset_mem_spread, for an explanation of cpuset
    memory spreading.

    This patch provides a slab cache SLAB_MEM_SPREAD flag. If set in the
    kmem_cache_create() call defining a slab cache, then any task marked with the
    process state flag PF_MEMSPREAD will spread memory page allocations for that
    cache over all the allowed nodes, instead of preferring the local (faulting)
    node.

    On systems not configured with CONFIG_NUMA, this results in no change to the
    page allocation code path for slab caches.

    On systems with cpusets configured in the kernel, but the "memory_spread"
    cpuset option not enabled for the current tasks cpuset, this adds a call to a
    cpuset routine and failed bit test of the processor state flag PF_SPREAD_SLAB.

    For tasks so marked, a second inline test is done for the slab cache flag
    SLAB_MEM_SPREAD, and if that is set and if the allocation is not
    in_interrupt(), this adds a call to to a cpuset routine that computes which of
    the tasks mems_allowed nodes should be preferred for this allocation.

    ==> This patch adds another hook into the performance critical
    code path to allocating objects from the slab cache, in the
    ____cache_alloc() chunk, below. The next patch optimizes this
    hook, reducing the impact of the combined mempolicy plus memory
    spreading hooks on this critical code path to a single check
    against the tasks task_struct flags word.

    This patch provides the generic slab flags and logic needed to apply memory
    spreading to a particular slab.

    A subsequent patch will mark a few specific slab caches for this placement
    policy.

    Signed-off-by: Paul Jackson
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Paul Jackson
     

22 Mar, 2006

14 commits

  • The alien cache rotor in mm/slab.c assumes that the first online node is
    node 0. Eventually for some archs, especially with hotplug, this will no
    longer be true.

    Fix the interleave rotor to handle the general case of node numbering.

    Signed-off-by: Paul Jackson
    Acked-by: Christoph Lameter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Paul Jackson
     
  • The list_lock also protects the shared array and we call drain_array() with
    the shared array. Therefore we cannot go as far as I wanted to but have to
    take the lock in a way so that it also protects the array_cache in
    drain_pages.

    (Note: maybe we should make the array_cache locking more consistent? I.e.
    always take the array cache lock for shared arrays and disable interrupts
    for the per cpu arrays?)

    Signed-off-by: Christoph Lameter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Lameter
     
  • Remove drain_array_locked and use that opportunity to limit the time the l3
    lock is taken further.

    Signed-off-by: Christoph Lameter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Lameter
     
  • And a parameter to drain_array to control the freeing of all objects and
    then use drain_array() to replace instances of drain_array_locked with
    drain_array. Doing so will avoid taking locks in those locations if the
    arrays are empty.

    Signed-off-by: Christoph Lameter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Lameter
     
  • cache_reap takes the l3->list_lock (disabling interrupts) unconditionally
    and then does a few checks and maybe does some cleanup. This patch makes
    cache_reap() only take the lock if there is work to do and then the lock is
    taken and released for each cleaning action.

    The checking of when to do the next reaping is done without any locking and
    becomes racy. Should not matter since reaping can also be skipped if the
    slab mutex cannot be acquired.

    The same is true for the touched processing. If we get this wrong once in
    awhile then we will mistakenly clean or not clean the shared cache. This
    will impact performance slightly.

    Note that the additional drain_array() function introduced here will fall
    out in a subsequent patch since array cleaning will now be very similar
    from all callers.

    Signed-off-by: Christoph Lameter
    Cc: Pekka Enberg
    Cc: Manfred Spraul
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Lameter
     
  • Now that compound page handling is properly fixed in the VM, move nommu
    over to using compound pages rather than rolling their own refcounting.

    nommu vm page refcounting is broken anyway, but there is no need to have
    divergent code in the core VM now, nor when it gets fixed.

    Signed-off-by: Nick Piggin
    Cc: David Howells

    (Needs testing, please).
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Nick Piggin
     
  • Slab duplicates on_each_cpu().

    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     
  • SLAB_NO_REAP is documented as an option that will cause this slab not to be
    reaped under memory pressure. However, that is not what happens. The only
    thing that SLAB_NO_REAP controls at the moment is the reclaim of the unused
    slab elements that were allocated in batch in cache_reap(). Cache_reap()
    is run every few seconds independently of memory pressure.

    Could we remove the whole thing? Its only used by three slabs anyways and
    I cannot find a reason for having this option.

    There is an additional problem with SLAB_NO_REAP. If set then the recovery
    of objects from alien caches is switched off. Objects not freed on the
    same node where they were initially allocated will only be reused if a
    certain amount of objects accumulates from one alien node (not very likely)
    or if the cache is explicitly shrunk. (Strangely __cache_shrink does not
    check for SLAB_NO_REAP)

    Getting rid of SLAB_NO_REAP fixes the problems with alien cache freeing.

    Signed-off-by: Christoph Lameter
    Cc: Pekka Enberg
    Cc: Manfred Spraul
    Cc: Mark Fasheh
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Lameter
     
  • Fix kernel-doc warnings in mm/slab.c.

    Signed-off-by: Randy Dunlap
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Randy Dunlap
     
  • Remove cachep->spinlock. Locking has moved to the kmem_list3 and most of
    the structures protected earlier by cachep->spinlock is now protected by
    the l3->list_lock. slab cache tunables like batchcount are accessed always
    with the cache_chain_mutex held.

    Patch tested on SMP and NUMA kernels with dbench processes running,
    constant onlining/offlining, and constant cache tuning, all at the same
    time.

    Signed-off-by: Ravikiran Thirumalai
    Cc: Christoph Lameter
    Cc: Pekka Enberg
    Cc: Manfred Spraul
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ravikiran G Thirumalai
     
  • slab.c has become a bit revolting again. Try to repair it.

    - Coding style fixes

    - Don't do assignments-in-if-statements.

    - Don't typecast assignments to/from void*

    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     
  • Extract setup_cpu_cache() function from kmem_cache_create() to make the
    latter a little less complex.

    Signed-off-by: Pekka Enberg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Pekka Enberg
     
  • Clean up the object to index mapping that has been spread around mm/slab.c.

    Signed-off-by: Pekka Enberg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Pekka Enberg
     
  • Atomic operation removal from slab

    Signed-off-by: Nick Piggin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Nick Piggin
     

10 Mar, 2006

1 commit

  • The cache reaper currently tries to free all alien caches and all remote
    per cpu pages in each pass of cache_reap. For a machines with large number
    of nodes (such as Altix) this may lead to sporadic delays of around ~10ms.
    Interrupts are disabled while reclaiming creating unacceptable delays.

    This patch changes that behavior by adding a per cpu reap_node variable.
    Instead of attempting to free all caches, we free only one alien cache and
    the per cpu pages from one remote node. That reduces the time spend in
    cache_reap. However, doing so will lengthen the time it takes to
    completely drain all remote per cpu pagesets and all alien caches. The
    time needed will grow with the number of nodes in the system. All caches
    are drained when they overflow their respective capacity. So the drawback
    here is only that a bit of memory may be wasted for awhile longer.

    Details:

    1. Rename drain_remote_pages to drain_node_pages to allow the specification
    of the node to drain of pcp pages.

    2. Add additional functions init_reap_node, next_reap_node for NUMA
    that manage a per cpu reap_node counter.

    3. Add a reap_alien function that reaps only from the current reap_node.

    For us this seems to be a critical issue. Holdoffs of an average of ~7ms
    cause some HPC benchmarks to slow down significantly. F.e. NAS parallel
    slows down dramatically. NAS parallel has a 12-16 seconds runtime w/o rotor
    compared to 5.8 secs with the rotor patches. It gets down to 5.05 secs with
    the additional interrupt holdoff reductions.

    Signed-off-by: Christoph Lameter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Lameter
     

09 Mar, 2006

2 commits


07 Mar, 2006

2 commits


11 Feb, 2006

1 commit


06 Feb, 2006

4 commits

  • The non-NUMA case would do an unmatched "free_alien_cache()" on an alien
    pointer that had never been allocated.

    It might not matter from a code generation standpoint (since in the
    non-NUMA case, the code doesn't actually _do_ anything), but it not only
    results in a compiler warning, it's really really ugly too.

    Fix the compiler warning by just having a matching dummy allocation.
    That also avoids an unnecessary #ifdef in the code.

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • This fixes locking and bugs in cpu_down and cpu_up paths of the NUMA slab
    allocator. Sonny Rao reported problems sometime back on
    POWER5 boxes, when the last cpu on the nodes were being offlined. We could
    not reproduce the same on x86_64 because the cpumask (node_to_cpumask) was not
    being updated on cpu down. Since that issue is now fixed, we can reproduce
    Sonny's problems on x86_64 NUMA, and here is the fix.

    The problem earlier was on CPU_DOWN, if it was the last cpu on the node to go
    down, the array_caches (shared, alien) and the kmem_list3 of the node were
    being freed (kfree) with the kmem_list3 lock held. If the l3 or the
    array_caches were to come from the same cache being cleared, we hit on
    badness.

    This patch cleans up the locking in cpu_up and cpu_down path. We cannot
    really free l3 on cpu down because, there is no node offlining yet and even
    though a cpu is not yet up, node local memory can be allocated for it. So l3s
    are usually allocated at keme_cache_create and destroyed at
    kmem_cache_destroy. Hence, we don't need cachep->spinlock protection to get
    to the cachep->nodelist[nodeid] either.

    Patch survived onlining and offlining on a 4 core 2 node Tyan box with a 4
    dbench process running all the time.

    Signed-off-by: Alok N Kataria
    Signed-off-by: Ravikiran Thirumalai
    Cc: Christoph Lameter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ravikiran G Thirumalai
     
  • Earlier, we had to disable on chip interrupts while taking the
    cachep->spinlock because, at cache_grow, on every addition of a slab to a slab
    cache, we incremented colour_next which was protected by the cachep->spinlock,
    and cache_grow could occur at interrupt context. Since, now we protect the
    per-node colour_next with the node's list_lock, we do not need to disable on
    chip interrupts while taking the per-cache spinlock, but we just need to
    disable interrupts when taking the per-node kmem_list3 list_lock.

    Signed-off-by: Alok N Kataria
    Signed-off-by: Ravikiran Thirumalai
    Signed-off-by: Shai Fultheim
    Cc: Christoph Lameter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ravikiran G Thirumalai
     
  • colour_next is used as an index to add a colouring offset to a new slab in the
    cache (colour_off * colour_next). Now with the NUMA aware slab allocator, it
    makes sense to colour slabs added on the same node sequentially with
    colour_next.

    This patch moves the colouring index "colour_next" per-node by placing it on
    kmem_list3 rather than kmem_cache.

    This also helps simplify locking for CPU up and down paths.

    Signed-off-by: Alok N Kataria
    Signed-off-by: Ravikiran Thirumalai
    Signed-off-by: Shai Fultheim
    Cc: Christoph Lameter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ravikiran G Thirumalai
     

02 Feb, 2006

12 commits

  • mm/slab.c:1522:13: error: incompatible types for operation (&)

    Signed-off-by: Randy Dunlap
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Randy Dunlap
     
  • Fix kernel-doc for calculate_slab_order().

    Signed-off-by: Randy Dunlap
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Randy.Dunlap
     
  • Fix kzalloc() and kstrdup() caller report for CONFIG_DEBUG_SLAB. We must
    pass the caller to __cache_alloc() instead of directly doing
    __builtin_return_address(0) there; otherwise kzalloc() and kstrdup() are
    reported as the allocation site instead of the real one.

    Thanks to Valdis Kletnieks for reporting the problem and Steven Rostedt for
    the original idea.

    Signed-off-by: Pekka Enberg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Pekka Enberg
     
  • Replace uses of kmem_cache_t with proper struct kmem_cache in mm/slab.c.

    Signed-off-by: Pekka Enberg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Pekka Enberg
     
  • Rename the ac_data() function to more descriptive cpu_cache_get().

    Acked-by: Manfred Spraul
    Signed-off-by: Pekka Enberg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Pekka Enberg
     
  • Introduce virt_to_cache() and virt_to_slab() functions to reduce duplicate
    code and introduce a proper abstraction should we want to support other kind
    of mapping for address to slab and cache (eg. for vmalloc() or I/O memory).

    Acked-by: Manfred Spraul
    Signed-off-by: Pekka Enberg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Pekka Enberg
     
  • From: Manfred Spraul

    Reduce the amount of inline functions in slab to the functions that
    are used in the hot path:

    - no inline for debug functions
    - no __always_inline, inline is already __always_inline
    - remove inline from a few numa support functions.

    Before:

    text data bss dec hex filename
    13588 752 48 14388 3834 mm/slab.o (defconfig)
    16671 2492 48 19211 4b0b mm/slab.o (numa)

    After:

    text data bss dec hex filename
    13366 752 48 14166 3756 mm/slab.o (defconfig)
    16230 2492 48 18770 4952 mm/slab.o (numa)

    Signed-off-by: Manfred Spraul
    Signed-off-by: Pekka Enberg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Pekka Enberg
     
  • Create two helper functions slab_get_obj() and slab_put_obj() to replace
    duplicated code in mm/slab.c

    Signed-off-by: Matthew Dobson
    Acked-by: Manfred Spraul
    Signed-off-by: Pekka Enberg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matthew Dobson
     
  • Create a helper function, slab_destroy_objs() which called from
    slab_destroy(). This makes slab_destroy() smaller and more readable, and
    moves ifdefs outside the function body.

    Signed-off-by: Matthew Dobson
    Acked-by: Manfred Spraul
    Signed-off-by: Pekka Enberg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matthew Dobson
     
  • Clean up cache_estimate() in mm/slab.c and improves the algorithm from O(n) to
    O(1). We first calculate the maximum number of objects a slab can hold after
    struct slab and kmem_bufctl_t for each object has been given enough space.
    After that, to respect alignment rules, we decrease the number of objects if
    necessary. As required padding is at most align-1 and memory of obj_size is
    at least align, it is always enough to decrease number of objects by one.

    The optimization was originally made by Balbir Singh with more improvements
    from Steven Rostedt. Manfred Spraul provider further modifications: no loop
    at all for the off-slab case and added comments to explain the background.

    Acked-by: Balbir Singh
    Signed-off-by: Manfred Spraul
    Signed-off-by: Steven Rostedt
    Signed-off-by: Pekka Enberg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Steven Rostedt
     
  • I noticed the code for index_of is a creative way of finding the cache
    index using the compiler to optimize to a single hard coded number. But
    I couldn't help noticing that it uses two methods to let you know that
    someone used it wrong. One is at compile time (the correct way), and
    the other is at run time (not good).

    Signed-off-by: Steven Rostedt
    Acked-by: Manfred Spraul
    Signed-off-by: Pekka Enberg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Steven Rostedt
     
  • Clean up kmem_cache_alloc_node a bit.

    Signed-off-by: Christoph Lameter
    Acked-by: Manfred Spraul
    Signed-off-by: Pekka Enberg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Lameter