Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1446964
| From | Juergen Gross <jgross@suse.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection |
| Date | 2016-07-20 06:40 +0200 |
| Message-ID | <rWRsB-55G-3@gated-at.bofh.it> (permalink) |
| References | (15 earlier) <mSsDN-4wa-33@gated-at.bofh.it> <rVEnL-8l8-5@gated-at.bofh.it> <rVEnM-8l8-11@gated-at.bofh.it> <rW98d-1ZF-1@gated-at.bofh.it> <rWEF3-5jj-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 19/07/16 16:56, SF Markus Elfring wrote:
>>> @@ -606,7 +606,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req,
>>> tmr = kzalloc(sizeof(struct scsiback_tmr), GFP_KERNEL);
>>> if (!tmr) {
>>> target_put_sess_cmd(se_cmd);
>>> - goto err;
>>> + goto do_resp;
>>> }
>>
>> Hmm, I'm not convinced this is an improvement.
>>
>> I'd rather rename the new error label to "put_cmd" and get rid of the
>> braces in above if statement:
>>
>> - if (!tmr) {
>> - target_put_sess_cmd(se_cmd);
>> - goto err;
>> - }
>> + if (!tmr)
>> + goto put_cmd;
>>
>> and then in the error path:
>>
>> -err:
>> +put_cmd:
>> + target_put_sess_cmd(se_cmd);
>
> I am unsure on the relevance of this function on such a source position.
> Would it make sense to move it further down at the end?
You only want to call it in the first error case (allocation failure).
>> +free_tmr:
>> kfree(tmr);
>
> How do you think about to skip this function call after a memory
> allocation failure?
I think this just doesn't matter. If it were a hot path, yes. But trying
to do micro-optimizations in an error path is just not worth the effort.
I like a linear error path containing all the needed cleanups best.
Juergen
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/3] xen-scsiback: Fine-tuning for scsiback_device_action() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-16 22:30 +0200
[PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-16 22:30 +0200
Re: [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection Juergen Gross <jgross@suse.com> - 2016-07-18 07:20 +0200
Re: [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-19 17:00 +0200
Re: [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection Juergen Gross <jgross@suse.com> - 2016-07-20 06:40 +0200
Re: [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-20 07:20 +0200
Re: [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection Juergen Gross <jgross@suse.com> - 2016-07-20 07:30 +0200
[PATCH v2 0/3] xen-scsiback: Fine-tuning for scsiback_device_action() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-20 13:30 +0200
[PATCH v2 1/3] xen-scsiback: Delete an unnecessary check before the function call "kfree" SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-20 13:40 +0200
Re: [PATCH v2 1/3] xen-scsiback: Delete an unnecessary check before the function call "kfree" Juergen Gross <jgross@suse.com> - 2016-07-20 13:50 +0200
[PATCH v2 3/3] xen-scsiback: Pass a failure indication as a constant SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-20 13:40 +0200
Re: [PATCH v2 3/3] xen-scsiback: Pass a failure indication as a constant Juergen Gross <jgross@suse.com> - 2016-07-20 13:50 +0200
[PATCH v2 2/3] xen-scsiback: Rename jump labels in scsiback_device_action() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-20 13:40 +0200
Re: [PATCH v2 2/3] xen-scsiback: Rename jump labels in scsiback_device_action() Juergen Gross <jgross@suse.com> - 2016-07-20 13:50 +0200
[PATCH 1/3] xen-scsiback: Delete an unnecessary check before the function call "kfree" SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-16 22:30 +0200
Re: [PATCH 1/3] xen-scsiback: Delete an unnecessary check before the function call "kfree" Juergen Gross <jgross@suse.com> - 2016-07-18 07:10 +0200
csiph-web