From: Bart Van Assche <bvanassche@acm.org>
To: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Cc: linux-scsi@vger.kernel.org, kvm@vger.kernel.org, mst@redhat.com,
linux-kernel@vger.kernel.org, JBottomley@parallels.com,
virtualization@lists.linux-foundation.org, pbonzini@redhat.com
Subject: Re: [PATCH V7 4/5] virtio-scsi: introduce multiqueue support
Date: Mon, 25 Mar 2013 08:25:58 +0100 [thread overview]
Message-ID: <514FFC06.9030703@acm.org> (raw)
In-Reply-To: <1364038124-32479-5-git-send-email-gaowanlong@cn.fujitsu.com>
On 03/23/13 12:28, Wanlong Gao wrote:
> +static struct virtio_scsi_vq *virtscsi_pick_vq(struct virtio_scsi *vscsi,
> + struct virtio_scsi_target_state *tgt)
> +{
> + struct virtio_scsi_vq *vq;
> + unsigned long flags;
> + u32 queue_num;
> +
> + spin_lock_irqsave(&tgt->tgt_lock, flags);
> +
> + /*
> + * The memory barrier after atomic_inc_return matches
> + * the smp_read_barrier_depends() in virtscsi_req_done.
> + */
> + if (atomic_inc_return(&tgt->reqs) > 1)
> + vq = ACCESS_ONCE(tgt->req_vq);
> + else {
> + queue_num = smp_processor_id();
> + while (unlikely(queue_num >= vscsi->num_queues))
> + queue_num -= vscsi->num_queues;
> +
> + tgt->req_vq = vq = &vscsi->req_vqs[queue_num];
> + }
> +
> + spin_unlock_irqrestore(&tgt->tgt_lock, flags);
> + return vq;
> +}
Is there any reason why the smp_processor_id() % vscsi->num_queues
computation in virtscsi_pick_vq() has been implemented as a loop instead
of as an arithmetic operation ? If so, I would appreciate it if that
could be explained in a comment.
Thanks,
Bart.
next prev parent reply other threads:[~2013-03-25 7:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-23 11:28 [PATCH V7 0/5] virtio-scsi multiqueue Wanlong Gao
2013-03-23 11:28 ` [PATCH V7 1/5] virtio-scsi: redo allocation of target data Wanlong Gao
2013-03-23 11:28 ` [PATCH V7 2/5] virtio-scsi: pass struct virtio_scsi to virtqueue completion function Wanlong Gao
2013-03-23 11:28 ` [PATCH V7 3/5] virtio-scsi: push vq lock/unlock into virtscsi_vq_done Wanlong Gao
2013-03-23 11:28 ` [PATCH V7 4/5] virtio-scsi: introduce multiqueue support Wanlong Gao
2013-03-25 7:25 ` Bart Van Assche [this message]
2013-03-25 14:27 ` Paolo Bonzini
2013-03-23 11:28 ` [PATCH V7 5/5] virtio-scsi: reset virtqueue affinity when doing cpu hotplug Wanlong Gao
2013-03-28 2:22 ` [PATCH V7 0/5] virtio-scsi multiqueue Wanlong Gao
2013-04-05 8:55 ` Wanlong Gao
2013-04-06 8:40 ` James Bottomley
2013-04-06 10:14 ` Wanlong Gao
2013-04-07 2:01 ` Asias He
2013-04-08 13:36 ` Rusty Russell
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=514FFC06.9030703@acm.org \
--to=bvanassche@acm.org \
--cc=JBottomley@parallels.com \
--cc=gaowanlong@cn.fujitsu.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
/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).