10 Jan, 2012

1 commit

  • Including trace/events/*.h TRACE_EVENT() macro headers in other headers
    can cause strange side effects if another trace/event/*.h header
    includes that header. Having trace/events/kmem.h inside slab_def.h
    caused a compile error in sparc64 when changes were done to some header
    files. Moving the kmem.h trace header out of slab.h and into slab.c
    fixes the problem.

    Note, both slub.c and slob.c already include the trace/events/kmem.h
    file. Only slab.c had it missing.

    Link: http://lkml.kernel.org/r/20120105190405.1e3191fb5a43b2a0f1655e1f@canb.auug.org.au

    Reported-by: Stephen Rothwell
    Signed-off-by: Steven Rostedt
    Signed-off-by: Linus Torvalds

    Steven Rostedt
     

21 Jul, 2011

1 commit

  • Reduce high order allocations for some setups.
    (NR_CPUS=4096 -> we need 64KB per kmem_cache struct)

    We now allocate exact needed size (using nr_cpu_ids and nr_node_ids)

    This also makes code a bit smaller on x86_64, since some field offsets
    are less than the 127 limit :

    Before patch :
    # size mm/slab.o
    text data bss dec hex filename
    22605 361665 32 384302 5dd2e mm/slab.o

    After patch :
    # size mm/slab.o
    text data bss dec hex filename
    22349 353473 8224 384046 5dc2e mm/slab.o

    CC: Andrew Morton
    Reported-by: Konstantin Khlebnikov
    Signed-off-by: Eric Dumazet
    Acked-by: Christoph Lameter
    Signed-off-by: Pekka Enberg

    Eric Dumazet
     

17 Jun, 2011

1 commit

  • Every slab has its on alignment definition in include/linux/sl?b_def.h. Extract those
    and define a common set in include/linux/slab.h.

    SLOB: As notes sometimes we need double word alignment on 32 bit. This gives all
    structures allocated by SLOB a unsigned long long alignment like the others do.

    SLAB: If ARCH_SLAB_MINALIGN is not set SLAB would set ARCH_SLAB_MINALIGN to
    zero meaning no alignment at all. Give it the default unsigned long long alignment.

    Signed-off-by: Christoph Lameter
    Signed-off-by: Pekka Enberg

    Christoph Lameter
     

29 Nov, 2010

1 commit


11 Aug, 2010

1 commit

  • Now each architecture has the own dma_get_cache_alignment implementation.

    dma_get_cache_alignment returns the minimum DMA alignment. Architectures
    define it as ARCH_KMALLOC_MINALIGN (it's used to make sure that malloc'ed
    buffer is DMA-safe; the buffer doesn't share a cache with the others). So
    we can unify dma_get_cache_alignment implementations.

    This patch:

    dma_get_cache_alignment() needs to know if an architecture defines
    ARCH_KMALLOC_MINALIGN or not (needs to know if architecture has DMA
    alignment restriction). However, slab.h define ARCH_KMALLOC_MINALIGN if
    architectures doesn't define it.

    Let's rename ARCH_KMALLOC_MINALIGN to ARCH_DMA_MINALIGN.
    ARCH_KMALLOC_MINALIGN is used only in the internals of slab/slob/slub
    (except for crypto).

    Signed-off-by: FUJITA Tomonori
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    FUJITA Tomonori
     

09 Jun, 2010

1 commit

  • We have been resisting new ftrace plugins and removing existing
    ones, and kmemtrace has been superseded by kmem trace events
    and perf-kmem, so we remove it.

    Signed-off-by: Li Zefan
    Acked-by: Pekka Enberg
    Acked-by: Eduard - Gabriel Munteanu
    Cc: Ingo Molnar
    Cc: Steven Rostedt
    [ remove kmemtrace from the makefile, handle slob too ]
    Signed-off-by: Frederic Weisbecker

    Li Zefan
     

20 May, 2010

1 commit


11 Dec, 2009

1 commit

  • Define kmem_trace_alloc_{,node}_notrace() if CONFIG_TRACING is
    enabled, otherwise perf-kmem will show wrong stats ifndef
    CONFIG_KMEM_TRACE, because a kmalloc() memory allocation may
    be traced by both trace_kmalloc() and trace_kmem_cache_alloc().

    Signed-off-by: Li Zefan
    Reviewed-by: Pekka Enberg
    Cc: Christoph Lameter
    Cc: Steven Rostedt
    Cc: Frederic Weisbecker
    Cc: linux-mm@kvack.org
    Cc: Eduard - Gabriel Munteanu
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Li Zefan
     

13 Jun, 2009

1 commit

  • Move the SLAB struct kmem_cache definition to like
    with SLUB so kmemcheck can access ->ctor and ->flags.

    Cc: Ingo Molnar
    Cc: Christoph Lameter
    Cc: Andrew Morton
    Signed-off-by: Pekka Enberg

    [rebased for mainline inclusion]
    Signed-off-by: Vegard Nossum

    Pekka Enberg
     

12 Apr, 2009

1 commit

  • Impact: refactor code for future changes

    Current kmemtrace.h is used both as header file of kmemtrace and kmem's
    tracepoints definition.

    Tracepoints' definition file may be used by other code, and should only have
    definition of tracepoint.

    We can separate include/trace/kmemtrace.h into 2 files:

    include/linux/kmemtrace.h: header file for kmemtrace
    include/trace/kmem.h: definition of kmem tracepoints

    Signed-off-by: Zhao Lei
    Acked-by: Eduard - Gabriel Munteanu
    Acked-by: Pekka Enberg
    Cc: Steven Rostedt
    Cc: Frederic Weisbecker
    Cc: Tom Zanussi
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Zhaolei
     

03 Apr, 2009

1 commit

  • kmemtrace now uses tracepoints instead of markers. We no longer need to
    use format specifiers to pass arguments.

    Signed-off-by: Eduard - Gabriel Munteanu
    [ folded: Use the new TP_PROTO and TP_ARGS to fix the build. ]
    [ folded: fix build when CONFIG_KMEMTRACE is disabled. ]
    [ folded: define tracepoints when CONFIG_TRACEPOINTS is enabled. ]
    Signed-off-by: Pekka Enberg
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Eduard - Gabriel Munteanu
     

03 Feb, 2009

1 commit


28 Jan, 2009

1 commit

  • The SLAB kmalloc with a constant value isn't consistent with the other
    implementations because it bails out with __you_cannot_kmalloc_that_much
    rather than returning NULL and properly allowing the caller to fall back
    to vmalloc or take other action. This doesn't happen with a non-constant
    value or with SLOB or SLUB.

    Starting with 2.6.28, I've been seeing build failures on s390x. This is
    due to init_section_page_cgroup trying to allocate 2.5MB when the max size
    for a kmalloc on s390x is 2MB.

    It's failing because the value is constant. The workarounds at the call
    size are ugly and the caller shouldn't have to change behavior depending
    on what the backend of the API is.

    So, this patch eliminates the link failure and returns NULL like the other
    implementations.

    Signed-off-by: Jeff Mahoney
    Cc: Martin Schwidefsky
    Cc: Heiko Carstens
    Cc: Christoph Lameter
    Cc: Pekka Enberg
    Cc: Matt Mackall
    Cc: Nick Piggin
    Cc: [2.6.28.x]
    Signed-off-by: Andrew Morton
    Signed-off-by: Pekka Enberg

    Jeff Mahoney
     

30 Dec, 2008

1 commit

  • Impact: new tracer plugin

    This patch adapts kmemtrace raw events tracing to the unified tracing API.

    To enable and use this tracer, just do the following:

    echo kmemtrace > /debugfs/tracing/current_tracer
    cat /debugfs/tracing/trace

    You will have the following output:

    # tracer: kmemtrace
    #
    #
    # ALLOC TYPE REQ GIVEN FLAGS POINTER NODE CALLER
    # FREE | | | | | | | |
    # |

    type_id 1 call_site 18446744071565527833 ptr 18446612134395152256
    type_id 0 call_site 18446744071565585597 ptr 18446612134405955584 bytes_req 4096 bytes_alloc 4096 gfp_flags 208 node -1
    type_id 1 call_site 18446744071565585534 ptr 18446612134405955584
    type_id 0 call_site 18446744071565585597 ptr 18446612134405955584 bytes_req 4096 bytes_alloc 4096 gfp_flags 208 node -1
    type_id 0 call_site 18446744071565636711 ptr 18446612134345164672 bytes_req 240 bytes_alloc 240 gfp_flags 208 node -1
    type_id 1 call_site 18446744071565585534 ptr 18446612134405955584
    type_id 0 call_site 18446744071565585597 ptr 18446612134405955584 bytes_req 4096 bytes_alloc 4096 gfp_flags 208 node -1
    type_id 0 call_site 18446744071565636711 ptr 18446612134345164912 bytes_req 240 bytes_alloc 240 gfp_flags 208 node -1
    type_id 1 call_site 18446744071565585534 ptr 18446612134405955584
    type_id 0 call_site 18446744071565585597 ptr 18446612134405955584 bytes_req 4096 bytes_alloc 4096 gfp_flags 208 node -1
    type_id 0 call_site 18446744071565636711 ptr 18446612134345165152 bytes_req 240 bytes_alloc 240 gfp_flags 208 node -1
    type_id 0 call_site 18446744071566144042 ptr 18446612134346191680 bytes_req 1304 bytes_alloc 1312 gfp_flags 208 node -1
    type_id 1 call_site 18446744071565585534 ptr 18446612134405955584
    type_id 0 call_site 18446744071565585597 ptr 18446612134405955584 bytes_req 4096 bytes_alloc 4096 gfp_flags 208 node -1
    type_id 1 call_site 18446744071565585534 ptr 18446612134405955584

    That was to stay backward compatible with the format output produced in
    inux/tracepoint.h.

    This is the default ouput, but note that I tried something else.

    If you change an option:

    echo kmem_minimalistic > /debugfs/trace_options

    and then cat /debugfs/trace, you will have the following output:

    # tracer: kmemtrace
    #
    #
    # ALLOC TYPE REQ GIVEN FLAGS POINTER NODE CALLER
    # FREE | | | | | | | |
    # |

    - C 0xffff88007c088780 file_free_rcu
    + K 4096 4096 000000d0 0xffff88007cad6000 -1 getname
    - C 0xffff88007cad6000 putname
    + K 4096 4096 000000d0 0xffff88007cad6000 -1 getname
    + K 240 240 000000d0 0xffff8800790dc780 -1 d_alloc
    - C 0xffff88007cad6000 putname
    + K 4096 4096 000000d0 0xffff88007cad6000 -1 getname
    + K 240 240 000000d0 0xffff8800790dc870 -1 d_alloc
    - C 0xffff88007cad6000 putname
    + K 4096 4096 000000d0 0xffff88007cad6000 -1 getname
    + K 240 240 000000d0 0xffff8800790dc960 -1 d_alloc
    + K 1304 1312 000000d0 0xffff8800791d7340 -1 reiserfs_alloc_inode
    - C 0xffff88007cad6000 putname
    + K 4096 4096 000000d0 0xffff88007cad6000 -1 getname
    - C 0xffff88007cad6000 putname
    + K 992 1000 000000d0 0xffff880079045b58 -1 alloc_inode
    + K 768 1024 000080d0 0xffff88007c096400 -1 alloc_pipe_info
    + K 240 240 000000d0 0xffff8800790dca50 -1 d_alloc
    + K 272 320 000080d0 0xffff88007c088780 -1 get_empty_filp
    + K 272 320 000080d0 0xffff88007c088000 -1 get_empty_filp

    Yeah I shall confess kmem_minimalistic should be: kmem_alternative.

    Whatever, I find it more readable but this a personal opinion of course.
    We can drop it if you want.

    On the ALLOC/FREE column, + means an allocation and - a free.

    On the type column, you have K = kmalloc, C = cache, P = page

    I would like the flags to be GFP_* strings but that would not be easy to not
    break the column with strings....

    About the node...it seems to always be -1. I don't know why but that shouldn't
    be difficult to find.

    I moved linux/tracepoint.h to trace/tracepoint.h as well. I think that would
    be more easy to find the tracer headers if they are all in their common
    directory.

    Signed-off-by: Frederic Weisbecker
    Signed-off-by: Ingo Molnar

    Frederic Weisbecker
     

29 Dec, 2008

1 commit

  • This adds hooks for the SLAB allocator, to allow tracing with kmemtrace.

    We also convert some inline functions to __always_inline to make sure
    _RET_IP_, which expands to __builtin_return_address(0), always works
    as expected.

    Signed-off-by: Eduard - Gabriel Munteanu
    Signed-off-by: Pekka Enberg

    Eduard - Gabriel Munteanu
     

07 Mar, 2008

1 commit


03 Jan, 2008

1 commit

  • Both SLUB and SLAB really did almost exactly the same thing for
    /proc/slabinfo setup, using duplicate code and per-allocator #ifdef's.

    This just creates a common CONFIG_SLABINFO that is enabled by both SLUB
    and SLAB, and shares all the setup code. Maybe SLOB will want this some
    day too.

    Reviewed-by: Pekka Enberg
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

18 Jul, 2007

2 commits

  • It becomes now easy to support the zeroing allocs with generic inline
    functions in slab.h. Provide inline definitions to allow the continued use of
    kzalloc, kmem_cache_zalloc etc but remove other definitions of zeroing
    functions from the slab allocators and util.c.

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

    Christoph Lameter
     
  • Define ZERO_OR_NULL_PTR macro to be able to remove the checks from the
    allocators. Move ZERO_SIZE_PTR related stuff into slab.h.

    Make ZERO_SIZE_PTR work for all slab allocators and get rid of the
    WARN_ON_ONCE(size == 0) that is still remaining in SLAB.

    Make slub return NULL like the other allocators if a too large memory segment
    is requested via __kmalloc.

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

    Christoph Lameter
     

17 Jul, 2007

1 commit

  • This adds preliminary NUMA support to SLOB, primarily aimed at systems with
    small nodes (tested all the way down to a 128kB SRAM block), whether
    asymmetric or otherwise.

    We follow the same conventions as SLAB/SLUB, preferring current node
    placement for new pages, or with explicit placement, if a node has been
    specified. Presently on UP NUMA this has the side-effect of preferring
    node#0 allocations (since numa_node_id() == 0, though this could be
    reworked if we could hand off a pfn to determine node placement), so
    single-CPU NUMA systems will want to place smaller nodes further out in
    terms of node id. Once a page has been bound to a node (via explicit node
    id typing), we only do block allocations from partial free pages that have
    a matching node id in the page flags.

    The current implementation does have some scalability problems, in that all
    partial free pages are tracked in the global freelist (with contention due
    to the single spinlock). However, these are things that are being reworked
    for SMP scalability first, while things like per-node freelists can easily
    be built on top of this sort of functionality once it's been added.

    More background can be found in:

    http://marc.info/?l=linux-mm&m=118117916022379&w=2
    http://marc.info/?l=linux-mm&m=118170446306199&w=2
    http://marc.info/?l=linux-mm&m=118187859420048&w=2

    and subsequent threads.

    Acked-by: Christoph Lameter
    Acked-by: Matt Mackall
    Signed-off-by: Paul Mundt
    Acked-by: Nick Piggin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Paul Mundt
     

17 May, 2007

1 commit


12 Feb, 2007

1 commit

  • Make ZONE_DMA optional in core code.

    - ifdef all code for ZONE_DMA and related definitions following the example
    for ZONE_DMA32 and ZONE_HIGHMEM.

    - Without ZONE_DMA, ZONE_HIGHMEM and ZONE_DMA32 we get to a ZONES_SHIFT of
    0.

    - Modify the VM statistics to work correctly without a DMA zone.

    - Modify slab to not create DMA slabs if there is no ZONE_DMA.

    [akpm@osdl.org: cleanup]
    [jdike@addtoit.com: build fix]
    [apw@shadowen.org: Simplify calculation of the number of bits we need for ZONES_SHIFT]
    Signed-off-by: Christoph Lameter
    Cc: Andi Kleen
    Cc: "Luck, Tony"
    Cc: Kyle McMartin
    Cc: Matthew Wilcox
    Cc: James Bottomley
    Cc: Paul Mundt
    Signed-off-by: Andy Whitcroft
    Signed-off-by: Jeff Dike
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Lameter
     

14 Dec, 2006

1 commit

  • This is a response to an earlier discussion on linux-mm about splitting
    slab.h components per allocator. Patch is against 2.6.19-git11. See
    http://marc.theaimsgroup.com/?l=linux-mm&m=116469577431008&w=2

    This patch cleans up the slab header definitions. We define the common
    functions of slob and slab in slab.h and put the extra definitions needed
    for slab's kmalloc implementations in . In order to get
    a greater set of common functions we add several empty functions to slob.c
    and also rename slob's kmalloc to __kmalloc.

    Slob does not need any special definitions since we introduce a fallback
    case. If there is no need for a slab implementation to provide its own
    kmalloc mess^H^H^Hacros then we simply fall back to __kmalloc functions.
    That is sufficient for SLOB.

    Sort the function in slab.h according to their functionality. First the
    functions operating on struct kmem_cache * then the kmalloc related
    functions followed by special debug and fallback definitions.

    Also redo a lot of comments.

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

    Christoph Lameter