linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bharath Vedartham <linux.bhar@gmail.com>
To: akpm@linux-foundation.org, vbabka@suse.cz, mhocko@suse.com,
	rientjes@google.com
Cc: khalid.aziz@oracle.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH] mm: Remove VM_BUG_ON in __alloc_pages_node
Date: Wed, 5 Jun 2019 11:32:29 +0530	[thread overview]
Message-ID: <20190605060229.GA9468@bharath12345-Inspiron-5559> (raw)

In __alloc_pages_node, there is a VM_BUG_ON on the condition (nid < 0 ||
nid >= MAX_NUMNODES). Remove this VM_BUG_ON and add a VM_WARN_ON, if the
condition fails and fail the allocation if an invalid NUMA node id is
passed to __alloc_pages_node.

The check (nid < 0 || nid >= MAX_NUMNODES) also considers NUMA_NO_NODE
as an invalid nid, but the caller of __alloc_pages_node is assumed to
have checked for the case where nid == NUMA_NO_NODE.

Signed-off-by: Bharath Vedartham <linux.bhar@gmail.com>
---
 include/linux/gfp.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 5f5e25f..075bdaf 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -480,7 +480,11 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order, int preferred_nid)
 static inline struct page *
 __alloc_pages_node(int nid, gfp_t gfp_mask, unsigned int order)
 {
-	VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES);
+	if (nid < 0 || nid >= MAX_NUMNODES) {
+		VM_WARN_ON(nid < 0 || nid >= MAX_NUMNODES);
+		return NULL; 
+	}
+
 	VM_WARN_ON((gfp_mask & __GFP_THISNODE) && !node_online(nid));
 
 	return __alloc_pages(gfp_mask, order, nid);
-- 
2.7.4


             reply	other threads:[~2019-06-05  6:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-05  6:02 Bharath Vedartham [this message]
2019-06-05  7:03 ` [PATCH] mm: Remove VM_BUG_ON in __alloc_pages_node Michal Hocko
2019-06-05 13:07   ` Bharath Vedartham
2019-06-05 14:22     ` Michal Hocko
2019-06-05 15:55       ` Bharath Vedartham
2019-06-06  5:29         ` Michal Hocko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190605060229.GA9468@bharath12345-Inspiron-5559 \
    --to=linux.bhar@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=khalid.aziz@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=rientjes@google.com \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).