lkml.org 
[lkml]   [2012]   [Mar]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[RFC PATCH 5/6] slob: add kmalloc_align()
    Date
    Add a __kmalloc_node_align() for kmalloc_align().

    Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
    ---
    include/linux/slob_def.h | 14 +++++++++++++-
    mm/slob.c | 8 ++++----
    2 files changed, 17 insertions(+), 5 deletions(-)

    diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
    index 0ec00b3..f2b0fe3 100644
    --- a/include/linux/slob_def.h
    +++ b/include/linux/slob_def.h
    @@ -9,7 +9,13 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
    return kmem_cache_alloc_node(cachep, flags, -1);
    }

    -void *__kmalloc_node(size_t size, gfp_t flags, int node);
    +void *__kmalloc_node_align(size_t size, gfp_t gfp, int align, int node);
    +
    +static __always_inline
    +void *__kmalloc_node(size_t size, gfp_t flags, int node)
    +{
    + return __kmalloc_node_align(size, flags, 0, -1);
    +}

    static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
    {
    @@ -34,4 +40,10 @@ static __always_inline void *__kmalloc(size_t size, gfp_t flags)
    return kmalloc(size, flags);
    }

    +static __always_inline
    +void *kmalloc_align(size_t size, gfp_t flags, size_t align)
    +{
    + return __kmalloc_node_align(ALIGN(size, align), flags, align, -1);
    +}
    +
    #endif /* __LINUX_SLOB_DEF_H */
    diff --git a/mm/slob.c b/mm/slob.c
    index 266e518..d46b986 100644
    --- a/mm/slob.c
    +++ b/mm/slob.c
    @@ -478,15 +478,15 @@ out:
    * End of slob allocator proper. Begin kmem_cache_alloc and kmalloc frontend.
    */

    -void *__kmalloc_node(size_t size, gfp_t gfp, int node)
    +void *__kmalloc_node_align(size_t size, gfp_t gfp, int align, int node)
    {
    unsigned int *m;
    int hsize = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
    - int align;
    void *ret;

    gfp &= gfp_allowed_mask;
    - align = hsize;
    + if (align < hsize)
    + align = hsize;

    lockdep_trace_alloc(gfp);

    @@ -522,7 +522,7 @@ void *__kmalloc_node(size_t size, gfp_t gfp, int node)
    kmemleak_alloc(ret, size, 1, gfp);
    return ret;
    }
    -EXPORT_SYMBOL(__kmalloc_node);
    +EXPORT_SYMBOL(__kmalloc_node_align);

    void kfree(const void *block)
    {
    --
    1.7.4.4


    \
     
     \ /
      Last update: 2012-03-20 11:19    [W:0.023 / U:1.268 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site