From: <miles.chen@mediatek.com>
To: Matthias Brugger <matthias.bgg@gmail.com>
Cc: <linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>,
<wsd_upstream@mediatek.com>, <linux-mediatek@lists.infradead.org>,
<linux-arm-kernel@lists.infradead.org>,
Joe Perches <joe@perches.com>, Michal Hocko <mhocko@kernel.org>,
Matthew Wilcox <willy@infradead.org>,
Miles Chen <miles.chen@mediatek.com>
Subject: [PATCHv2] mm/page_owner: use kvmalloc instead of kmalloc
Date: Mon, 29 Oct 2018 10:16:43 +0800 [thread overview]
Message-ID: <1540779403-27622-1-git-send-email-miles.chen@mediatek.com> (raw)
From: Miles Chen <miles.chen@mediatek.com>
The kbuf used by page owner is allocated by kmalloc(), which means it
can use only normal memory and there might be a "out of memory"
issue when we're out of normal memory.
Use kvmalloc() so we can also allocate kbuf from
normal/hihghmem on 32bit kernel.
Clamp the kbuf size to PAGE_SIZE.
Change since v1:
- use kvmalloc()
- clamp buffer size to PAGE_SIZE
Signed-off-by: Miles Chen <miles.chen@mediatek.com>
Cc: Joe Perches <joe@perches.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Michal Hocko <mhocko@kernel.org>
---
mm/page_owner.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mm/page_owner.c b/mm/page_owner.c
index d80adfe..a064cd0 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/debugfs.h>
#include <linux/mm.h>
-#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/bootmem.h>
#include <linux/stacktrace.h>
@@ -351,7 +350,8 @@ void pagetypeinfo_showmixedcount_print(struct seq_file *m,
.skip = 0
};
- kbuf = kmalloc(count, GFP_KERNEL);
+ count = count > PAGE_SIZE ? PAGE_SIZE : count;
+ kbuf = kvmalloc(count, GFP_KERNEL);
if (!kbuf)
return -ENOMEM;
@@ -397,11 +397,11 @@ void pagetypeinfo_showmixedcount_print(struct seq_file *m,
if (copy_to_user(buf, kbuf, ret))
ret = -EFAULT;
- kfree(kbuf);
+ kvfree(kbuf);
return ret;
err:
- kfree(kbuf);
+ kvfree(kbuf);
return -ENOMEM;
}
--
1.9.1
next reply other threads:[~2018-10-29 2:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-29 2:16 miles.chen [this message]
2018-10-29 2:30 ` [PATCHv2] mm/page_owner: use kvmalloc instead of kmalloc Matthew Wilcox
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=1540779403-27622-1-git-send-email-miles.chen@mediatek.com \
--to=miles.chen@mediatek.com \
--cc=joe@perches.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-mm@kvack.org \
--cc=matthias.bgg@gmail.com \
--cc=mhocko@kernel.org \
--cc=willy@infradead.org \
--cc=wsd_upstream@mediatek.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;
as well as URLs for NNTP newsgroup(s).