[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v3 1/3] libxl/cpumap: Add xc_cpumap_[setcpu, clearcpu, testcpu] to complement xc_cpumap_alloc.
On Tue, Mar 24, 2015 at 05:46:04PM +0000, Ian Campbell wrote: > On Tue, 2015-03-24 at 11:39 -0400, Konrad Rzeszutek Wilk wrote: > > Please make sure you CC all of the toolstack maintainers. > > > +void xc_cpumap_clearcpu(int cpu, xc_cpumap_t map) > > +{ > > + clear_bit(cpu, (unsigned long *)map); > > Is it necessary to worry about alignment here, since xc_cpumap_t is > actually a uint8_t*. > > I'm afraid I think it probably is on ARM at least, which is rather > tedious. > > Or do we rely on all of these always being dynamically allocated (via > xc_cpumap_alloc) and therefore "suitably aligned so that it may be > assigned to a pointer to any type of object"[0] following calloc , > avoids the issue in practice? > > I think we probably do, does anyone disagree with that assessment? We can also do and not worry about it: From 4620f9b35622ddf70db754f87a9114c235eb01de Mon Sep 17 00:00:00 2001 From: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> Date: Tue, 24 Mar 2015 16:23:08 -0400 Subject: [PATCH] swap --- tools/libxc/xc_misc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/libxc/xc_misc.c b/tools/libxc/xc_misc.c index 7514b84..19a1b18 100644 --- a/tools/libxc/xc_misc.c +++ b/tools/libxc/xc_misc.c @@ -94,19 +94,22 @@ xc_cpumap_t xc_cpumap_alloc(xc_interface *xch) return calloc(1, sz); } +#define BITS_PER_CPUMAP(map) (sizeof(*map) * 8) +#define CPUMAP_ENTRY(cpu, map) ((map))[(cpu) / BITS_PER_CPUMAP(map)] +#define CPUMAP_SHIFT(cpu, map) ((cpu) % BITS_PER_CPUMAP(map)) void xc_cpumap_clearcpu(int cpu, xc_cpumap_t map) { - clear_bit(cpu, (unsigned long *)map); + CPUMAP_ENTRY(cpu, map) &= ~(1U << CPUMAP_SHIFT(cpu, map)); } void xc_cpumap_setcpu(int cpu, xc_cpumap_t map) { - set_bit(cpu, (unsigned long *)map); + CPUMAP_ENTRY(cpu, map) |= (1U << CPUMAP_SHIFT(cpu, map)); } int xc_cpumap_testcpu(int cpu, xc_cpumap_t map) { - return test_bit(cpu, (unsigned long *)map); + return (CPUMAP_ENTRY(cpu, map) >> CPUMAP_SHIFT(cpu, map)) & 1; } xc_nodemap_t xc_nodemap_alloc(xc_interface *xch) -- 2.1.0 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |