Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: introduce PF_MEMALLOC_NORECLAIM, PF_MEMALLOC_NOWARN

Introduce PF_MEMALLOC_* equivalents of some GFP_ flags:

PF_MEMALLOC_NORECLAIM -> GFP_NOWAIT
PF_MEMALLOC_NOWARN -> __GFP_NOWARN

Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Darrick J. Wong <djwong@kernel.org>
Cc: linux-mm@kvack.org
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>

+15 -6
+2 -2
include/linux/sched.h
··· 1636 1636 * I am cleaning dirty pages from some other bdi. */ 1637 1637 #define PF_KTHREAD 0x00200000 /* I am a kernel thread */ 1638 1638 #define PF_RANDOMIZE 0x00400000 /* Randomize virtual address space */ 1639 - #define PF__HOLE__00800000 0x00800000 1640 - #define PF__HOLE__01000000 0x01000000 1639 + #define PF_MEMALLOC_NORECLAIM 0x00800000 /* All allocation requests will clear __GFP_DIRECT_RECLAIM */ 1640 + #define PF_MEMALLOC_NOWARN 0x01000000 /* All allocation requests will inherit __GFP_NOWARN */ 1641 1641 #define PF__HOLE__02000000 0x02000000 1642 1642 #define PF_NO_SETAFFINITY 0x04000000 /* Userland is not allowed to meddle with cpus_mask */ 1643 1643 #define PF_MCE_EARLY 0x08000000 /* Early kill for mce process policy */
+13 -4
include/linux/sched/mm.h
··· 236 236 { 237 237 unsigned int pflags = READ_ONCE(current->flags); 238 238 239 - if (unlikely(pflags & (PF_MEMALLOC_NOIO | PF_MEMALLOC_NOFS | PF_MEMALLOC_PIN))) { 239 + if (unlikely(pflags & (PF_MEMALLOC_NOIO | 240 + PF_MEMALLOC_NOFS | 241 + PF_MEMALLOC_NORECLAIM | 242 + PF_MEMALLOC_NOWARN | 243 + PF_MEMALLOC_PIN))) { 240 244 /* 241 - * NOIO implies both NOIO and NOFS and it is a weaker context 242 - * so always make sure it makes precedence 245 + * Stronger flags before weaker flags: 246 + * NORECLAIM implies NOIO, which in turn implies NOFS 243 247 */ 244 - if (pflags & PF_MEMALLOC_NOIO) 248 + if (pflags & PF_MEMALLOC_NORECLAIM) 249 + flags &= ~__GFP_DIRECT_RECLAIM; 250 + else if (pflags & PF_MEMALLOC_NOIO) 245 251 flags &= ~(__GFP_IO | __GFP_FS); 246 252 else if (pflags & PF_MEMALLOC_NOFS) 247 253 flags &= ~__GFP_FS; 254 + 255 + if (pflags & PF_MEMALLOC_NOWARN) 256 + flags |= __GFP_NOWARN; 248 257 249 258 if (pflags & PF_MEMALLOC_PIN) 250 259 flags &= ~__GFP_MOVABLE;