From: Wei Wang <wei.w.wang@intel.com>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>, willy@infradead.org
Cc: virtio-dev@lists.oasis-open.org, linux-kernel@vger.kernel.org,
qemu-devel@nongnu.org, virtualization@lists.linux-foundation.org,
kvm@vger.kernel.org, linux-mm@kvack.org, mst@redhat.com,
mhocko@kernel.org, akpm@linux-foundation.org,
mawilcox@microsoft.com
Subject: [virtio-dev] Re: [PATCH v20 3/7 RESEND] xbitmap: add more operations
Date: Sun, 24 Dec 2017 15:31:28 +0800 [thread overview]
Message-ID: <5A3F57D0.9050007@intel.com> (raw)
In-Reply-To: <201712232333.BAH82874.FFFtOMHSLVQOOJ@I-love.SAKURA.ne.jp>
On 12/23/2017 10:33 PM, Tetsuo Handa wrote:
>>>> + bitmap = rcu_dereference_raw(*slot);
>>>> + if (!bitmap) {
>>>> + bitmap = this_cpu_xchg(ida_bitmap, NULL);
>>>> + if (!bitmap)
>>>> + return -ENOMEM;
>>> I can't understand this. I can understand if it were
>>>
>>> BUG_ON(!bitmap);
>>>
>>> because you called xb_preload().
>>>
>>> But
>>>
>>> /*
>>> * Regular test 2
>>> * set bit 2000, 2001, 2040
>>> * Next 1 in [0, 2048) --> 2000
>>> * Next 1 in [2000, 2002) --> 2000
>>> * Next 1 in [2002, 2041) --> 2040
>>> * Next 1 in [2002, 2040) --> none
>>> * Next 0 in [2000, 2048) --> 2002
>>> * Next 0 in [2048, 2060) --> 2048
>>> */
>>> xb_preload(GFP_KERNEL);
>>> assert(!xb_set_bit(&xb1, 2000));
>>> assert(!xb_set_bit(&xb1, 2001));
>>> assert(!xb_set_bit(&xb1, 2040));
>> [...]
>>> xb_preload_end();
>>>
>>> you are not calling xb_preload() prior to each xb_set_bit() call.
>>> This means that, if each xb_set_bit() is not surrounded with
>>> xb_preload()/xb_preload_end(), there is possibility of hitting
>>> this_cpu_xchg(ida_bitmap, NULL) == NULL.
>> This is just a lazy test. We "know" that the bits in the range 1024-2047
>> will all land in the same bitmap, so there's no need to preload for each
>> of them.
> Testcases also serves as how to use that API.
> Assuming such thing leads to incorrect usage.
If callers are aware that the bits that they going to record locate in
the same bitmap, I think they should also perform the xb_ APIs with only
one preload. So the test cases here have shown them a correct example.
We can probably add some comments above to explain this.
Best,
Wei
---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
WARNING: multiple messages have this Message-ID (diff)
From: Wei Wang <wei.w.wang@intel.com>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>, willy@infradead.org
Cc: virtio-dev@lists.oasis-open.org, linux-kernel@vger.kernel.org,
qemu-devel@nongnu.org, virtualization@lists.linux-foundation.org,
kvm@vger.kernel.org, linux-mm@kvack.org, mst@redhat.com,
mhocko@kernel.org, akpm@linux-foundation.org,
mawilcox@microsoft.com
Subject: Re: [PATCH v20 3/7 RESEND] xbitmap: add more operations
Date: Sun, 24 Dec 2017 15:31:28 +0800 [thread overview]
Message-ID: <5A3F57D0.9050007@intel.com> (raw)
In-Reply-To: <201712232333.BAH82874.FFFtOMHSLVQOOJ@I-love.SAKURA.ne.jp>
On 12/23/2017 10:33 PM, Tetsuo Handa wrote:
>>>> + bitmap = rcu_dereference_raw(*slot);
>>>> + if (!bitmap) {
>>>> + bitmap = this_cpu_xchg(ida_bitmap, NULL);
>>>> + if (!bitmap)
>>>> + return -ENOMEM;
>>> I can't understand this. I can understand if it were
>>>
>>> BUG_ON(!bitmap);
>>>
>>> because you called xb_preload().
>>>
>>> But
>>>
>>> /*
>>> * Regular test 2
>>> * set bit 2000, 2001, 2040
>>> * Next 1 in [0, 2048) --> 2000
>>> * Next 1 in [2000, 2002) --> 2000
>>> * Next 1 in [2002, 2041) --> 2040
>>> * Next 1 in [2002, 2040) --> none
>>> * Next 0 in [2000, 2048) --> 2002
>>> * Next 0 in [2048, 2060) --> 2048
>>> */
>>> xb_preload(GFP_KERNEL);
>>> assert(!xb_set_bit(&xb1, 2000));
>>> assert(!xb_set_bit(&xb1, 2001));
>>> assert(!xb_set_bit(&xb1, 2040));
>> [...]
>>> xb_preload_end();
>>>
>>> you are not calling xb_preload() prior to each xb_set_bit() call.
>>> This means that, if each xb_set_bit() is not surrounded with
>>> xb_preload()/xb_preload_end(), there is possibility of hitting
>>> this_cpu_xchg(ida_bitmap, NULL) == NULL.
>> This is just a lazy test. We "know" that the bits in the range 1024-2047
>> will all land in the same bitmap, so there's no need to preload for each
>> of them.
> Testcases also serves as how to use that API.
> Assuming such thing leads to incorrect usage.
If callers are aware that the bits that they going to record locate in
the same bitmap, I think they should also perform the xb_ APIs with only
one preload. So the test cases here have shown them a correct example.
We can probably add some comments above to explain this.
Best,
Wei
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: Wei Wang <wei.w.wang@intel.com>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>, willy@infradead.org
Cc: virtio-dev@lists.oasis-open.org, linux-kernel@vger.kernel.org,
qemu-devel@nongnu.org, virtualization@lists.linux-foundation.org,
kvm@vger.kernel.org, linux-mm@kvack.org, mst@redhat.com,
mhocko@kernel.org, akpm@linux-foundation.org,
mawilcox@microsoft.com
Subject: Re: [PATCH v20 3/7 RESEND] xbitmap: add more operations
Date: Sun, 24 Dec 2017 15:31:28 +0800 [thread overview]
Message-ID: <5A3F57D0.9050007@intel.com> (raw)
In-Reply-To: <201712232333.BAH82874.FFFtOMHSLVQOOJ@I-love.SAKURA.ne.jp>
On 12/23/2017 10:33 PM, Tetsuo Handa wrote:
>>>> + bitmap = rcu_dereference_raw(*slot);
>>>> + if (!bitmap) {
>>>> + bitmap = this_cpu_xchg(ida_bitmap, NULL);
>>>> + if (!bitmap)
>>>> + return -ENOMEM;
>>> I can't understand this. I can understand if it were
>>>
>>> BUG_ON(!bitmap);
>>>
>>> because you called xb_preload().
>>>
>>> But
>>>
>>> /*
>>> * Regular test 2
>>> * set bit 2000, 2001, 2040
>>> * Next 1 in [0, 2048) --> 2000
>>> * Next 1 in [2000, 2002) --> 2000
>>> * Next 1 in [2002, 2041) --> 2040
>>> * Next 1 in [2002, 2040) --> none
>>> * Next 0 in [2000, 2048) --> 2002
>>> * Next 0 in [2048, 2060) --> 2048
>>> */
>>> xb_preload(GFP_KERNEL);
>>> assert(!xb_set_bit(&xb1, 2000));
>>> assert(!xb_set_bit(&xb1, 2001));
>>> assert(!xb_set_bit(&xb1, 2040));
>> [...]
>>> xb_preload_end();
>>>
>>> you are not calling xb_preload() prior to each xb_set_bit() call.
>>> This means that, if each xb_set_bit() is not surrounded with
>>> xb_preload()/xb_preload_end(), there is possibility of hitting
>>> this_cpu_xchg(ida_bitmap, NULL) == NULL.
>> This is just a lazy test. We "know" that the bits in the range 1024-2047
>> will all land in the same bitmap, so there's no need to preload for each
>> of them.
> Testcases also serves as how to use that API.
> Assuming such thing leads to incorrect usage.
If callers are aware that the bits that they going to record locate in
the same bitmap, I think they should also perform the xb_ APIs with only
one preload. So the test cases here have shown them a correct example.
We can probably add some comments above to explain this.
Best,
Wei
next prev parent reply other threads:[~2017-12-24 7:29 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-21 2:30 [virtio-dev] [PATCH v20 3/7 RESEND] xbitmap: add more operations Wei Wang
2017-12-21 2:30 ` Wei Wang
2017-12-21 2:30 ` Wei Wang
2017-12-21 14:18 ` Matthew Wilcox
2017-12-21 14:18 ` Matthew Wilcox
2017-12-21 14:18 ` Matthew Wilcox
2017-12-21 14:37 ` Tetsuo Handa
2017-12-21 14:37 ` Tetsuo Handa
2017-12-22 8:45 ` Wei Wang
2017-12-22 8:45 ` [virtio-dev] " Wei Wang
2017-12-22 8:45 ` Wei Wang
2017-12-22 8:45 ` Wei Wang
2017-12-21 21:03 ` Matthew Wilcox
2017-12-21 21:03 ` Matthew Wilcox
2017-12-22 8:49 ` [virtio-dev] " Wei Wang
2017-12-22 8:49 ` Wei Wang
2017-12-22 8:49 ` Wei Wang
2018-01-02 14:09 ` Matthew Wilcox
2018-01-02 14:09 ` Matthew Wilcox
2018-01-03 8:56 ` Wei Wang
2018-01-03 8:56 ` [virtio-dev] " Wei Wang
2018-01-03 8:56 ` Wei Wang
2018-01-03 8:56 ` Wei Wang
2018-01-02 14:09 ` Matthew Wilcox
2017-12-22 8:49 ` Wei Wang
2017-12-23 2:59 ` Tetsuo Handa
2017-12-23 2:59 ` Tetsuo Handa
2017-12-23 3:29 ` Matthew Wilcox
2017-12-23 3:29 ` Matthew Wilcox
2017-12-23 3:29 ` Matthew Wilcox
2017-12-23 14:33 ` Tetsuo Handa
2017-12-23 14:33 ` Tetsuo Handa
2017-12-23 14:58 ` Matthew Wilcox
2017-12-23 14:58 ` Matthew Wilcox
2017-12-23 14:58 ` Matthew Wilcox
2017-12-24 7:31 ` Wei Wang
2017-12-24 7:31 ` Wei Wang [this message]
2017-12-24 7:31 ` Wei Wang
2017-12-24 7:31 ` Wei Wang
2017-12-21 21:03 ` Matthew Wilcox
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=5A3F57D0.9050007@intel.com \
--to=wei.w.wang@intel.com \
--cc=akpm@linux-foundation.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mawilcox@microsoft.com \
--cc=mhocko@kernel.org \
--cc=mst@redhat.com \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=qemu-devel@nongnu.org \
--cc=virtio-dev@lists.oasis-open.org \
--cc=virtualization@lists.linux-foundation.org \
--cc=willy@infradead.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 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.