Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e97ca8e5 authored by Johannes Weiner's avatar Johannes Weiner Committed by Linus Torvalds
Browse files

mm: fix GFP_THISNODE callers and clarify



GFP_THISNODE is for callers that implement their own clever fallback to
remote nodes.  It restricts the allocation to the specified node and
does not invoke reclaim, assuming that the caller will take care of it
when the fallback fails, e.g.  through a subsequent allocation request
without GFP_THISNODE set.

However, many current GFP_THISNODE users only want the node exclusive
aspect of the flag, without actually implementing their own fallback or
triggering reclaim if necessary.  This results in things like page
migration failing prematurely even when there is easily reclaimable
memory available, unless kswapd happens to be running already or a
concurrent allocation attempt triggers the necessary reclaim.

Convert all callsites that don't implement their own fallback strategy
to __GFP_THISNODE.  This restricts the allocation a single node too, but
at the same time allows the allocator to enter the slowpath, wake
kswapd, and invoke direct reclaim if necessary, to make the allocation
happen when memory is full.

Signed-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Acked-by: default avatarRik van Riel <riel@redhat.com>
Cc: Jan Stancek <jstancek@redhat.com>
Cc: Mel Gorman <mgorman@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent fa389e22
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ static int uncached_add_chunk(struct uncached_pool *uc_pool, int nid)
	/* attempt to allocate a granule's worth of cached memory pages */

	page = alloc_pages_exact_node(nid,
				GFP_KERNEL | __GFP_ZERO | GFP_THISNODE,
				GFP_KERNEL | __GFP_ZERO | __GFP_THISNODE,
				IA64_GRANULE_SHIFT-PAGE_SHIFT);
	if (!page) {
		mutex_unlock(&uc_pool->add_chunk_mutex);
+2 −1
Original line number Diff line number Diff line
@@ -123,7 +123,8 @@ static int __init cbe_ptcal_enable_on_node(int nid, int order)

	area->nid = nid;
	area->order = order;
	area->pages = alloc_pages_exact_node(area->nid, GFP_KERNEL|GFP_THISNODE,
	area->pages = alloc_pages_exact_node(area->nid,
						GFP_KERNEL|__GFP_THISNODE,
						area->order);

	if (!area->pages) {
+1 −1
Original line number Diff line number Diff line
@@ -240,7 +240,7 @@ xpc_create_gru_mq_uv(unsigned int mq_size, int cpu, char *irq_name,

	nid = cpu_to_node(cpu);
	page = alloc_pages_exact_node(nid,
				      GFP_KERNEL | __GFP_ZERO | GFP_THISNODE,
				      GFP_KERNEL | __GFP_ZERO | __GFP_THISNODE,
				      pg_order);
	if (page == NULL) {
		dev_err(xpc_part, "xpc_create_gru_mq_uv() failed to alloc %d "
+4 −0
Original line number Diff line number Diff line
@@ -123,6 +123,10 @@ struct vm_area_struct;
			 __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN | \
			 __GFP_NO_KSWAPD)

/*
 * GFP_THISNODE does not perform any reclaim, you most likely want to
 * use __GFP_THISNODE to allocate from a given node without fallback!
 */
#ifdef CONFIG_NUMA
#define GFP_THISNODE	(__GFP_THISNODE | __GFP_NOWARN | __GFP_NORETRY)
#else
+2 −2
Original line number Diff line number Diff line
@@ -590,10 +590,10 @@ static inline bool zone_is_empty(struct zone *zone)

/*
 * The NUMA zonelists are doubled because we need zonelists that restrict the
 * allocations to a single node for GFP_THISNODE.
 * allocations to a single node for __GFP_THISNODE.
 *
 * [0]	: Zonelist with fallback
 * [1]	: No fallback (GFP_THISNODE)
 * [1]	: No fallback (__GFP_THISNODE)
 */
#define MAX_ZONELISTS 2

Loading