[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20150720162800.734632f4e05ffae173cff527@linux-foundation.org>
Date: Mon, 20 Jul 2015 16:28:00 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Rasmus Villemoes <linux@...musvillemoes.dk>
Cc: Guenter Roeck <linux@...ck-us.net>,
Sowmini Varadhan <sowmini.varadhan@...cle.com>,
linux-kernel@...r.kernel.org, benh@...nel.crashing.org,
davem@...emloft.net
Subject: Re: [PATCH] iommu-common: Do not use 64 bit constant
0xffffffffffffffffl for computing align_mask
On Mon, 20 Jul 2015 19:57:18 +0200 Rasmus Villemoes <linux@...musvillemoes.dk> wrote:
> On Mon, Jul 20 2015, Guenter Roeck <linux@...ck-us.net> wrote:
>
> > So either case ~0l appears to be wrong; it should be ~0ul.
>
> Yes, right-shifting -1 of any type is probably always wrong, as it will
> always give -1 again.
Not for unsigned types.
The kernel uses "-1UL" and "-1ULL" quite a lot - it's a convenient way
of saying "all ones, regardless of size". Also, assigning plain old
"-1" to an unsigned variable will make that variable all-ones
regardless of size.
In this case I expect we could do
align_mask = -1UL >> (64 - align_order);
but I don't know about that 64. Maybe it should be BITS_PER_LONG?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists