linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Douglas Gilbert <dgilbert@interlog.com>
To: Bart Van Assche <bart.vanassche@sandisk.com>, linux-scsi@vger.kernel.org
Cc: martin.petersen@oracle.com, tomas.winkler@intel.com, emilne@redhat.com
Subject: Re: [PATCH 07/12] scsi_debug: use likely hints on fast path
Date: Wed, 27 Apr 2016 01:25:11 -0400	[thread overview]
Message-ID: <57204D37.3050302@interlog.com> (raw)
In-Reply-To: <571FE840.1010304@sandisk.com>

On 2016-04-26 06:14 PM, Bart Van Assche wrote:
> On 04/25/2016 09:16 AM, Douglas Gilbert wrote:
>> -    if ((SDEBUG_OPT_MEDIUM_ERR & sdebug_opts) &&
>> -        (lba <= (OPT_MEDIUM_ERR_ADDR + OPT_MEDIUM_ERR_NUM - 1)) &&
>> -        ((lba + num) > OPT_MEDIUM_ERR_ADDR)) {
>> +    if (unlikely((SDEBUG_OPT_MEDIUM_ERR & sdebug_opts) &&
>> +             (lba <= (OPT_MEDIUM_ERR_ADDR + OPT_MEDIUM_ERR_NUM - 1)) &&
>> +             ((lba + num) > OPT_MEDIUM_ERR_ADDR))) {
>  > [ ... ]
>> -    if ((qa_indx < 0) || (qa_indx >= SCSI_DEBUG_CANQUEUE)) {
>> +    if (unlikely((qa_indx < 0) || (qa_indx >= SCSI_DEBUG_CANQUEUE))) {
>  > [ ... ]
>> -    if ((qdepth > 0) && (num_in_q >= qdepth)) {
>> +    if (unlikely((qdepth > 0) && (num_in_q >= qdepth))) {
>  > [ ... ]
>> -    } else if ((sdebug_every_nth != 0) &&
>> -           (SDEBUG_OPT_RARE_TSF & sdebug_opts) &&
>> -           (scsi_result == 0)) {
>> +    } else if (unlikely((sdebug_every_nth != 0) &&
>> +                (SDEBUG_OPT_RARE_TSF & sdebug_opts) &&
>> +                (scsi_result == 0))) {
>
> Since you are modifying this code, please remove the superfluous parentheses.

I can find no reference to "superfluous parentheses" in
Documentation/CodingStyle . As for the improved readability of:

            else if (unlikely(sdebug_every_nth != 0 &&
                       SDEBUG_OPT_RARE_TSF & sdebug_opts &&
                       scsi_result == 0)) {
I have my doubts.

>  > -    struct sdebug_host_info * sdbg_host;
>  > -    struct sdebug_dev_info * open_devip = NULL;
>  > -    struct sdebug_dev_info * devip =
>  > -            (struct sdebug_dev_info *)sdev->hostdata;
>  > +    struct sdebug_host_info *sdbg_host;
>  > +    struct sdebug_dev_info *open_devip = NULL;
>  > +    struct sdebug_dev_info *devip;
>  >
>  > -    if (devip)
>  > -        return devip;
>
> Has this change been described in the patch description?

The function was previously called devInfoReg() and was called
irrespective of whether a suitable sdebug_dev_info instance
existed or not. So that function call just wasted time if an
instance existed. That function is replaced by
find_build_dev_info() which is only called when non trivial work
is needed. Its invocation looks like this:
         if (NULL == devip) {
                 devip = find_build_dev_info(sdp);
                 if (NULL == devip)
                         return 1;  /* no resources, will be marked offline */
         }

Do all re-factorings of code need a patch description?

>> @@ -4632,9 +4617,11 @@ static int __init scsi_debug_init(void)
>>       switch (sdebug_dif) {
>>
>>       case SD_DIF_TYPE0_PROTECTION:
>> +        break;
>>       case SD_DIF_TYPE1_PROTECTION:
>>       case SD_DIF_TYPE2_PROTECTION:
>>       case SD_DIF_TYPE3_PROTECTION:
>> +        have_dif_prot = true;
>>           break;
>
> Same comment for this code: has this change been explained in the patch
> description?

The code previously did things like
         if (!sdebug_dif) { /* whatever */ }
which annoyed me because it relied on knowing that the badly
named SD_DIF_TYPE0_PROTECTION (which is _no_ protection) has
the value 0. So I introduced a bool at file scope (thus it is
initialized to false and checkpatch.pl complains if that is
stated explicitly). The above code is where the bool (i.e.
have_dif_prot) is set.

Doug Gilbert


  reply	other threads:[~2016-04-27  5:25 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-25 16:16 [PATCH 00/12] scsi_debug: multiple queue support and cleanup Douglas Gilbert
2016-04-25 16:16 ` [PATCH 01/12] scsi_debug: cleanup naming and bit crunching Douglas Gilbert
2016-04-26  6:14   ` Hannes Reinecke
2016-04-26 18:13   ` Bart Van Assche
2016-04-26 18:27     ` James Bottomley
2016-04-27  5:25     ` Douglas Gilbert
2016-04-25 16:16 ` [PATCH 02/12] scsi_debug: ignore host lock option Douglas Gilbert
2016-04-26  6:15   ` Hannes Reinecke
2016-04-25 16:16 ` [PATCH 03/12] scsi_debug: replace jiffy timers with hr timers Douglas Gilbert
2016-04-26  6:17   ` Hannes Reinecke
2016-04-26 18:38   ` Bart Van Assche
2016-04-25 16:16 ` [PATCH 04/12] scsi_debug: make jiffy delay name clearer Douglas Gilbert
2016-04-26  6:17   ` Hannes Reinecke
2016-04-25 16:16 ` [PATCH 05/12] scsi_debug: replace tasklet with work queue Douglas Gilbert
2016-04-26  6:20   ` Hannes Reinecke
2016-04-25 16:16 ` [PATCH 06/12] scsi_debug: re-order file scope declarations Douglas Gilbert
2016-04-26  6:21   ` Hannes Reinecke
2016-04-26 20:55   ` Bart Van Assche
2016-04-25 16:16 ` [PATCH 07/12] scsi_debug: use likely hints on fast path Douglas Gilbert
2016-04-26  6:22   ` Hannes Reinecke
2016-04-26 22:14   ` Bart Van Assche
2016-04-27  5:25     ` Douglas Gilbert [this message]
2016-04-27  5:33       ` Bart Van Assche
2016-04-27 14:29       ` Bart Van Assche
2016-04-25 16:16 ` [PATCH 08/12] scsi_debug: rework resp_report_luns Douglas Gilbert
2016-04-26  6:26   ` Hannes Reinecke
2016-04-27  4:08     ` Douglas Gilbert
2016-04-27  5:58       ` Hannes Reinecke
2016-04-26  7:33   ` Winkler, Tomas
2016-04-27 23:09   ` Bart Van Assche
2016-04-25 16:16 ` [PATCH 09/12] scsi_debug: add multiple queue support Douglas Gilbert
2016-04-26  6:29   ` Hannes Reinecke
2016-04-26 22:19   ` Bart Van Assche
2016-04-25 16:16 ` [PATCH 10/12] scsi_debug: vpd and mode page work Douglas Gilbert
2016-04-26  6:29   ` Hannes Reinecke
2016-04-25 16:16 ` [PATCH 11/12] scsi_debug: uuid for lu name Douglas Gilbert
2016-04-26  6:30   ` Hannes Reinecke
2016-04-25 16:16 ` [PATCH 12/12] scsi_debug: use locally assigned naa Douglas Gilbert
2016-04-26  6:31   ` Hannes Reinecke
2016-04-29 23:53 ` [PATCH 00/12] scsi_debug: multiple queue support and cleanup Martin K. Petersen
2016-04-30  2:06   ` Douglas Gilbert

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=57204D37.3050302@interlog.com \
    --to=dgilbert@interlog.com \
    --cc=bart.vanassche@sandisk.com \
    --cc=emilne@redhat.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=tomas.winkler@intel.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;
as well as URLs for NNTP newsgroup(s).