Skip to content

Commit 53dabce

Browse files
tehcasterakpm00
authored andcommitted
mm, page_alloc: put should_fail_alloc_page() back behing CONFIG_FAIL_PAGE_ALLOC
This mostly reverts commit af3b854 ("mm/page_alloc.c: allow error injection"). The commit made should_fail_alloc_page() a noinline function that's always called from the page allocation hotpath, even if it's empty because CONFIG_FAIL_PAGE_ALLOC is not enabled, and there is no option to disable it and prevent the associated function call overhead. As with the preceding patch "mm, slab: put should_failslab back behind CONFIG_SHOULD_FAILSLAB" and for the same reasons, put the should_fail_alloc_page() back behind the config option. When enabled, the ALLOW_ERROR_INJECTION and BTF_ID records are preserved so it's not a complete revert. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Vlastimil Babka <[email protected]> Cc: Akinobu Mita <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Andrii Nakryiko <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: Daniel Borkmann <[email protected]> Cc: David Rientjes <[email protected]> Cc: Eduard Zingerman <[email protected]> Cc: Hao Luo <[email protected]> Cc: Hyeonggon Yoo <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Fastabend <[email protected]> Cc: KP Singh <[email protected]> Cc: Martin KaFai Lau <[email protected]> Cc: Mateusz Guzik <[email protected]> Cc: Roman Gushchin <[email protected]> Cc: Song Liu <[email protected]> Cc: Stanislav Fomichev <[email protected]> Cc: Yonghong Song <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent a7526fe commit 53dabce

File tree

4 files changed

+7
-11
lines changed

4 files changed

+7
-11
lines changed

include/linux/fault-inject.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,10 @@ static inline void fault_config_init(struct fault_config *config,
9191

9292
struct kmem_cache;
9393

94-
bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order);
95-
9694
#ifdef CONFIG_FAIL_PAGE_ALLOC
97-
bool __should_fail_alloc_page(gfp_t gfp_mask, unsigned int order);
95+
bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order);
9896
#else
99-
static inline bool __should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
97+
static inline bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
10098
{
10199
return false;
102100
}

kernel/bpf/verifier.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21122,7 +21122,9 @@ BTF_SET_START(btf_non_sleepable_error_inject)
2112221122
* Assume non-sleepable from bpf safety point of view.
2112321123
*/
2112421124
BTF_ID(func, __filemap_add_folio)
21125+
#ifdef CONFIG_FAIL_PAGE_ALLOC
2112521126
BTF_ID(func, should_fail_alloc_page)
21127+
#endif
2112621128
#ifdef CONFIG_FAILSLAB
2112721129
BTF_ID(func, should_failslab)
2112821130
#endif

mm/fail_page_alloc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#include <linux/fault-inject.h>
3+
#include <linux/error-injection.h>
34
#include <linux/mm.h>
45

56
static struct {
@@ -21,7 +22,7 @@ static int __init setup_fail_page_alloc(char *str)
2122
}
2223
__setup("fail_page_alloc=", setup_fail_page_alloc);
2324

24-
bool __should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
25+
bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
2526
{
2627
int flags = 0;
2728

@@ -41,6 +42,7 @@ bool __should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
4142

4243
return should_fail_ex(&fail_page_alloc.attr, 1 << order, flags);
4344
}
45+
ALLOW_ERROR_INJECTION(should_fail_alloc_page, TRUE);
4446

4547
#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
4648

mm/page_alloc.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3050,12 +3050,6 @@ struct page *rmqueue(struct zone *preferred_zone,
30503050
return page;
30513051
}
30523052

3053-
noinline bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
3054-
{
3055-
return __should_fail_alloc_page(gfp_mask, order);
3056-
}
3057-
ALLOW_ERROR_INJECTION(should_fail_alloc_page, TRUE);
3058-
30593053
static inline long __zone_watermark_unusable_free(struct zone *z,
30603054
unsigned int order, unsigned int alloc_flags)
30613055
{

0 commit comments

Comments
 (0)