Davidlohr Bueso
2aadf7fc7d
rbtree: optimize root-check during rebalancing loop
...
The only times the nil-parent (root node) condition is true is when the
node is the first in the tree, or after fixing rbtree rule #4 and the
case 1 rebalancing made the node the root. Such conditions do not apply
most of the time:
(i) The common case in an rbtree is to have more than a single node,
so this is only true for the first rb_insert().
(ii) While there is a chance only one first rotation is needed, cases
where the node's uncle is black (cases 2,3) are more common as we can
have the following scenarios during the rotation looping:
case1 only, case1+1, case2+3, case1+2+3, case3 only, etc.
This patch, therefore, adds an unlikely() optimization to this
conditional. When profiling with CONFIG_PROFILE_ANNOTATED_BRANCHES, a
kernel build shows that the incorrect rate is less than 15%, and for
workloads that involve insert mostly trees overtime tend to have less
than 2% incorrect rate.
Link: http://lkml.kernel.org/r/20170719014603.19029-3-dave@stgolabs.net
Signed-off-by: Davidlohr Bueso <dbueso@suse.de >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:48 -07:00
Davidlohr Bueso
cd9e61ed1e
rbtree: cache leftmost node internally
...
Patch series "rbtree: Cache leftmost node internally", v4.
A series to extending rbtrees to internally cache the leftmost node such
that we can have fast overlap check optimization for all interval tree
users[1]. The benefits of this series are that:
(i) Unify users that do internal leftmost node caching.
(ii) Optimize all interval tree users.
(iii) Convert at least two new users (epoll and procfs) to the new interface.
This patch (of 16):
Red-black tree semantics imply that nodes with smaller or greater (or
equal for duplicates) keys always be to the left and right,
respectively. For the kernel this is extremely evident when considering
our rb_first() semantics. Enabling lookups for the smallest node in the
tree in O(1) can save a good chunk of cycles in not having to walk down
the tree each time. To this end there are a few core users that
explicitly do this, such as the scheduler and rtmutexes. There is also
the desire for interval trees to have this optimization allowing faster
overlap checking.
This patch introduces a new 'struct rb_root_cached' which is just the
root with a cached pointer to the leftmost node. The reason why the
regular rb_root was not extended instead of adding a new structure was
that this allows the user to have the choice between memory footprint
and actual tree performance. The new wrappers on top of the regular
rb_root calls are:
- rb_first_cached(cached_root) -- which is a fast replacement
for rb_first.
- rb_insert_color_cached(node, cached_root, new)
- rb_erase_cached(node, cached_root)
In addition, augmented cached interfaces are also added for basic
insertion and deletion operations; which becomes important for the
interval tree changes.
With the exception of the inserts, which adds a bool for updating the
new leftmost, the interfaces are kept the same. To this end, porting rb
users to the cached version becomes really trivial, and keeping current
rbtree semantics for users that don't care about the optimization
requires zero overhead.
Link: http://lkml.kernel.org/r/20170719014603.19029-2-dave@stgolabs.net
Signed-off-by: Davidlohr Bueso <dbueso@suse.de >
Reviewed-by: Jan Kara <jack@suse.cz >
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:48 -07:00
Matthias Kaehlcke
c32ee3d9ab
bitops: avoid integer overflow in GENMASK(_ULL)
...
GENMASK(_ULL) performs a left-shift of ~0UL(L), which technically
results in an integer overflow. clang raises a warning if the overflow
occurs in a preprocessor expression. Clear the low-order bits through a
substraction instead of the left-shift to avoid the overflow.
(akpm: no change in .text size in my testing)
Link: http://lkml.kernel.org/r/20170803212020.24939-1-mka@chromium.org
Signed-off-by: Matthias Kaehlcke <mka@chromium.org >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:48 -07:00
Babu Moger
e9ef073a07
include: warn for inconsistent endian config definition
...
We have seen some generic code use config parameter CONFIG_CPU_BIG_ENDIAN
to decide the endianness.
Here are the few examples.
include/asm-generic/qrwlock.h
drivers/of/base.c
drivers/of/fdt.c
drivers/tty/serial/earlycon.c
drivers/tty/serial/serial_core.c
Display warning if CPU_BIG_ENDIAN is not defined on big endian
architecture and also warn if it defined on little endian architectures.
Here is our original discussion
https://lkml.org/lkml/2017/5/24/620
Link: http://lkml.kernel.org/r/1499358861-179979-4-git-send-email-babu.moger@oracle.com
Signed-off-by: Babu Moger <babu.moger@oracle.com >
Suggested-by: Arnd Bergmann <arnd@arndb.de >
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org >
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org >
Cc: Alexander Viro <viro@zeniv.linux.org.uk >
Cc: David S. Miller <davem@davemloft.net >
Cc: Greg KH <gregkh@linuxfoundation.org >
Cc: Helge Deller <deller@gmx.de >
Cc: Ingo Molnar <mingo@elte.hu >
Cc: Jonas Bonn <jonas@southpole.se >
Cc: Max Filippov <jcmvbkbc@gmail.com >
Cc: Michael Ellerman <mpe@ellerman.id.au > (powerpc)
Cc: Michal Simek <monstr@monstr.eu >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Stafford Horne <shorne@gmail.com >
Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi >
Cc: Yoshinori Sato <ysato@users.sourceforge.jp >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:48 -07:00
Babu Moger
206d3642d8
arch/microblaze: add choice for endianness and update Makefile
...
microblaze architectures can be configured for either little or big endian
formats. Add a choice option for the user to select the correct endian
format(default to big endian).
Also update the Makefile so toolchain can compile for the format it is
configured for.
Link: http://lkml.kernel.org/r/1499358861-179979-3-git-send-email-babu.moger@oracle.com
Signed-off-by: Babu Moger <babu.moger@oracle.com >
Signed-off-by: Arnd Bergmann <arnd@arndb.de >
Cc: Michal Simek <monstr@monstr.eu >
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org >
Cc: Alexander Viro <viro@zeniv.linux.org.uk >
Cc: David S. Miller <davem@davemloft.net >
Cc: Geert Uytterhoeven <geert@linux-m68k.org >
Cc: Greg KH <gregkh@linuxfoundation.org >
Cc: Helge Deller <deller@gmx.de >
Cc: Ingo Molnar <mingo@elte.hu >
Cc: Jonas Bonn <jonas@southpole.se >
Cc: Max Filippov <jcmvbkbc@gmail.com >
Cc: Michael Ellerman <mpe@ellerman.id.au > (powerpc)
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Stafford Horne <shorne@gmail.com >
Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi >
Cc: Yoshinori Sato <ysato@users.sourceforge.jp >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:48 -07:00
Babu Moger
4c97a0c8fe
arch: define CPU_BIG_ENDIAN for all fixed big endian archs
...
Patch series "Define CPU_BIG_ENDIAN or warn for inconsistencies", v3.
While working on enabling queued rwlock on SPARC, found this following
code in include/asm-generic/qrwlock.h which uses CONFIG_CPU_BIG_ENDIAN to
clear a byte.
static inline u8 *__qrwlock_write_byte(struct qrwlock *lock)
{
return (u8 *)lock + 3 * IS_BUILTIN(CONFIG_CPU_BIG_ENDIAN);
}
Problem is many of the fixed big endian architectures don't define
CPU_BIG_ENDIAN and clears the wrong byte.
Define CPU_BIG_ENDIAN for all the fixed big endian architecture to fix it.
Also found few more references of this config parameter in
drivers/of/base.c
drivers/of/fdt.c
drivers/tty/serial/earlycon.c
drivers/tty/serial/serial_core.c
Be aware that this may cause regressions if someone has worked-around
problems in the above code already. Remove the work-around.
Here is our original discussion
https://lkml.org/lkml/2017/5/24/620
Link: http://lkml.kernel.org/r/1499358861-179979-2-git-send-email-babu.moger@oracle.com
Signed-off-by: Babu Moger <babu.moger@oracle.com >
Suggested-by: Arnd Bergmann <arnd@arndb.de >
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org >
Acked-by: David S. Miller <davem@davemloft.net >
Acked-by: Stafford Horne <shorne@gmail.com >
Cc: Yoshinori Sato <ysato@users.sourceforge.jp >
Cc: Jonas Bonn <jonas@southpole.se >
Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi >
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org >
Cc: Helge Deller <deller@gmx.de >
Cc: Alexander Viro <viro@zeniv.linux.org.uk >
Cc: Michal Simek <monstr@monstr.eu >
Cc: Michael Ellerman <mpe@ellerman.id.au > (powerpc)
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ingo Molnar <mingo@elte.hu >
Cc: Max Filippov <jcmvbkbc@gmail.com >
Cc: Greg KH <gregkh@linuxfoundation.org >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:48 -07:00
Alexey Dobriyan
9b130ad5bb
treewide: make "nr_cpu_ids" unsigned
...
First, number of CPUs can't be negative number.
Second, different signnnedness leads to suboptimal code in the following
cases:
1)
kmalloc(nr_cpu_ids * sizeof(X));
"int" has to be sign extended to size_t.
2)
while (loff_t *pos < nr_cpu_ids)
MOVSXD is 1 byte longed than the same MOV.
Other cases exist as well. Basically compiler is told that nr_cpu_ids
can't be negative which can't be deduced if it is "int".
Code savings on allyesconfig kernel: -3KB
add/remove: 0/0 grow/shrink: 25/264 up/down: 261/-3631 (-3370)
function old new delta
coretemp_cpu_online 450 512 +62
rcu_init_one 1234 1272 +38
pci_device_probe 374 399 +25
...
pgdat_reclaimable_pages 628 556 -72
select_fallback_rq 446 369 -77
task_numa_find_cpu 1923 1807 -116
Link: http://lkml.kernel.org/r/20170819114959.GA30580@avx2
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:48 -07:00
Matthew Wilcox
ac036f9570
vga: optimise console scrolling
...
Where possible, call memset16(), memmove() or memcpy() instead of using
open-coded loops. I don't like the calling convention that uses a byte
count instead of a count of u16s, but it's a little late to change that.
Reduces code size of fbcon.o by almost 400 bytes on my laptop build.
[akpm@linux-foundation.org: fix build]
Link: http://lkml.kernel.org/r/20170720184539.31609-9-willy@infradead.org
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com >
Cc: Ralf Baechle <ralf@linux-mips.org >
Cc: David Miller <davem@davemloft.net >
Cc: Sam Ravnborg <sam@ravnborg.org >
Cc: "H. Peter Anvin" <hpa@zytor.com >
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com >
Cc: "Martin K. Petersen" <martin.petersen@oracle.com >
Cc: Ingo Molnar <mingo@elte.hu >
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru >
Cc: Matt Turner <mattst88@gmail.com >
Cc: Michael Ellerman <mpe@ellerman.id.au >
Cc: Minchan Kim <minchan@kernel.org >
Cc: Richard Henderson <rth@twiddle.net >
Cc: Russell King <rmk+kernel@armlinux.org.uk >
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com >
Cc: Thomas Gleixner <tglx@linutronix.de >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:48 -07:00
Matthew Wilcox
1caffba9db
drivers/scsi/sym53c8xx_2/sym_hipd.c: convert to use memset32
...
memset32() can be used to initialise these three arrays. Minor code
footprint reduction.
Link: http://lkml.kernel.org/r/20170720184539.31609-8-willy@infradead.org
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com >
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com >
Cc: "Martin K. Petersen" <martin.petersen@oracle.com >
Cc: "H. Peter Anvin" <hpa@zytor.com >
Cc: David Miller <davem@davemloft.net >
Cc: Ingo Molnar <mingo@elte.hu >
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru >
Cc: Matt Turner <mattst88@gmail.com >
Cc: Michael Ellerman <mpe@ellerman.id.au >
Cc: Minchan Kim <minchan@kernel.org >
Cc: Ralf Baechle <ralf@linux-mips.org >
Cc: Richard Henderson <rth@twiddle.net >
Cc: Russell King <rmk+kernel@armlinux.org.uk >
Cc: Sam Ravnborg <sam@ravnborg.org >
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com >
Cc: Thomas Gleixner <tglx@linutronix.de >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:48 -07:00
Matthew Wilcox
48ad1abef4
drivers/block/zram/zram_drv.c: convert to using memset_l
...
zram was the motivation for creating memset_l(). Minchan Kim sees a 7%
performance improvement on x86 with 100MB of non-zero deduplicatable
data:
perf stat -r 10 dd if=/dev/zram0 of=/dev/null
vanilla: 0.232050465 seconds time elapsed ( +- 0.51% )
memset_l: 0.217219387 seconds time elapsed ( +- 0.07% )
Link: http://lkml.kernel.org/r/20170720184539.31609-7-willy@infradead.org
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com >
Tested-by: Minchan Kim <minchan@kernel.org >
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com >
Cc: "H. Peter Anvin" <hpa@zytor.com >
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com >
Cc: "Martin K. Petersen" <martin.petersen@oracle.com >
Cc: David Miller <davem@davemloft.net >
Cc: Ingo Molnar <mingo@elte.hu >
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru >
Cc: Matt Turner <mattst88@gmail.com >
Cc: Michael Ellerman <mpe@ellerman.id.au >
Cc: Ralf Baechle <ralf@linux-mips.org >
Cc: Richard Henderson <rth@twiddle.net >
Cc: Russell King <rmk+kernel@armlinux.org.uk >
Cc: Sam Ravnborg <sam@ravnborg.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:48 -07:00
Matthew Wilcox
92ce4c3ea7
alpha: add support for memset16
...
Alpha already had an optimised fill-memory-with-16-bit-quantity
assembler routine called memsetw(). It has a slightly different calling
convention from memset16() in that it takes a byte count, not a count of
words. That's the same convention used by ARM's __memset routines, so
rename Alpha's routine to match and add a memset16() wrapper around it.
Then convert Alpha's scr_memsetw() to call memset16() instead of
memsetw().
Link: http://lkml.kernel.org/r/20170720184539.31609-6-willy@infradead.org
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com >
Cc: Richard Henderson <rth@twiddle.net >
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru >
Cc: Matt Turner <mattst88@gmail.com >
Cc: "H. Peter Anvin" <hpa@zytor.com >
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com >
Cc: "Martin K. Petersen" <martin.petersen@oracle.com >
Cc: David Miller <davem@davemloft.net >
Cc: Ingo Molnar <mingo@elte.hu >
Cc: Michael Ellerman <mpe@ellerman.id.au >
Cc: Minchan Kim <minchan@kernel.org >
Cc: Ralf Baechle <ralf@linux-mips.org >
Cc: Russell King <rmk+kernel@armlinux.org.uk >
Cc: Sam Ravnborg <sam@ravnborg.org >
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com >
Cc: Thomas Gleixner <tglx@linutronix.de >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:48 -07:00
Matthew Wilcox
fd1d362600
ARM: implement memset32 & memset64
...
Reuse the existing optimised memset implementation to implement an
optimised memset32 and memset64.
Link: http://lkml.kernel.org/r/20170720184539.31609-5-willy@infradead.org
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com >
Reviewed-by: Russell King <rmk+kernel@armlinux.org.uk >
Cc: "H. Peter Anvin" <hpa@zytor.com >
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com >
Cc: "Martin K. Petersen" <martin.petersen@oracle.com >
Cc: David Miller <davem@davemloft.net >
Cc: Ingo Molnar <mingo@elte.hu >
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru >
Cc: Matt Turner <mattst88@gmail.com >
Cc: Michael Ellerman <mpe@ellerman.id.au >
Cc: Minchan Kim <minchan@kernel.org >
Cc: Ralf Baechle <ralf@linux-mips.org >
Cc: Richard Henderson <rth@twiddle.net >
Cc: Sam Ravnborg <sam@ravnborg.org >
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com >
Cc: Thomas Gleixner <tglx@linutronix.de >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:48 -07:00
Matthew Wilcox
4c51248533
x86: implement memset16, memset32 & memset64
...
These are single instructions on x86. There's no 64-bit instruction for
x86-32, but we don't yet have any user for memset64() on 32-bit
architectures, so don't bother to implement it.
Link: http://lkml.kernel.org/r/20170720184539.31609-4-willy@infradead.org
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com >
Cc: Minchan Kim <minchan@kernel.org >
Cc: Michael Ellerman <mpe@ellerman.id.au >
Cc: Ingo Molnar <mingo@elte.hu >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: "H. Peter Anvin" <hpa@zytor.com >
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com >
Cc: "Martin K. Petersen" <martin.petersen@oracle.com >
Cc: David Miller <davem@davemloft.net >
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru >
Cc: Matt Turner <mattst88@gmail.com >
Cc: Ralf Baechle <ralf@linux-mips.org >
Cc: Richard Henderson <rth@twiddle.net >
Cc: Russell King <rmk+kernel@armlinux.org.uk >
Cc: Sam Ravnborg <sam@ravnborg.org >
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:48 -07:00
Matthew Wilcox
03270c13c5
lib/string.c: add testcases for memset16/32/64
...
[akpm@linux-foundation.org: minor tweaks]
Link: http://lkml.kernel.org/r/20170720184539.31609-3-willy@infradead.org
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com >
Cc: "H. Peter Anvin" <hpa@zytor.com >
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com >
Cc: "Martin K. Petersen" <martin.petersen@oracle.com >
Cc: David Miller <davem@davemloft.net >
Cc: Ingo Molnar <mingo@elte.hu >
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru >
Cc: Matt Turner <mattst88@gmail.com >
Cc: Michael Ellerman <mpe@ellerman.id.au >
Cc: Minchan Kim <minchan@kernel.org >
Cc: Ralf Baechle <ralf@linux-mips.org >
Cc: Richard Henderson <rth@twiddle.net >
Cc: Russell King <rmk+kernel@armlinux.org.uk >
Cc: Sam Ravnborg <sam@ravnborg.org >
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com >
Cc: Thomas Gleixner <tglx@linutronix.de >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:48 -07:00
Matthew Wilcox
3b3c4babd8
lib/string.c: add multibyte memset functions
...
Patch series "Multibyte memset variations", v4.
A relatively common idiom we're missing is a function to fill an area of
memory with a pattern which is larger than a single byte. I first
noticed this with a zram patch which wanted to fill a page with an
'unsigned long' value. There turn out to be quite a few places in the
kernel which can benefit from using an optimised function rather than a
loop; sometimes text size, sometimes speed, and sometimes both. The
optimised PowerPC version (not included here) improves performance by
about 30% on POWER8 on just the raw memset_l().
Most of the extra lines of code come from the three testcases I added.
This patch (of 8):
memset16(), memset32() and memset64() are like memset(), but allow the
caller to fill the destination with a value larger than a single byte.
memset_l() and memset_p() allow the caller to use unsigned long and
pointer values respectively.
Link: http://lkml.kernel.org/r/20170720184539.31609-2-willy@infradead.org
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com >
Cc: "H. Peter Anvin" <hpa@zytor.com >
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com >
Cc: "Martin K. Petersen" <martin.petersen@oracle.com >
Cc: David Miller <davem@davemloft.net >
Cc: Ingo Molnar <mingo@elte.hu >
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru >
Cc: Matt Turner <mattst88@gmail.com >
Cc: Michael Ellerman <mpe@ellerman.id.au >
Cc: Minchan Kim <minchan@kernel.org >
Cc: Ralf Baechle <ralf@linux-mips.org >
Cc: Richard Henderson <rth@twiddle.net >
Cc: Russell King <rmk+kernel@armlinux.org.uk >
Cc: Sam Ravnborg <sam@ravnborg.org >
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com >
Cc: Thomas Gleixner <tglx@linutronix.de >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:48 -07:00
Masahiro Yamada
604df32236
linux/kernel.h: move DIV_ROUND_DOWN_ULL() macro
...
This macro is useful to avoid link error on 32-bit systems.
We have the same definition in two drivers, so move it to
include/linux/kernel.h
While we are here, refactor DIV_ROUND_UP_ULL() by using
DIV_ROUND_DOWN_ULL().
Link: http://lkml.kernel.org/r/1500945156-12907-1-git-send-email-yamada.masahiro@socionext.com
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com >
Acked-by: Mark Brown <broonie@kernel.org >
Cc: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr >
Cc: Jaroslav Kysela <perex@perex.cz >
Cc: Takashi Iwai <tiwai@suse.com >
Cc: Liam Girdwood <lgirdwood@gmail.com >
Cc: Boris Brezillon <boris.brezillon@free-electrons.com >
Cc: Marek Vasut <marek.vasut@gmail.com >
Cc: Brian Norris <computersforpeace@gmail.com >
Cc: Richard Weinberger <richard@nod.at >
Cc: David Woodhouse <dwmw2@infradead.org >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:47 -07:00
David Rientjes
1403830294
fs, proc: unconditional cond_resched when reading smaps
...
If there are large numbers of hugepages to iterate while reading
/proc/pid/smaps, the page walk never does cond_resched(). On archs
without split pmd locks, there can be significant and observable
contention on mm->page_table_lock which cause lengthy delays without
rescheduling.
Always reschedule in smaps_pte_range() if necessary since the pagewalk
iteration can be expensive.
Link: http://lkml.kernel.org/r/alpine.DEB.2.10.1708211405520.131071@chino.kir.corp.google.com
Signed-off-by: David Rientjes <rientjes@google.com >
Cc: Minchan Kim <minchan@kernel.org >
Cc: Hugh Dickins <hughd@google.com >
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:47 -07:00
Alexey Dobriyan
855d97657d
proc: uninline proc_create()
...
Save some code from ~320 invocations all clearing last argument.
add/remove: 3/0 grow/shrink: 0/158 up/down: 45/-702 (-657)
function old new delta
proc_create - 17 +17
__ksymtab_proc_create - 16 +16
__kstrtab_proc_create - 12 +12
yam_init_driver 301 298 -3
...
cifs_proc_init 249 228 -21
via_fb_pci_probe 2304 2280 -24
Link: http://lkml.kernel.org/r/20170819094702.GA27864@avx2
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:47 -07:00
Michal Hocko
1240ea0dc3
fs, proc: remove priv argument from is_stack
...
Commit b18cb64ead ("fs/proc: Stop trying to report thread stacks")
removed the priv parameter user in is_stack so the argument is
redundant. Drop it.
[arnd@arndb.de: remove unused variable]
Link: http://lkml.kernel.org/r/20170801120150.1520051-1-arnd@arndb.de
Link: http://lkml.kernel.org/r/20170728075833.7241-1-mhocko@kernel.org
Signed-off-by: Michal Hocko <mhocko@suse.com >
Signed-off-by: Arnd Bergmann <arnd@arndb.de >
Cc: Andy Lutomirski <luto@amacapital.net >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:47 -07:00
Anshuman Khandual
149728e913
mm/mempolicy.c: remove BUG_ON() checks for VMA inside mpol_misplaced()
...
VMA and its address bounds checks are too late in this function. They
must have been verified earlier in the page fault sequence. Hence just
remove them.
Link: http://lkml.kernel.org/r/20170901130137.7617-1-khandual@linux.vnet.ibm.com
Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com >
Suggested-by: Vlastimil Babka <vbabka@suse.cz >
Acked-by: Vlastimil Babka <vbabka@suse.cz >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:47 -07:00
David Rientjes
b6b1fd2a6b
mm/swapfile.c: fix swapon frontswap_map memory leak on error
...
Free frontswap_map if an error is encountered before enable_swap_info().
Signed-off-by: David Rientjes <rientjes@google.com >
Reviewed-by: "Huang, Ying" <ying.huang@intel.com >
Cc: Darrick J. Wong <darrick.wong@oracle.com >
Cc: Hugh Dickins <hughd@google.com >
Cc: <stable@vger.kernel.org > [4.12+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:47 -07:00
Darrick J. Wong
8606a1a94d
mm: kvfree the swap cluster info if the swap file is unsatisfactory
...
If initializing a small swap file fails because the swap file has a
problem (holes, etc.) then we need to free the cluster info as part of
cleanup. Unfortunately a previous patch changed the code to use kvzalloc
but did not change all the vfree calls to use kvfree.
Found by running generic/357 from xfstests.
Link: http://lkml.kernel.org/r/20170831233515.GR3775@magnolia
Fixes: 54f180d3c1 ("mm, swap: use kvzalloc to allocate some swap data structures")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com >
Reviewed-by: "Huang, Ying" <ying.huang@intel.com >
Acked-by: David Rientjes <rientjes@google.com >
Cc: Hugh Dickins <hughd@google.com >
Cc: <stable@vger.kernel.org > [4.12+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:47 -07:00
Tetsuo Handa
f19360f015
mm/page_alloc.c: apply gfp_allowed_mask before the first allocation attempt
...
We are by error initializing alloc_flags before gfp_allowed_mask is
applied. This could cause problems after pm_restrict_gfp_mask() is called
during suspend operation. Apply gfp_allowed_mask before initializing
alloc_flags so that the first allocation attempt uses correct flags.
Link: http://lkml.kernel.org/r/201709020016.ADJ21342.OFLJHOOSMFVtFQ@I-love.SAKURA.ne.jp
Fixes: 83d4ca8148 ("mm, page_alloc: move __GFP_HARDWALL modifications out of the fastpath")
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp >
Acked-by: Michal Hocko <mhocko@suse.com >
Acked-by: Vlastimil Babka <vbabka@suse.cz >
Cc: Mel Gorman <mgorman@techsingularity.net >
Cc: Jesper Dangaard Brouer <brouer@redhat.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:47 -07:00
Cyrill Gorcunov
66559a691a
tools/testing/selftests/kcmp/kcmp_test.c: add KCMP_EPOLL_TFD testing
...
KCMP's KCMP_EPOLL_TFD mode merged in commit 0791e3644e ("kcmp: add
KCMP_EPOLL_TFD mode to compare epoll target files") we've had no selftest
for it yet (except in criu development list). Thus add it.
Link: http://lkml.kernel.org/r/20170901151620.GK1898@uranus.lan
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org >
Cc: Andrey Vagin <avagin@openvz.org >
Cc: Pavel Emelyanov <xemul@virtuozzo.com >
Cc: Michael Kerrisk <mtk.manpages@gmail.com >
Cc: Shuah Khan <shuah@kernel.org >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:47 -07:00
Michal Hocko
b4ccec41af
mm/sparse.c: fix typo in online_mem_sections
...
online_mem_sections() accidentally marks online only the first section
in the given range. This is a typo which hasn't been noticed because I
haven't tested large 2GB blocks previously. All users of
pfn_to_online_page would get confused on the the rest of the pfn range
in the block.
All we need to fix this is to use iterator (pfn) rather than start_pfn.
Link: http://lkml.kernel.org/r/20170904112210.3401-1-mhocko@kernel.org
Fixes: 2d070eab2e ("mm: consider zone which is not fully populated to have holes")
Signed-off-by: Michal Hocko <mhocko@suse.com >
Acked-by: Vlastimil Babka <vbabka@suse.cz >
Cc: Anshuman Khandual <khandual@linux.vnet.ibm.com >
Cc: <stable@vger.kernel.org >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-09-08 18:26:47 -07:00