Re: [BUG 2.6.31-rc1] HIGHMEM64G causes hang in PCI init on 32-bit x86
- From: Yinghai Lu <yinghai@xxxxxxxxxx>
- Date: Tue, 30 Jun 2009 15:30:55 -0700
Linus Torvalds wrote:
On Tue, 30 Jun 2009, Yinghai Lu wrote:
?
+#define round_up(x, y) ({ __typeof__(x) __mask = (y)-1; \
+ ((x)+__mask) & ~__mask; })
+#define round_down(x, y) ({ __typeof__(x) __mask = (y)-1; (x) & ~__mask; })
Yes, except we might as well simplify it. Do it without the statement
expressions, using just a single 'y'. Like this:
#define __round_mask(x,y) ((__typeof__(x))((y)-1))
#define round_up(x,y) (((x) | __round_mask(x,y))+1)
#define round_down(x,y) ((x) & ~__round_mask(x,y))
(Yeah, it uses 'x' twice, but the second one is for 'typeof', which
doesn't actually cause the value to be evaluated, so it's ok).
Now those 'round_xyz()' operations will always return a value of a type
that is the same as the type of 'x' except it's gone through the normal C
integer promotion rules (ie if 'x' is a smaller type than 'int', then it
will be promoted to 'int').
Not very well tested, but it _looks_ correct, and uses Peter's trick, and
willlet the compiler notice that
round_up(x,y)-1
is the same thing as
x | (y-1)
which it _could_ have perhaps figured out before, but now it's way more
obvious.
how about x = 0, y = 0x100?
YH
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
- Follow-Ups:
- Re: [BUG 2.6.31-rc1] HIGHMEM64G causes hang in PCI init on 32-bit x86
- From: Linus Torvalds
- Re: [BUG 2.6.31-rc1] HIGHMEM64G causes hang in PCI init on 32-bit x86
- From: Yinghai Lu
- Re: [BUG 2.6.31-rc1] HIGHMEM64G causes hang in PCI init on 32-bit x86
- References:
- Re: [BUG 2.6.31-rc1] HIGHMEM64G causes hang in PCI init on 32-bit x86
- From: Yinghai Lu
- Re: [BUG 2.6.31-rc1] HIGHMEM64G causes hang in PCI init on 32-bit x86
- From: Linus Torvalds
- Re: [BUG 2.6.31-rc1] HIGHMEM64G causes hang in PCI init on 32-bit x86
- Prev by Date: [RFC] Run-time PM framework (was: Re: [patch update] PM: Introduce core framework for run-time PM of I/O devices (rev. 6))
- Next by Date: Re: [PATCHSET] percpu: generalize first chunk allocators and improve lpage NUMA support
- Previous by thread: Re: [BUG 2.6.31-rc1] HIGHMEM64G causes hang in PCI init on 32-bit x86
- Next by thread: Re: [BUG 2.6.31-rc1] HIGHMEM64G causes hang in PCI init on 32-bit x86
- Index(es):
Relevant Pages
|