From: Miles Chen <miles.chen@mediatek.com> To: Joe Perches <joe@perches.com> Cc: Matthias Brugger <matthias.bgg@gmail.com>, <linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>, <wsd_upstream@mediatek.com>, <linux-mediatek@lists.infradead.org>, <linux-arm-kernel@lists.infradead.org> Subject: Re: [PATCH] mm/page_owner: use vmalloc instead of kmalloc Date: Fri, 26 Oct 2018 16:01:07 +0800 [thread overview] Message-ID: <1540540867.21297.2.camel@mtkswgap22> (raw) In-Reply-To: <e0cd65fdd6afc17b2be9b3ac64d50b95b2c2f32e.camel@perches.com> On Thu, 2018-10-25 at 11:44 -0700, Joe Perches wrote: > On Fri, 2018-10-26 at 02:34 +0800, miles.chen@mediatek.com wrote: > > 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 vmalloc() so we can also allocate kbuf from highmem > > on 32bit kernel. > > If this is really necessary, using kvmalloc/kvfree would > be better as the vmalloc space is also limited. thanks for the advise. kvmalloc/kvfree is better here. > > > diff --git 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> > > @@ -10,6 +9,7 @@ > > #include <linux/migrate.h> > > #include <linux/stackdepot.h> > > #include <linux/seq_file.h> > > +#include <linux/vmalloc.h> > > > > #include "internal.h" > > > > @@ -351,7 +351,7 @@ print_page_owner(char __user *buf, size_t count, unsigned long pfn, > > .skip = 0 > > }; > > > > - kbuf = kmalloc(count, GFP_KERNEL); > > + kbuf = vmalloc(count); > > if (!kbuf) > > return -ENOMEM; > > > > @@ -397,11 +397,11 @@ print_page_owner(char __user *buf, size_t count, unsigned long pfn, > > if (copy_to_user(buf, kbuf, ret)) > > ret = -EFAULT; > > > > - kfree(kbuf); > > + vfree(kbuf); > > return ret; > > > > err: > > - kfree(kbuf); > > + vfree(kbuf); > > return -ENOMEM; > > } > > >
next prev parent reply other threads:[~2018-10-26 8:01 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-10-25 18:34 miles.chen 2018-10-25 18:44 ` Joe Perches 2018-10-26 8:01 ` Miles Chen [this message] 2018-10-25 19:27 ` Matthew Wilcox 2018-10-26 8:50 ` Miles Chen 2018-10-26 10:56 ` 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=1540540867.21297.2.camel@mtkswgap22 \ --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=wsd_upstream@mediatek.com \ --subject='Re: [PATCH] mm/page_owner: use vmalloc instead of kmalloc' \ /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
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).