* [PATCH] block: replace kmalloc and then memcpy with kmemdup
@ 2013-03-11 11:23 Mihnea Dobrescu-Balaur
2013-03-11 14:54 ` Konrad Rzeszutek Wilk
0 siblings, 1 reply; 3+ messages in thread
From: Mihnea Dobrescu-Balaur @ 2013-03-11 11:23 UTC (permalink / raw)
To: xen-devel
Cc: konrad.wilk, jeremy, virtualization, linux-kernel,
Mihnea Dobrescu-Balaur
Signed-off-by: Mihnea Dobrescu-Balaur <mihneadb@gmail.com>
---
drivers/block/xen-blkfront.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index c3dae2e..9620644 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -1203,11 +1203,10 @@ static int blkif_recover(struct blkfront_info *info)
int j;
/* Stage 1: Make a safe copy of the shadow state. */
- copy = kmalloc(sizeof(info->shadow),
+ copy = kmemdup(info->shadow, sizeof(info->shadow),
GFP_NOIO | __GFP_REPEAT | __GFP_HIGH);
if (!copy)
return -ENOMEM;
- memcpy(copy, info->shadow, sizeof(info->shadow));
/* Stage 2: Set up free list. */
memset(&info->shadow, 0, sizeof(info->shadow));
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] block: replace kmalloc and then memcpy with kmemdup
2013-03-11 11:23 [PATCH] block: replace kmalloc and then memcpy with kmemdup Mihnea Dobrescu-Balaur
@ 2013-03-11 14:54 ` Konrad Rzeszutek Wilk
2013-03-11 15:17 ` Daniel Baluta
0 siblings, 1 reply; 3+ messages in thread
From: Konrad Rzeszutek Wilk @ 2013-03-11 14:54 UTC (permalink / raw)
To: Mihnea Dobrescu-Balaur; +Cc: xen-devel, jeremy, virtualization, linux-kernel
On Mon, Mar 11, 2013 at 01:23:36PM +0200, Mihnea Dobrescu-Balaur wrote:
Are there performance improvements to doing it this way?
> Signed-off-by: Mihnea Dobrescu-Balaur <mihneadb@gmail.com>
> ---
> drivers/block/xen-blkfront.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
> index c3dae2e..9620644 100644
> --- a/drivers/block/xen-blkfront.c
> +++ b/drivers/block/xen-blkfront.c
> @@ -1203,11 +1203,10 @@ static int blkif_recover(struct blkfront_info *info)
> int j;
>
> /* Stage 1: Make a safe copy of the shadow state. */
> - copy = kmalloc(sizeof(info->shadow),
> + copy = kmemdup(info->shadow, sizeof(info->shadow),
> GFP_NOIO | __GFP_REPEAT | __GFP_HIGH);
> if (!copy)
> return -ENOMEM;
> - memcpy(copy, info->shadow, sizeof(info->shadow));
>
> /* Stage 2: Set up free list. */
> memset(&info->shadow, 0, sizeof(info->shadow));
> --
> 1.7.10.4
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] block: replace kmalloc and then memcpy with kmemdup
2013-03-11 14:54 ` Konrad Rzeszutek Wilk
@ 2013-03-11 15:17 ` Daniel Baluta
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Baluta @ 2013-03-11 15:17 UTC (permalink / raw)
To: Konrad Rzeszutek Wilk
Cc: Mihnea Dobrescu-Balaur, jeremy, xen-devel, linux-kernel,
virtualization
Hi Konrad,
The performance is the same using kmemdup, but we have the following advantages:
* code is cleaner
* kmemdup adds additional debugging info useful for tracking the real
place where memory was allocated [1] [2].
thanks,
Daniel.
[1] http://lxr.linux.no/#linux+v3.8.2/mm/util.c#L61
[2] http://lxr.linux.no/#linux+v3.8.2/include/linux/slab.h#L363
On Mon, Mar 11, 2013 at 4:54 PM, Konrad Rzeszutek Wilk
<konrad.wilk@oracle.com> wrote:
> On Mon, Mar 11, 2013 at 01:23:36PM +0200, Mihnea Dobrescu-Balaur wrote:
>
> Are there performance improvements to doing it this way?
>
>> Signed-off-by: Mihnea Dobrescu-Balaur <mihneadb@gmail.com>
>> ---
>> drivers/block/xen-blkfront.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
>> index c3dae2e..9620644 100644
>> --- a/drivers/block/xen-blkfront.c
>> +++ b/drivers/block/xen-blkfront.c
>> @@ -1203,11 +1203,10 @@ static int blkif_recover(struct blkfront_info *info)
>> int j;
>>
>> /* Stage 1: Make a safe copy of the shadow state. */
>> - copy = kmalloc(sizeof(info->shadow),
>> + copy = kmemdup(info->shadow, sizeof(info->shadow),
>> GFP_NOIO | __GFP_REPEAT | __GFP_HIGH);
>> if (!copy)
>> return -ENOMEM;
>> - memcpy(copy, info->shadow, sizeof(info->shadow));
>>
>> /* Stage 2: Set up free list. */
>> memset(&info->shadow, 0, sizeof(info->shadow));
>> --
>> 1.7.10.4
>>
> _______________________________________________
> Virtualization mailing list
> Virtualization@lists.linux-foundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-03-11 15:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-11 11:23 [PATCH] block: replace kmalloc and then memcpy with kmemdup Mihnea Dobrescu-Balaur
2013-03-11 14:54 ` Konrad Rzeszutek Wilk
2013-03-11 15:17 ` Daniel Baluta
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox