RE: [PATCH 2/3] bnx2x: Casting page alignment

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Vladislav Zolotarov
Date: Wednesday, March 11, 2009 - 5:51 am

See below. 

PAGES_PER_SGE_SHIFT)

SGE_X macros represent the interface to our microcode, which currently
works with native page sizes, however this may change in the future (and
it was different in the past). So, as long as it doesn't harm the performance,
adds readability and is a better programming style (as long as it
implements specific functionality) I'd prefer to leave it the way it is. 

But thanks for reviewing, Bjorn.


Frankly speaking I thought of it too, when I found the "bug" and I was quite pissed off
with the change in PAGE_ALIGN macro introduced in 2.6.27 (http://lkml.org/lkml/2008/6/15/85).
It's always pissing off when u have to change your code... ;)
But then I gave it another look and agreed that it's only the mater of semantics.

To recall, the change in general was to perform the alignment inside the range of the type
of the argument, which means, for example, when u have something like:

/* e.g. ppc64 with 64K page size */
#define PAGE_SIZE 65536  /* 64KB */

u16 k = 10;
u32 n = PAGE_ALIGN(k); /* This will give u 0 and not 64K as u might expect */

/* End of example */

The semantics had been changed to implement the following sentence:
"PAGE_ALIGN(k) is a value that k would have if aligned to the PAGE_SIZE"
rather than "PAGE_ALIGN(k) is the smallest multiple of PAGE_SIZE larger than k".
There were reasons for that - see the comments for the Andrea's patch.

So, as I said, when I was going to submit a patch fixing PAGE_ALIGN
macro:
 - PAGE_SIZE should be of the integer type having the same size as void*.
 - PAGE_ALIGN(x) should be defined as (((x)+PAGE_SIZE-1) & PAGE_MASK).

I understood that there is no actually important reason not to use ALIGN(x,a) macro for
PAGE_ALIGN and redefine it.

Right, there is this "feature" that I've described above but it's quite fair: aligned value stays inside
the boundaries of the value u r going to align, and if u expect it to the larger - do the proper cast.
This is exactly what my patch is doing.

Once again, thanks for reviewing and sorry if I talked to much... :)

Regards,
vlad
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 2/3] bnx2x: Casting page alignment, Eilon Greenstein, (Mon Mar 9, 3:52 am)
Re: [PATCH 2/3] bnx2x: Casting page alignment, Bjorn Helgaas, (Tue Mar 10, 8:48 pm)
RE: [PATCH 2/3] bnx2x: Casting page alignment, Vladislav Zolotarov, (Wed Mar 11, 5:51 am)