incoming
Subsystems (14)
Andrew Morton
maintainer12 patches, based on 33256ce194110874d4bc90078b577c59f9076c59.
Subsystems affected by this patch series:
lib
coredump
mm/memcg
mm/zsmalloc
mm/swap
mailmap
mm/selftests
mm/pagecache
mm/hugetlb
mm/pagemap
Subsystem: lib
Randy Dunlap <[email protected]>:
zlib: export S390 symbols for zlib modules
Subsystem: coredump
Menglong Dong <[email protected]>:
coredump: fix core_pattern parse error
Subsystem: mm/memcg
Roman Gushchin <[email protected]>:
mm: memcg/slab: fix obj_cgroup_charge() return value handling
Yang Shi <[email protected]>:
mm: list_lru: set shrinker map bit when child nr_items is not zero
Subsystem: mm/zsmalloc
Minchan Kim <[email protected]>:
mm/zsmalloc.c: drop ZSMALLOC_PGTABLE_MAPPING
Subsystem: mm/swap
Qian Cai <[email protected]>:
mm/swapfile: do not sleep with a spin lock held
Subsystem: mailmap
Uwe Kleine-König <[email protected]>:
mailmap: add two more addresses of Uwe Kleine-König
Subsystem: mm/selftests
Xingxing Su <[email protected]>:
tools/testing/selftests/vm: fix build error
Axel Rasmussen <[email protected]>:
userfaultfd: selftests: fix SIGSEGV if huge mmap fails
Subsystem: mm/pagecache
Alex Shi <[email protected]>:
mm/filemap: add static for function __add_to_page_cache_locked
Subsystem: mm/hugetlb
Mike Kravetz <[email protected]>:
hugetlb_cgroup: fix offline of hugetlb cgroup with reservations
Subsystem: mm/pagemap
Liu Zixian <[email protected]>:
mm/mmap.c: fix mmap return value when vma is merged after call_mmap()
.mailmap | 2 + arch/arm/configs/omap2plus_defconfig | 1 fs/coredump.c | 3 + include/linux/zsmalloc.h | 1 lib/zlib_dfltcc/dfltcc_inflate.c | 3 + mm/Kconfig | 13 ------- mm/filemap.c | 2 - mm/hugetlb_cgroup.c | 8 +--- mm/list_lru.c | 10 ++--- mm/mmap.c | 26 ++++++-------- mm/slab.h | 40 +++++++++++++--------- mm/swapfile.c | 4 +- mm/zsmalloc.c | 54 ------------------------------- tools/testing/selftests/vm/Makefile | 4 ++ tools/testing/selftests/vm/userfaultfd.c | 25 +++++++++----- 15 files changed, 75 insertions(+), 121 deletions(-)
Andrew Morton
maintainerPATCH 1/12 zlib: export S390 symbols for zlib modules
From: Randy Dunlap <[email protected]>
Subject: zlib: export S390 symbols for zlib modules
Fix build errors when ZLIB_INFLATE=m and ZLIB_DEFLATE=m and ZLIB_DFLTCC=y by exporting the 2 needed symbols in dfltcc_inflate.c.
Fixes these build errors:
ERROR: modpost: "dfltcc_inflate" [lib/zlib_inflate/zlib_inflate.ko] undefined!
ERROR: modpost: "dfltcc_can_inflate" [lib/zlib_inflate/zlib_inflate.ko] undefined!
---
lib/zlib_dfltcc/dfltcc_inflate.c | 3 +++ 1 file changed, 3 insertions(+)
lib/zlib_dfltcc/dfltcc_inflate.c renamed from lib/zlib_dfltcc/dfltcc_inflate.c~zlib-export-s390-symbols-for-zlib-modules +3 -0
@@ -4,6 +4,7 @@#include "dfltcc_util.h" #include "dfltcc.h" #include <asm/setup.h> +#include <linux/export.h> #include <linux/zutil.h> /*
@@ -29,6 +30,7 @@ int dfltcc_can_inflate(return is_bit_set (dfltcc_state->af.fns,DFLTCC_XPND ) &&is_bit_set (dfltcc_state->af.fmts,DFLTCC_FMT0 ); } +EXPORT_SYMBOL (dfltcc_can_inflate);static int dfltcc_was_inflate_used ( z_streamp strm
@@ -147,3 +149,4 @@ dfltcc_inflate_action dfltcc_inflate(return (cc ==DFLTCC_CC_OP1_TOO_SHORT || cc ==DFLTCC_CC_OP2_TOO_SHORT ) ?DFLTCC_INFLATE_BREAK :DFLTCC_INFLATE_CONTINUE ; } +EXPORT_SYMBOL (dfltcc_inflate);
_
Re: [patch 01/12] zlib: export S390 symbols for zlib modules
Hello,
should we probably put these to lib/zlib_dfltcc/dfltcc_syms.c along with the other EXPORT_SYMBOL statements?
Quoted 51 lines · Andrew Morton
From: Randy Dunlap <[email protected]>
Subject: zlib: export S390 symbols for zlib modulesFix build errors when ZLIB_INFLATE=m and ZLIB_DEFLATE=m and ZLIB_DFLTCC=y by exporting the 2 needed symbols in
dfltcc_inflate.c.Fixes these build errors:
ERROR: modpost: "
dfltcc_inflate" [lib/zlib_inflate/zlib_inflate.ko] undefined!
ERROR: modpost: "dfltcc_can_inflate" [lib/zlib_inflate/zlib_inflate.ko] undefined!Fixes 126196100063 ("lib/zlib: add s390 hardware support for kernel zlib_inflate")Signed-off-by Randy Dunlap <[email protected]>Reported-by kernel test robot <[email protected]>Acked-by Ilya Leoshkevich <[email protected]>Cc Mikhail Zaslonko <[email protected]>Cc Heiko Carstens <[email protected]>Cc Vasily Gorbik <[email protected]>Cc Christian Borntraeger <[email protected]>Signed-off-by Andrew Morton <[email protected]>---
lib/zlib_dfltcc/dfltcc_inflate.c | 3 +++ 1 file changed, 3 insertions(+)lib/zlib_dfltcc/dfltcc_inflate.c renamed from lib/zlib_dfltcc/dfltcc_inflate.c~zlib-export-s390-symbols-for-zlib-modules +3
-0@@ -4,6 +4,7 @@#include "dfltcc_util.h" #include "dfltcc.h" #include <asm/setup.h> +#include <linux/export.h> #include <linux/zutil.h> /* @@ -29,6 +30,7 @@ int dfltcc_can_inflate(return is_bit_set (dfltcc_state->af.fns,DFLTCC_XPND ) &&is_bit_set (dfltcc_state->af.fmts,DFLTCC_FMT0 ); } +EXPORT_SYMBOL (dfltcc_can_inflate);static int dfltcc_was_inflate_used ( z_streamp strm@@ -147,3 +149,4 @@ dfltcc_inflate_action dfltcc_inflate(return (cc ==DFLTCC_CC_OP1_TOO_SHORT || cc ==DFLTCC_CC_OP2_TOO_SHORT ) ?DFLTCC_INFLATE_BREAK :DFLTCC_INFLATE_CONTINUE ; } +EXPORT_SYMBOL (dfltcc_inflate);_
Re: [patch 01/12] zlib: export S390 symbols for zlib modules
Quoted 3 lines · Zaslonko Mikhail
Hello,
should we probably put these to
lib/zlib_dfltcc/dfltcc_syms.calong with the otherEXPORT_SYMBOLstatements?
Hi,
I didn't know about that file. :)
That change makes sense. At least that's how some modules used to do it. Not so much nowadays, but this one might as well consistent within itself.
Do you want to fix it or should I?
Thanks.
Quoted 54 lines
Reviewed-by Mikhail Zaslonko <[email protected]>Quoted 51 lines · Andrew Morton
From: Randy Dunlap <[email protected]>
Subject: zlib: export S390 symbols for zlib modulesFix build errors when ZLIB_INFLATE=m and ZLIB_DEFLATE=m and ZLIB_DFLTCC=y by exporting the 2 needed symbols in
dfltcc_inflate.c.Fixes these build errors:
ERROR: modpost: "
dfltcc_inflate" [lib/zlib_inflate/zlib_inflate.ko] undefined!
ERROR: modpost: "dfltcc_can_inflate" [lib/zlib_inflate/zlib_inflate.ko] undefined!Fixes 126196100063 ("lib/zlib: add s390 hardware support for kernel zlib_inflate")Signed-off-by Randy Dunlap <[email protected]>Reported-by kernel test robot <[email protected]>Acked-by Ilya Leoshkevich <[email protected]>Cc Mikhail Zaslonko <[email protected]>Cc Heiko Carstens <[email protected]>Cc Vasily Gorbik <[email protected]>Cc Christian Borntraeger <[email protected]>Signed-off-by Andrew Morton <[email protected]>---
lib/zlib_dfltcc/dfltcc_inflate.c | 3 +++ 1 file changed, 3 insertions(+)lib/zlib_dfltcc/dfltcc_inflate.c renamed from lib/zlib_dfltcc/dfltcc_inflate.c~zlib-export-s390-symbols-for-zlib-modules +3
-0@@ -4,6 +4,7 @@#include "dfltcc_util.h" #include "dfltcc.h" #include <asm/setup.h> +#include <linux/export.h> #include <linux/zutil.h> /* @@ -29,6 +30,7 @@ int dfltcc_can_inflate(return is_bit_set (dfltcc_state->af.fns,DFLTCC_XPND ) &&is_bit_set (dfltcc_state->af.fmts,DFLTCC_FMT0 ); } +EXPORT_SYMBOL (dfltcc_can_inflate);static int dfltcc_was_inflate_used ( z_streamp strm@@ -147,3 +149,4 @@ dfltcc_inflate_action dfltcc_inflate(return (cc ==DFLTCC_CC_OP1_TOO_SHORT || cc ==DFLTCC_CC_OP2_TOO_SHORT ) ?DFLTCC_INFLATE_BREAK :DFLTCC_INFLATE_CONTINUE ; } +EXPORT_SYMBOL (dfltcc_inflate);_
Signature · 2 lines
~Randy Reported-by: Randy Dunlap <[email protected]>
Re: [patch 01/12] zlib: export S390 symbols for zlib modules
Quoted 5 lines · Randy Dunlap
Quoted 3 lines · Zaslonko Mikhail
Hello,
should we probably put these to
lib/zlib_dfltcc/dfltcc_syms.calong with the otherEXPORT_SYMBOLstatements?
Quoted 8 lines
Hi,
I didn't know about that file. :)That change makes sense. At least that's how some modules used to do it. Not so much nowadays, but this one might as well consistent within itself.
Do you want to fix it or should I?
Please, go ahead.
Thanks.
Quoted 59 lines
Thanks.
Quoted 54 lines
Reviewed-by Mikhail Zaslonko <[email protected]>Quoted 51 lines · Andrew Morton
From: Randy Dunlap <[email protected]>
Subject: zlib: export S390 symbols for zlib modulesFix build errors when ZLIB_INFLATE=m and ZLIB_DEFLATE=m and ZLIB_DFLTCC=y by exporting the 2 needed symbols in
dfltcc_inflate.c.Fixes these build errors:
ERROR: modpost: "
dfltcc_inflate" [lib/zlib_inflate/zlib_inflate.ko] undefined!
ERROR: modpost: "dfltcc_can_inflate" [lib/zlib_inflate/zlib_inflate.ko] undefined!Fixes 126196100063 ("lib/zlib: add s390 hardware support for kernel zlib_inflate")Signed-off-by Randy Dunlap <[email protected]>Reported-by kernel test robot <[email protected]>Acked-by Ilya Leoshkevich <[email protected]>Cc Mikhail Zaslonko <[email protected]>Cc Heiko Carstens <[email protected]>Cc Vasily Gorbik <[email protected]>Cc Christian Borntraeger <[email protected]>Signed-off-by Andrew Morton <[email protected]>---
lib/zlib_dfltcc/dfltcc_inflate.c | 3 +++ 1 file changed, 3 insertions(+)lib/zlib_dfltcc/dfltcc_inflate.c renamed from lib/zlib_dfltcc/dfltcc_inflate.c~zlib-export-s390-symbols-for-zlib-modules +3
-0@@ -4,6 +4,7 @@#include "dfltcc_util.h" #include "dfltcc.h" #include <asm/setup.h> +#include <linux/export.h> #include <linux/zutil.h> /* @@ -29,6 +30,7 @@ int dfltcc_can_inflate(return is_bit_set (dfltcc_state->af.fns,DFLTCC_XPND ) &&is_bit_set (dfltcc_state->af.fmts,DFLTCC_FMT0 ); } +EXPORT_SYMBOL (dfltcc_can_inflate);static int dfltcc_was_inflate_used ( z_streamp strm@@ -147,3 +149,4 @@ dfltcc_inflate_action dfltcc_inflate(return (cc ==DFLTCC_CC_OP1_TOO_SHORT || cc ==DFLTCC_CC_OP2_TOO_SHORT ) ?DFLTCC_INFLATE_BREAK :DFLTCC_INFLATE_CONTINUE ; } +EXPORT_SYMBOL (dfltcc_inflate);_
Re: [patch 01/12] zlib: export S390 symbols for zlib modules
Quoted 15 lines · Zaslonko Mikhail
Quoted 12 lines · Randy Dunlap
Quoted 3 lines · Zaslonko Mikhail
Hello,
should we probably put these to
lib/zlib_dfltcc/dfltcc_syms.calong with the otherEXPORT_SYMBOLstatements?Hi,
I didn't know about that file. :)That change makes sense. At least that's how some modules used to do it. Not so much nowadays, but this one might as well consistent within itself.
Quoted 5 lines
Quoted 1 line
Do you want to fix it or should I?
Please, go ahead.
Thanks.
Hi,
How do you feel about eliminating the dfltcc_syms.c file and putting the EXPORT_SYMBOL()s in the source file(s) where they occur? as expressed in coding-style.rst:
In source files, separate functions with one blank line. If the function is exported, the **EXPORT** macro for it should follow immediately after the closing function brace line.
(also move the MODULE_LICENSE() to a different source file.)
Quoted 11 lines
Quoted 11 lines
Thanks.
Quoted 8 lines
Reviewed-by Mikhail Zaslonko <[email protected]>Quoted 5 lines · Andrew Morton
From: Randy Dunlap <[email protected]>
Subject: zlib: export S390 symbols for zlib modulesFix build errors when ZLIB_INFLATE=m and ZLIB_DEFLATE=m and ZLIB_DFLTCC=y by exporting the 2 needed symbols in
dfltcc_inflate.c.
thanks.
Signature · 1 line
~Randy
Andrew Morton
maintainerPATCH 2/12 coredump: fix core_pattern parse error
In reply to Andrew MortonFrom: Menglong Dong <[email protected]>
Subject: coredump: fix core_pattern parse error
'format_corename()' will splite 'core_pattern' on spaces when it is in pipe mode, and take helper_argv[0] as the path to usermode executable.
It works fine in most cases. However, if there is a space between '|' and '/file/path', such as
'| /usr/lib/systemd/systemd-coredump %P %u %g', helper_argv[0] will be parsed as '', and users will get a 'Core dump to | disabled'.
It is not friendly to users, as the pattern above was valid previously. Fix this by ignoring the spaces between '|' and '/file/path'.
---
fs/coredump.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/coredump.c renamed from fs/coredump.c~coredump-fix-core_pattern-parse-error +2 -1
@@ -229,7 +229,8 @@ static int format_corename(struct core_n*/ if (ispipe) {if (isspace (*pat_ptr)) { - was_space = true; +if (cn->used !=0 ) + was_space = true; pat_ptr++;continue ; }else if (was_space) {
_
Andrew Morton
maintainerPATCH 3/12 mm: memcg/slab: fix obj_cgroup_charge() return value handling
In reply to Andrew MortonFrom: Roman Gushchin <[email protected]>
Subject: mm: memcg/slab: fix obj_cgroup_charge() return value handling
Commit 10befea91b61 ("mm: memcg/slab: use a single set of kmem_caches for all allocations") introduced a regression into the handling of the obj_cgroup_charge() return value. If a non-zero value is returned (indicating of exceeding one of memory.max limits), the allocation should fail, instead of falling back to non-accounted mode.
To make the code more readable, move memcg_slab_pre_alloc_hook() and memcg_slab_post_alloc_hook() calling conditions into bodies of these hooks.
---
mm/slab.h | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-)
mm/slab.h renamed from mm/slab.h~mm-memcg-slab-fix-obj_cgroup_charge-return-value-handling +24 -16
@@ -274,22 +274,32 @@ static inline size_t obj_full_size(strucreturn s->size +sizeof (struct obj_cgroup *); } -static inline struct obj_cgroup *memcg_slab_pre_alloc_hook (struct kmem_cache *s, -size_t objects, -gfp_t flags) +/* +* Returns false if the allocation should fail. +*/ +static inline bool memcg_slab_pre_alloc_hook (struct kmem_cache *s, +struct obj_cgroup **objcgp, +size_t objects,gfp_t flags) {struct obj_cgroup *objcg; +if (!memcg_kmem_enabled ()) +return true; + +if (!(flags & __GFP_ACCOUNT) && !(s->flags &SLAB_ACCOUNT )) +return true; + objcg =get_obj_cgroup_from_current ();if (!objcg) -return NULL ; +return true;if (obj_cgroup_charge (objcg, flags, objects *obj_full_size (s))) {obj_cgroup_put (objcg); -return NULL ; +return false; } -return objcg; + *objcgp = objcg; +return true; } static inline void mod_objcg_state(struct obj_cgroup *objcg,
@@ -315,7 +325,7 @@ static inline void memcg_slab_post_allocunsigned long off;size_t i; -if (!objcg) +if (!memcg_kmem_enabled () || !objcg)return ; flags &= ~__GFP_ACCOUNT;
@@ -400,11 +410,11 @@ static inline void memcg_free_page_obj_c { } -static inline struct obj_cgroup *memcg_slab_pre_alloc_hook (struct kmem_cache *s, -size_t objects, -gfp_t flags) +static inline bool memcg_slab_pre_alloc_hook (struct kmem_cache *s, +struct obj_cgroup **objcgp, +size_t objects,gfp_t flags) { -return NULL ; +return true; } static inline void memcg_slab_post_alloc_hook(struct kmem_cache *s,
@@ -508,9 +518,8 @@ static inline struct kmem_cache *slab_prif (should_failslab (s, flags))return NULL ; -if (memcg_kmem_enabled () && - ((flags & __GFP_ACCOUNT) || (s->flags &SLAB_ACCOUNT ))) - *objcgp =memcg_slab_pre_alloc_hook (s, size, flags); +if (!memcg_slab_pre_alloc_hook (s, objcgp, size, flags)) +return NULL ;return s; }
@@ -529,8 +538,7 @@ static inline void slab_post_alloc_hook( s->flags, flags); } -if (memcg_kmem_enabled ()) -memcg_slab_post_alloc_hook (s, objcg, flags, size, p); +memcg_slab_post_alloc_hook (s, objcg, flags, size, p); }#ifndef CONFIG_SLOB
_
Andrew Morton
maintainerPATCH 4/12 mm: list_lru: set shrinker map bit when child nr_items is not zero
In reply to Andrew MortonFrom: Yang Shi <[email protected]>
Subject: mm: list_lru: set shrinker map bit when child nr_items is not zero
When investigating a slab cache bloat problem, significant amount of negative dentry cache was seen, but confusingly they neither got shrunk by reclaimer (the host has very tight memory) nor be shrunk by dropping cache. The vmcore shows there are over 14M negative dentry objects on lru, but tracing result shows they were even not scanned at all. The further investigation shows the memcg's vfs shrinker_map bit is not set. So the reclaimer or dropping cache just skip calling vfs shrinker. So we have to reboot the hosts to get the memory back.
I didn't manage to come up with a reproducer in test environment, and the problem can't be reproduced after rebooting. But it seems there is race between shrinker map bit clear and reparenting by code inspection. The hypothesis is elaborated as below.
The memcg hierarchy on our production environment looks like:
root
/ \
system userThe main workloads are running under user slice's children, and it creates and removes memcg frequently. So reparenting happens very often under user slice, but no task is under user slice directly.
So with the frequent reparenting and tight memory pressure, the below hypothetical race condition may happen:
CPU A CPU B
reparent
dst->nr_items == 0
shrinker:
total_objects == 0
add src->nr_items to dst
set_bit
return SHRINK_EMPTY
clear_bitchild memcg offline
replace child's kmemcg_id with
parent's (in memcg_offline_kmem())
list_lru_del() between shrinker runs
see parent's kmemcg_id dec dst->nr_items
reparent again
dst->nr_items may go negative
due to concurrent list_lru_del()
The second run of shrinker:
read nr_items without any synchronization, so it may see intermediate negative nr_items then total_objects may return 0 coincidently
keep the bit cleared
dst->nr_items != 0
skip set_bit
add scr->nr_item to dst
After this point dst->nr_item may never go zero, so reparenting will not set shrinker_map bit anymore. And since there is no task under user slice directly, so no new object will be added to its lru to set the shrinker map bit either. That bit is kept cleared forever.
How does list_lru_del() race with reparenting? It is because reparenting replaces children's kmemcg_id to parent's without protecting from nlru->lock, so list_lru_del() may see parent's kmemcg_id but actually deleting items from child's lru, but dec'ing parent's nr_items, so the parent's nr_items may go negative as commit 2788cf0c401c268b4819c5407493a8769b7007aa ("memcg: reparent list_lrus and free kmemcg_id on css offline") says.
Since it is impossible that dst->nr_items goes negative and src->nr_items goes zero at the same time, so it seems we could set the shrinker map bit iff src->nr_items != 0. We could synchronize list_lru_count_one() and reparenting with nlru->lock, but it seems checking src->nr_items in reparenting is the simplest and avoids lock contention.
---
mm/list_lru.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
mm/list_lru.c renamed from mm/list_lru.c~mm-list_lru-set-shrinker-map-bit-when-child-nr_items-is-not-zero +5 -5
@@ -534,7 +534,6 @@ static void memcg_drain_list_lru_node(ststruct list_lru_node *nlru = &lru->node[nid];int dst_idx = dst_memcg->kmemcg_id;struct list_lru_one *src, *dst; -bool set;/* * Since list_lru_{add,del} may be called under an IRQ-safe lock,
@@ -546,11 +545,12 @@ static void memcg_drain_list_lru_node(st dst =list_lru_from_memcg_idx (nlru, dst_idx);list_splice_init (&src->list, &dst->list); - set = (!dst->nr_items && src->nr_items); - dst->nr_items += src->nr_items; -if (set) + +if (src->nr_items) { + dst->nr_items += src->nr_items;memcg_set_shrinker_bit (dst_memcg, nid,lru_shrinker_id (lru)); - src->nr_items =0 ; + src->nr_items =0 ; + }spin_unlock_irq (&nlru->lock); }
_
Andrew Morton
maintainerPATCH 5/12 mm/zsmalloc.c: drop ZSMALLOC_PGTABLE_MAPPING
In reply to Andrew MortonFrom: Minchan Kim <[email protected]>
Subject: mm/zsmalloc.c: drop ZSMALLOC_PGTABLE_MAPPING
While I was doing zram testing, I found sometimes decompression failed since the compression buffer was corrupted. With investigation, I found below commit calls cond_resched unconditionally so it could make a problem in atomic context if the task is reschedule.
[ 55.109012] BUG: sleeping function called from invalid context at mm/vmalloc.c:108
[ 55.110774] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 946, name: memhog
[ 55.111973] 3 locks held by memhog/946:
[ 55.112807] #0: ffff9d01d4b193e8 (&mm->mmap_lock#2){++++}-{4:4}, at: __mm_populate+0x103/0x160
[ 55.114151] #1: ffffffffa3d53de0 (fs_reclaim){+.+.}-{0:0}, at: __alloc_pages_slowpath.constprop.0+0xa98/0x1160
[ 55.115848] #2: ffff9d01d56b8110 (&zspage->lock){.+.+}-{3:3}, at: zs_map_object+0x8e/0x1f0
[ 55.118947] CPU: 0 PID: 946 Comm: memhog Not tainted 5.9.3-00011-gc5bfc0287345-dirty #316
[ 55.121265] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1 04/01/2014
[ 55.122540] Call Trace:
[ 55.122974] dump_stack+0x8b/0xb8
[ 55.123588] ___might_sleep.cold+0xb6/0xc6
[ 55.124328] unmap_kernel_range_noflush+0x2eb/0x350
[ 55.125198] unmap_kernel_range+0x14/0x30
[ 55.125920] zs_unmap_object+0xd5/0xe0
[ 55.126604] zram_bvec_rw.isra.0+0x38c/0x8e0
[ 55.127462] zram_rw_page+0x90/0x101
[ 55.128199] bdev_write_page+0x92/0xe0
[ 55.128957] ? swap_slot_free_notify+0xb0/0xb0
[ 55.129841] __swap_writepage+0x94/0x4a0
[ 55.130636] ? do_raw_spin_unlock+0x4b/0xa0
[ 55.131462] ? _raw_spin_unlock+0x1f/0x30
[ 55.132261] ? page_swapcount+0x6c/0x90
[ 55.133038] pageout+0xe3/0x3a0
[ 55.133702] shrink_page_list+0xb94/0xd60
[ 55.134626] shrink_inactive_list+0x158/0x460We can fix this by removing the ZSMALLOC_PGTABLE_MAPPING feature (which contains the offending calling code) from zsmalloc.
Even though this option showed some amount improvement(e.g., 30%) in some arm32 platforms, it has been headache to maintain since it have abused APIs[1](e.g., unmap_kernel_range in atomic context).
Since we are approaching to deprecate 32bit machines and already made the config option available for only builtin build since v5.8, lastly it has been not default option in zsmalloc, it's time to drop the option for better maintenance.
[1] http://lore.kernel.org/linux-mm/[email protected]
---
arch/arm/configs/omap2plus_defconfig | 1 include/linux/zsmalloc.h | 1 mm/Kconfig | 13 ------ mm/zsmalloc.c | 54 ------------------------- 4 files changed, 69 deletions(-)
arch/arm/configs/omap2plus_defconfig renamed from arch/arm/configs/omap2plus_defconfig~mm-zsmallocc-drop-zsmalloc_pgtable_mapping +0 -1
@@ -81,7 +81,6 @@ CONFIG_PARTITION_ADVANCED=y CONFIG_BINFMT_MISC=y CONFIG_CMA=y CONFIG_ZSMALLOC=m -CONFIG_ZSMALLOC_PGTABLE_MAPPING=y CONFIG_NET=y CONFIG_PACKET=y CONFIG_UNIX=y
include/linux/zsmalloc.h renamed from include/linux/zsmalloc.h~mm-zsmallocc-drop-zsmalloc_pgtable_mapping +0 -1
@@ -20,7 +20,6 @@* zsmalloc mapping modes * * NOTE: These only make a difference when a mapped object spans pages. -* They also have no effect when ZSMALLOC_PGTABLE_MAPPING is selected. */ enum zs_mapmode {ZS_MM_RW ,/* normal read-write mapping */
mm/Kconfig renamed from mm/Kconfig~mm-zsmallocc-drop-zsmalloc_pgtable_mapping +0 -13
@@ -707,19 +707,6 @@ config ZSMALLOC returned by an alloc(). This handle must be mapped in order to access the allocated space. -config ZSMALLOC_PGTABLE_MAPPING - bool "Use page table mapping to access object in zsmalloc" - depends on ZSMALLOC=y - help - By default, zsmalloc uses a copy-based object mapping method to - access allocations that span two pages. However, if a particular - architecture (ex, ARM) performs VM mapping faster than copying, - then you should select this. This causes zsmalloc to use page table - mapping rather than copying for object mapping. - - You can check speed with zsmalloc benchmark: - https://github.com/spartacus06/zsmapbench - config ZSMALLOC_STAT bool "Export zsmalloc statistics" depends on ZSMALLOC
mm/zsmalloc.c renamed from mm/zsmalloc.c~mm-zsmallocc-drop-zsmalloc_pgtable_mapping +0 -54
73 lines not on this page · raw message
_
Andrew Morton
maintainerPATCH 6/12 mm/swapfile: do not sleep with a spin lock held
In reply to Andrew MortonFrom: Qian Cai <[email protected]>
Subject: mm/swapfile: do not sleep with a spin lock held
We can't call kvfree() with a spin lock held, so defer it. Fixes a might_sleep() runtime warning.
---
mm/swapfile.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
mm/swapfile.c renamed from mm/swapfile.c~mm-swapfile-do-not-sleep-with-a-spin-lock-held +3 -1
@@ -2867,6 +2867,7 @@ late_initcall(max_swapfiles_check);static struct swap_info_struct *alloc_swap_info (void ) {struct swap_info_struct *p; +struct swap_info_struct *defer =NULL ;unsigned int type;int i;
@@ -2895,7 +2896,7 @@ static struct swap_info_struct *alloc_swsmp_wmb ();WRITE_ONCE (nr_swapfiles, nr_swapfiles +1 ); }else { -kvfree (p); + defer = p; p = swap_info[type];/* * Do not memset this entry: a racing procfs swap_next()
@@ -2908,6 +2909,7 @@ static struct swap_info_struct *alloc_swplist_node_init (&p->avail_lists[i],0 ); p->flags =SWP_USED ;spin_unlock (&swap_lock); +kvfree (defer);spin_lock_init (&p->lock);spin_lock_init (&p->cont_lock);
_
Andrew Morton
maintainerPATCH 7/12 mailmap: add two more addresses of Uwe Kleine-König
In reply to Andrew MortonFrom: Uwe Kleine-König <[email protected]>
Subject: mailmap: add two more addresses of Uwe Kleine-König
This fixes attribution for the commits (among others)
- d4097456cd1d ("video/framebuffer: move the probe func into .devinit.text in Blackfin LCD driver")
- 0312e024d6cd ("mfd: mc13xxx: Add support for mc34708")
---
.mailmap | 2 ++ 1 file changed, 2 insertions(+)
.mailmap renamed from .mailmap~mailmap-add-two-more-addresses-of-uwe-kleine-oenig +2 -0
@@ -322,6 +322,8 @@ TripleX Chung <[email protected]> <zhong Tsuneo Yoshioka <[email protected]> Tycho Andersen <[email protected]> <[email protected]> Uwe Kleine-König <[email protected]> +Uwe Kleine-König <[email protected]> +Uwe Kleine-König <[email protected]> Uwe Kleine-König <[email protected]> Uwe Kleine-König <[email protected]> Valdis Kletnieks <[email protected]>
_
Andrew Morton
maintainerPATCH 8/12 tools/testing/selftests/vm: fix build error
In reply to Andrew MortonFrom: Xingxing Su <[email protected]>
Subject: tools/testing/selftests/vm: fix build error
Only x86 and PowerPC implement the pkey-xxx.h, and an error was reported when compiling protection_keys.c.
Add a Arch judgment to compile "protection_keys" in the Makefile.
If other arch implement this, add the arch name to the Makefile. eg:
ifneq (,$(findstring $(ARCH),powerpc mips ... ))
Following build errors:
pkey-helpers.h:93:2: error: #error Architecture not supported
#error Architecture not supported
pkey-helpers.h:96:20: error: `PKEY_DISABLE_ACCESS' undeclared
#define PKEY_MASK (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE)
^
protection_keys.c:218:45: error: `PKEY_DISABLE_WRITE' undeclared
pkey_assert(flags & (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE));
^
---
tools/testing/selftests/vm/Makefile | 4 ++++ 1 file changed, 4 insertions(+)
tools/testing/selftests/vm/Makefile renamed from tools/testing/selftests/vm/Makefile~selftest-vm-fix-build-error +4 -0
@@ -60,9 +60,13 @@ ifeq ($(CAN_BUILD_X86_64),1) TEST_GEN_FILES += $(BINARIES_64) endif else + +ifneq (,$(findstring $(ARCH),powerpc)) TEST_GEN_FILES += protection_keys endif +endif + ifneq (,$(filter $(MACHINE),arm64 ia64 mips64 parisc64 ppc64 ppc64le riscv64 s390x sh64 sparc64 x86_64)) TEST_GEN_FILES += va_128TBswitch TEST_GEN_FILES += virtual_address_range
_
Andrew Morton
maintainerPATCH 9/12 userfaultfd: selftests: fix SIGSEGV if huge mmap fails
In reply to Andrew MortonFrom: Axel Rasmussen <[email protected]>
Subject: userfaultfd: selftests: fix SIGSEGV if huge mmap fails
The error handling in hugetlb_allocate_area() was incorrect for the hugetlb_shared test case.
Previously the behavior was:
- mmap a hugetlb area
- If this fails, set the pointer to NULL, and carry on
- mmap an alias of the same hugetlb fd
- If this fails, munmap the original area
If the original mmap failed, it's likely the second one did too. If both failed, we'd blindly try to munmap a NULL pointer, causing a SIGSEGV. Instead, "goto fail" so we return before trying to mmap the alias.
This issue can be hit "in real life" by forgetting to set /proc/sys/vm/nr_hugepages (leaving it at 0), and then trying to run the hugetlb_shared test.
Another small improvement is, when the original mmap fails, don't just print "it failed": perror(), so we can see *why*. :)
---
tools/testing/selftests/vm/userfaultfd.c | 25 +++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-)
tools/testing/selftests/vm/userfaultfd.c renamed from tools/testing/selftests/vm/userfaultfd.c~userfaultfd-selftests-fix-sigsegv-if-huge-mmap-fails +16 -9
@@ -206,19 +206,19 @@ static int hugetlb_release_pages(char *rreturn ret; } -static void hugetlb_allocate_area (void **alloc_area) {void *area_alias =NULL ;char **alloc_area_alias; + *alloc_area =mmap (NULL , nr_pages * page_size,PROT_READ |PROT_WRITE , (map_shared ?MAP_SHARED :MAP_PRIVATE ) |MAP_HUGETLB , huge_fd, *alloc_area == area_src ?0 : nr_pages * page_size);if (*alloc_area ==MAP_FAILED ) { -fprintf (stderr,"mmap of hugetlbfs file failed\n" ); - *alloc_area =NULL ; +perror ("mmap of hugetlbfs file failed" ); + goto fail; }if (map_shared) {
@@ -227,14 +227,11 @@ static void hugetlb_allocate_area(void * huge_fd, *alloc_area == area_src ?0 : nr_pages * page_size);if (area_alias ==MAP_FAILED ) { -if (munmap (*alloc_area, nr_pages * page_size) <0 ) { -perror ("hugetlb munmap" ); -exit (1 ); - } - *alloc_area =NULL ; -return ; +perror ("mmap of hugetlb file alias failed" ); + goto fail_munmap; } } +if (*alloc_area == area_src) { huge_fd_off0 = *alloc_area; alloc_area_alias = &area_src_alias;
@@ -243,6 +240,16 @@ static void hugetlb_allocate_area(void * }if (area_alias) *alloc_area_alias = area_alias; + +return ; + +fail_munmap: +if (munmap (*alloc_area, nr_pages * page_size) <0 ) { +perror ("hugetlb munmap" ); +exit (1 ); + } +fail: + *alloc_area =NULL ; }static void hugetlb_alias_mapping (__u64 *start,size_t len,unsigned long offset)
_
Andrew Morton
maintainerPATCH 10/12 mm/filemap: add static for function __add_to_page_cache_locked
In reply to Andrew MortonFrom: Alex Shi <[email protected]>
Subject: mm/filemap: add static for function __add_to_page_cache_locked
../mm/filemap.c:830:14: warning: no previous prototype for `__add_to_page_cache_locked' [-Wmissing-prototypes]
noinline int __add_to_page_cache_locked(struct page *page,
---
mm/filemap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/filemap.c renamed from mm/filemap.c~mm-filemap-add-static-for-function-__add_to_page_cache_locked +1 -1
@@ -827,7 +827,7 @@ int replace_page_cache_page(struct page }EXPORT_SYMBOL_GPL (replace_page_cache_page); -noinline int __add_to_page_cache_locked(struct page *page, +static noinline int __add_to_page_cache_locked(struct page *page,struct address_space *mapping,pgoff_t offset,gfp_t gfp,void **shadowp)
_
Andrew Morton
maintainerPATCH 11/12 hugetlb_cgroup: fix offline of hugetlb cgroup with reservations
In reply to Andrew MortonFrom: Mike Kravetz <[email protected]>
Subject: hugetlb_cgroup: fix offline of hugetlb cgroup with reservations
Adrian Moreno was ruuning a kubernetes 1.19 + containerd/docker workload using hugetlbfs. In this environment the issue is reproduced by:
1 - Start a simple pod that uses the recently added HugePages medium
feature (pod yaml attached)
2 - Start a DPDK app. It doesn't need to run successfully (as in transfer
packets) nor interact with real hardware. It seems just initializing the EAL layer (which handles hugepage reservation and locking) is enough to trigger the issue
3 - Delete the Pod (or let it "Complete").
This would result in a kworker thread going into a tight loop (top output):
1425 root 20 0 0 0 0 R 99.7 0.0 5:22.45
kworker/28:7+cgroup_destroy
'perf top -g' reports:
- 63.28% 0.01% [kernel] [k] worker_thread
- 49.97% worker_thread
- 52.64% process_one_work
- 62.08% css_killed_work_fn
- hugetlb_cgroup_css_offline
41.52% _raw_spin_lock
- 2.82% _cond_resched
rcu_all_qs
2.66% PageHuge
- 0.57% schedule
- 0.57% __schedule
We are spinning in the do-while loop in hugetlb_cgroup_css_offline. Worse yet, we are holding the master cgroup lock (cgroup_mutex) while infinitely spinning. Little else can be done on the system as the cgroup_mutex can not be acquired.
Do note that the issue can be reproduced by simply offlining a hugetlb cgroup containing pages with reservation counts.
The loop in hugetlb_cgroup_css_offline is moving page counts from the cgroup being offlined to the parent cgroup. This is done for each hstate, and is repeated until hugetlb_cgroup_have_usage returns false. The routine moving counts (hugetlb_cgroup_move_parent) is only moving 'usage' counts. The routine hugetlb_cgroup_have_usage is checking for both 'usage' and 'reservation' counts. Discussion about what to do with reservation counts when reparenting was discussed here:
The decision was made to leave a zombie cgroup for with reservation counts. Unfortunately, the code checking reservation counts was incorrectly added to hugetlb_cgroup_have_usage.
To fix the issue, simply remove the check for reservation counts. While fixing this issue, a related bug in hugetlb_cgroup_css_offline was noticed. The hstate index is not reinitialized each time through the do-while loop. Fix this as well.
---
mm/hugetlb_cgroup.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
mm/hugetlb_cgroup.c renamed from mm/hugetlb_cgroup.c~hugetlb_cgroup-fix-offline-of-hugetlb-cgroup-with-reservations +3 -5
@@ -82,11 +82,8 @@ static inline bool hugetlb_cgroup_have_ufor (idx =0 ; idx < hugetlb_max_hstate; idx++) {if (page_counter_read ( -hugetlb_cgroup_counter_from_cgroup (h_cg, idx)) || -page_counter_read (hugetlb_cgroup_counter_from_cgroup_rsvd ( - h_cg, idx))) { +hugetlb_cgroup_counter_from_cgroup (h_cg, idx)))return true; - } }return false; }
@@ -202,9 +199,10 @@ static void hugetlb_cgroup_css_offline(sstruct hugetlb_cgroup *h_cg =hugetlb_cgroup_from_css (css);struct hstate *h;struct page *page; -int idx =0 ; +int idx; do { + idx = 0; for_each_hstate(h) { spin_lock(&hugetlb_lock); list_for_each_entry(page, &h->hugepage_activelist, lru)
_
Andrew Morton
maintainerPATCH 12/12 mm/mmap.c: fix mmap return value when vma is merged after call_mmap()
In reply to Andrew MortonFrom: Liu Zixian <[email protected]>
Subject: mm/mmap.c: fix mmap return value when vma is merged after call_mmap()
On success, mmap should return the begin address of newly mapped area, but patch "mm: mmap: merge vma after call_mmap() if possible" set vm_start of newly merged vma to return value addr. Users of mmap will get wrong address if vma is merged after call_mmap(). We fix this by moving the assignment to addr before merging vma.
We have a driver which changes vm_flags, and this bug is found by our testcases.
---
mm/mmap.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
mm/mmap.c renamed from mm/mmap.c~fix-mmap-return-value-when-vma-is-merged-after-call_mmap +12 -14
@@ -1808,6 +1808,17 @@ unsigned long mmap_region(struct file *fif (error) goto unmap_and_free_vma; +/* Can addr have changed?? +* +* Answer: Yes, several device drivers can do it in their +* f_op->mmap method. -DaveM +* Bug: If addr is changed, prev, rb_link, rb_parent should +* be updated for vma_link() +*/ +WARN_ON_ONCE (addr != vma->vm_start); + + addr = vma->vm_start; +/* If vm_flags changed after call_mmap(), we should try merge vma again * as we may succeed this time. */
@@ -1822,25 +1833,12 @@ unsigned long mmap_region(struct file *ffput (vma->vm_file);vm_area_free (vma); vma = merge; -/* Update vm_flags and possible addr to pick up the change. We don't -* warn here if addr changed as the vma is not linked by vma_link(). -*/ - addr = vma->vm_start; +/* Update vm_flags to pick up the change. */ vm_flags = vma->vm_flags; goto unmap_writable; } } -/* Can addr have changed?? -* -* Answer: Yes, several device drivers can do it in their -* f_op->mmap method. -DaveM -* Bug: If addr is changed, prev, rb_link, rb_parent should -* be updated for vma_link() -*/ -WARN_ON_ONCE (addr != vma->vm_start); - - addr = vma->vm_start; vm_flags = vma->vm_flags; }else if (vm_flags &VM_SHARED ) { error =shmem_zero_setup (vma);
_