From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: virtio-dev-return-2895-cohuck=redhat.com@lists.oasis-open.org Sender: List-Post: List-Help: List-Unsubscribe: List-Subscribe: Received: from lists.oasis-open.org (oasis-open.org [66.179.20.138]) by lists.oasis-open.org (Postfix) with ESMTP id B7BC358191A8 for ; Wed, 3 Jan 2018 00:54:32 -0800 (PST) Message-ID: <5A4C9ACF.2090000@intel.com> Date: Wed, 03 Jan 2018 16:56:47 +0800 From: Wei Wang MIME-Version: 1.0 References: <1513823406-43632-1-git-send-email-wei.w.wang@intel.com> <20171221210327.GB25009@bombadil.infradead.org> <5A3CC707.9070708@intel.com> <20180102140906.GC8222@bombadil.infradead.org> In-Reply-To: <20180102140906.GC8222@bombadil.infradead.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: [virtio-dev] Re: [PATCH v20 3/7 RESEND] xbitmap: add more operations To: Matthew Wilcox 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, penguin-kernel@I-love.SAKURA.ne.jp List-ID: On 01/02/2018 10:09 PM, Matthew Wilcox wrote: > On Fri, Dec 22, 2017 at 04:49:11PM +0800, Wei Wang wrote: >> Thanks for the improvement. I also found a small bug in xb_zero. With the >> following changes, it has passed the current test cases and tested with the >> virtio-balloon usage without any issue. > Thanks; I applied the change. Can you supply a test-case for testing > xb_zero please? > Sure. Please check below the test cases. Do you plan to send out the new version of xbitmap yourself? If so, I will wait for that to send out the virtio-balloon patches. static void xbitmap_check_zero_bits(void) { assert(xb_empty(&xb1)); /* Zero an empty xbitmap should work though no real work to do */ xb_zero(&xb1, 0, ULONG_MAX); assert(xb_empty(&xb1)); xb_preload(GFP_KERNEL); assert(xb_set_bit(&xb1, 0) == 0); xb_preload_end(); /* Overflow test */ xb_zero(&xb1, ULONG_MAX - 10, ULONG_MAX); assert(xb_test_bit(&xb1, 0)); xb_preload(GFP_KERNEL); assert(xb_set_bit(&xb1, ULONG_MAX) == 0); xb_preload_end(); xb_zero(&xb1, 0, ULONG_MAX); assert(xb_empty(&xb1)); } /* * In the following tests, preload is called once when all the bits to set * locate in the same ida bitmap. Otherwise, it is recommended to call * preload for each xb_set_bit. */ static void xbitmap_check_bit_range(void) { unsigned long nbit = 0; /* Regular test1: node = NULL */ xb_preload(GFP_KERNEL); xb_set_bit(&xb1, 700); xb_preload_end(); assert(xb_find_set(&xb1, ULONG_MAX, &nbit) == true); assert(nbit == 700); nbit++; assert(xb_find_set(&xb1, ULONG_MAX, &nbit) == false); assert(nbit == 701); xb_zero(&xb1, 0, 1023); /* * Regular test2 * set bit 2000, 2001, 2040 * Next 1 in [0, 2048] --> 2000 * Next 1 in [2000, 2002] --> 2000 * Next 1 in [2002, 2040] --> 2040 * Next 1 in [2002, 2039] --> 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)); nbit = 0; assert(xb_find_set(&xb1, 2048, &nbit) == true); assert(nbit == 2000); assert(xb_find_set(&xb1, 2002, &nbit) == true); assert(nbit == 2000); nbit = 2002; assert(xb_find_set(&xb1, 2040, &nbit) == true); assert(nbit == 2040); nbit = 2002; assert(xb_find_set(&xb1, 2039, &nbit) == false); assert(nbit == 2002); nbit = 2000; assert(xb_find_zero(&xb1, 2048, &nbit) == true); assert(nbit == 2002); nbit = 2048; assert(xb_find_zero(&xb1, 2060, &nbit) == true); assert(nbit == 2048); xb_zero(&xb1, 0, 2048); nbit = 0; assert(xb_find_set(&xb1, 2048, &nbit) == false); assert(nbit == 0); xb_preload_end(); /* * Overflow tests: * Set bit 1 and ULONG_MAX - 4 * Next 1 in [0, ULONG_MAX] --> 1 * Next 1 in [1, ULONG_MAX] --> 1 * Next 1 in [2, ULONG_MAX] --> ULONG_MAX - 4 * Next 1 in [ULONG_MAX - 3, 2] --> none * Next 0 in [ULONG_MAX - 4, ULONG_MAX] --> ULONG_MAX - 3 * Zero [ULONG_MAX - 4, ULONG_MAX] * Next 1 in [ULONG_MAX - 10, ULONG_MAX] --> none * Next 1 in [ULONG_MAX - 1, 2] --> none * Zero [0, 1] * Next 1 in [0, 2] --> none */ xb_preload(GFP_KERNEL); assert(!xb_set_bit(&xb1, 1)); xb_preload_end(); xb_preload(GFP_KERNEL); assert(!xb_set_bit(&xb1, ULONG_MAX - 4)); nbit = 0; assert(xb_find_set(&xb1, ULONG_MAX, &nbit) == true); assert(nbit == 1); nbit = 1; assert(xb_find_set(&xb1, ULONG_MAX, &nbit) == true); assert(nbit == 1); nbit = 2; assert(xb_find_set(&xb1, ULONG_MAX, &nbit) == true); assert(nbit == ULONG_MAX - 4); nbit++; assert(xb_find_set(&xb1, 2, &nbit) == false); assert(nbit == ULONG_MAX - 3); nbit--; assert(xb_find_zero(&xb1, ULONG_MAX, &nbit) == true); assert(nbit == ULONG_MAX - 3); xb_zero(&xb1, ULONG_MAX - 4, ULONG_MAX); nbit = ULONG_MAX - 10; assert(xb_find_set(&xb1, ULONG_MAX, &nbit) == false); assert(nbit == ULONG_MAX - 10); nbit = ULONG_MAX - 1; assert(xb_find_set(&xb1, 2, &nbit) == false); xb_zero(&xb1, 0, 1); nbit = 0; assert(xb_find_set(&xb1, 2, &nbit) == false); assert(nbit == 0); xb_preload_end(); assert(xb_empty(&xb1)); } 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Wang Subject: Re: [PATCH v20 3/7 RESEND] xbitmap: add more operations Date: Wed, 03 Jan 2018 16:56:47 +0800 Message-ID: <5A4C9ACF.2090000@intel.com> References: <1513823406-43632-1-git-send-email-wei.w.wang@intel.com> <20171221210327.GB25009@bombadil.infradead.org> <5A3CC707.9070708@intel.com> <20180102140906.GC8222@bombadil.infradead.org> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit 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, penguin-kernel@I-love.SAKURA.ne.jp To: Matthew Wilcox Return-path: In-Reply-To: <20180102140906.GC8222@bombadil.infradead.org> Sender: owner-linux-mm@kvack.org List-Id: kvm.vger.kernel.org On 01/02/2018 10:09 PM, Matthew Wilcox wrote: > On Fri, Dec 22, 2017 at 04:49:11PM +0800, Wei Wang wrote: >> Thanks for the improvement. I also found a small bug in xb_zero. With the >> following changes, it has passed the current test cases and tested with the >> virtio-balloon usage without any issue. > Thanks; I applied the change. Can you supply a test-case for testing > xb_zero please? > Sure. Please check below the test cases. Do you plan to send out the new version of xbitmap yourself? If so, I will wait for that to send out the virtio-balloon patches. static void xbitmap_check_zero_bits(void) { assert(xb_empty(&xb1)); /* Zero an empty xbitmap should work though no real work to do */ xb_zero(&xb1, 0, ULONG_MAX); assert(xb_empty(&xb1)); xb_preload(GFP_KERNEL); assert(xb_set_bit(&xb1, 0) == 0); xb_preload_end(); /* Overflow test */ xb_zero(&xb1, ULONG_MAX - 10, ULONG_MAX); assert(xb_test_bit(&xb1, 0)); xb_preload(GFP_KERNEL); assert(xb_set_bit(&xb1, ULONG_MAX) == 0); xb_preload_end(); xb_zero(&xb1, 0, ULONG_MAX); assert(xb_empty(&xb1)); } /* * In the following tests, preload is called once when all the bits to set * locate in the same ida bitmap. Otherwise, it is recommended to call * preload for each xb_set_bit. */ static void xbitmap_check_bit_range(void) { unsigned long nbit = 0; /* Regular test1: node = NULL */ xb_preload(GFP_KERNEL); xb_set_bit(&xb1, 700); xb_preload_end(); assert(xb_find_set(&xb1, ULONG_MAX, &nbit) == true); assert(nbit == 700); nbit++; assert(xb_find_set(&xb1, ULONG_MAX, &nbit) == false); assert(nbit == 701); xb_zero(&xb1, 0, 1023); /* * Regular test2 * set bit 2000, 2001, 2040 * Next 1 in [0, 2048] --> 2000 * Next 1 in [2000, 2002] --> 2000 * Next 1 in [2002, 2040] --> 2040 * Next 1 in [2002, 2039] --> 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)); nbit = 0; assert(xb_find_set(&xb1, 2048, &nbit) == true); assert(nbit == 2000); assert(xb_find_set(&xb1, 2002, &nbit) == true); assert(nbit == 2000); nbit = 2002; assert(xb_find_set(&xb1, 2040, &nbit) == true); assert(nbit == 2040); nbit = 2002; assert(xb_find_set(&xb1, 2039, &nbit) == false); assert(nbit == 2002); nbit = 2000; assert(xb_find_zero(&xb1, 2048, &nbit) == true); assert(nbit == 2002); nbit = 2048; assert(xb_find_zero(&xb1, 2060, &nbit) == true); assert(nbit == 2048); xb_zero(&xb1, 0, 2048); nbit = 0; assert(xb_find_set(&xb1, 2048, &nbit) == false); assert(nbit == 0); xb_preload_end(); /* * Overflow tests: * Set bit 1 and ULONG_MAX - 4 * Next 1 in [0, ULONG_MAX] --> 1 * Next 1 in [1, ULONG_MAX] --> 1 * Next 1 in [2, ULONG_MAX] --> ULONG_MAX - 4 * Next 1 in [ULONG_MAX - 3, 2] --> none * Next 0 in [ULONG_MAX - 4, ULONG_MAX] --> ULONG_MAX - 3 * Zero [ULONG_MAX - 4, ULONG_MAX] * Next 1 in [ULONG_MAX - 10, ULONG_MAX] --> none * Next 1 in [ULONG_MAX - 1, 2] --> none * Zero [0, 1] * Next 1 in [0, 2] --> none */ xb_preload(GFP_KERNEL); assert(!xb_set_bit(&xb1, 1)); xb_preload_end(); xb_preload(GFP_KERNEL); assert(!xb_set_bit(&xb1, ULONG_MAX - 4)); nbit = 0; assert(xb_find_set(&xb1, ULONG_MAX, &nbit) == true); assert(nbit == 1); nbit = 1; assert(xb_find_set(&xb1, ULONG_MAX, &nbit) == true); assert(nbit == 1); nbit = 2; assert(xb_find_set(&xb1, ULONG_MAX, &nbit) == true); assert(nbit == ULONG_MAX - 4); nbit++; assert(xb_find_set(&xb1, 2, &nbit) == false); assert(nbit == ULONG_MAX - 3); nbit--; assert(xb_find_zero(&xb1, ULONG_MAX, &nbit) == true); assert(nbit == ULONG_MAX - 3); xb_zero(&xb1, ULONG_MAX - 4, ULONG_MAX); nbit = ULONG_MAX - 10; assert(xb_find_set(&xb1, ULONG_MAX, &nbit) == false); assert(nbit == ULONG_MAX - 10); nbit = ULONG_MAX - 1; assert(xb_find_set(&xb1, 2, &nbit) == false); xb_zero(&xb1, 0, 1); nbit = 0; assert(xb_find_set(&xb1, 2, &nbit) == false); assert(nbit == 0); xb_preload_end(); assert(xb_empty(&xb1)); } 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751603AbeACIyc (ORCPT + 1 other); Wed, 3 Jan 2018 03:54:32 -0500 Received: from mga01.intel.com ([192.55.52.88]:10545 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750748AbeACIyb (ORCPT ); Wed, 3 Jan 2018 03:54:31 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,500,1508828400"; d="scan'208";a="7657883" Message-ID: <5A4C9ACF.2090000@intel.com> Date: Wed, 03 Jan 2018 16:56:47 +0800 From: Wei Wang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Matthew Wilcox 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, penguin-kernel@I-love.SAKURA.ne.jp Subject: Re: [PATCH v20 3/7 RESEND] xbitmap: add more operations References: <1513823406-43632-1-git-send-email-wei.w.wang@intel.com> <20171221210327.GB25009@bombadil.infradead.org> <5A3CC707.9070708@intel.com> <20180102140906.GC8222@bombadil.infradead.org> In-Reply-To: <20180102140906.GC8222@bombadil.infradead.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On 01/02/2018 10:09 PM, Matthew Wilcox wrote: > On Fri, Dec 22, 2017 at 04:49:11PM +0800, Wei Wang wrote: >> Thanks for the improvement. I also found a small bug in xb_zero. With the >> following changes, it has passed the current test cases and tested with the >> virtio-balloon usage without any issue. > Thanks; I applied the change. Can you supply a test-case for testing > xb_zero please? > Sure. Please check below the test cases. Do you plan to send out the new version of xbitmap yourself? If so, I will wait for that to send out the virtio-balloon patches. static void xbitmap_check_zero_bits(void) { assert(xb_empty(&xb1)); /* Zero an empty xbitmap should work though no real work to do */ xb_zero(&xb1, 0, ULONG_MAX); assert(xb_empty(&xb1)); xb_preload(GFP_KERNEL); assert(xb_set_bit(&xb1, 0) == 0); xb_preload_end(); /* Overflow test */ xb_zero(&xb1, ULONG_MAX - 10, ULONG_MAX); assert(xb_test_bit(&xb1, 0)); xb_preload(GFP_KERNEL); assert(xb_set_bit(&xb1, ULONG_MAX) == 0); xb_preload_end(); xb_zero(&xb1, 0, ULONG_MAX); assert(xb_empty(&xb1)); } /* * In the following tests, preload is called once when all the bits to set * locate in the same ida bitmap. Otherwise, it is recommended to call * preload for each xb_set_bit. */ static void xbitmap_check_bit_range(void) { unsigned long nbit = 0; /* Regular test1: node = NULL */ xb_preload(GFP_KERNEL); xb_set_bit(&xb1, 700); xb_preload_end(); assert(xb_find_set(&xb1, ULONG_MAX, &nbit) == true); assert(nbit == 700); nbit++; assert(xb_find_set(&xb1, ULONG_MAX, &nbit) == false); assert(nbit == 701); xb_zero(&xb1, 0, 1023); /* * Regular test2 * set bit 2000, 2001, 2040 * Next 1 in [0, 2048] --> 2000 * Next 1 in [2000, 2002] --> 2000 * Next 1 in [2002, 2040] --> 2040 * Next 1 in [2002, 2039] --> 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)); nbit = 0; assert(xb_find_set(&xb1, 2048, &nbit) == true); assert(nbit == 2000); assert(xb_find_set(&xb1, 2002, &nbit) == true); assert(nbit == 2000); nbit = 2002; assert(xb_find_set(&xb1, 2040, &nbit) == true); assert(nbit == 2040); nbit = 2002; assert(xb_find_set(&xb1, 2039, &nbit) == false); assert(nbit == 2002); nbit = 2000; assert(xb_find_zero(&xb1, 2048, &nbit) == true); assert(nbit == 2002); nbit = 2048; assert(xb_find_zero(&xb1, 2060, &nbit) == true); assert(nbit == 2048); xb_zero(&xb1, 0, 2048); nbit = 0; assert(xb_find_set(&xb1, 2048, &nbit) == false); assert(nbit == 0); xb_preload_end(); /* * Overflow tests: * Set bit 1 and ULONG_MAX - 4 * Next 1 in [0, ULONG_MAX] --> 1 * Next 1 in [1, ULONG_MAX] --> 1 * Next 1 in [2, ULONG_MAX] --> ULONG_MAX - 4 * Next 1 in [ULONG_MAX - 3, 2] --> none * Next 0 in [ULONG_MAX - 4, ULONG_MAX] --> ULONG_MAX - 3 * Zero [ULONG_MAX - 4, ULONG_MAX] * Next 1 in [ULONG_MAX - 10, ULONG_MAX] --> none * Next 1 in [ULONG_MAX - 1, 2] --> none * Zero [0, 1] * Next 1 in [0, 2] --> none */ xb_preload(GFP_KERNEL); assert(!xb_set_bit(&xb1, 1)); xb_preload_end(); xb_preload(GFP_KERNEL); assert(!xb_set_bit(&xb1, ULONG_MAX - 4)); nbit = 0; assert(xb_find_set(&xb1, ULONG_MAX, &nbit) == true); assert(nbit == 1); nbit = 1; assert(xb_find_set(&xb1, ULONG_MAX, &nbit) == true); assert(nbit == 1); nbit = 2; assert(xb_find_set(&xb1, ULONG_MAX, &nbit) == true); assert(nbit == ULONG_MAX - 4); nbit++; assert(xb_find_set(&xb1, 2, &nbit) == false); assert(nbit == ULONG_MAX - 3); nbit--; assert(xb_find_zero(&xb1, ULONG_MAX, &nbit) == true); assert(nbit == ULONG_MAX - 3); xb_zero(&xb1, ULONG_MAX - 4, ULONG_MAX); nbit = ULONG_MAX - 10; assert(xb_find_set(&xb1, ULONG_MAX, &nbit) == false); assert(nbit == ULONG_MAX - 10); nbit = ULONG_MAX - 1; assert(xb_find_set(&xb1, 2, &nbit) == false); xb_zero(&xb1, 0, 1); nbit = 0; assert(xb_find_set(&xb1, 2, &nbit) == false); assert(nbit == 0); xb_preload_end(); assert(xb_empty(&xb1)); } Best, Wei