21 Apr, 2013

2 commits

  • Pull kdump fixes from Peter Anvin:
    "The kexec/kdump people have found several problems with the support
    for loading over 4 GiB that was introduced in this merge cycle. This
    is partly due to a number of design problems inherent in the way the
    various pieces of kdump fit together (it is pretty horrifically manual
    in many places.)

    After a *lot* of iterations this is the patchset that was agreed upon,
    but of course it is now very late in the cycle. However, because it
    changes both the syntax and semantics of the crashkernel option, it
    would be desirable to avoid a stable release with the broken
    interfaces."

    I'm not happy with the timing, since originally the plan was to release
    the final 3.9 tomorrow. But apparently I'm doing an -rc8 instead...

    * 'x86-kdump-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    kexec: use Crash kernel for Crash kernel low
    x86, kdump: Change crashkernel_high/low= to crashkernel=,high/low
    x86, kdump: Retore crashkernel= to allocate under 896M
    x86, kdump: Set crashkernel_low automatically

    Linus Torvalds
     
  • Pull x86 fixes from Peter Anvin:
    "Three groups of fixes:

    1. Make sure we don't execute the early microcode patching if family
    < 6, since it would touch MSRs which don't exist on those
    families, causing crashes.

    2. The Xen partial emulation of HyperV can be dealt with more
    gracefully than just disabling the driver.

    3. More EFI variable space magic. In particular, variables hidden
    from runtime code need to be taken into account too."

    * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    x86, microcode: Verify the family before dispatching microcode patching
    x86, hyperv: Handle Xen emulation of Hyper-V more gracefully
    x86,efi: Implement efi_no_storage_paranoia parameter
    efi: Export efi_query_variable_store() for efivars.ko
    x86/Kconfig: Make EFI select UCS2_STRING
    efi: Distinguish between "remaining space" and actually used space
    efi: Pass boot services variable info to runtime code
    Move utf16 functions to kernel core and rename
    x86,efi: Check max_size only if it is non-zero.
    x86, efivars: firmware bug workarounds should be in platform code

    Linus Torvalds
     

20 Apr, 2013

1 commit

  • Matt Fleming (1):
    x86, efivars: firmware bug workarounds should be in platform
    code

    Matthew Garrett (3):
    Move utf16 functions to kernel core and rename
    efi: Pass boot services variable info to runtime code
    efi: Distinguish between "remaining space" and actually used
    space

    Richard Weinberger (2):
    x86,efi: Check max_size only if it is non-zero.
    x86,efi: Implement efi_no_storage_paranoia parameter

    Sergey Vlasov (2):
    x86/Kconfig: Make EFI select UCS2_STRING
    efi: Export efi_query_variable_store() for efivars.ko

    Signed-off-by: H. Peter Anvin

    H. Peter Anvin
     

18 Apr, 2013

1 commit

  • Chao said that kdump does does work well on his system on 3.8
    without extra parameter, even iommu does not work with kdump.
    And now have to append crashkernel_low=Y in first kernel to make
    kdump work.

    We have now modified crashkernel=X to allocate memory beyong 4G (if
    available) and do not allocate low range for crashkernel if the user
    does not specify that with crashkernel_low=Y. This causes regression
    if iommu is not enabled. Without iommu, swiotlb needs to be setup in
    first 4G and there is no low memory available to second kernel.

    Set crashkernel_low automatically if the user does not specify that.

    For system that does support IOMMU with kdump properly, user could
    specify crashkernel_low=0 to save that 72M low ram.

    -v3: add swiotlb_size() according to Konrad.
    -v4: add comments what 8M is for according to hpa.
    also update more crashkernel_low= in kernel-parameters.txt
    -v5: update changelog according to Vivek.
    -v6: Change description about swiotlb referring according to HATAYAMA.

    Reported-by: WANG Chao
    Tested-by: WANG Chao
    Signed-off-by: Yinghai Lu
    Link: http://lkml.kernel.org/r/1366089828-19692-2-git-send-email-yinghai@kernel.org
    Acked-by: Vivek Goyal
    Signed-off-by: H. Peter Anvin

    Yinghai Lu
     

16 Apr, 2013

1 commit

  • We want to be able to use the utf16 functions that are currently present
    in the EFI variables code in platform-specific code as well. Move them to
    the kernel core, and in the process rename them to accurately describe what
    they do - they don't handle UTF16, only UCS2.

    Signed-off-by: Matthew Garrett
    Signed-off-by: Matt Fleming

    Matthew Garrett
     

14 Apr, 2013

