qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Ladi Prosek <lprosek@redhat.com>
Cc: Amit Shah <amit.shah@redhat.com>, pagupta <pagupta@redhat.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] rng: switch request queue to QSIMPLEQ
Date: Fri, 4 Mar 2016 10:27:57 +0100	[thread overview]
Message-ID: <56D9551D.3070607@redhat.com> (raw)
In-Reply-To: <CABdb7358H7SAAkmNUeiaTWLYPRiBtA0K+L-pc945jvTVqDLDyQ@mail.gmail.com>



On 04/03/2016 10:19, Ladi Prosek wrote:
> On Fri, Mar 4, 2016 at 10:12 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:
>>
>>
>> On 04/03/2016 09:04, Ladi Prosek wrote:
>>>>>>> +    QSIMPLEQ_INIT(&s->requests);
>>>>>>>  }
>>>>>
>>>>> This init here isn't necessary, the accessors for the queue will take
>>>>> care of this.
>>> We are basically purging the queue here and we want to leave it in a
>>> consistent state. Without the QSIMPLEQ_INIT the queue head would
>>> become a pair of dangling pointers. Let me know if I misunderstood
>>> your comment.
>>
>> It wouldn't, check out QSIMPLEQ_REMOVE_HEAD:
>>
>> #define QSIMPLEQ_REMOVE_HEAD(head, field) do {
>>     if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL)
>>         (head)->sqh_last = &(head)->sqh_first;
>> } while (/*CONSTCOND*/0)
>>
>> The queue would become { NULL, &s->requests.sqh_first }.  So the
>> QSIMPLEQ_INIT is indeed redundant.
> 
> Right, but we're not running QSIMPLEQ_REMOVE_HEAD in this function. We
> iterate the queue and free all elements without writing anything to
> the head or to the next ptr. This is the only "write" we do in
> rng_backend_free_requests.

Ah, sorry, I was convinced that rng_backend_free_request did the remove,
but now I remember checking it yesterday (after making the same
reasoning as Amit) and indeed it doesn't. :)

So the patch is okay.  It's just a slightly unusual use of
QSIMPLEQ_FOREACH_SAFE.

Paolo

  reply	other threads:[~2016-03-04  9:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-03 13:16 [Qemu-devel] [PATCH] rng: switch request queue to QSIMPLEQ Ladi Prosek
2016-03-03 13:34 ` Paolo Bonzini
2016-03-04  6:27 ` Amit Shah
2016-03-04  8:04   ` Ladi Prosek
2016-03-04  9:12     ` Paolo Bonzini
2016-03-04  9:19       ` Ladi Prosek
2016-03-04  9:27         ` Paolo Bonzini [this message]
2016-03-04  9:46           ` Amit Shah
2016-03-04  9:16     ` Amit Shah
2016-03-04  9:46 ` Amit Shah

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=56D9551D.3070607@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=lprosek@redhat.com \
    --cc=pagupta@redhat.com \
    --cc=qemu-devel@nongnu.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).