From: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
To: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
Michal Hocko <mhocko@suse.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 2] mm/kvmalloc: do not call kmalloc for size > KMALLOC_MAX_SIZE
Date: Thu, 01 Nov 2018 13:09:16 +0300 [thread overview]
Message-ID: <154106695670.898059.5301435081426064314.stgit@buzz> (raw)
In-Reply-To: <154106356066.887821.4649178319705436373.stgit@buzz>
Allocations over KMALLOC_MAX_SIZE could be served only by vmalloc.
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
---
mm/util.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mm/util.c b/mm/util.c
index 8bf08b5b5760..f5f04fa22814 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -392,6 +392,9 @@ void *kvmalloc_node(size_t size, gfp_t flags, int node)
gfp_t kmalloc_flags = flags;
void *ret;
+ if (size > KMALLOC_MAX_SIZE)
+ goto fallback;
+
/*
* vmalloc uses GFP_KERNEL for some internal allocations (e.g page tables)
* so the given set of flags has to be compatible.
@@ -422,6 +425,7 @@ void *kvmalloc_node(size_t size, gfp_t flags, int node)
if (ret || size <= PAGE_SIZE)
return ret;
+fallback:
return __vmalloc_node_flags_caller(size, node, flags,
__builtin_return_address(0));
}
next prev parent reply other threads:[~2018-11-01 10:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-01 9:12 [PATCH] mm/kvmalloc: do not confuse kmalloc with page order over MAX_ORDER Konstantin Khlebnikov
2018-11-01 9:33 ` Michal Hocko
2018-11-01 10:09 ` Konstantin Khlebnikov [this message]
2018-11-01 10:24 ` [PATCH 2] mm/kvmalloc: do not call kmalloc for size > KMALLOC_MAX_SIZE Michal Hocko
2018-11-01 10:48 ` Konstantin Khlebnikov
2018-11-01 12:55 ` Michal Hocko
2018-11-01 16:42 ` Konstantin Khlebnikov
2018-11-01 16:55 ` Michal Hocko
2018-11-05 13:03 ` Vlastimil Babka
2018-11-05 16:19 ` Konstantin Khlebnikov
2018-11-05 16:52 ` Vlastimil Babka
2018-11-05 16:57 ` 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=154106695670.898059.5301435081426064314.stgit@buzz \
--to=khlebnikov@yandex-team.ru \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
/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