From: George Dunlap <george.dunlap@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Juergen Gross <JGross@suse.com>,
keir@xen.org, george.dunlap@eu.citrix.com,
andrew.cooper3@citrix.com, dario.faggioli@citrix.com,
xen-devel@lists.xen.org
Subject: Re: [PATCH 4/5] xen: use masking operation instead of test_bit for VPF bits
Date: Mon, 5 Oct 2015 15:31:23 +0100 [thread overview]
Message-ID: <561289BB.6040705@citrix.com> (raw)
In-Reply-To: <56129FC602000078000A8290@prv-mh.provo.novell.com>
On 05/10/15 15:05, Jan Beulich wrote:
>>>> On 05.10.15 at 15:45, <george.dunlap@citrix.com> wrote:
>> On 05/10/15 14:36, Jan Beulich wrote:
>>>>>> On 05.10.15 at 15:18, <george.dunlap@citrix.com> wrote:
>>>> On 02/10/15 05:40, Juergen Gross wrote:
>>>>> Use a bit mask for testing of a set bit instead of test_bit in case no
>>>>> atomic operation is needed, as this will lead to smaller and more
>>>>> effective code.
>>>>>
>>>>> Signed-off-by: Juergen Gross <jgross@suse.com>
>>>>
>>>> I'm a bit confused here -- exactly when is an atomic operation needed or
>>>> not needed? Isn't it the case that we always need to do an atomic read
>>>> if we ever do an atomic write without a lock held?
>>>
>>> First of all - what is an atomic read from CPU perspective other than
>>> just a read? Since we talk about individual bits here, we don't care
>>> about the granularity the compiler may convert the read to, and even
>>> if the compiler chose to do multiple reads the result would still be
>>> correct, as only one of those reads can possibly have read the bit
>>> in question.
>>>
>>> And then, the old mechanism was in no way "atomic", all it added was
>>> a kind of compiler barrier (due to the cast to volatile). Yet in none of
>>> the cases changed I was able to spot a need for such a barrier.
>>
>> OK, so the key thing about test_bit isn't that it's atomic, so much that
>> it's an implicit memory barrier. So as long as you're not doing a
>> lockless careful-ordering sort of thing, then a simple memory read
>> should be fine. Is that correct?
>
> Yes.
>
>> In that case, it's likely that the patch is correct (though I'll take a
>> closer look just to be sure).
>
> Thanks.
OK, I've looked through again and don't see anything that looks racy:
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
next prev parent reply other threads:[~2015-10-05 14:31 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-02 4:40 [PATCH 0/5] use mask operations instead of test_bit() Juergen Gross
2015-10-02 4:40 ` [PATCH 1/5] xen: use masking operation instead of test_bit for RTDS bits Juergen Gross
2015-10-02 10:21 ` Dario Faggioli
2015-10-05 13:30 ` George Dunlap
2015-10-02 4:40 ` [PATCH 2/5] xen: use masking operation instead of test_bit for CSFLAG bits Juergen Gross
2015-10-02 10:45 ` Dario Faggioli
2015-10-05 13:30 ` George Dunlap
2015-10-02 4:40 ` [PATCH 3/5] xen: use masking operation instead of test_bit for VGCF bits Juergen Gross
2015-10-02 4:40 ` [PATCH 4/5] xen: use masking operation instead of test_bit for VPF bits Juergen Gross
2015-10-05 13:18 ` George Dunlap
2015-10-05 13:36 ` Jan Beulich
2015-10-05 13:45 ` George Dunlap
2015-10-05 14:05 ` Jan Beulich
2015-10-05 14:31 ` George Dunlap [this message]
2015-10-05 13:39 ` Juergen Gross
2015-10-05 13:24 ` George Dunlap
2015-10-05 13:40 ` Jan Beulich
2015-10-02 4:40 ` [PATCH 5/5] xen: use masking operation instead of test_bit for MCSF bits Juergen Gross
2015-10-02 9:03 ` [PATCH 0/5] use mask operations instead of test_bit() Dario Faggioli
2015-10-02 9:10 ` Juergen Gross
2015-10-02 9:33 ` Dario Faggioli
2015-10-02 9:44 ` Jan Beulich
2015-10-02 9:47 ` Andrew Cooper
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=561289BB.6040705@citrix.com \
--to=george.dunlap@citrix.com \
--cc=JBeulich@suse.com \
--cc=JGross@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=dario.faggioli@citrix.com \
--cc=george.dunlap@eu.citrix.com \
--cc=keir@xen.org \
--cc=xen-devel@lists.xen.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).