From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=39338 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ObwCc-0004mY-Q9 for qemu-devel@nongnu.org; Thu, 22 Jul 2010 09:52:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ObwCb-0002DI-KY for qemu-devel@nongnu.org; Thu, 22 Jul 2010 09:52:46 -0400 Received: from va3ehsobe001.messaging.microsoft.com ([216.32.180.11]:7006 helo=VA3EHSOBE001.bigfish.com) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ObwCb-0002Cz-IE for qemu-devel@nongnu.org; Thu, 22 Jul 2010 09:52:45 -0400 Message-ID: <4C484BBE.40908@amd.com> Date: Thu, 22 Jul 2010 15:46:38 +0200 From: Andre Przywara MIME-Version: 1.0 Subject: Re: [Qemu-devel] New Bitmap module ? References: In-Reply-To: Content-Type: multipart/mixed; boundary="------------090201070208040708020802" List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Corentin Chary Cc: Anthony Liguori , Qemu-development List , Alexander Graf --------------090201070208040708020802 Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Corentin Chary wrote: > Hi, > I was working on merging VNC updates into bigger ones to see if it > lower the overhead (big updates sometime use less network/cpu than a > lot of small updates). > For that, I needed some new bitmap functions, and no we got, in vnc.c: > - set_bit > - clear_bit > - set_bits > - clear_bits > - find_next_bit > - find_next_zero_bit > - find_next_zero_area > > Should we move that into bitmap.c/bitmap.h ? Definitely! For my NUMA work I have also coded some bitmap functions. Since mine are not performance critical, I reverted from implementing set_bits and clear_bits and replaced them with a loop in the calling code. So I could just could come around with a macro only implementation, for which a header file suffices (attached for reference). > Which part of QEMU could > use that (block.c maybe ?) As mentioned, the yet to be submitted NUMA code would benefit from it. Linux has also bitmap code, maybe you could leverage this (if not already done). Regards, Andre. -- Andre Przywara AMD-Operating System Research Center (OSRC), Dresden, Germany Tel: +49 351 448-3567-12 --------------090201070208040708020802 Content-Type: text/plain; name="bitmap.h" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="bitmap.h" #ifndef __BITMAP_H__ #define __BITMAP_H__ #ifndef HOST_LONG_BITS #define HOST_LONG_BITS (sizeof(long) * 8) #endif #define bitmap_isset(bm,bit) \ (!!bm[(bit) / HOST_LONG_BITS] & (1ULL << ((bit) % HOST_LONG_BITS))) #define bitmap_set(bm,bit) \ (bm[(bit) / HOST_LONG_BITS] |= (1ULL << ((bit) % HOST_LONG_BITS))) #define bitmap_unset(bm,bit) \ (bm[(bit) / HOST_LONG_BITS] &= ~(1ULL << ((bit) % HOST_LONG_BITS))) #define DECLARE_BITMAP(bm,len) \ unsigned long bm[((len) + HOST_LONG_BITS - 1) / HOST_LONG_BITS] #define bitmap_clear(bm,len) \ memset(bm, 0, (len + 7) / 8) #define bitmap_fill(bm,len) \ memset(bm, 0xFF, (len + 7) / 8) #endif --------------090201070208040708020802--