From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42725) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4OaC-0007AE-4B for qemu-devel@nongnu.org; Thu, 03 Dec 2015 02:45:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a4Oa6-0005xZ-U8 for qemu-devel@nongnu.org; Thu, 03 Dec 2015 02:45:39 -0500 Received: from mx2.parallels.com ([199.115.105.18]:58727) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4Oa6-0005wx-HE for qemu-devel@nongnu.org; Thu, 03 Dec 2015 02:45:34 -0500 Message-ID: <565FF2DD.9070908@virtuozzo.com> Date: Thu, 3 Dec 2015 10:44:29 +0300 From: Vladimir Sementsov-Ogievskiy MIME-Version: 1.0 References: <1447255003-2043-1-git-send-email-vsementsov@virtuozzo.com> <1447255003-2043-2-git-send-email-vsementsov@virtuozzo.com> <20151203073511.GA31986@ad.usersys.redhat.com> In-Reply-To: <20151203073511.GA31986@ad.usersys.redhat.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 01/13] hbitmap: serialization List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: kwolf@redhat.com, peter.maydell@linaro.org, quintela@redhat.com, qemu-devel@nongnu.org, dgilbert@redhat.com, stefanha@redhat.com, den@openvz.org, amit.shah@redhat.com, pbonzini@redhat.com, jsnow@redhat.com On 03.12.2015 10:35, Fam Zheng wrote: > On Wed, 11/11 18:16, Vladimir Sementsov-Ogievskiy wrote: >> +void hbitmap_deserialize_finish(HBitmap *bitmap) >> +{ >> + int64_t i, size, prev_size; >> + int lev; >> + >> + /* restore levels starting from penultimate to zero level, assuming >> + * that the last level is ok */ >> + size = MAX((bitmap->size + BITS_PER_LONG - 1) >> BITS_PER_LEVEL, 1); >> + for (lev = HBITMAP_LEVELS - 1; lev-- > 0; ) { >> + prev_size = size; >> + size = MAX((size + BITS_PER_LONG - 1) >> BITS_PER_LEVEL, 1); >> + memset(bitmap->levels[lev], 0, size * sizeof(unsigned long)); >> + >> + for (i = 0; i < prev_size; ++i) { >> + if (bitmap->levels[lev + 1][i]) { >> + bitmap->levels[lev][i >> BITS_PER_LEVEL] |= >> + 1 << (i & (BITS_PER_LONG - 1)); > This should be 1UL. Yes, I've found it yesterday.. with two days of debugging) > > Fam > >> + } >> + } >> + } >> + >> + bitmap->levels[0][0] |= 1UL << (BITS_PER_LONG - 1); >> +} >> + >> void hbitmap_free(HBitmap *hb) >> { >> unsigned i; >> -- >> 2.1.4 >> >> -- Best regards, Vladimir * now, @virtuozzo.com instead of @parallels.com. Sorry for this inconvenience.