From: Mikulas Patocka <mpatocka@redhat.com>
To: Mike Snitzer <msnitzer@redhat.com>
Cc: "Alasdair G. Kergon" <agk@redhat.com>,
Edward Thornber <thornber@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
David Rientjes <rientjes@google.com>,
Vivek Goyal <vgoyal@redhat.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
dm-devel@redhat.com
Subject: [PATCH 3/7] dm-ioctl: join flags DM_PARAMS_KMALLOC and DM_PARAMS_VMALLOC
Date: Tue, 7 Jul 2015 11:10:36 -0400 (EDT) [thread overview]
Message-ID: <alpine.LRH.2.02.1507071110130.23387@file01.intranet.prod.int.rdu2.redhat.com> (raw)
In-Reply-To: <alpine.LRH.2.02.1507071058350.23387@file01.intranet.prod.int.rdu2.redhat.com>
Join flags DM_PARAMS_KMALLOC and DM_PARAMS_VMALLOC into just one flag
DM_PARAMS_ALLOC. We can determine if the block was allocated with kmalloc
or vmalloc with the function is_vmalloc_addr, so there is no need to have
separate flags for that.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
---
drivers/md/dm-ioctl.c | 17 +++++++++--------
drivers/md/dm-stats.c | 20 ++++++++++----------
2 files changed, 19 insertions(+), 18 deletions(-)
Index: linux-4.1/drivers/md/dm-ioctl.c
===================================================================
--- linux-4.1.orig/drivers/md/dm-ioctl.c 2015-07-02 18:24:08.000000000 +0200
+++ linux-4.1/drivers/md/dm-ioctl.c 2015-07-02 18:52:52.000000000 +0200
@@ -1668,8 +1668,7 @@ static int check_version(unsigned int cm
return r;
}
-#define DM_PARAMS_KMALLOC 0x0001 /* Params alloced with kmalloc */
-#define DM_PARAMS_VMALLOC 0x0002 /* Params alloced with vmalloc */
+#define DM_PARAMS_ALLOC 0x0001 /* Params alloced with kmalloc or vmalloc */
#define DM_WIPE_BUFFER 0x0010 /* Wipe input buffer before returning from ioctl */
static void free_params(struct dm_ioctl *param, size_t param_size, int param_flags)
@@ -1677,10 +1676,12 @@ static void free_params(struct dm_ioctl
if (param_flags & DM_WIPE_BUFFER)
memset(param, 0, param_size);
- if (param_flags & DM_PARAMS_KMALLOC)
- kfree(param);
- if (param_flags & DM_PARAMS_VMALLOC)
- vfree(param);
+ if (param_flags & DM_PARAMS_ALLOC) {
+ if (is_vmalloc_addr(param))
+ vfree(param);
+ else
+ kfree(param);
+ }
}
static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl *param_kernel,
@@ -1715,7 +1716,7 @@ static int copy_params(struct dm_ioctl _
if (param_kernel->data_size <= KMALLOC_MAX_SIZE) {
dmi = kmalloc(param_kernel->data_size, GFP_NOIO | __GFP_NORETRY | __GFP_NOMEMALLOC | __GFP_NOWARN);
if (dmi)
- *param_flags |= DM_PARAMS_KMALLOC;
+ *param_flags |= DM_PARAMS_ALLOC;
}
if (!dmi) {
@@ -1724,7 +1725,7 @@ static int copy_params(struct dm_ioctl _
dmi = __vmalloc(param_kernel->data_size, GFP_NOIO | __GFP_REPEAT | __GFP_HIGH | __GFP_HIGHMEM, PAGE_KERNEL);
memalloc_noio_restore(noio_flag);
if (dmi)
- *param_flags |= DM_PARAMS_VMALLOC;
+ *param_flags |= DM_PARAMS_ALLOC;
}
if (!dmi) {
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2015-07-07 15:10 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-07 15:08 [PATCH 0/7] mm: reliable memory allocation with kvmalloc Mikulas Patocka
2015-07-07 15:09 ` [PATCH 1/7] mm/vmalloc: export __vmalloc_node_flags Mikulas Patocka
2015-07-07 15:10 ` [PATCH 2/7] mm: introduce kvmalloc and kvmalloc_node Mikulas Patocka
2015-07-07 21:41 ` Andrew Morton
2015-07-08 7:34 ` [dm-devel] " Zdenek Kabelac
2015-07-08 23:03 ` Mikulas Patocka
2015-07-08 23:18 ` Andrew Morton
2015-07-09 14:45 ` Mikulas Patocka
2015-07-14 21:13 ` David Rientjes
2015-07-14 21:19 ` Mike Snitzer
2015-07-14 21:24 ` David Rientjes
2015-07-14 21:54 ` Dave Chinner
2015-07-14 22:45 ` David Rientjes
2015-07-15 0:25 ` Dave Chinner
2015-07-14 21:24 ` Andrew Morton
2015-07-07 15:10 ` Mikulas Patocka [this message]
2015-07-07 15:11 ` [PATCH 4/7] dm: use kvmalloc Mikulas Patocka
2015-07-07 15:11 ` [PATCH 5/7] dm-thin: " Mikulas Patocka
2015-07-07 15:12 ` [PATCH 6/7] dm-stats: use kvmalloc_node Mikulas Patocka
2015-07-07 15:13 ` [PATCH 7/7] dm: make dm_vcalloc use kvmalloc 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=alpine.LRH.2.02.1507071110130.23387@file01.intranet.prod.int.rdu2.redhat.com \
--to=mpatocka@redhat.com \
--cc=agk@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dm-devel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=msnitzer@redhat.com \
--cc=rientjes@google.com \
--cc=thornber@redhat.com \
--cc=vgoyal@redhat.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