From: Wei Liu Subject: Re: [PATCH 6/8] evtchn: alter internal object handling scheme Date: Fri, 16 Aug 2013 17:55:12 +0100 Message-ID: <20130816165512.GF12674@zion.uk.xensource.com> References: <1376071720-17644-1-git-send-email-david.vrabel@citrix.com> <1376071720-17644-7-git-send-email-david.vrabel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1376071720-17644-7-git-send-email-david.vrabel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: David Vrabel Cc: Wei Liu , Malcolm Crossley , Keir Fraser , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Fri, Aug 09, 2013 at 07:08:38PM +0100, David Vrabel wrote: [...] > #define BITS_PER_EVTCHN_WORD(d) (has_32bit_shinfo(d) ? 32 : BITS_PER_XEN_ULONG) > #endif > -#define MAX_EVTCHNS(d) (BITS_PER_EVTCHN_WORD(d) * BITS_PER_EVTCHN_WORD(d)) > -#define EVTCHNS_PER_BUCKET 128 > -#define NR_EVTCHN_BUCKETS (NR_EVENT_CHANNELS / EVTCHNS_PER_BUCKET) > + > +#define BUCKETS_PER_GROUP (PAGE_SIZE/sizeof(struct evtchn *)) > +/* Round size of struct evtchn up to power of 2 size */ > +#define b2(x) ( (x) | ( (x) >> 1) ) > +#define b4(x) ( b2(x) | ( b2(x) >> 2) ) > +#define b8(x) ( b4(x) | ( b4(x) >> 4) ) > +#define b16(x) ( b8(x) | ( b8(x) >> 8) ) > +#define b32(x) (b16(x) | (b16(x) >>16) ) > +#define next_power_of_2(x) (b32(x-1) + 1) > + These macros are generic, can they be moved to a generic header so that other code can reuse them? Wei.