[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120320092058.1b3271a4@wrlaptop>
Date: Tue, 20 Mar 2012 09:20:58 -0500
From: Peter Seebach <peter.seebach@...driver.com>
To: Michal Nazarewicz <mina86@...a86.com>
CC: Christoph Lameter <cl@...ux-foundation.org>,
Pekka Enberg <penberg@...nel.org>,
Matt Mackall <mpm@...enic.com>, Tejun Heo <tj@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Lai Jiangshan <laijs@...fujitsu.com>,
<linux-kernel@...r.kernel.org>, <linux-mm@...ck.org>
Subject: Re: [RFC PATCH 1/6] kenrel.h: add ALIGN_OF_LAST_BIT()
On Tue, 20 Mar 2012 12:32:14 +0100
Michal Nazarewicz <mina86@...a86.com> wrote:
> >+#define ALIGN_OF_LAST_BIT(x) ((((x)^((x) - 1))>>1) + 1)
>
> Wouldn't ALIGNMENT() be less confusing? After all, that's what this
> macro is calculating, right? Alignment of given address.
Why not just LAST_BIT(x)? It's not particularly specific to pointer
alignment, even though that's the context in which it apparently came
up. So far as I can tell, this isn't even meaningfully defined on
pointer types as such; you'd have to convert. So the implications for
alignment seem a convenient side-effect, really.
It might be instructive to see some example proposed uses; the question
of why I'd care what alignment something had, rather than whether it
was aligned for a given type, is one that will doubtless keep me awake
nights.
I guess this feels like it answers a question that is usually the wrong
question. Imagine if you will a couple-page block of memory, full of
unsigned shorts. Iterate through the array, calculating
ALIGN_OF_LAST_BIT(&a[i]). Do we really *care* that it's PAGE_SIZE for
some i, and 2 (I assume) for other i, and PAGE_SIZE*2 for either i==0 or
i==PAGE_SIZE? (Apologies if this is a silly question; maybe this is
such a commonly-needed feature that it's obvious.)
-s
--
Listen, get this. Nobody with a good compiler needs to be justified.
--
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