Re: [PATCHv4 27/39] x86-64, mm: proper alignment mappings with hugepages

From: Dave Hansen
Date: Tue Jun 25 2013 - 12:46:46 EST


On 06/25/2013 07:56 AM, Kirill A. Shutemov wrote:
> Dave Hansen wrote:
>> On 05/11/2013 06:23 PM, Kirill A. Shutemov wrote:
>>> +static inline unsigned long mapping_align_mask(struct address_space *mapping)
>>> +{
>>> + if (mapping_can_have_hugepages(mapping))
>>> + return PAGE_MASK & ~HPAGE_MASK;
>>> + return get_align_mask();
>>> +}
>>
>> get_align_mask() appears to be a bit more complicated to me than just a
>> plain old mask. Are you sure you don't need to pick up any of its
>> behavior for the mapping_can_have_hugepages() case?
>
> get_align_mask() never returns more strict mask then we do in
> mapping_can_have_hugepages() case.
>
> I can modify it this way:
>
> unsigned long mask = get_align_mask();
>
> if (mapping_can_have_hugepages(mapping))
> mask &= PAGE_MASK & ~HPAGE_MASK;
> return mask;
>
> But it looks more confusing for me. What do you think?

Personally, I find that a *LOT* more clear. The &= pretty much spells
out what you said in your explanation: get_align_mask()'s mask can only
be made more strict when we encounter a huge page.

The relationship between the two masks is not apparent at all in your
original code. This is all nitpicking though, I just wanted to make
sure you'd considered if you were accidentally changing behavior.
--
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/