mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-11-19 08:29:42 +01:00
Model call chain after should_failslab(). Likewise, we can now use a kprobe to override the return value of should_fail_alloc_page() and inject allocation failures into alloc_page*(). This will allow injecting allocation failures using the BCC tools even without building kernel with CONFIG_FAIL_PAGE_ALLOC and booting it with a fail_page_alloc= parameter, which incurs some overhead even when failures are not being injected. On the other hand, this patch adds an unconditional call to should_fail_alloc_page() from page allocation hotpath. That overhead should be rather negligible with CONFIG_FAIL_PAGE_ALLOC=n when there's no kprobe attached, though. [[email protected]: changelog addition] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Benjamin Poirier <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Pavel Tatashin <[email protected]> Cc: Oscar Salvador <[email protected]> Cc: Mike Rapoport <[email protected]> Cc: Joonsoo Kim <[email protected]> Cc: Alexander Duyck <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
37 lines
1.0 KiB
C
37 lines
1.0 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _ASM_GENERIC_ERROR_INJECTION_H
|
|
#define _ASM_GENERIC_ERROR_INJECTION_H
|
|
|
|
#if defined(__KERNEL__) && !defined(__ASSEMBLY__)
|
|
enum {
|
|
EI_ETYPE_NONE, /* Dummy value for undefined case */
|
|
EI_ETYPE_NULL, /* Return NULL if failure */
|
|
EI_ETYPE_ERRNO, /* Return -ERRNO if failure */
|
|
EI_ETYPE_ERRNO_NULL, /* Return -ERRNO or NULL if failure */
|
|
EI_ETYPE_TRUE, /* Return true if failure */
|
|
};
|
|
|
|
struct error_injection_entry {
|
|
unsigned long addr;
|
|
int etype;
|
|
};
|
|
|
|
#ifdef CONFIG_FUNCTION_ERROR_INJECTION
|
|
/*
|
|
* Whitelist ganerating macro. Specify functions which can be
|
|
* error-injectable using this macro.
|
|
*/
|
|
#define ALLOW_ERROR_INJECTION(fname, _etype) \
|
|
static struct error_injection_entry __used \
|
|
__attribute__((__section__("_error_injection_whitelist"))) \
|
|
_eil_addr_##fname = { \
|
|
.addr = (unsigned long)fname, \
|
|
.etype = EI_ETYPE_##_etype, \
|
|
};
|
|
#else
|
|
#define ALLOW_ERROR_INJECTION(fname, _etype)
|
|
#endif
|
|
#endif
|
|
|
|
#endif /* _ASM_GENERIC_ERROR_INJECTION_H */
|