Re: [PATCH v1] drivers/base/memory.c: Don't store end_section_nr in memory blocks
From: David Hildenbrand
Date: Thu Aug 01 2019 - 02:48:20 EST
On 31.07.19 22:57, Andrew Morton wrote:
> On Wed, 31 Jul 2019 14:22:13 +0200 David Hildenbrand <david@xxxxxxxxxx> wrote:
>
>> Each memory block spans the same amount of sections/pages/bytes. The size
>> is determined before the first memory block is created. No need to store
>> what we can easily calculate - and the calculations even look simpler now.
>>
>> While at it, fix the variable naming in register_mem_sect_under_node() -
>> we no longer talk about a single section.
>>
>> ...
>>
>> --- a/include/linux/memory.h
>> +++ b/include/linux/memory.h
>> @@ -40,6 +39,8 @@ int arch_get_memory_phys_device(unsigned long start_pfn);
>> unsigned long memory_block_size_bytes(void);
>> int set_memory_block_size_order(unsigned int order);
>>
>> +#define PAGES_PER_MEMORY_BLOCK (memory_block_size_bytes() / PAGE_SIZE)
>
> Please let's not hide function calls inside macros which look like
> compile-time constants! Adding "()" to the macro would be a bit
> better. Making it a regular old inline C function would be better
> still. But I'd suggest just open-coding this at the macro's single
> callsite.
>
Sure, makes sense. Thanks!
--
Thanks,
David / dhildenb