All of lore.kernel.org
 help / color / mirror / Atom feed
From: "xinhui.pan" <xinhuix.pan@intel.com>
To: linux-kernel@vger.kernel.org, agk@redhat.com, snitzer@redhat.com,
	dm-devel@redhat.com
Cc: yanmin_zhang@linux.intel.com, "Liu, ShuoX" <shuox.liu@intel.com>
Subject: [PATCH] md/dm-ioctl.c: optimize memory allocation in copy_params
Date: Fri, 04 Jul 2014 18:22:32 +0800	[thread overview]
Message-ID: <53B68068.2060102@intel.com> (raw)

KMALLOC_MAX_SIZE is too big, it easily cause memory fragmented and low memory when param_kernel->data_size
is also big. That's not nice. So use vmalloc instead of kmalloc when size is larger than (PAGE_SIZE << 2).
There are other drivers using kmalloc to gain a big size memory. And that cause our devices to hit hang and
many worse issues. We don't benefit much when using kmalloc in such scenario.

Signed-off-by: xinhui.pan <xinhuiX.pan@intel.com>
Signed-off-by: yanmin.zhang <yanmin_zhang@linux.intel.com>
---
 drivers/md/dm-ioctl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 5152142..31c3af9 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1709,7 +1709,7 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl *param_kern
         * Use kmalloc() rather than vmalloc() when we can.
         */
        dmi = NULL;
-       if (param_kernel->data_size <= KMALLOC_MAX_SIZE) {
+       if (param_kernel->data_size <= (PAGE_SIZE << 2)) {
                dmi = kmalloc(param_kernel->data_size, GFP_NOIO | __GFP_NORETRY | __GFP_NOMEMALLOC | __GFP_NOWARN);
                if (dmi)
                        *param_flags |= DM_PARAMS_KMALLOC;
-- 
1.7.9.5

             reply	other threads:[~2014-07-04 10:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-04 10:22 xinhui.pan [this message]
2014-07-08 22:39 ` [dm-devel] [PATCH] md/dm-ioctl.c: optimize memory allocation in copy_params Mikulas Patocka
2014-07-09  2:01   ` Zhang, Yanmin
2014-07-09  3:37     ` xinhui.pan
2014-07-09 14:53     ` Mikulas Patocka
2014-07-22  1:02       ` Zhang, Yanmin
2014-07-22  1:23         ` Alasdair G Kergon
2014-07-22  2:04           ` Alasdair G Kergon
2014-07-23  3:15             ` Zhang, Yanmin
2014-07-23  3:06           ` Zhang, Yanmin
2014-07-23 12:16             ` Mikulas Patocka
2014-07-23 12:54               ` Alasdair G Kergon
2014-07-23 17:14                 ` Mikulas Patocka
2014-07-24  5:53                   ` Zhang, Yanmin
2014-07-23 12:39         ` Mikulas Patocka

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=53B68068.2060102@intel.com \
    --to=xinhuix.pan@intel.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shuox.liu@intel.com \
    --cc=snitzer@redhat.com \
    --cc=yanmin_zhang@linux.intel.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 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.