23 Jan, 2016

1 commit

  • Merge misc fixes from Andrew Morton:
    "Six fixes"

    * emailed patches from Andrew Morton :
    ocfs2: NFS hangs in __ocfs2_cluster_lock due to race with ocfs2_unblock_lock
    reiserfs: fix dereference of ERR_PTR
    ratelimit: fix bug in time interval by resetting right begin time
    mm: fix kernel crash in khugepaged thread
    mm: fix mlock accouting
    thp: change pmd_trans_huge_lock() interface to return ptl

    Linus Torvalds
     

22 Jan, 2016

4 commits

  • Pull block driver updates from Jens Axboe:
    "This is the block driver pull request for 4.5, with the exception of
    NVMe, which is in a separate branch and will be posted after this one.

    This pull request contains:

    - A set of bcache stability fixes, which have been acked by Kent.
    These have been used and tested for more than a year by the
    community, so it's about time that they got in.

    - A set of drbd updates from the drbd team (Andreas, Lars, Philipp)
    and Markus Elfring, Oleg Drokin.

    - A set of fixes for xen blkback/front from the usual suspects, (Bob,
    Konrad) as well as community based fixes from Kiri, Julien, and
    Peng.

    - A 2038 time fix for sx8 from Shraddha, with a fix from me.

    - A small mtip32xx cleanup from Zhu Yanjun.

    - A null_blk division fix from Arnd"

    * 'for-4.5/drivers' of git://git.kernel.dk/linux-block: (71 commits)
    null_blk: use sector_div instead of do_div
    mtip32xx: restrict variables visible in current code module
    xen/blkfront: Fix crash if backend doesn't follow the right states.
    xen/blkback: Fix two memory leaks.
    xen/blkback: make st_ statistics per ring
    xen/blkfront: Handle non-indirect grant with 64KB pages
    xen-blkfront: Introduce blkif_ring_get_request
    xen-blkback: clear PF_NOFREEZE for xen_blkif_schedule()
    xen/blkback: Free resources if connect_ring failed.
    xen/blocks: Return -EXX instead of -1
    xen/blkback: make pool of persistent grants and free pages per-queue
    xen/blkback: get the number of hardware queues/rings from blkfront
    xen/blkback: pseudo support for multi hardware queues/rings
    xen/blkback: separate ring information out of struct xen_blkif
    xen/blkfront: correct setting for xen_blkif_max_ring_order
    xen/blkfront: make persistent grants pool per-queue
    xen/blkfront: Remove duplicate setting of ->xbdev.
    xen/blkfront: Cleanup of comments, fix unaligned variables, and syntax errors.
    xen/blkfront: negotiate number of queues/rings to be used with backend
    xen/blkfront: split per device io_lock
    ...

    Linus Torvalds
     
  • rs->begin in ratelimit is set in two cases.
    1) when rs->begin was not initialized
    2) when rs->interval was passed

    For case #2, current ratelimit sets the begin to 0. This incurrs
    improper suppression. The begin value will be set in the next ratelimit
    call by 1). Then the time interval check will be always false, and
    rs->printed will not be initialized. Although enough time passed,
    ratelimit may return 0 if rs->printed is not less than rs->burst. To
    reset interval properly, begin should be jiffies rather than 0.

    For an example code below:

    static DEFINE_RATELIMIT_STATE(mylimit, 1, 1);
    for (i = 1; i
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jaewon Kim
     
  • Expose an interface to allow users to mark several accesses together as
    being user space accesses, allowing batching of the surrounding user
    space access markers (SMAP on x86, PAN on arm64, domain register
    switching on arm).

    This is currently only used for the user string lenth and copying
    functions, where the SMAP overhead on x86 drowned the actual user
    accesses (only noticeable on newer microarchitectures that support SMAP
    in the first place, of course).

    * user access batching branch:
    Use the new batched user accesses in generic user string handling
    Add 'unsafe' user access functions for batched accesses
    x86: reorganize SMAP handling in user space accesses

    Linus Torvalds
     
  • Merge third patch-bomb from Andrew Morton:
    "I'm pretty much done for -rc1 now:

    - the rest of MM, basically

    - lib/ updates

    - checkpatch, epoll, hfs, fatfs, ptrace, coredump, exit

    - cpu_mask simplifications

    - kexec, rapidio, MAINTAINERS etc, etc.

    - more dma-mapping cleanups/simplifications from hch"

    * emailed patches from Andrew Morton : (109 commits)
    MAINTAINERS: add/fix git URLs for various subsystems
    mm: memcontrol: add "sock" to cgroup2 memory.stat
    mm: memcontrol: basic memory statistics in cgroup2 memory controller
    mm: memcontrol: do not uncharge old page in page cache replacement
    Documentation: cgroup: add memory.swap.{current,max} description
    mm: free swap cache aggressively if memcg swap is full
    mm: vmscan: do not scan anon pages if memcg swap limit is hit
    swap.h: move memcg related stuff to the end of the file
    mm: memcontrol: replace mem_cgroup_lruvec_online with mem_cgroup_online
    mm: vmscan: pass memcg to get_scan_count()
    mm: memcontrol: charge swap to cgroup2
    mm: memcontrol: clean up alloc, online, offline, free functions
    mm: memcontrol: flatten struct cg_proto
    mm: memcontrol: rein in the CONFIG space madness
    net: drop tcp_memcontrol.c
    mm: memcontrol: introduce CONFIG_MEMCG_LEGACY_KMEM
    mm: memcontrol: allow to disable kmem accounting for cgroup2
    mm: memcontrol: account "kmem" consumers in cgroup2 memory controller
    mm: memcontrol: move kmem accounting code to CONFIG_MEMCG
    mm: memcontrol: separate kmem code from legacy tcp accounting code
    ...

    Linus Torvalds
     

21 Jan, 2016

16 commits

  • Pull asm-generic updates from Arnd Bergmann:
    "The asm-generic tree this time contains one series from Nicolas Pitre
    that makes the optimized do_div() implementation from the ARM
    architecture available to all architectures.

    This also adds stricter type checking for callers of do_div, which has
    uncovered a number of bugs in existing code, and fixes up the ones we
    have found"

    * tag 'asm-generic-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic:
    ARM: asm/div64.h: adjust to generic codde
    __div64_32(): make it overridable at compile time
    __div64_const32(): abstract out the actual 128-bit cross product code
    do_div(): generic optimization for constant divisor on 32-bit machines
    div64.h: optimize do_div() for power-of-two constant divisors
    mtd/sm_ftl.c: fix wrong do_div() usage
    drm/mgag200/mgag200_mode.c: fix wrong do_div() usage
    hid-sensor-hub.c: fix wrong do_div() usage
    ti/fapll: fix wrong do_div() usage
    ti/clkt_dpll: fix wrong do_div() usage
    tegra/clk-divider: fix wrong do_div() usage
    imx/clk-pllv2: fix wrong do_div() usage
    imx/clk-pllv1: fix wrong do_div() usage
    nouveau/nvkm/subdev/clk/gk20a.c: fix wrong do_div() usage

    Linus Torvalds
     
  • Larry Finger reports:
    "My PowerBook G4 Aluminum with a 32-bit PPC processor fails to boot for
    the 4.4-git series".

    This is likely due to X still needing /dev/mem access on this platform.

    CONFIG_IO_STRICT_DEVMEM is not yet safe to turn on when
    CONFIG_STRICT_DEVMEM=y.

    Remove the default so that old configurations do not change behavior.

    Fixes: 90a545e98126 ("restrict /dev/mem to idle io memory ranges")
    Reported-by: Larry Finger
    Tested-by: Larry Finger
    Link: http://marc.info/?l=linux-kernel&m=145332012023825&w=2
    Acked-by: Kees Cook
    Cc: Arnd Bergmann
    Cc: Ingo Molnar
    Cc: Russell King
    Cc: Andrew Morton
    Cc: Greg Kroah-Hartman
    Signed-off-by: Dan Williams
    Signed-off-by: Linus Torvalds

    Dan Williams
     
  • UBSAN uses compile-time instrumentation to catch undefined behavior
    (UB). Compiler inserts code that perform certain kinds of checks before
    operations that could cause UB. If check fails (i.e. UB detected)
    __ubsan_handle_* function called to print error message.

    So the most of the work is done by compiler. This patch just implements
    ubsan handlers printing errors.

    GCC has this capability since 4.9.x [1] (see -fsanitize=undefined
    option and its suboptions).
    However GCC 5.x has more checkers implemented [2].
    Article [3] has a bit more details about UBSAN in the GCC.

    [1] - https://gcc.gnu.org/onlinedocs/gcc-4.9.0/gcc/Debugging-Options.html
    [2] - https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html
    [3] - http://developerblog.redhat.com/2014/10/16/gcc-undefined-behavior-sanitizer-ubsan/

    Issues which UBSAN has found thus far are:

    Found bugs:

    * out-of-bounds access - 97840cb67ff5 ("netfilter: nfnetlink: fix
    insufficient validation in nfnetlink_bind")

    undefined shifts:

    * d48458d4a768 ("jbd2: use a better hash function for the revoke
    table")

    * 10632008b9e1 ("clockevents: Prevent shift out of bounds")

    * 'x << -1' shift in ext4 -
    http://lkml.kernel.org/r/

    * undefined rol32(0) -
    http://lkml.kernel.org/r/

    * undefined dirty_ratelimit calculation -
    http://lkml.kernel.org/r/

    * undefined roundown_pow_of_two(0) -
    http://lkml.kernel.org/r/

    * [WONTFIX] undefined shift in __bpf_prog_run -
    http://lkml.kernel.org/r/

    WONTFIX here because it should be fixed in bpf program, not in kernel.

    signed overflows:

    * 32a8df4e0b33f ("sched: Fix odd values in effective_load()
    calculations")

    * mul overflow in ntp -
    http://lkml.kernel.org/r/

    * incorrect conversion into rtc_time in rtc_time64_to_tm() -
    http://lkml.kernel.org/r/

    * unvalidated timespec in io_getevents() -
    http://lkml.kernel.org/r/

    * [NOTABUG] signed overflow in ktime_add_safe() -
    http://lkml.kernel.org/r/

    [akpm@linux-foundation.org: fix unused local warning]
    [akpm@linux-foundation.org: fix __int128 build woes]
    Signed-off-by: Andrey Ryabinin
    Cc: Peter Zijlstra
    Cc: Sasha Levin
    Cc: Randy Dunlap
    Cc: Rasmus Villemoes
    Cc: Jonathan Corbet
    Cc: Michal Marek
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: "H. Peter Anvin"
    Cc: Yury Gribov
    Cc: Dmitry Vyukov
    Cc: Konstantin Khlebnikov
    Cc: Kostya Serebryany
    Cc: Johannes Berg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Ryabinin
     
  • The clz table (__clz_tab) in lib/clz_tab.c is also provided as part of
    libgcc.a, and many architectures link against libgcc. To allow the
    linker to avoid a multiple-definition link failure, clz_tab.o has to be
    in lib/lib.a rather than lib/builtin.o. The specific issue is that
    libgcc.a comes before lib/builtin.o on vmlinux.o's link command line, so
    its _clz.o is pulled to satisfy __clz_tab, and then when the remainder
    of lib/builtin.o is pulled in to satisfy all the other dependencies, the
    __clz_tab symbols conflict. By putting clz_tab.o in lib.a, the linker
    can simply avoid pulling it into vmlinux.o when this situation arises.

    The definitions of __clz_tab are the same in libgcc.a and in the kernel;
    arguably we could also simply rename the kernel version, but it's
    unlikely the libgcc version will ever change to become incompatible, so
    just using it seems reasonably safe.

    Signed-off-by: Chris Metcalf
    Acked-by: David S. Miller
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Chris Metcalf
     
  • Like others test are doing print the gathered statistics after test module
    is finished. Return from the module based on the result.

    Signed-off-by: Andy Shevchenko
    Acked-by: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • Currently the only one combination is tested for overflow, i.e. rowsize =
    16, groupsize = 1, len = 1. Do various test to go through all possible
    branches.

    Signed-off-by: Andy Shevchenko
    Cc: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • After processing by hex_dump_to_buffer() check all the parts to be expected.

    Part 1. The actual expected hex dump with or without ASCII part.

    Part 2. Check if the buffer is dirty beyond needed.

    Part 3. Return code should be as expected.

    This is done by using comparison of the return code and memcmp() against
    the test buffer. We fill the buffer by FILL_CHAR ('#') characters, so, we
    expect to have a tail of the buffer will be left untouched. The
    terminating NUL is also checked by memcmp().

    Signed-off-by: Andy Shevchenko
    Cc: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • Better to use memcmp() against entire buffer to check that nothing is
    happened to the data in the tail.

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

    Andy Shevchenko
     
  • The magic numbers of the length are converted to their actual meaning,
    such as end of the buffer with and without ASCII part.

    We don't touch the rest of the magic constants that will be removed in the
    following commits.

    Signed-off-by: Andy Shevchenko
    Cc: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • When test for overflow do iterate the buffer length in a range 0 ..
    BUF_SIZE.

    Signed-off-by: Andy Shevchenko
    Cc: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • Define a character to fill the test buffers. Though the character should
    be printable since it's used when errors are reported. It should neither
    be from hex digit [a-fA-F0-9] dictionary nor space. It is recommended not
    to use one which is present in ASCII part of the test data. Later on we
    might switch to unprintable character to make test case more robust.

    Signed-off-by: Andy Shevchenko
    Suggested-by: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • The function prepares the expected result in the provided buffer.

    Signed-off-by: Andy Shevchenko
    Acked-by: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • The test suite currently doesn't cover many corner cases when
    hex_dump_to_buffer() runs into overflow. Refactor and amend test suite
    to cover most of the cases.

    This patch (of 9):

    Just to follow the scheme that most of the test modules are using.

    There is no fuctional change.

    Signed-off-by: Andy Shevchenko
    Acked-by: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • Some drivers need to read data out of iomem areas 32-bits at a time.
    Add an API to do this.

    Signed-off-by: Stephen Boyd
    Cc: Bjorn Andersson
    Cc:
    Cc: David Howells
    Cc: Hauke Mehrtens
    Cc: Paul Walmsley
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Boyd
     
  • It was noticed that we lose precision in the final calculation for some
    inputs. The most egregious example is size=3000 blk_size=1900 in units
    of 10 should yield 5.70 MB but in fact yields 3.00 MB (oops).

    This is because the current algorithm doesn't correctly account for
    all the remainders in the logarithms. Fix this by doing a correct
    calculation in the remainders based on napier's algorithm.

    Additionally, now we have the correct result, we have to account for
    arithmetic rounding because we're printing 3 digits of precision. This
    means that if the fourth digit is five or greater, we have to round up,
    so add a section to ensure correct rounding. Finally account for all
    possible inputs correctly, including zero for block size.

    Fixes: b9f28d863594c429e1df35a0474d2663ca28b307
    Signed-off-by: James Bottomley
    Reported-by: Vitaly Kuznetsov
    Cc: [delay until after 4.4 release]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    James Bottomley
     
  • Fix the following build warning:

    lib/libcrc32c.c:42:5: warning: no previous prototype for "crc32c" [-Wmissing-prototypes]
    u32 crc32c(u32 crc, const void *address, unsigned int length)
    ^

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

    Jean Delvare
     

18 Jan, 2016

1 commit

  • …/git/shuah/linux-kselftest

    Pull kselftest updates from Shuah Khan:
    "This 14 patch update:

    - adds a new test for intel_pstate driver
    - adds empty string and async test cases to firmware class tests
    - fixes and cleans up several existing tests"

    * tag 'linux-kselftest-4.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
    selftests: firmware: add empty string and async tests
    firmware: actually return NULL on failed request_firmware_nowait()
    test: firmware_class: add asynchronous request trigger
    test: firmware_class: use kstrndup() where appropriate
    test: firmware_class: report errors properly on failure
    selftests/seccomp: fix 32-bit build warnings
    add breakpoints/.gitignore
    add ptrace/.gitignore
    update .gitignore in selftests/timers
    update .gitignore in selftests/vm
    tools, testing, add test for intel_pstate driver
    selftest/ipc: actually test it
    selftests/capabilities: actually test it
    selftests/capabilities: clean up for Makefile

    Linus Torvalds
     

17 Jan, 2016

17 commits

  • Move switch case to the netdev_features_string() and rename it to
    netdev_bits(). In the future we can extend it as needed.

    Here we replace the fallback of %pN from '%p' with possible flags to
    sticter '0x%p' without any flags variation.

    Signed-off-by: Andy Shevchenko
    Cc: Rasmus Villemoes
    Cc: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • special_hex_number() is a helper to print a fixed size type in a hex
    format with '0x' prefix, zero padding, and small letters. In the module
    we have already several copies of such code. Consolidate them under
    special_hex_number() helper.

    There are couple of differences though.

    It seems nobody cared about the output in case of CONFIG_KALLSYMS=n,
    when printing symbol address, because the asked field width is not
    enough to care last 2 characters in the string represantation of the
    pointer. Fixed here.

    The %pNF specifier used to be allowed with a specific field width,
    though there is neither any user of it nor mention the possibility in
    the documentation.

    Signed-off-by: Andy Shevchenko
    Cc: Rasmus Villemoes
    Cc: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • Signed-off-by: Rasmus Villemoes
    Cc: Al Viro
    Cc: Andy Shevchenko
    Cc: Ingo Molnar
    Cc: Joe Perches
    Cc: Kees Cook
    Cc: Maurizio Lombardi
    Cc: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • Following "lib/vsprintf.c: expand field_width to 24 bits", let's add a
    test to see that we now actually support bitmaps with 65536 bits.

    Signed-off-by: Rasmus Villemoes
    Acked-by: Kees Cook
    Cc: Al Viro
    Cc: Andy Shevchenko
    Cc: Ingo Molnar
    Cc: Joe Perches
    Cc: Maurizio Lombardi
    Cc: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • These should also count as performed tests.

    Signed-off-by: Rasmus Villemoes
    Acked-by: Kees Cook
    Cc: Al Viro
    Cc: Andy Shevchenko
    Cc: Ingo Molnar
    Cc: Joe Perches
    Cc: Maurizio Lombardi
    Cc: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • This adds a few tests to test_number, one of which serves to document
    another deviation from POSIX/C99 (printing 0 with an explicit precision
    of 0).

    Signed-off-by: Rasmus Villemoes
    Cc: Al Viro
    Cc: Andy Shevchenko
    Cc: Ingo Molnar
    Cc: Joe Perches
    Cc: Kees Cook
    Cc: Maurizio Lombardi
    Cc: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • The kernel's printf doesn't follow the standards in a few corner cases
    (which are probably mostly irrelevant). Add tests that document the
    current behaviour.

    Signed-off-by: Rasmus Villemoes
    Cc: Al Viro
    Cc: Andy Shevchenko
    Cc: Ingo Molnar
    Cc: Joe Perches
    Cc: Kees Cook
    Cc: Maurizio Lombardi
    Cc: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • Add a few padding bytes on either side of the test buffer, and check
    that these (and the part of the buffer not used) are untouched by
    vsnprintf.

    Signed-off-by: Rasmus Villemoes
    Acked-by: Kees Cook
    Cc: Al Viro
    Cc: Andy Shevchenko
    Cc: Ingo Molnar
    Cc: Joe Perches
    Cc: Maurizio Lombardi
    Cc: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • BUG is a completely unnecessarily big hammer, and we're more likely to
    get the internal bug reported if we just pr_err() and ensure the test
    suite fails.

    Signed-off-by: Rasmus Villemoes
    Acked-by: Kees Cook
    Cc: Al Viro
    Cc: Andy Shevchenko
    Cc: Ingo Molnar
    Cc: Joe Perches
    Cc: Maurizio Lombardi
    Cc: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • kasprintf relies on being able to replay the formatting and getting the
    same result (in particular, the same length). This will almost always
    work, but it is possible that the object pointed to by a %s or %p
    argument changed under us (so we might get truncated output). Add a
    somewhat paranoid sanity check and let's see if it ever triggers.

    Signed-off-by: Rasmus Villemoes
    Cc: Al Viro
    Cc: Andy Shevchenko
    Cc: Ingo Molnar
    Cc: Joe Perches
    Cc: Kees Cook
    Cc: Maurizio Lombardi
    Cc: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • The field width is overloaded to pass some extra information for some %p
    extensions (e.g. #bits for %pb). But we might silently truncate the
    passed value when we stash it in struct printf_spec (see e.g.
    "lib/vsprintf.c: expand field_width to 24 bits"). Hopefully 23 value
    bits should now be enough for everybody, but if not, let's make some
    noise.

    Do the same for the precision. In both cases, clamping seems more
    sensible than truncating. While, according to POSIX, "A negative
    precision is taken as if the precision were omitted.", the kernel's
    printf has always treated that case as if the precision was 0, so we use
    that as lower bound. For the field width, the smallest representable
    value is actually -(1<
    Cc: Al Viro
    Cc: Andy Shevchenko
    Cc: Ingo Molnar
    Cc: Joe Perches
    Cc: Kees Cook
    Cc: Maurizio Lombardi
    Cc: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • One consequence of the reorganization of struct printf_spec to make
    field_width 24 bits was that number() gained about 180 bytes. Since
    spec is never passed to other functions, we can help gcc make number()
    lose most of that extra weight by using local variables for the field
    width and precision.

    Reviewed-by: Andy Shevchenko
    Signed-off-by: Rasmus Villemoes
    Cc: Al Viro
    Cc: Ingo Molnar
    Cc: Joe Perches
    Cc: Kees Cook
    Cc: Maurizio Lombardi
    Cc: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • Maurizio Lombardi reported a problem [1] with the %pb extension: It
    doesn't work for sufficiently large bitmaps, since the size is stashed
    in the field_width field of the struct printf_spec, which is currently
    an s16. Concretely, this manifested itself in
    /sys/bus/pseudo/drivers/scsi_debug/map being empty, since the bitmap
    printer got a size of 0, which is the 16 bit truncation of the actual
    bitmap size.

    We do want to keep struct printf_spec at 8 bytes so that it can cheaply
    be passed by value. The qualifier field is only used for internal
    bookkeeping in format_decode, so we might as well use a local variable
    for that. This gives us an additional 8 bits, which we can then use for
    the field width.

    To stay in 8 bytes, we need to do a little rearranging and make the type
    member a bitfield as well. For consistency, change all the members to
    bit fields. gcc doesn't generate much worse code with these changes (in
    fact, bloat-o-meter says we save 300 bytes - which I think is a little
    surprising).

    I didn't find a BUILD_BUG/compiletime_assertion/... which would work
    outside function context, so for now I just open-coded it.

    [1] http://thread.gmane.org/gmane.linux.kernel/2034835

    [akpm@linux-foundation.org: avoid open-coded BUILD_BUG_ON]
    Signed-off-by: Rasmus Villemoes
    Reported-by: Maurizio Lombardi
    Acked-by: Tejun Heo
    Cc: Al Viro
    Cc: Andy Shevchenko
    Cc: Ingo Molnar
    Cc: Joe Perches
    Cc: Kees Cook
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • If the string corresponding to a %s specifier can change under us, we
    might end up copying a \0 byte to the output buffer. There might be
    callers who expect the output buffer to contain a genuine C string whose
    length is exactly the snprintf return value (assuming truncation hasn't
    happened or has been checked for).

    We can avoid this by only passing over the source string once, stopping
    the first time we meet a nul byte (or when we reach the given
    precision), and then letting widen_string() handle left/right space
    padding. As a small bonus, this code reuse also makes the generated
    code slightly smaller.

    Signed-off-by: Rasmus Villemoes
    Cc: Al Viro
    Cc: Andy Shevchenko
    Cc: Ingo Molnar
    Cc: Joe Perches
    Cc: Kees Cook
    Cc: Maurizio Lombardi
    Cc: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • This is pure code movement, making sure the widen_string() helper is
    defined before the string() function.

    Signed-off-by: Rasmus Villemoes
    Cc: Al Viro
    Cc: Andy Shevchenko
    Cc: Ingo Molnar
    Cc: Joe Perches
    Cc: Kees Cook
    Cc: Maurizio Lombardi
    Cc: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • Pull out the logic in dentry_name() which handles field width space
    padding, in preparation for reusing it from string(). Rename the
    widen() helper to move_right(), since it is used for handling the
    !(flags & LEFT) case.

    Signed-off-by: Rasmus Villemoes
    Cc: Al Viro
    Cc: Andy Shevchenko
    Cc: Ingo Molnar
    Cc: Joe Perches
    Cc: Kees Cook
    Cc: Maurizio Lombardi
    Cc: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • As illustrated by commit a3afe70b83fd ("[S390] latencytop s390
    support."), HAVE_LATENCYTOP_SUPPORT is defined by an architecture to
    advertise an implementation of save_stack_trace_tsk.

    However, as of 9212ddb5eada ("stacktrace: provide save_stack_trace_tsk()
    weak alias") a dummy implementation is provided if STACKTRACE=y. Given
    that LATENCYTOP already depends on STACKTRACE_SUPPORT and selects
    STACKTRACE, we can remove HAVE_LATENCYTOP_SUPPORT altogether.

    Signed-off-by: Will Deacon
    Acked-by: Heiko Carstens
    Cc: Vineet Gupta
    Cc: Russell King
    Cc: James Hogan
    Cc: Michal Simek
    Cc: Helge Deller
    Acked-by: Michael Ellerman
    Cc: "David S. Miller"
    Cc: Guan Xuetao
    Cc: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Will Deacon
     

16 Jan, 2016

1 commit

  • get_dev_page() enables paths like get_user_pages() to pin a dynamically
    mapped pfn-range (devm_memremap_pages()) while the resulting struct page
    objects are in use. Unlike get_page() it may fail if the device is, or
    is in the process of being, disabled. While the initial lookup of the
    range may be an expensive list walk, the result is cached to speed up
    subsequent lookups which are likely to be in the same mapped range.

    devm_memremap_pages() now requires a reference counter to be specified
    at init time. For pmem this means moving request_queue allocation into
    pmem_alloc() so the existing queue usage counter can track "device
    pages".

    ZONE_DEVICE pages always have an elevated count and will never be on an
    lru reclaim list. That space in 'struct page' can be redirected for
    other uses, but for safety introduce a poison value that will always
    trip __list_add() to assert. This allows half of the struct list_head
    storage to be reclaimed with some assurance to back up the assumption
    that the page count never goes to zero and a list_add() is never
    attempted.

    Signed-off-by: Dan Williams
    Tested-by: Logan Gunthorpe
    Cc: Dave Hansen
    Cc: Matthew Wilcox
    Cc: Ross Zwisler
    Cc: Alexander Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Dan Williams