All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Eykholt <jeykholt@cisco.com>
To: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: fix duplicate host number
Date: Tue, 16 Jun 2009 14:02:28 -0700	[thread overview]
Message-ID: <4A380864.9020604@cisco.com> (raw)
In-Reply-To: <4A37CFEA.3070106@s5r6.in-berlin.de>

Stefan Richter wrote:
> Joe Eykholt wrote:
>> Subtract 1, so that scsi_host still starts with 0.
> ...
>> -static int scsi_host_next_hn;        /* host_no for next new host */
>> +static atomic_t scsi_host_next_hn;    /* host_no for next new host */
>>  
>>  
>>  static void scsi_host_cls_release(struct device *dev)
>> @@ -333,7 +333,7 @@ struct Scsi_Host *scsi_host_alloc(struct 
>> scsi_host_template *sht, int privsize)
>>  
>>      mutex_init(&shost->scan_mutex);
>>  
>> -    shost->host_no = scsi_host_next_hn++; /* XXX(hch): still racy */
>> +    shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
> 
> Can also be written
> 
> static atomic_t scsi_host_next_hn = ATOMIC_INIT(-1);
> ...
>     shost->host_no = atomic_inc_return(&scsi_host_next_hn);

Yes, I considered that, but then the variable name and comment wouldn't be correct.

Also, the initializer adds 4 bytes to the initialized data section, and
the code for -1 should increase text size by less than that, so I think it's a wash.
An atomic_fetch_and_add() would be handy.

	Cheers,
	Joe



      reply	other threads:[~2009-06-16 21:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-16  6:22 [PATCH] scsi: fix duplicate host number Joe Eykholt
2009-06-16 17:01 ` Stefan Richter
2009-06-16 21:02   ` Joe Eykholt [this message]

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=4A380864.9020604@cisco.com \
    --to=jeykholt@cisco.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=stefanr@s5r6.in-berlin.de \
    /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.