1 commit

  • Anatol Pomozov identified a race condition that hits module unloading
    and re-loading. To quote Anatol:

    "This is a race codition that exists between kset_find_obj() and
    kobject_put(). kset_find_obj() might return kobject that has refcount
    equal to 0 if this kobject is freeing by kobject_put() in other
    thread.

    Here is timeline for the crash in case if kset_find_obj() searches for
    an object tht nobody holds and other thread is doing kobject_put() on
    the same kobject:

    THREAD A (calls kset_find_obj()) THREAD B (calls kobject_put())
    splin_lock()
    atomic_dec_return(kobj->kref), counter gets zero here
    ... starts kobject cleanup ....
    spin_lock() // WAIT thread A in kobj_kset_leave()
    iterate over kset->list
    atomic_inc(kobj->kref) (counter becomes 1)
    spin_unlock()
    spin_lock() // taken
    // it does not know that thread A increased counter so it
    remove obj from list
    spin_unlock()
    vfree(module) // frees module object with containing kobj

    // kobj points to freed memory area!!
    kobject_put(kobj) // OOPS!!!!

    The race above happens because module.c tries to use kset_find_obj()
    when somebody unloads module. The module.c code was introduced in
    commit 6494a93d55fa"

    Anatol supplied a patch specific for module.c that worked around the
    problem by simply not using kset_find_obj() at all, but rather than make
    a local band-aid, this just fixes kset_find_obj() to be thread-safe
    using the proper model of refusing the get a new reference if the
    refcount has already dropped to zero.

    See examples of this proper refcount handling not only in the kref
    documentation, but in various other equivalent uses of this pattern by
    grepping for atomic_inc_not_zero().

    [ Side note: the module race does indicate that module loading and
    unloading is not properly serialized wrt sysfs information using the
    module mutex. That may require further thought, but this is the
    correct fix at the kobject layer regardless. ]

    Reported-analyzed-and-tested-by: Anatol Pomozov
    Cc: Greg Kroah-Hartman
    Cc: Al Viro
    Cc: stable@vger.kernel.org
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

23 Mar, 2013

3 commits

  • There were reports of the igb driver unmapping buffers without calling
    dma_mapping_error. On closer inspection issues were found in the DMA
    debug API and how it handled multiple mappings of the same buffer.

    The issue I found is the fact that the debug_dma_mapping_error would
    only set the map_err_type to MAP_ERR_CHECKED in the case that the was
    only one match for device and device address. However in the case of
    non-IOMMU, multiple addresses existed and as a result it was not setting
    this field once a second mapping was instantiated. I have resolved this
    by changing the search so that it instead will now set MAP_ERR_CHECKED
    on the first buffer that matches the device and DMA address that is
    currently in the state MAP_ERR_NOT_CHECKED.

    A secondary side effect of this patch is that in the case of multiple
    buffers using the same address only the last mapping will have a valid
    map_err_type. The previous mappings will all end up with map_err_type
    set to MAP_ERR_CHECKED because of the dma_mapping_error call in
    debug_dma_map_page. However this behavior may be preferable as it means
    you will likely only see one real error per multi-mapped buffer, versus
    the current behavior of multiple false errors mer multi-mapped buffer.

    Signed-off-by: Alexander Duyck
    Cc: Joerg Roedel
    Reviewed-by: Shuah Khan
    Tested-by: Shuah Khan
    Cc: Jakub Kicinski
    Cc: Konrad Rzeszutek Wilk
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexander Duyck
     
  • In check_unmap() it is possible to get into a dead-locked state if
    dma_mapping_error is called. The problem is that the bucket is locked in
    check_unmap, and locked again by debug_dma_mapping_error which is called
    by dma_mapping_error. To resolve that we must release the lock on the
    bucket before making the call to dma_mapping_error.

    [akpm@linux-foundation.org: restore 80-col trickery to be consistent with the rest of the file]
    Signed-off-by: Alexander Duyck
    Cc: Joerg Roedel
    Reviewed-by: Shuah Khan
    Tested-by: Shuah Khan
    Cc: Jakub Kicinski
    Cc: Konrad Rzeszutek Wilk
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexander Duyck
     
  • wake_up_klogd() is useless when CONFIG_PRINTK=n because neither printk()
    nor printk_sched() are in use and there are actually no waiter on
    log_wait waitqueue. It should be a stub in this case for users like
    bust_spinlocks().

    Otherwise this results in this warning when CONFIG_PRINTK=n and
    CONFIG_IRQ_WORK=n:

    kernel/built-in.o In function `wake_up_klogd':
    (.text.wake_up_klogd+0xb4): undefined reference to `irq_work_queue'

    To fix this, provide an off-case for wake_up_klogd() when
    CONFIG_PRINTK=n.

    There is much more from console_unlock() and other console related code
    in printk.c that should be moved under CONFIG_PRINTK. But for now,
    focus on a minimal fix as we passed the merged window already.

    [akpm@linux-foundation.org: include printk.h in bust_spinlocks.c]
    Signed-off-by: Frederic Weisbecker
    Reported-by: James Hogan
    Cc: James Hogan
    Cc: Steven Rostedt
    Cc: Peter Zijlstra
    Cc: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Frederic Weisbecker
     

