Re: pmd_addr_end Doubt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Venkatram,

On Sun, Oct 3, 2010 at 7:28 PM, Venkatram Tummala
<venkatram867@xxxxxxxxx> wrote:
> Hi All,
>
> Can somebody explain the macro pmd_addr_end(addr, end)
>
> #define pmd_addr_end(addr, end)                                         \
>  ({      unsigned long __boundary = ((addr) + PMD_SIZE) & PMD_MASK;      \
>         (__boundary - 1 < (end) - 1)? __boundary: (end);                \
>  })
>
> I know that this macro rounds the addr value to next higher multiple
> of PMD_SIZE. If this "ceiling" is greater than end, then the value is
> end. What i dont understand is why is "boundary - 1 < end -1"  used
> instead of just boundary < end.

When the address happens to fall in the range of the highest PMD
that's addressable, then end wraps to zero (~0 + 1 == 0). end -1 winds
up being ~0. By adding -1 for both boundary and end you don't need to
add special logic to deal with that particular case.

-- 
Dave Hylands
Shuswap, BC, Canada
http://www.DaveHylands.com/

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ




[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux