All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mm/page_alloc: skip setting nodemask when we are in interrupt
@ 2020-07-06  2:59 Muchun Song
  2020-07-06 11:49   ` Pekka Enberg
  0 siblings, 1 reply; 3+ messages in thread
From: Muchun Song @ 2020-07-06  2:59 UTC (permalink / raw)
  To: akpm, david, penberg; +Cc: linux-mm, linux-kernel, Muchun Song

When we are in the interrupt context, it is irrelevant to the
current task context. If we use current task's mems_allowed, we
can fair to alloc pages in the fast path and fall back to slow
path memory allocation when the current node(which is the current
task mems_allowed) does not have enough memory to allocate. In
this case, it slows down the memory allocation speed of interrupt
context. So we can skip setting the nodemask to allow any node
to allocate memory, so that fast path allocation can success.

Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---

changelog in v2:
 1) rework the code suggested by Pekka Enberg
 2) add a comment

 mm/page_alloc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 9808339a6e93b..6678c4c1c3087 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4799,7 +4799,11 @@ static inline bool prepare_alloc_pages(gfp_t gfp_mask, unsigned int order,
 
 	if (cpusets_enabled()) {
 		*alloc_mask |= __GFP_HARDWALL;
-		if (!ac->nodemask)
+		/*
+		 * When we are in the interrupt context, it is irrelevant
+		 * to the current task context. It means that any node ok.
+		 */
+		if (!in_interrupt() && !ac->nodemask)
 			ac->nodemask = &cpuset_current_mems_allowed;
 		else
 			*alloc_flags |= ALLOC_CPUSET;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] mm/page_alloc: skip setting nodemask when we are in interrupt
  2020-07-06  2:59 [PATCH v2] mm/page_alloc: skip setting nodemask when we are in interrupt Muchun Song
@ 2020-07-06 11:49   ` Pekka Enberg
  0 siblings, 0 replies; 3+ messages in thread
From: Pekka Enberg @ 2020-07-06 11:49 UTC (permalink / raw)
  To: Muchun Song; +Cc: Andrew Morton, David Hildenbrand, linux-mm, LKML

On Mon, Jul 6, 2020 at 5:59 AM Muchun Song <songmuchun@bytedance.com> wrote:
> When we are in the interrupt context, it is irrelevant to the
> current task context. If we use current task's mems_allowed, we
> can fair to alloc pages in the fast path and fall back to slow
> path memory allocation when the current node(which is the current
> task mems_allowed) does not have enough memory to allocate. In
> this case, it slows down the memory allocation speed of interrupt
> context. So we can skip setting the nodemask to allow any node
> to allocate memory, so that fast path allocation can success.
>
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>

Reviewed-by: Pekka Enberg <penberg@kernel.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] mm/page_alloc: skip setting nodemask when we are in interrupt
@ 2020-07-06 11:49   ` Pekka Enberg
  0 siblings, 0 replies; 3+ messages in thread
From: Pekka Enberg @ 2020-07-06 11:49 UTC (permalink / raw)
  To: Muchun Song; +Cc: Andrew Morton, David Hildenbrand, linux-mm, LKML

On Mon, Jul 6, 2020 at 5:59 AM Muchun Song <songmuchun@bytedance.com> wrote:
> When we are in the interrupt context, it is irrelevant to the
> current task context. If we use current task's mems_allowed, we
> can fair to alloc pages in the fast path and fall back to slow
> path memory allocation when the current node(which is the current
> task mems_allowed) does not have enough memory to allocate. In
> this case, it slows down the memory allocation speed of interrupt
> context. So we can skip setting the nodemask to allow any node
> to allocate memory, so that fast path allocation can success.
>
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>

Reviewed-by: Pekka Enberg <penberg@kernel.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-06 11:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-06  2:59 [PATCH v2] mm/page_alloc: skip setting nodemask when we are in interrupt Muchun Song
2020-07-06 11:49 ` Pekka Enberg
2020-07-06 11:49   ` Pekka Enberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.