Unverified Commit b84dc01b authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!14091 mm, slab: put should_failslab() back behind CONFIG_SHOULD_FAILSLAB

Merge Pull Request from: @ci-robot 
 
PR sync from: Jinjie Ruan <ruanjinjie@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/DMK4SJOOGNUVV7ELLIQHQ44GW46ZLSIK/ 
Backport 2 salb improve patch, which has 1% improve for fork.

Vlastimil Babka (2):
  mm, slab: put should_failslab() back behind CONFIG_SHOULD_FAILSLAB
  mm, page_alloc: put should_fail_alloc_page() back behing
    CONFIG_FAIL_PAGE_ALLOC


-- 
2.34.1
 
https://gitee.com/src-openeuler/kernel/issues/IB0VAP 
 
Link:https://gitee.com/openeuler/kernel/pulls/14091

 

Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarZhang Peng <zhangpeng362@huawei.com>
parents 94f82afb 4b0e0ccd
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -91,22 +91,19 @@ static inline void fault_config_init(struct fault_config *config,

struct kmem_cache;

bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order);

#ifdef CONFIG_FAIL_PAGE_ALLOC
bool __should_fail_alloc_page(gfp_t gfp_mask, unsigned int order);
bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order);
#else
static inline bool __should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
static inline bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
{
	return false;
}
#endif /* CONFIG_FAIL_PAGE_ALLOC */

int should_failslab(struct kmem_cache *s, gfp_t gfpflags);
#ifdef CONFIG_FAILSLAB
extern bool __should_failslab(struct kmem_cache *s, gfp_t gfpflags);
int should_failslab(struct kmem_cache *s, gfp_t gfpflags);
#else
static inline bool __should_failslab(struct kmem_cache *s, gfp_t gfpflags)
static inline int should_failslab(struct kmem_cache *s, gfp_t gfpflags)
{
	return false;
}
+4 −0
Original line number Diff line number Diff line
@@ -20012,8 +20012,12 @@ BTF_SET_START(btf_non_sleepable_error_inject)
 * Assume non-sleepable from bpf safety point of view.
 */
BTF_ID(func, __filemap_add_folio)
#ifdef CONFIG_FAIL_PAGE_ALLOC
BTF_ID(func, should_fail_alloc_page)
#endif
#ifdef CONFIG_FAILSLAB
BTF_ID(func, should_failslab)
#endif
BTF_SET_END(btf_non_sleepable_error_inject)
static int check_non_sleepable_error_inject(u32 btf_id)
+3 −1
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
#include <linux/fault-inject.h>
#include <linux/error-injection.h>
#include <linux/mm.h>

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

bool __should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
{
	int flags = 0;

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

	return should_fail_ex(&fail_page_alloc.attr, 1 << order, flags);
}
ALLOW_ERROR_INJECTION(should_fail_alloc_page, TRUE);

#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS

+8 −6
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
#include <linux/fault-inject.h>
#include <linux/error-injection.h>
#include <linux/slab.h>
#include <linux/mm.h>
#include "slab.h"
@@ -14,23 +15,23 @@ static struct {
	.cache_filter = false,
};

bool __should_failslab(struct kmem_cache *s, gfp_t gfpflags)
int should_failslab(struct kmem_cache *s, gfp_t gfpflags)
{
	int flags = 0;

	/* No fault-injection for bootstrap cache */
	if (unlikely(s == kmem_cache))
		return false;
		return 0;

	if (gfpflags & __GFP_NOFAIL)
		return false;
		return 0;

	if (failslab.ignore_gfp_reclaim &&
			(gfpflags & __GFP_DIRECT_RECLAIM))
		return false;
		return 0;

	if (failslab.cache_filter && !(s->flags & SLAB_FAILSLAB))
		return false;
		return 0;

	/*
	 * In some cases, it expects to specify __GFP_NOWARN
@@ -41,8 +42,9 @@ bool __should_failslab(struct kmem_cache *s, gfp_t gfpflags)
	if (gfpflags & __GFP_NOWARN)
		flags |= FAULT_NOWARN;

	return should_fail_ex(&failslab.attr, s->object_size, flags);
	return should_fail_ex(&failslab.attr, s->object_size, flags) ? -ENOMEM : 0;
}
ALLOW_ERROR_INJECTION(should_failslab, ERRNO);

static int __init setup_failslab(char *str)
{
+0 −6
Original line number Diff line number Diff line
@@ -2959,12 +2959,6 @@ struct page *rmqueue(struct zone *preferred_zone,
	return page;
}

noinline bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
{
	return __should_fail_alloc_page(gfp_mask, order);
}
ALLOW_ERROR_INJECTION(should_fail_alloc_page, TRUE);

static inline long __zone_watermark_unusable_free(struct zone *z,
				unsigned int order, unsigned int alloc_flags)
{
Loading