31 Aug, 2010

1 commit

  • When alloc fails, free_table is being called. Depending on the number of
    bytes requested, we determine if we are going to call _get_free_page()
    or kmalloc(). When alloc fails, our math is wrong (due to sg_size - 1),
    and the last buffer is wrongfully assumed to have been allocated by
    kmalloc. Hence, kfree gets called and a panic occurs.

    Signed-off-by: Jeffrey Carlyle
    Signed-off-by: Olusanya Soyannwo
    Acked-by: Tejun Heo
    Signed-off-by: Jens Axboe

    Jeffrey Carlyle
     

29 Jul, 2010

1 commit

  • kmemleak ignores page_alloc() and so believes the final sub-page
    allocation using the plain kmalloc is decoupled and lost. This leads to
    lots of false-positives with code that uses scatterlists.

    The options seem to be either to tell kmemleak that the kmalloc is not
    leaked or to notify kmemleak of the page allocations. The danger of the
    first approach is that we may hide a real leak, so choose the latter
    approach (of which I am not sure of the downsides).

    v2: Added comments on the suggestion of Catalin.

    Signed-off-by: Chris Wilson
    Cc: Tejun Heo
    Cc: Jens Axboe
    Signed-off-by: Catalin Marinas

    Chris Wilson
     

30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

31 Jul, 2009

1 commit

  • sg_miter_start() is currently unaware of the direction of the copy
    process (to or from the scatter list). It is important to know the
    direction because the page has to be flushed in case the data written
    is seen on a different mapping in user land on cache incoherent
    architectures.

    Signed-off-by: Sebastian Andrzej Siewior
    Acked-by: FUJITA Tomonori
    Acked-by: Tejun Heo
    Signed-off-by: Pierre Ossman

    Sebastian Andrzej Siewior
     

22 Apr, 2009

1 commit


20 Nov, 2008

1 commit

  • kunmap() takes as argument the struct page that orginally got kmap()'d,
    however the sg_miter_stop() function passed it the kernel virtual address
    instead, resulting in weird stuff.

    Somehow I ended up fixing this bug by accident while looking for a bug in
    the same area.

    Reported-by: kerneloops.org
    Acked-by: Tejun Heo
    Signed-off-by: Arjan van de Ven
    Cc: Hugh Dickins
    Cc: [2.6.27.x]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arjan van de Ven
     

12 Sep, 2008

1 commit

  • The callers of sg_copy_buffer must disable interrupts before calling
    it (since it uses kmap_atomic). Some callers use it on
    interrupt-disabled code but some need to take the trouble to disable
    interrupts just for this. No wonder they forget about it and we hit a
    bug like:

    http://bugzilla.kernel.org/show_bug.cgi?id=11529

    James said that it might be better to disable interrupts inside the
    function rather than risk the callers getting it wrong.

    Signed-off-by: FUJITA Tomonori
    Signed-off-by: Jens Axboe

    FUJITA Tomonori
     

23 Jul, 2008

1 commit

  • This is alternative implementation of sg content iterator introduced
    by commit 83e7d317... from Pierre Ossman in next-20080716. As there's
    already an sg iterator which iterates over sg entries themselves, name
    this sg_mapping_iterator.

    Slightly edited description from the original implementation follows.

    Iteration over a sg list is not that trivial when you take into
    account that memory pages might have to be mapped before being used.
    Unfortunately, that means that some parts of the kernel restrict
    themselves to directly accesible memory just to not have to deal with
    the mess.

    This patch adds a simple iterator system that allows any code to
    easily traverse an sg list and not have to deal with all the details.
    The user can decide to consume part of the iteration. Also, iteration
    can be stopped and resumed later if releasing the kmap between
    iteration steps is necessary. These features are useful to implement
    piecemeal sg copying for interrupt drive PIO for example.

    Signed-off-by: Tejun Heo
    Signed-off-by: Pierre Ossman

    Tejun Heo
     

08 Apr, 2008

1 commit

  • This patch adds new three helper functions to copy data between an SG
    list and a linear buffer.

    - sg_copy_from_buffer copies data from linear buffer to an SG list

    - sg_copy_to_buffer copies data from an SG list to a linear buffer

    When the APIs copy data from a linear buffer to an SG list,
    flush_kernel_dcache_page is called. It's not necessary for everyone
    but it's a no-op on most architectures and in general the API is not
    used in performance critical path.

    Signed-off-by: FUJITA Tomonori
    Acked-by: Jens Axboe
    Signed-off-by: James Bottomley

    FUJITA Tomonori
     

28 Jan, 2008

2 commits