14 Mar, 2013

3 commits

  • GFP_NOIO is often used for idr_alloc() inside preloaded section as the
    allocation mask doesn't really matter. If the idr tree needs to be
    expanded, idr_alloc() first tries to allocate using the specified
    allocation mask and if it fails falls back to the preloaded buffer. This
    order prevent non-preloading idr_alloc() users from taking advantage of
    preloading ones by using preload buffer without filling it shifting the
    burden of allocation to the preload users.

    Unfortunately, this allowed/expected-to-fail kmem_cache allocation ends up
    generating spurious slab lowmem warning before succeeding the request from
    the preload buffer.

    This patch makes idr_layer_alloc() add __GFP_NOWARN to the first
    kmem_cache attempt and try kmem_cache again w/o __GFP_NOWARN after
    allocation from preload_buffer fails so that lowmem warning is generated
    if not suppressed by the original @gfp_mask.

    Signed-off-by: Tejun Heo
    Reported-by: David Teigland
    Tested-by: David Teigland
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tejun Heo
     
  • Commit 5dc49c75a26b ("decompressors: make the default XZ_DEC_* config
    match the selected architecture") added

    default y if POWERPC

    to lib/xz/Kconfig. But there is no Kconfig symbol POWERPC. The most
    general Kconfig symbol for the powerpc architecture is PPC. So let's
    use that.

    Signed-off-by: Paul Bolle
    Cc: Florian Fainelli
    Cc: Lasse Collin
    Cc: Benjamin Herrenschmidt
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Paul Bolle
     
  • Now that all in-kernel users are converted to ues the new alloc
    interface, mark the old interface deprecated. We should be able to
    remove these in a few releases.

    Signed-off-by: Tejun Heo
    Cc: Rusty Russell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tejun Heo
     

13 Mar, 2013

1 commit

  • Fix new kernel-doc warnings in idr:

    Warning(include/linux/idr.h:113): No description found for parameter 'idr'
    Warning(include/linux/idr.h:113): Excess function parameter 'idp' description in 'idr_find'
    Warning(lib/idr.c:232): Excess function parameter 'id' description in 'sub_alloc'
    Warning(lib/idr.c:232): Excess function parameter 'id' description in 'sub_alloc'

    Signed-off-by: Randy Dunlap
    Acked-by: Tejun Heo
    Signed-off-by: Linus Torvalds

    Randy Dunlap
     

09 Mar, 2013

1 commit

  • idr_find(), idr_remove() and idr_replace() used to silently ignore the
    sign bit and perform lookup with the rest of the bits. The weird behavior
    has been changed such that negative IDs are treated as invalid. As the
    behavior change was subtle, WARN_ON_ONCE() was added in the hope of
    determining who's calling idr functions with negative IDs so that they can
    be examined for problems.

    Up until now, all two reported cases are ID number coming directly from
    userland and getting fed into idr_find() and the warnings seem to cause
    more problems than being helpful. Drop the WARN_ON_ONCE()s.

    Signed-off-by: Tejun Heo
    Reported-by:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tejun Heo
     

04 Mar, 2013

1 commit

  • Pull new ImgTec Meta architecture from James Hogan:
    "This adds core architecture support for Imagination's Meta processor
    cores, followed by some later miscellaneous arch/metag cleanups and
    fixes which I kept separate to ease review:

    - Support for basic Meta 1 (ATP) and Meta 2 (HTP) core architecture
    - A few fixes all over, particularly for symbol prefixes
    - A few privilege protection fixes
    - Several cleanups (setup.c includes, split out a lot of
    metag_ksyms.c)
    - Fix some missing exports
    - Convert hugetlb to use vm_unmapped_area()
    - Copy device tree to non-init memory
    - Provide dma_get_sgtable()"

    * tag 'metag-v3.9-rc1-v4' of git://git.kernel.org/pub/scm/linux/kernel/git/jhogan/metag: (61 commits)
    metag: Provide dma_get_sgtable()
    metag: prom.h: remove declaration of metag_dt_memblock_reserve()
    metag: copy devicetree to non-init memory
    metag: cleanup metag_ksyms.c includes
    metag: move mm/init.c exports out of metag_ksyms.c
    metag: move usercopy.c exports out of metag_ksyms.c
    metag: move setup.c exports out of metag_ksyms.c
    metag: move kick.c exports out of metag_ksyms.c
    metag: move traps.c exports out of metag_ksyms.c
    metag: move irq enable out of irqflags.h on SMP
    genksyms: fix metag symbol prefix on crc symbols
    metag: hugetlb: convert to vm_unmapped_area()
    metag: export clear_page and copy_page
    metag: export metag_code_cache_flush_all
    metag: protect more non-MMU memory regions
    metag: make TXPRIVEXT bits explicit
    metag: kernel/setup.c: sort includes
    perf: Enable building perf tools for Meta
    metag: add boot time LNKGET/LNKSET check
    metag: add __init to metag_cache_probe()
    ...

    Linus Torvalds
     

03 Mar, 2013

2 commits

  • Add [!]METAG to a couple of Kconfig dependencies in lib/Kconfig.debug.
    Don't allow stack utilization instrumentation on metag, and allow
    building with frame pointers.

    Signed-off-by: James Hogan
    Cc: Andrew Morton
    Cc: "Paul E. McKenney"
    Cc: Akinobu Mita
    Cc: Michel Lespinasse
    Cc: Catalin Marinas

    James Hogan
     
  • Pull KGDB/KDB fixes and cleanups from Jason Wessel:
    "For a change we removed more code than we added. If people aren't
    using it we shouldn't be carrying it. :-)

    Cleanups:
    - Remove kdb ssb command - there is no in kernel disassembler to
    support it

    - Remove kdb ll command - Always caused a kernel oops and there were
    no bug reports so no one was using this command

    - Use kernel ARRAY_SIZE macro instead of array computations

    Fixes:
    - Stop oops in kdb if user executes kdb_defcmd with args

    - kdb help command truncated text

    - ppc64 support for kgdbts

    - Add missing kconfig option from original kdb port for dealing with
    catastrophic kernel crashes such that you can reboot automatically
    on continue from kdb"

    * tag 'for_linux-3.9' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/kgdb:
    kdb: Remove unhandled ssb command
    kdb: Prevent kernel oops with kdb_defcmd
    kdb: Remove the ll command
    kdb_main: fix help print
    kdb: Fix overlap in buffers with strcpy
    Fixed dead ifdef block by adding missing Kconfig option.
    kdb: Setup basic kdb state before invoking commands via kgdb
    kdb: use ARRAY_SIZE where possible
    kgdb/kgdbts: support ppc64
    kdb: A fix for kdb command table expansion

    Linus Torvalds
     

02 Mar, 2013

2 commits

  • Pull new ARC architecture from Vineet Gupta:
    "Initial ARC Linux port with some fixes on top for 3.9-rc1:

    I would like to introduce the Linux port to ARC Processors (from
    Synopsys) for 3.9-rc1. The patch-set has been discussed on the public
    lists since Nov and has received a fair bit of review, specially from
    Arnd, tglx, Al and other subsystem maintainers for DeviceTree, kgdb...

    The arch bits are in arch/arc, some asm-generic changes (acked by
    Arnd), a minor change to PARISC (acked by Helge).

    The series is a touch bigger for a new port for 2 main reasons:

    1. It enables a basic kernel in first sub-series and adds
    ptrace/kgdb/.. later

    2. Some of the fallout of review (DeviceTree support, multi-platform-
    image support) were added on top of orig series, primarily to
    record the revision history.

    This updated pull request additionally contains

    - fixes due to our GNU tools catching up with the new syscall/ptrace
    ABI

    - some (minor) cross-arch Kconfig updates."

    * tag 'arc-v3.9-rc1-late' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc: (82 commits)
    ARC: split elf.h into uapi and export it for userspace
    ARC: Fixup the current ABI version
    ARC: gdbserver using regset interface possibly broken
    ARC: Kconfig cleanup tracking cross-arch Kconfig pruning in merge window
    ARC: make a copy of flat DT
    ARC: [plat-arcfpga] DT arc-uart bindings change: "baud" => "current-speed"
    ARC: Ensure CONFIG_VIRT_TO_BUS is not enabled
    ARC: Fix pt_orig_r8 access
    ARC: [3.9] Fallout of hlist iterator update
    ARC: 64bit RTSC timestamp hardware issue
    ARC: Don't fiddle with non-existent caches
    ARC: Add self to MAINTAINERS
    ARC: Provide a default serial.h for uart drivers needing BASE_BAUD
    ARC: [plat-arcfpga] defconfig for fully loaded ARC Linux
    ARC: [Review] Multi-platform image #8: platform registers SMP callbacks
    ARC: [Review] Multi-platform image #7: SMP common code to use callbacks
    ARC: [Review] Multi-platform image #6: cpu-to-dma-addr optional
    ARC: [Review] Multi-platform image #5: NR_IRQS defined by ARC core
    ARC: [Review] Multi-platform image #4: Isolate platform headers
    ARC: [Review] Multi-platform image #3: switch to board callback
    ...

    Linus Torvalds
     
  • Added missing Kconfig option KDB_CONTINUE_CATASTROPHIC which lead to a dead
    ifdef block in kernel/debug/kdb/kdb_main.c:73-75.

    The code using KDB_CONTINUE_CATASTROPHIC was originally introduced in
    commit '5d5314d6795f3c1c0f415348ff8c51f7de042b77' by Jason Wessel.
    This patchset ("kdb: core for kgdb back end (1 of 2)")
    added platform independent part of kdb to the linux kernel.

    The Kernel option however, even though it had the same options and
    behaviour on all supported architectures, was part of the x86 and
    ia64 patchset of KDB and therefore not pulled into the mainline kernel tree.

    I actually took the originally written Kconfig by
    Keith Owens (2003-06-20 according to KDB changelog)
    and changed it to reflect the correct behaviour,
    as the KDUMP patchset is not part of the kernel and the expected
    functionality is missing from it.

    Signed-off-by: Robert Obermeier
    Signed-off-by: Jason Wessel

    Robert Obermeier
     

01 Mar, 2013

1 commit

  • Pull LZO compression update from Markus Oberhumer:
    "Summary:
    ========

    Update the Linux kernel LZO compression and decompression code to the
    current upstream version which features significant performance
    improvements on modern machines.

    Some *synthetic* benchmarks:
    ============================

    x86_64 (Sandy Bridge), gcc-4.6 -O3, Silesia test corpus, 256 kB block-size:

    compression speed decompression speed

    LZO-2005 : 150 MB/sec 468 MB/sec
    LZO-2012 : 434 MB/sec 1210 MB/sec

    i386 (Sandy Bridge), gcc-4.6 -O3, Silesia test corpus, 256 kB block-size:

    compression speed decompression speed

    LZO-2005 : 143 MB/sec 409 MB/sec
    LZO-2012 : 372 MB/sec 1121 MB/sec

    armv7 (Cortex-A9), Linaro gcc-4.6 -O3, Silesia test corpus, 256 kB block-size:

    compression speed decompression speed

    LZO-2005 : 27 MB/sec 84 MB/sec
    LZO-2012 : 44 MB/sec 117 MB/sec
    **LZO-2013-UA : 47 MB/sec 167 MB/sec

    Legend:

    LZO-2005 : LZO version in current 3.8 kernel (which is based on
    the LZO 2.02 release from 2005)
    LZO-2012 : updated LZO version available in linux-next
    **LZO-2013-UA : updated LZO version available in linux-next plus experimental
    ARM Unaligned Access patch. This needs approval
    from some ARM maintainer ist NOT YET INCLUDED."

    Andrew Morton acks it and says:
    "There's a new LZ4 on the block which is even faster than the sped-up
    LZO, but various filesystems and things use LZO"

    * tag 'lzo-update-signature-20130226' of git://github.com/markus-oberhumer/linux:
    crypto: testmgr - update LZO compression test vectors
    lib/lzo: Update LZO compression to current upstream version
    lib/lzo: Rename lzo1x_decompress.c to lzo1x_decompress_safe.c

    Linus Torvalds
     

28 Feb, 2013

19 commits

  • I'm not sure why, but the hlist for each entry iterators were conceived

    list_for_each_entry(pos, head, member)

    The hlist ones were greedy and wanted an extra parameter:

    hlist_for_each_entry(tpos, pos, head, member)

    Why did they need an extra pos parameter? I'm not quite sure. Not only
    they don't really need it, it also prevents the iterator from looking
    exactly like the list iterator, which is unfortunate.

    Besides the semantic patch, there was some manual work required:

    - Fix up the actual hlist iterators in linux/list.h
    - Fix up the declaration of other iterators based on the hlist ones.
    - A very small amount of places were using the 'node' parameter, this
    was modified to use 'obj->member' instead.
    - Coccinelle didn't handle the hlist_for_each_entry_safe iterator
    properly, so those had to be fixed up manually.

    The semantic patch which is mostly the work of Peter Senna Tschudin is here:

    @@
    iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;

    type T;
    expression a,c,d,e;
    identifier b;
    statement S;
    @@

    -T b;

    [akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
    [akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
    [akpm@linux-foundation.org: checkpatch fixes]
    [akpm@linux-foundation.org: fix warnings]
    [akpm@linux-foudnation.org: redo intrusive kvm changes]
    Tested-by: Peter Senna Tschudin
    Acked-by: Paul E. McKenney
    Signed-off-by: Sasha Levin
    Cc: Wu Fengguang
    Cc: Marcelo Tosatti
    Cc: Gleb Natapov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sasha Levin
     
  • Fix kfifo_alloc() and kfifo_init() to alloc at least the requested number
    of elements. Since the kfifo operates on power of 2 the request size will
    be rounded up to the next power of two.

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

    Stefani Seibold
     
  • Move kfifo.c from kernel/ to lib/

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

    Stefani Seibold
     
  • Until recently, when an negative ID is specified, idr functions used to
    ignore the sign bit and proceeded with the operation with the rest of
    bits, which is bizarre and error-prone. The behavior recently got changed
    so that negative IDs are treated as invalid but we're triggering
    WARN_ON_ONCE() on negative IDs just in case somebody was depending on the
    sign bit being ignored, so that those can be detected and fixed easily.

    We only need this for a while. Explain why WARN_ON_ONCE()s are there and
    that they can be removed later.

    Signed-off-by: Tejun Heo
    Acked-by: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tejun Heo
     
  • While idr lookup isn't a particularly heavy operation, it still is too
    substantial to use in hot paths without worrying about the performance
    implications. With recent changes, each idr_layer covers 256 slots
    which should be enough to cover most use cases with single idr_layer
    making lookup hint very attractive.

    This patch adds idr->hint which points to the idr_layer which
    allocated an ID most recently and the fast path lookup becomes

    if (look up target's prefix matches that of the hinted layer)
    return hint->ary[ID's offset in the leaf layer];

    which can be inlined.

    idr->hint is set to the leaf node on idr_fill_slot() and cleared from
    free_layer().

    [andriy.shevchenko@linux.intel.com: always do slow path when hint is uninitialized]
    Signed-off-by: Tejun Heo
    Cc: Kirill A. Shutemov
    Cc: Sasha Levin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tejun Heo
     
  • Add a field which carries the prefix of ID the idr_layer covers. This
    will be used to implement lookup hint.

    This patch doesn't make use of the new field and doesn't introduce any
    behavior difference.

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

    Tejun Heo
     
  • Currently, idr->bitmap is declared as an unsigned long which restricts
    the number of bits an idr_layer can contain. All bitops can handle
    arbitrary positive integer bit number and there's no reason for this
    restriction.

    Declare idr_layer->bitmap using DECLARE_BITMAP() instead of a single
    unsigned long.

    * idr_layer->bitmap is now an array. '&' dropped from params to
    bitops.

    * Replaced "== IDR_FULL" tests with bitmap_full() and removed
    IDR_FULL.

    * Replaced find_next_bit() on ~bitmap with find_next_zero_bit().

    * Replaced "bitmap = 0" with bitmap_clear().

    This patch doesn't (or at least shouldn't) introduce any behavior
    changes.

    [akpm@linux-foundation.org: checkpatch fixes]
    Signed-off-by: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tejun Heo
     
  • MAX_IDR_MASK is another weirdness in the idr interface. As idr covers
    whole positive integer range, it's defined as 0x7fffffff or INT_MAX.

    Its usage in idr_find(), idr_replace() and idr_remove() is bizarre.
    They basically mask off the sign bit and operate on the rest, so if
    the caller, by accident, passes in a negative number, the sign bit
    will be masked off and the remaining part will be used as if that was
    the input, which is worse than crashing.

    The constant is visible in idr.h and there are several users in the
    kernel.

    * drivers/i2c/i2c-core.c:i2c_add_numbered_adapter()

    Basically used to test if adap->nr is a negative number which isn't
    -1 and returns -EINVAL if so. idr_alloc() already has negative
    @start checking (w/ WARN_ON_ONCE), so this can go away.

    * drivers/infiniband/core/cm.c:cm_alloc_id()
    drivers/infiniband/hw/mlx4/cm.c:id_map_alloc()

    Used to wrap cyclic @start. Can be replaced with max(next, 0).
    Note that this type of cyclic allocation using idr is buggy. These
    are prone to spurious -ENOSPC failure after the first wraparound.

    * fs/super.c:get_anon_bdev()

    The ID allocated from ida is masked off before being tested whether
    it's inside valid range. ida allocated ID can never be a negative
    number and the masking is unnecessary.

    Update idr_*() functions to fail with -EINVAL when negative @id is
    specified and update other MAX_IDR_MASK users as described above.

    This leaves MAX_IDR_MASK without any user, remove it and relocate
    other MAX_IDR_* constants to lib/idr.c.

    Signed-off-by: Tejun Heo
    Cc: Jean Delvare
    Cc: Roland Dreier
    Cc: Sean Hefty
    Cc: Hal Rosenstock
    Cc: "Marciniszyn, Mike"
    Cc: Jack Morgenstein
    Cc: Or Gerlitz
    Cc: Al Viro
    Acked-by: Wolfram Sang
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tejun Heo
     
  • Most functions in idr fail to deal with the high bits when the idr
    tree grows to the maximum height.

    * idr_get_empty_slot() stops growing idr tree once the depth reaches
    MAX_IDR_LEVEL - 1, which is one depth shallower than necessary to
    cover the whole range. The function doesn't even notice that it
    didn't grow the tree enough and ends up allocating the wrong ID
    given sufficiently high @starting_id.

    For example, on 64 bit, if the starting id is 0x7fffff01,
    idr_get_empty_slot() will grow the tree 5 layer deep, which only
    covers the 30 bits and then proceed to allocate as if the bit 30
    wasn't specified. It ends up allocating 0x3fffff01 without the bit
    30 but still returns 0x7fffff01.

    * __idr_remove_all() will not remove anything if the tree is fully
    grown.

    * idr_find() can't find anything if the tree is fully grown.

    * idr_for_each() and idr_get_next() can't iterate anything if the tree
    is fully grown.

    Fix it by introducing idr_max() which returns the maximum possible ID
    given the depth of tree and replacing the id limit checks in all
    affected places.

    As the idr_layer pointer array pa[] needs to be 1 larger than the
    maximum depth, enlarge pa[] arrays by one.

    While this plugs the discovered issues, the whole code base is
    horrible and in desparate need of rewrite. It's fragile like hell,

    Signed-off-by: Tejun Heo
    Cc: Rusty Russell
    Cc:

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

    Tejun Heo
     
  • The current idr interface is very cumbersome.

    * For all allocations, two function calls - idr_pre_get() and
    idr_get_new*() - should be made.

    * idr_pre_get() doesn't guarantee that the following idr_get_new*()
    will not fail from memory shortage. If idr_get_new*() returns
    -EAGAIN, the caller is expected to retry pre_get and allocation.

    * idr_get_new*() can't enforce upper limit. Upper limit can only be
    enforced by allocating and then freeing if above limit.

    * idr_layer buffer is unnecessarily per-idr. Each idr ends up keeping
    around MAX_IDR_FREE idr_layers. The memory consumed per idr is
    under two pages but it makes it difficult to make idr_layer larger.

    This patch implements the following new set of allocation functions.

    * idr_preload[_end]() - Similar to radix preload but doesn't fail.
    The first idr_alloc() inside preload section can be treated as if it
    were called with @gfp_mask used for idr_preload().

    * idr_alloc() - Allocate an ID w/ lower and upper limits. Takes
    @gfp_flags and can be used w/o preloading. When used inside
    preloaded section, the allocation mask of preloading can be assumed.

    If idr_alloc() can be called from a context which allows sufficiently
    relaxed @gfp_mask, it can be used by itself. If, for example,
    idr_alloc() is called inside spinlock protected region, preloading can
    be used like the following.

    idr_preload(GFP_KERNEL);
    spin_lock(lock);

    id = idr_alloc(idr, ptr, start, end, GFP_NOWAIT);

    spin_unlock(lock);
    idr_preload_end();
    if (id < 0)
    error;

    which is much simpler and less error-prone than idr_pre_get and
    idr_get_new*() loop.

    The new interface uses per-pcu idr_layer buffer and thus the number of
    idr's in the system doesn't affect the amount of memory used for
    preloading.

    idr_layer_alloc() is introduced to handle idr_layer allocations for
    both old and new ID allocation paths. This is a bit hairy now but the
    new interface is expected to replace the old and the internal
    implementation eventually will become simpler.

    Signed-off-by: Tejun Heo
    Cc: Rusty Russell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tejun Heo
     
  • Move slot filling to idr_fill_slot() from idr_get_new_above_int() and
    make idr_get_new_above() directly call it. idr_get_new_above_int() is
    no longer needed and removed.

    This will be used to implement a new ID allocation interface.

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

    Tejun Heo
     
  • idr uses -1, IDR_NEED_TO_GROW and IDR_NOMORE_SPACE to communicate
    exception conditions internally. The return value is later translated
    to errno values using _idr_rc_to_errno().

    This is confusing. Drop the custom ones and consistently use -EAGAIN
    for "tree needs to grow", -ENOMEM for "need more memory" and -ENOSPC for
    "ran out of ID space".

    Due to the weird memory preloading mechanism, [ra]_get_new*() return
    -EAGAIN on memory shortage, so we need to substitute -ENOMEM w/
    -EAGAIN on those interface functions. They'll eventually be cleaned
    up and the translations will go away.

    This patch doesn't introduce any functional changes.

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

    Tejun Heo
     
  • * Move idr_for_each_entry() definition next to other idr related
    definitions.

    * Make id[r|a]_get_new() inline wrappers of id[r|a]_get_new_above().

    This changes the implementation of idr_get_new() but the new
    implementation is trivial. This patch doesn't introduce any
    functional change.

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

    Tejun Heo
     
  • There was only one legitimate use of idr_remove_all() and a lot more of
    incorrect uses (or lack of it). Now that idr_destroy() implies
    idr_remove_all() and all the in-kernel users updated not to use it,
    there's no reason to keep it around. Mark it deprecated so that we can
    later unexport it.

    idr_remove_all() is made an inline function calling __idr_remove_all()
    to avoid triggering deprecated warning on EXPORT_SYMBOL().

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

    Tejun Heo
     
  • idr is silly in quite a few ways, one of which is how it's supposed to
    be destroyed - idr_destroy() doesn't release IDs and doesn't even whine
    if the idr isn't empty. If the caller forgets idr_remove_all(), it
    simply leaks memory.

    Even ida gets this wrong and leaks memory on destruction. There is
    absoltely no reason not to call idr_remove_all() from idr_destroy().
    Nobody is abusing idr_destroy() for shrinking free layer buffer and
    continues to use idr after idr_destroy(), so it's safe to do remove_all
    from destroy.

    In the whole kernel, there is only one place where idr_remove_all() is
    legitimiately used without following idr_destroy() while there are quite
    a few places where the caller forgets either idr_remove_all() or
    idr_destroy() leaking memory.

    This patch makes idr_destroy() call idr_destroy_all() and updates the
    function description accordingly.

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

    Tejun Heo
     
  • The iteration logic of idr_get_next() is borrowed mostly verbatim from
    idr_for_each(). It walks down the tree looking for the slot matching
    the current ID. If the matching slot is not found, the ID is
    incremented by the distance of single slot at the given level and
    repeats.

    The implementation assumes that during the whole iteration id is aligned
    to the layer boundaries of the level closest to the leaf, which is true
    for all iterations starting from zero or an existing element and thus is
    fine for idr_for_each().

    However, idr_get_next() may be given any point and if the starting id
    hits in the middle of a non-existent layer, increment to the next layer
    will end up skipping the same offset into it. For example, an IDR with
    IDs filled between [64, 127] would look like the following.

    [ 0 64 ... ]
    /----/ |
    | |
    NULL [ 64 ... 127 ]

    If idr_get_next() is called with 63 as the starting point, it will try
    to follow down the pointer from 0. As it is NULL, it will then try to
    proceed to the next slot in the same level by adding the slot distance
    at that level which is 64 - making the next try 127. It goes around the
    loop and finds and returns 127 skipping [64, 126].

    Note that this bug also triggers in idr_for_each_entry() loop which
    deletes during iteration as deletions can make layers go away leaving
    the iteration with unaligned ID into missing layers.

    Fix it by ensuring proceeding to the next slot doesn't carry over the
    unaligned offset - ie. use round_up(id + 1, slot_distance) instead of
    id += slot_distance.

    Signed-off-by: Tejun Heo
    Reported-by: David Teigland
    Cc: KAMEZAWA Hiroyuki
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tejun Heo
     
  • For better code reuse use the newly added page iterator to iterate
    through the pages. The offset, length within the page is still
    calculated by the mapping iterator as well as the actual mapping. Idea
    from Tejun Heo.

    Signed-off-by: Imre Deak
    Cc: Maxim Levitsky
    Cc: Tejun Heo
    Cc: Daniel Vetter
    Cc: James Hogan
    Cc: Stephen Warren
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Imre Deak
     
  • Add an iterator to walk through a scatter list a page at a time starting
    at a specific page offset. As opposed to the mapping iterator this is
    meant to be small, performing well even in simple loops like collecting
    all pages on the scatterlist into an array or setting up an iommu table
    based on the pages' DMA address.

    Signed-off-by: Imre Deak
    Cc: Maxim Levitsky
    Cc: Tejun Heo
    Cc: Daniel Vetter
    Tested-by: Stephen Warren
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Imre Deak
     
  • A misplaced #endif causes link errors related to pcim_*() functions.

    This is because pcim_*() functions are related to CONFIG_PCI option,
    however these are not related to CONFIG_HAS_IOPORT option. Therefore,
    when CONFIG_PCI is enabled and CONFIG_HAS_IOPORT is not enabled, it makes
    link errors related to pcim_*() functions as below:

    drivers/ata/libata-sff.c:3233: undefined reference to `pcim_iomap_regions'
    drivers/ata/libata-sff.c:3238: undefined reference to `pcim_iomap_table'
    drivers/built-in.o: In function `ata_pci_sff_init_host':
    drivers/ata/libata-sff.c:2318: undefined reference to `pcim_iomap_regions'
    drivers/ata/libata-sff.c:2329: undefined reference to `pcim_iomap_table

    Signed-off-by: Jingoo Han
    Cc: Greg KH
    Cc: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jingoo Han
     

26 Feb, 2013

1 commit

  • Pull module update from Rusty Russell:
    "The sweeping change is to make add_taint() explicitly indicate whether
    to disable lockdep, but it's a mechanical change."

    * tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
    MODSIGN: Add option to not sign modules during modules_install
    MODSIGN: Add -s option to sign-file
    MODSIGN: Specify the hash algorithm on sign-file command line
    MODSIGN: Simplify Makefile with a Kconfig helper
    module: clean up load_module a little more.
    modpost: Ignore ARC specific non-alloc sections
    module: constify within_module_*
    taint: add explicit flag to show whether lock dep is still OK.
    module: printk message when module signature fail taints kernel.

    Linus Torvalds