From: Paulo Marques <pmarques@grupopie.com>
To: Jiri Slaby <jirislaby@gmail.com>
Cc: Om Narasimhan <om.turyx@gmail.com>,
Nishanth Aravamudan <nacc@us.ibm.com>,
linux-kernel@vger.kernel.org, kernel-janitors@lists.osdl.org
Subject: Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
Date: Fri, 22 Sep 2006 11:28:55 +0000 [thread overview]
Message-ID: <4513C8F7.2020608@grupopie.com> (raw)
In-Reply-To: <4513A098.4060505@gmail.com>
Jiri Slaby wrote:
> Om Narasimhan wrote:
>> Thanks for the comments.
>>> >
>>> > Signed off by Om Narasimhan <om.turyx@gmail.com>
>>>
>>> This is not the canonical format, per SubmittingPatches. It should be:
>>>
>>> Signed-off-by: Random J Developer <random@developer.example.org>
>> OK. I would take care of it.
>>>
>>> > drivers/block/cciss.c | 4 +--
>>> > drivers/block/cpqarray.c | 72
>>> +++++++++++++++-------------------------------
>>> > drivers/block/loop.c | 4 +--
>>> > 3 files changed, 25 insertions(+), 55 deletions(-)
>>>
>>> Your diffstat should have indicated to you that this should be split up
>>> better. Please (re-)read SubmittingPatches. *One* logical change per
>>> patch, most importantly.
>> OK. I would resubmit.
>>> >
>>> > diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
>>> > index 2cd3391..a800a69 100644
>>> > --- a/drivers/block/cciss.c
>>> > +++ b/drivers/block/cciss.c
>>> > @@ -900,7 +900,7 @@ #if 0 /* 'buf_size'
>>> member is 16-bits
>>> > return -EINVAL;
>>> > #endif
>>> > if (iocommand.buf_size > 0) {
>>> > - buff = kmalloc(iocommand.buf_size,
>>> GFP_KERNEL);
>>> > + buff = kzalloc(iocommand.buf_size,
>>> GFP_KERNEL);
>>> > if (buff = NULL)
>>> > return -EFAULT;
>>> > }
>>> > @@ -911,8 +911,6 @@ #endif
>>> > kfree(buff);
>>> > return -EFAULT;
>>> > }
>>> > - } else {
>>> > - memset(buff, 0, iocommand.buf_size);
>>> > }
>>> > if ((c = cmd_alloc(host, 0)) = NULL) {
>>> > kfree(buff);
>>>
>>> This changes performance potentially, no? The memset before was
>>> conditional upon (iocommand.Request.Type.Direction = XFER_WRITE) and
>>> now the memory will always be zero'd.
>> Yes, but not the functionality.
>> if (iocommand.buf_size > 0), code allocates using kmalloc. if
>> direction is XFER_WRITE, it does a copy_from_user(), and free()s the
>> allocated buffer, not really caring what data came in from userspace.
You really misread that code. It frees the buffer and returns -EFAULT if
the copy_from_user _failed_. This is standard procedure and that code
doesn't need to be changed to kzalloc.
Please only do kmalloc to k[zc]alloc changes that are really trivial.
There is no point in risking inserting new bugs (or performance
regressions) for some micro-space-optimization such as this.
--
Paulo Marques - www.grupopie.com
"The face of a child can say it all, especially the
mouth part of the face."
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
WARNING: multiple messages have this Message-ID (diff)
From: Paulo Marques <pmarques@grupopie.com>
To: Jiri Slaby <jirislaby@gmail.com>
Cc: Om Narasimhan <om.turyx@gmail.com>,
Nishanth Aravamudan <nacc@us.ibm.com>,
linux-kernel@vger.kernel.org, kernel-janitors@lists.osdl.org
Subject: Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]
Date: Fri, 22 Sep 2006 12:28:55 +0100 [thread overview]
Message-ID: <4513C8F7.2020608@grupopie.com> (raw)
In-Reply-To: <4513A098.4060505@gmail.com>
Jiri Slaby wrote:
> Om Narasimhan wrote:
>> Thanks for the comments.
>>> >
>>> > Signed off by Om Narasimhan <om.turyx@gmail.com>
>>>
>>> This is not the canonical format, per SubmittingPatches. It should be:
>>>
>>> Signed-off-by: Random J Developer <random@developer.example.org>
>> OK. I would take care of it.
>>>
>>> > drivers/block/cciss.c | 4 +--
>>> > drivers/block/cpqarray.c | 72
>>> +++++++++++++++-------------------------------
>>> > drivers/block/loop.c | 4 +--
>>> > 3 files changed, 25 insertions(+), 55 deletions(-)
>>>
>>> Your diffstat should have indicated to you that this should be split up
>>> better. Please (re-)read SubmittingPatches. *One* logical change per
>>> patch, most importantly.
>> OK. I would resubmit.
>>> >
>>> > diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
>>> > index 2cd3391..a800a69 100644
>>> > --- a/drivers/block/cciss.c
>>> > +++ b/drivers/block/cciss.c
>>> > @@ -900,7 +900,7 @@ #if 0 /* 'buf_size'
>>> member is 16-bits
>>> > return -EINVAL;
>>> > #endif
>>> > if (iocommand.buf_size > 0) {
>>> > - buff = kmalloc(iocommand.buf_size,
>>> GFP_KERNEL);
>>> > + buff = kzalloc(iocommand.buf_size,
>>> GFP_KERNEL);
>>> > if (buff == NULL)
>>> > return -EFAULT;
>>> > }
>>> > @@ -911,8 +911,6 @@ #endif
>>> > kfree(buff);
>>> > return -EFAULT;
>>> > }
>>> > - } else {
>>> > - memset(buff, 0, iocommand.buf_size);
>>> > }
>>> > if ((c = cmd_alloc(host, 0)) == NULL) {
>>> > kfree(buff);
>>>
>>> This changes performance potentially, no? The memset before was
>>> conditional upon (iocommand.Request.Type.Direction == XFER_WRITE) and
>>> now the memory will always be zero'd.
>> Yes, but not the functionality.
>> if (iocommand.buf_size > 0), code allocates using kmalloc. if
>> direction is XFER_WRITE, it does a copy_from_user(), and free()s the
>> allocated buffer, not really caring what data came in from userspace.
You really misread that code. It frees the buffer and returns -EFAULT if
the copy_from_user _failed_. This is standard procedure and that code
doesn't need to be changed to kzalloc.
Please only do kmalloc to k[zc]alloc changes that are really trivial.
There is no point in risking inserting new bugs (or performance
regressions) for some micro-space-optimization such as this.
--
Paulo Marques - www.grupopie.com
"The face of a child can say it all, especially the
mouth part of the face."
next prev parent reply other threads:[~2006-09-22 11:28 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-18 0:53 [KJ] kmalloc to kzalloc patches for drivers/mfd Om Narasimhan
2006-09-18 0:53 ` Om Narasimhan
2006-09-18 0:53 ` [KJ] kmalloc to kzalloc patches for drivers/atm Om Narasimhan
2006-09-18 0:53 ` Om Narasimhan
2006-09-18 1:19 ` [KJ] " Dmitry Torokhov
2006-09-18 1:19 ` Dmitry Torokhov
2006-09-18 9:42 ` [KJ] " Alan Cox
2006-09-18 9:42 ` Alan Cox
2006-09-18 12:07 ` [KJ] " Pekka Enberg
2006-09-18 12:07 ` Pekka Enberg
2006-09-18 0:53 ` [KJ] kmalloc to kzalloc patches for drivers/base Om Narasimhan
2006-09-18 0:53 ` Om Narasimhan
2006-09-18 1:08 ` [KJ] " Dmitry Torokhov
2006-09-18 1:08 ` Dmitry Torokhov
2006-09-18 2:27 ` [KJ] " Om Narasimhan
2006-09-18 2:27 ` Om Narasimhan
2006-09-18 9:40 ` [KJ] " Alan Cox
2006-09-18 9:40 ` Alan Cox
2006-09-18 12:31 ` [KJ] " Greg KH
2006-09-18 12:31 ` Greg KH
2006-09-18 0:54 ` [KJ] kmalloc to kzalloc patches for drivers/block Om Narasimhan
2006-09-18 0:54 ` Om Narasimhan
2006-09-18 9:43 ` [KJ] kmalloc to kzalloc patches for drivers/mfd Alan Cox
2006-09-18 9:43 ` Alan Cox
2006-09-21 6:11 ` [KJ] kmalloc to kzalloc patches for drivers/block [sane version] Om Narasimhan
2006-09-21 6:11 ` Om Narasimhan
2006-09-21 7:20 ` [KJ] " Nishanth Aravamudan
2006-09-21 7:20 ` Nishanth Aravamudan
2006-09-22 5:40 ` Om Narasimhan
2006-09-22 5:40 ` Om Narasimhan
2006-09-22 6:04 ` Om Narasimhan
2006-09-22 6:04 ` Om Narasimhan
2006-09-22 8:43 ` Jiri Slaby
2006-09-22 8:43 ` Jiri Slaby
2006-09-22 11:32 ` Paulo Marques
2006-09-22 11:32 ` Paulo Marques
2006-09-22 12:03 ` Pekka Enberg
2006-09-22 12:03 ` Pekka Enberg
2006-09-22 13:03 ` Paulo Marques
2006-09-22 13:03 ` Paulo Marques
2006-09-22 13:45 ` Dmitry Torokhov
2006-09-22 13:45 ` Dmitry Torokhov
2006-09-22 22:55 ` Om Narasimhan
2006-09-22 22:55 ` Om Narasimhan
2006-09-22 8:36 ` Jiri Slaby
2006-09-22 8:36 ` Jiri Slaby
2006-09-22 11:28 ` Paulo Marques [this message]
2006-09-22 11:28 ` Paulo Marques
2006-09-21 7:12 ` [KJ] kmalloc to kzalloc patches for drivers/atm " Om Narasimhan
2006-09-21 7:12 ` Om Narasimhan
2006-09-21 13:36 ` [KJ] " Dmitry Torokhov
2006-09-21 13:36 ` Dmitry Torokhov
2006-09-22 5:29 ` [KJ] " Om Narasimhan
2006-09-22 5:29 ` Om Narasimhan
2006-09-21 7:35 ` [KJ] kmalloc to kzalloc patches for drivers/block " Thomas Petazzoni
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=4513C8F7.2020608@grupopie.com \
--to=pmarques@grupopie.com \
--cc=jirislaby@gmail.com \
--cc=kernel-janitors@lists.osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nacc@us.ibm.com \
--cc=om.turyx@gmail.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.