From: SF Markus Elfring <hidden> Date: 2017-05-20 14:30:33
From: Markus Elfring <redacted>
Date: Sat, 20 May 2017 16:25:04 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Improve a size determination in four functions
Delete error messages for failed memory allocations in five functions
drivers/vhost/scsi.c | 33 +++++++++++----------------------
1 file changed, 11 insertions(+), 22 deletions(-)
--
2.13.0
From: SF Markus Elfring <hidden> Date: 2017-05-20 14:31:24
From: Markus Elfring <redacted>
Date: Sat, 20 May 2017 13:48:44 +0200
Replace the specification of four data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
Signed-off-by: Markus Elfring <redacted>
---
drivers/vhost/scsi.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
From: SF Markus Elfring <hidden> Date: 2017-05-20 14:32:27
From: Markus Elfring <redacted>
Date: Sat, 20 May 2017 15:50:30 +0200
Omit seven extra messages for memory allocation failures in these functions.
This issue was detected by using the Coccinelle software.
Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <redacted>
---
drivers/vhost/scsi.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
@@ -417,5 +417,4 @@ vhost_scsi_allocate_evt(struct vhost_scsi *vs,if(!evt){-vq_err(vq,"Failed to allocate vhost_scsi_evt\n");vs->vs_events_missed=true;returnNULL;}
@@ -1722,21 +1721,15 @@ static int vhost_scsi_nexus_cb(struct se_portal_group *se_tpg,-if(!tv_cmd->tvc_sgl){-pr_err("Unable to allocate tv_cmd->tvc_sgl\n");+if(!tv_cmd->tvc_sgl)gotoout;-}tv_cmd->tvc_upages=kzalloc(sizeof(structpage*)*VHOST_SCSI_PREALLOC_UPAGES,GFP_KERNEL);-if(!tv_cmd->tvc_upages){-pr_err("Unable to allocate tv_cmd->tvc_upages\n");+if(!tv_cmd->tvc_upages)gotoout;-}tv_cmd->tvc_prot_sgl=kzalloc(sizeof(structscatterlist)*VHOST_SCSI_PREALLOC_PROT_SGLS,GFP_KERNEL);-if(!tv_cmd->tvc_prot_sgl){-pr_err("Unable to allocate tv_cmd->tvc_prot_sgl\n");+if(!tv_cmd->tvc_prot_sgl)gotoout;-}}return0;out:
@@ -1760,6 +1753,5 @@ static int vhost_scsi_make_nexus(struct vhost_scsi_tpg *tpg,if(!tv_nexus){mutex_unlock(&tpg->tv_tpg_mutex);-pr_err("Unable to allocate struct vhost_scsi_nexus\n");return-ENOMEM;}/*
From: Stefan Hajnoczi <hidden> Date: 2017-05-22 09:37:08
On Sat, May 20, 2017 at 04:31:13PM +0200, SF Markus Elfring wrote:
From: Markus Elfring <redacted>
Date: Sat, 20 May 2017 13:48:44 +0200
Replace the specification of four data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
Signed-off-by: Markus Elfring <redacted>
---
drivers/vhost/scsi.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Please include an actual explanation for this change instead of linking
to slides. Why are you trying to get rid of memory allocation failure
messages?
Please include an actual explanation for this change instead of linking
to slides.
Do you care for a bit of code size reduction by removal of questionable
error messages?
Why are you trying to get rid of memory allocation failure messages?
Do you find information from a Linux allocation failure report sufficient
for any function implementations here?
quoted
+++ b/drivers/vhost/scsi.c
@@ -417,5 +417,4 @@ vhost_scsi_allocate_evt(struct vhost_scsi *vs,if(!evt){-vq_err(vq,"Failed to allocate vhost_scsi_evt\n");
#define vq_err(vq, fmt, ...) do { \
pr_debug(pr_fmt(fmt), ##__VA_ARGS__); \
if ((vq)->error_ctx) \
eventfd_signal((vq)->error_ctx, 1);\
} while (0)
You silently dropped the eventfd_signal() call.
Do you prefer to preserve this special error handling then?
Regards,
Markus
From: Stefan Hajnoczi <hidden> Date: 2017-05-22 11:23:29
On Mon, May 22, 2017 at 12:50:39PM +0200, SF Markus Elfring wrote:
quoted
Why are you trying to get rid of memory allocation failure messages?
Do you find information from a Linux allocation failure report sufficient
for any function implementations here?
If kmalloc() and friends guarantee to print a warning and backtrace on
every allocation failure, then there's no need for error messages in
callers.
That seems like good justification that can go in the commit
description, but I'm not sure if kmalloc() and friends guarantee to show
a message (not just the first time, but for every failed allocation)?
quoted
quoted
+++ b/drivers/vhost/scsi.c
@@ -417,5 +417,4 @@ vhost_scsi_allocate_evt(struct vhost_scsi *vs,if(!evt){-vq_err(vq,"Failed to allocate vhost_scsi_evt\n");
#define vq_err(vq, fmt, ...) do { \
pr_debug(pr_fmt(fmt), ##__VA_ARGS__); \
if ((vq)->error_ctx) \
eventfd_signal((vq)->error_ctx, 1);\
} while (0)
You silently dropped the eventfd_signal() call.
Do you prefer to preserve this special error handling then?
From: SF Markus Elfring <hidden> Date: 2017-05-22 11:34:45
quoted
Do you find information from a Linux allocation failure report sufficient
for any function implementations here?
If kmalloc() and friends guarantee to print a warning and backtrace on
every allocation failure, then there's no need for error messages in
callers.
That seems like good justification that can go in the commit
description, but I'm not sure if kmalloc() and friends guarantee to show
a message (not just the first time, but for every failed allocation)?
I am also looking for a more complete and easier accessible documentation
for this aspect of the desired exception handling.
How would we like to resolve any remaining open issues there?
Regards,
Markus
From: Stefan Hajnoczi <hidden> Date: 2017-05-22 14:09:43
On Mon, May 22, 2017 at 01:34:34PM +0200, SF Markus Elfring wrote:
quoted
quoted
Do you find information from a Linux allocation failure report sufficient
for any function implementations here?
If kmalloc() and friends guarantee to print a warning and backtrace on
every allocation failure, then there's no need for error messages in
callers.
That seems like good justification that can go in the commit
description, but I'm not sure if kmalloc() and friends guarantee to show
a message (not just the first time, but for every failed allocation)?
I am also looking for a more complete and easier accessible documentation
for this aspect of the desired exception handling.
How would we like to resolve any remaining open issues there?
No objection from me but please make sure to keep vq_err().
Stefan
From: SF Markus Elfring <hidden> Date: 2017-05-22 14:22:19
No objection from me but please make sure to keep vq_err().
How long should I wait before I may dare to send another variant for the
discussed update suggestion?
Which commit message would be acceptable then for this update step?
Regards,
Markus