~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/mm/failslab.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 #include <linux/fault-inject.h>
  3 #include <linux/error-injection.h>
  4 #include <linux/slab.h>
  5 #include <linux/mm.h>
  6 #include "slab.h"
  7 
  8 static struct {
  9         struct fault_attr attr;
 10         bool ignore_gfp_reclaim;
 11         bool cache_filter;
 12 } failslab = {
 13         .attr = FAULT_ATTR_INITIALIZER,
 14         .ignore_gfp_reclaim = true,
 15         .cache_filter = false,
 16 };
 17 
 18 int should_failslab(struct kmem_cache *s, gfp_t gfpflags)
 19 {
 20         int flags = 0;
 21 
 22         /* No fault-injection for bootstrap cache */
 23         if (unlikely(s == kmem_cache))
 24                 return 0;
 25 
 26         if (gfpflags & __GFP_NOFAIL)
 27                 return 0;
 28 
 29         if (failslab.ignore_gfp_reclaim &&
 30                         (gfpflags & __GFP_DIRECT_RECLAIM))
 31                 return 0;
 32 
 33         if (failslab.cache_filter && !(s->flags & SLAB_FAILSLAB))
 34                 return 0;
 35 
 36         /*
 37          * In some cases, it expects to specify __GFP_NOWARN
 38          * to avoid printing any information(not just a warning),
 39          * thus avoiding deadlocks. See commit 6b9dbedbe349 for
 40          * details.
 41          */
 42         if (gfpflags & __GFP_NOWARN)
 43                 flags |= FAULT_NOWARN;
 44 
 45         return should_fail_ex(&failslab.attr, s->object_size, flags) ? -ENOMEM : 0;
 46 }
 47 ALLOW_ERROR_INJECTION(should_failslab, ERRNO);
 48 
 49 static int __init setup_failslab(char *str)
 50 {
 51         return setup_fault_attr(&failslab.attr, str);
 52 }
 53 __setup("failslab=", setup_failslab);
 54 
 55 #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
 56 static int __init failslab_debugfs_init(void)
 57 {
 58         struct dentry *dir;
 59         umode_t mode = S_IFREG | 0600;
 60 
 61         dir = fault_create_debugfs_attr("failslab", NULL, &failslab.attr);
 62         if (IS_ERR(dir))
 63                 return PTR_ERR(dir);
 64 
 65         debugfs_create_bool("ignore-gfp-wait", mode, dir,
 66                             &failslab.ignore_gfp_reclaim);
 67         debugfs_create_bool("cache-filter", mode, dir,
 68                             &failslab.cache_filter);
 69 
 70         return 0;
 71 }
 72 
 73 late_initcall(failslab_debugfs_init);
 74 
 75 #endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */
 76 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php