11 Jul, 2017

40 commits

  • Fixes the following false warning among others for LLIST_HEAD and
    PLIST_HEAD:

    WARNING: Missing a blank line after declarations
    #71: FILE: drivers/s390/scsi/zfcp_fsf.c:422:
    + struct hlist_node *tmp;
    + HLIST_HEAD(remove_queue);

    Link: http://lkml.kernel.org/r/20170614133512.89425-1-maier@linux.vnet.ibm.com
    Signed-off-by: Steffen Maier
    Acked-by: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Steffen Maier
     
  • For consistency, MAINTAINERS entries should be an upper case letter,
    then a colon, then a tab, then the value.

    Warn when an entry doesn't have this form. --fix it too.

    Link: http://lkml.kernel.org/r/9aaaf03ec10adf3888b5e98dd2176b7fe9b5fad8.1496343345.git.joe@perches.com
    Signed-off-by: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • Use the context around a patch to avoid missing some candidates.

    Link: http://lkml.kernel.org/r/865e874fbae5decc331a849bd8d71c325db6bc80.1496343345.git.joe@perches.com
    Signed-off-by: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • There is a slightly faster way (in terms of the number of instructions
    being used) to calculate the position of a middle element, preserving
    integer overflow safeness.

    ./scripts/bloat-o-meter lib/bsearch.o.old lib/bsearch.o.new
    add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-24 (-24)
    function old new delta
    bsearch 122 98 -24

    TEST

    INT array of size 100001, elements [0..100000]. gcc 7.1, Os, x86_64.

    a) bsearch() of existing key "100001 - 2":

    BASE
    ====

    $ perf stat ./a.out

    Performance counter stats for './a.out':

    619.445196 task-clock:u (msec) # 0.999 CPUs utilized
    0 context-switches:u # 0.000 K/sec
    0 cpu-migrations:u # 0.000 K/sec
    133 page-faults:u # 0.215 K/sec
    1,949,517,279 cycles:u # 3.147 GHz (83.06%)
    181,017,938 stalled-cycles-frontend:u # 9.29% frontend cycles idle (83.05%)
    82,959,265 stalled-cycles-backend:u # 4.26% backend cycles idle (67.02%)
    4,355,706,383 instructions:u # 2.23 insn per cycle
    # 0.04 stalled cycles per insn (83.54%)
    1,051,539,242 branches:u # 1697.550 M/sec (83.54%)
    15,263,381 branch-misses:u # 1.45% of all branches (83.43%)

    0.620082548 seconds time elapsed

    PATCHED
    =======

    $ perf stat ./a.out

    Performance counter stats for './a.out':

    475.097316 task-clock:u (msec) # 0.999 CPUs utilized
    0 context-switches:u # 0.000 K/sec
    0 cpu-migrations:u # 0.000 K/sec
    135 page-faults:u # 0.284 K/sec
    1,487,467,717 cycles:u # 3.131 GHz (82.95%)
    186,537,162 stalled-cycles-frontend:u # 12.54% frontend cycles idle (82.93%)
    28,797,869 stalled-cycles-backend:u # 1.94% backend cycles idle (67.10%)
    3,807,564,203 instructions:u # 2.56 insn per cycle
    # 0.05 stalled cycles per insn (83.57%)
    1,049,344,291 branches:u # 2208.693 M/sec (83.60%)
    5,485 branch-misses:u # 0.00% of all branches (83.58%)

    0.475760235 seconds time elapsed

    b) bsearch() of un-existing key "100001 + 2":

    BASE
    ====

    $ perf stat ./a.out

    Performance counter stats for './a.out':

    499.244480 task-clock:u (msec) # 0.999 CPUs utilized
    0 context-switches:u # 0.000 K/sec
    0 cpu-migrations:u # 0.000 K/sec
    132 page-faults:u # 0.264 K/sec
    1,571,194,855 cycles:u # 3.147 GHz (83.18%)
    13,450,980 stalled-cycles-frontend:u # 0.86% frontend cycles idle (83.18%)
    21,256,072 stalled-cycles-backend:u # 1.35% backend cycles idle (66.78%)
    4,171,197,909 instructions:u # 2.65 insn per cycle
    # 0.01 stalled cycles per insn (83.68%)
    1,009,175,281 branches:u # 2021.405 M/sec (83.79%)
    3,122 branch-misses:u # 0.00% of all branches (83.37%)

    0.499871144 seconds time elapsed

    PATCHED
    =======

    $ perf stat ./a.out

    Performance counter stats for './a.out':

    399.023499 task-clock:u (msec) # 0.998 CPUs utilized
    0 context-switches:u # 0.000 K/sec
    0 cpu-migrations:u # 0.000 K/sec
    134 page-faults:u # 0.336 K/sec
    1,245,793,991 cycles:u # 3.122 GHz (83.39%)
    11,529,273 stalled-cycles-frontend:u # 0.93% frontend cycles idle (83.46%)
    12,116,311 stalled-cycles-backend:u # 0.97% backend cycles idle (66.92%)
    3,679,710,005 instructions:u # 2.95 insn per cycle
    # 0.00 stalled cycles per insn (83.47%)
    1,009,792,625 branches:u # 2530.660 M/sec (83.46%)
    2,590 branch-misses:u # 0.00% of all branches (83.12%)

    0.399733539 seconds time elapsed

    Link: http://lkml.kernel.org/r/20170607150457.5905-1-sergey.senozhatsky@gmail.com
    Signed-off-by: Sergey Senozhatsky
    Cc: Peter Zijlstra
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sergey Senozhatsky
     
  • [thomas@m3y3r.de: v3: fix arch specific implementations]
    Link: http://lkml.kernel.org/r/1497890858.12931.7.camel@m3y3r.de
    Signed-off-by: Thomas Meyer
    Cc: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Thomas Meyer
     
  • bucket_table_alloc() can be currently called with GFP_KERNEL or
    GFP_ATOMIC. For the former we basically have an open coded kvzalloc()
    while the later only uses kzalloc(). Let's simplify the code a bit by
    the dropping the open coded path and replace it with kvzalloc().

    Link: http://lkml.kernel.org/r/20170531155145.17111-3-mhocko@kernel.org
    Signed-off-by: Michal Hocko
    Cc: Thomas Graf
    Cc: Herbert Xu
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michal Hocko
     
  • ... such that a user can specify visiting all the nodes in the tree
    (intersects with the world). This is a nice opposite from the very
    basic default query which is a single point.

    Link: http://lkml.kernel.org/r/20170518174936.20265-5-dave@stgolabs.net
    Signed-off-by: Davidlohr Bueso
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Davidlohr Bueso
     
  • Add a 'max_endpoint' parameter such that users may easily limit the size
    of the intervals that are randomly generated.

    Link: http://lkml.kernel.org/r/20170518174936.20265-4-dave@stgolabs.net
    Signed-off-by: Davidlohr Bueso
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Davidlohr Bueso
     
  • Allows for more flexible debugging.

    Link: http://lkml.kernel.org/r/20170518174936.20265-3-dave@stgolabs.net
    Signed-off-by: Davidlohr Bueso
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Davidlohr Bueso
     
  • Patch series "lib/interval_tree_test: some debugging improvements".

    Here are some patches that update the interval_tree_test module allowing
    users to pass finer grained options to run the actual test.

    This patch (of 4):

    It is a tristate after all, and also serves well for quick debugging.

    Link: http://lkml.kernel.org/r/20170518174936.20265-2-dave@stgolabs.net
    Signed-off-by: Davidlohr Bueso
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Davidlohr Bueso
     
  • gcc does generates stupid code sign extending data back and forth. Help
    by using "unsigned int".

    add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-61 (-61)
    function old new delta
    _parse_integer 128 123 -5

    It _still_ does generate useless MOVSX but I don't know how to delete it:

    0000000000000070 :
    ...
    a0: 89 c2 mov edx,eax
    a2: 83 e8 30 sub eax,0x30
    a5: 83 f8 09 cmp eax,0x9
    a8: 76 11 jbe bb
    aa: 83 ca 20 or edx,0x20
    ad: 0f be c2 ===> movsx eax,dl
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     
  • Standard "while (*s)" test is unnecessary because NUL won't pass
    valid-digit test anyway. Save one branch per parsed character.

    Link: http://lkml.kernel.org/r/20170514193756.GA32563@avx2
    Signed-off-by: Alexey Dobriyan
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     
  • Commit 7dd968163f7c ("bitmap: bitmap_equal memcmp optimization") was
    rather more restrictive than necessary; we can use memcmp() to implement
    bitmap_equal() as long as the number of bits can be proved to be a
    multiple of 8. And architectures other than s390 may be able to make
    good use of this optimisation.

    [arnd@arndb.de: fix build: add a memcmp() declaration]
    Link: http://lkml.kernel.org/r/20170630153908.3439707-1-arnd@arndb.de
    Link: http://lkml.kernel.org/r/20170628153221.11322-5-willy@infradead.org
    Signed-off-by: Matthew Wilcox
    Signed-off-by: Arnd Bergmann
    Acked-by: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matthew Wilcox
     
  • Several callers have constant 'start' and an 'nbits' that is a multiple
    of 8, so we can turn them into calls to memset. We don't need the
    entirety of 'start' and 'nbits' to be constant, we just need to know
    whether they're divisible by 8.

    Link: http://lkml.kernel.org/r/20170628153221.11322-4-willy@infradead.org
    Signed-off-by: Matthew Wilcox
    Acked-by: Rasmus Villemoes
    Cc: Martin Schwidefsky
    Cc: Matthew Wilcox
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matthew Wilcox
     
  • We have eight users calling bitmap_clear for a single bit and seventeen
    calling bitmap_set for a single bit. Rather than fix all of them to
    call __clear_bit or __set_bit, turn bitmap_clear and bitmap_set into
    inline functions and make this special case efficient.

    Link: http://lkml.kernel.org/r/20170628153221.11322-3-willy@infradead.org
    Signed-off-by: Matthew Wilcox
    Acked-by: Rasmus Villemoes
    Cc: Martin Schwidefsky
    Cc: Matthew Wilcox
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matthew Wilcox
     
  • Patch series "Bitmap optimisations", v2.

    These three bitmap patches use more efficient specialisations when the
    compiler can figure out that it's safe to do so. Thanks to Rasmus's
    eagle eyes, a nasty bug in v1 was avoided, and I've added a test case
    which would have caught it.

    This patch (of 4):

    This version of the test is actually a no-op; the next patch will enable
    it.

    Link: http://lkml.kernel.org/r/20170628153221.11322-2-willy@infradead.org
    Signed-off-by: Matthew Wilcox
    Cc: Rasmus Villemoes
    Cc: Martin Schwidefsky
    Cc: Matthew Wilcox
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matthew Wilcox
     
  • We poke at proc sysctl enough that really we should declare it
    maintained. We'll just be Cc'd and sending updates / ACK'ing changes
    through akpm's tree.

    Link: http://lkml.kernel.org/r/20170524231305.8649-1-mcgrof@kernel.org
    Signed-off-by: Luis R. Rodriguez
    Acked-by: Kees Cook
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Luis R. Rodriguez
     
  • 'all_var' looks like a variable, but is actually a macro. Use
    IS_ENABLED(CONFIG_KALLSYMS_ALL) for clarification.

    Link: http://lkml.kernel.org/r/1497577591-3434-1-git-send-email-yamada.masahiro@socionext.com
    Signed-off-by: Masahiro Yamada
    Cc: Alexei Starovoitov
    Cc: Daniel Borkmann
    Cc: "David S. Miller"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Masahiro Yamada
     
  • setgroups is not exactly a hot path, so we might as well use the library
    function instead of open-coding the sorting. Saves ~150 bytes.

    Link: http://lkml.kernel.org/r/1497301378-22739-1-git-send-email-linux@rasmusvillemoes.dk
    Signed-off-by: Rasmus Villemoes
    Cc: Matthew Wilcox
    Cc: Michal Hocko
    Cc: Alexey Dobriyan
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • attribute_groups are not supposed to change at runtime. All functions
    working with attribute_groups provided by work with
    const attribute_group. So mark the non-const structs as const.

    File size before:
    text data bss dec hex filename
    1120 544 16 1680 690 kernel/ksysfs.o

    File size After adding 'const':
    text data bss dec hex filename
    1160 480 16 1656 678 kernel/ksysfs.o

    Link: http://lkml.kernel.org/r/aa224b3cc923fdbb3edd0c41b2c639c85408c9e8.1498737347.git.arvind.yadav.cs@gmail.com
    Signed-off-by: Arvind Yadav
    Acked-by: Kees Cook
    Cc: Russell King
    Cc: Dave Young
    Cc: Hari Bathini
    Cc: Petr Tesarik
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arvind Yadav
     
  • The global variable 'rd_size' is declared as 'int' in source file
    arch/arm/kernel/atags_parse.c and as 'unsigned long' in
    drivers/block/brd.c. Fix this inconsistency.

    Additionally, remove the declarations of rd_image_start, rd_prompt and
    rd_doload from parse_tag_ramdisk() since these duplicate existing
    declarations in .

    Link: http://lkml.kernel.org/r/20170627065024.12347-1-bart.vanassche@wdc.com
    Signed-off-by: Bart Van Assche
    Acked-by: Russell King
    Cc: Jens Axboe
    Cc: Jan Kara
    Cc: Jason Yan
    Cc: Zhaohongjiang
    Cc: Miao Xie
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Bart Van Assche
     
  • Including pulls in a lot of bloat from and
    that is not needed to call the BUILD_BUG() family of
    macros. Split them out into their own header, .

    Also correct some checkpatch.pl errors for the BUILD_BUG_ON_ZERO() and
    BUILD_BUG_ON_NULL() macros by adding parentheses around the bitfield
    widths that begin with a minus sign.

    Link: http://lkml.kernel.org/r/20170525120316.24473-6-abbotti@mev.co.uk
    Signed-off-by: Ian Abbott
    Acked-by: Michal Nazarewicz
    Acked-by: Kees Cook
    Cc: Steven Rostedt
    Cc: Peter Zijlstra
    Cc: Jakub Kicinski
    Cc: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Abbott
     
  • Correct these checkpatch.pl errors:

    |ERROR: space required before that '-' (ctx:OxO)
    |#37: FILE: include/linux/bug.h:37:
    |+#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))

    |ERROR: space required before that '-' (ctx:OxO)
    |#38: FILE: include/linux/bug.h:38:
    |+#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))

    I decided to wrap the bitfield expressions that begin with minus signs
    in parentheses rather than insert spaces before the minus signs.

    Link: http://lkml.kernel.org/r/20170525120316.24473-5-abbotti@mev.co.uk
    Signed-off-by: Ian Abbott
    Acked-by: Michal Nazarewicz
    Cc: Kees Cook
    Cc: Steven Rostedt
    Cc: Peter Zijlstra
    Cc: Jakub Kicinski
    Cc: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Abbott
     
  • Correct this checkpatch.pl error:

    |ERROR: "(foo*)" should be "(foo *)"
    |#19: FILE: include/linux/bug.h:19:
    |+#define BUILD_BUG_ON_NULL(e) ((void*)0)

    Link: http://lkml.kernel.org/r/20170525120316.24473-4-abbotti@mev.co.uk
    Signed-off-by: Ian Abbott
    Acked-by: Michal Nazarewicz
    Cc: Kees Cook
    Cc: Steven Rostedt
    Cc: Peter Zijlstra
    Cc: Jakub Kicinski
    Cc: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Abbott
     
  • Correct these checkpatch.pl warnings:

    |WARNING: Block comments use * on subsequent lines
    |#34: FILE: include/linux/bug.h:34:
    |+/* Force a compilation error if condition is true, but also produce a
    |+ result (of value 0 and type size_t), so the expression can be used

    |WARNING: Block comments use a trailing */ on a separate line
    |#36: FILE: include/linux/bug.h:36:
    |+ aren't permitted). */

    Link: http://lkml.kernel.org/r/20170525120316.24473-3-abbotti@mev.co.uk
    Signed-off-by: Ian Abbott
    Acked-by: Michal Nazarewicz
    Cc: Kees Cook
    Cc: Steven Rostedt
    Cc: Peter Zijlstra
    Cc: Jakub Kicinski
    Cc: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Abbott
     
  • This series of patches splits BUILD_BUG related macros out of
    "include/linux/bug.h" into new file "include/linux/build_bug.h" (patch
    5), and changes the pointer type checking in the `container_of()` macro
    to deal with pointers of array type better (patch 6). Patches 1 to 4
    are prerequisites.

    Patches 2, 3, 4, and 5 have been inserted since the previous version of
    this patch series. Patch 6 here corresponds to v3 and v4's patch 2.

    Patch 1 was a prerequisite in v3 of this series to avoid a lot of
    warnings when was included by . That is
    no longer relevant for v5 of the series, but I left it in because it was
    acked by a Arnd Bergmann and Michal Nazarewicz.

    Patches 2, 3, and 4 are some checkpatch clean-ups on
    "include/linux/bug.h" before splitting out the BUILD_BUG stuff in patch
    5.

    Patch 5 splits the BUILD_BUG related macros out of "include/linux/bug.h"
    into new file "include/linux/build_bug.h" because including
    in "include/linux/kernel.h" would result in build failures
    due to circular dependencies.

    Patch 6 changes the pointer type checking by `container_of()` to avoid
    some incompatible pointer warnings when the dereferenced pointer has
    array type.

    1) asm-generic/bug.h: declare struct pt_regs; before function prototype
    2) linux/bug.h: correct formatting of block comment
    3) linux/bug.h: correct "(foo*)" should be "(foo *)"
    4) linux/bug.h: correct "space required before that '-'"
    5) bug: split BUILD_BUG stuff out into
    6) kernel.h: handle pointers to arrays better in container_of()

    This patch (of 6):

    The declaration of `__warn()` has `struct pt_regs *regs` as one of its
    parameters. This can result in compiler warnings if `struct regs` is not
    already declared. Add an empty declaration of `struct pt_regs` to avoid
    the warnings.

    Link: http://lkml.kernel.org/r/20170525120316.24473-2-abbotti@mev.co.uk
    Signed-off-by: Ian Abbott
    Acked-by: Arnd Bergmann
    Acked-by: Michal Nazarewicz
    Cc: Arnd Bergmann
    Cc: Kees Cook
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Abbott
     
  • The code can be much simplified by switching to ida_simple_get/remove.

    Link: http://lkml.kernel.org/r/8d1cc9f7-5115-c9dc-028e-c0770b6bfe1f@gmail.com
    Signed-off-by: Heiner Kallweit
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Heiner Kallweit
     
  • FRV supports 64-bit cmpxchg, which is provided by the arch code as
    __cmpxchg_64 and subsequently used to implement atomic64_cmpxchg.

    This patch hooks up the generic cmpxchg64 API using the same function,
    which also provides default definitions of the relaxed, acquire and
    release variants. This fixes the build when COMPILE_TEST=y and
    IOMMU_IO_PGTABLE_LPAE=y.

    Link: http://lkml.kernel.org/r/1499084670-6996-1-git-send-email-will.deacon@arm.com
    Signed-off-by: Will Deacon
    Reported-by: kbuild test robot
    Cc: Joerg Roedel
    Cc: Robin Murphy
    Cc: Peter Zijlstra
    Cc: Ingo Molnar
    Cc: David Howells
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Will Deacon
     
  • The arch uses a verbatim copy of the asm-generic version and does not
    add any own implementations to the header, so use asm-generic/fb.h
    instead of duplicating code.

    Link: http://lkml.kernel.org/r/20170517083307.1697-1-tklauser@distanz.ch
    Signed-off-by: Tobias Klauser
    Reviewed-by: David Howells
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tobias Klauser
     
  • frv's asm/device.h is merely including asm-generic/device.h. Thus, the
    arch specific header can be omitted and the generic header can be used
    directly.

    Link: http://lkml.kernel.org/r/20170517124915.26904-1-tklauser@distanz.ch
    Signed-off-by: Tobias Klauser
    Reviewed-by: David Howells
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tobias Klauser
     
  • The helper function get_wild_bug_type() does not need to be in global
    scope, so make it static.

    Cleans up sparse warning:

    "symbol 'get_wild_bug_type' was not declared. Should it be static?"

    Link: http://lkml.kernel.org/r/20170622090049.10658-1-colin.king@canonical.com
    Signed-off-by: Colin Ian King
    Acked-by: Dmitry Vyukov
    Cc: Andrey Ryabinin
    Cc: Alexander Potapenko
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Colin Ian King
     
  • They return positive value, that is, true, if non-zero value is found.
    Rename them to reduce confusion.

    Link: http://lkml.kernel.org/r/20170516012350.GA16015@js1304-desktop
    Signed-off-by: Joonsoo Kim
    Cc: Andrey Ryabinin
    Cc: Alexander Potapenko
    Cc: Dmitry Vyukov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joonsoo Kim
     
  • KASAN doesn't happen work with memory hotplug because hotplugged memory
    doesn't have any shadow memory. So any access to hotplugged memory
    would cause a crash on shadow check.

    Use memory hotplug notifier to allocate and map shadow memory when the
    hotplugged memory is going online and free shadow after the memory
    offlined.

    Link: http://lkml.kernel.org/r/20170601162338.23540-4-aryabinin@virtuozzo.com
    Signed-off-by: Andrey Ryabinin
    Cc: "H. Peter Anvin"
    Cc: Alexander Potapenko
    Cc: Catalin Marinas
    Cc: Dmitry Vyukov
    Cc: Ingo Molnar
    Cc: Ingo Molnar
    Cc: Mark Rutland
    Cc: Thomas Gleixner
    Cc: Will Deacon
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Ryabinin
     
  • We used to read several bytes of the shadow memory in advance.
    Therefore additional shadow memory mapped to prevent crash if
    speculative load would happen near the end of the mapped shadow memory.

    Now we don't have such speculative loads, so we no longer need to map
    additional shadow memory.

    Link: http://lkml.kernel.org/r/20170601162338.23540-3-aryabinin@virtuozzo.com
    Signed-off-by: Andrey Ryabinin
    Acked-by: Mark Rutland
    Cc: Catalin Marinas
    Cc: Will Deacon
    Cc: "H. Peter Anvin"
    Cc: Alexander Potapenko
    Cc: Dmitry Vyukov
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Ryabinin
     
  • We used to read several bytes of the shadow memory in advance.
    Therefore additional shadow memory mapped to prevent crash if
    speculative load would happen near the end of the mapped shadow memory.

    Now we don't have such speculative loads, so we no longer need to map
    additional shadow memory.

    Link: http://lkml.kernel.org/r/20170601162338.23540-2-aryabinin@virtuozzo.com
    Signed-off-by: Andrey Ryabinin
    Cc: Mark Rutland
    Cc: "H. Peter Anvin"
    Cc: Alexander Potapenko
    Cc: Catalin Marinas
    Cc: Dmitry Vyukov
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: Will Deacon
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Ryabinin
     
  • For some unaligned memory accesses we have to check additional byte of
    the shadow memory. Currently we load that byte speculatively to have
    only single load + branch on the optimistic fast path.

    However, this approach has some downsides:

    - It's unaligned access, so this prevents porting KASAN on
    architectures which doesn't support unaligned accesses.

    - We have to map additional shadow page to prevent crash if speculative
    load happens near the end of the mapped memory. This would
    significantly complicate upcoming memory hotplug support.

    I wasn't able to notice any performance degradation with this patch. So
    these speculative loads is just a pain with no gain, let's remove them.

    Link: http://lkml.kernel.org/r/20170601162338.23540-1-aryabinin@virtuozzo.com
    Signed-off-by: Andrey Ryabinin
    Acked-by: Dmitry Vyukov
    Cc: Alexander Potapenko
    Cc: Mark Rutland
    Cc: Catalin Marinas
    Cc: Will Deacon
    Cc: "H. Peter Anvin"
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Ryabinin
     
  • There is missing optimization in zero_p4d_populate() that can save some
    memory when mapping zero shadow. Implement it like as others.

    Link: http://lkml.kernel.org/r/1494829255-23946-1-git-send-email-iamjoonsoo.kim@lge.com
    Signed-off-by: Joonsoo Kim
    Acked-by: Andrey Ryabinin
    Cc: "Kirill A . Shutemov"
    Cc: Alexander Potapenko
    Cc: Dmitry Vyukov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joonsoo Kim
     
  • Commit 40f9fb8cffc6 ("mm/zsmalloc: support allocating obj with size of
    ZS_MAX_ALLOC_SIZE") fixes a size calculation error that prevented
    zsmalloc to allocate an object of the maximal size (ZS_MAX_ALLOC_SIZE).
    I think however the fix is unneededly complicated.

    This patch replaces the dynamic calculation of zs_size_classes at init
    time by a compile time calculation that uses the DIV_ROUND_UP() macro
    already used in get_size_class_index().

    [akpm@linux-foundation.org: use min_t]
    Link: http://lkml.kernel.org/r/20170630114859.1979-1-jmarchan@redhat.com
    Signed-off-by: Jerome Marchand
    Acked-by: Minchan Kim
    Cc: Sergey Senozhatsky
    Cc: Mahendran Ganesh
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jerome Marchand
     
  • attribute_groups are not supposed to change at runtime. All functions
    working with attribute_groups provided by work with
    const attribute_group. So mark the non-const structs as const.

    File size before:
    text data bss dec hex filename
    8293 841 4 9138 23b2 drivers/block/zram/zram_drv.o

    File size After adding 'const':
    text data bss dec hex filename
    8357 777 4 9138 23b2 drivers/block/zram/zram_drv.o

    Link: http://lkml.kernel.org/r/65680c1c4d85818f7094cbfa31c91bf28185ba1b.1499061182.git.arvind.yadav.cs@gmail.com
    Signed-off-by: Arvind Yadav
    Acked-by: Minchan Kim
    Cc: Sergey Senozhatsky
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arvind Yadav
     
  • early_pfn_to_nid will return node 0 if both HAVE_ARCH_EARLY_PFN_TO_NID
    and HAVE_MEMBLOCK_NODE_MAP are disabled. It seems we are safe now
    because all architectures which support NUMA define one of them (with an
    exception of alpha which however has CONFIG_NUMA marked as broken) so
    this works as expected. It can get silently and subtly broken too
    easily, though. Make sure we fail the compilation if NUMA is enabled
    and there is no proper implementation for this function. If that ever
    happens we know that either the specific configuration is invalid and
    the fix should either disable NUMA or enable one of the above configs.

    Link: http://lkml.kernel.org/r/20170704075803.15979-1-mhocko@kernel.org
    Signed-off-by: Michal Hocko
    Acked-by: Vlastimil Babka
    Cc: Joonsoo Kim
    Cc: Yang Shi
    Cc: Mel Gorman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michal Hocko