Re: [PATCH v6 10/10] mm/memory_hotplug: Cleanup __remove_pages()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: Segher Boessenkool <segher@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: [PATCH v6 10/10] mm/memory_hotplug: Cleanup __remove_pages()
- From: David Hildenbrand <david@xxxxxxxxxx>
- Date: Tue, 4 Feb 2020 14:38:51 +0100
- Cc: Oscar Salvador <osalvador@xxxxxxx>, linux-s390@xxxxxxxxxxxxxxx, Michal Hocko <mhocko@xxxxxxxx>, linux-ia64@xxxxxxxxxxxxxxx, Pavel Tatashin <pasha.tatashin@xxxxxxxxxx>, linux-sh@xxxxxxxxxxxxxxx, x86@xxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, linux-mm@xxxxxxxxx, Wei Yang <richardw.yang@xxxxxxxxxxxxxxx>, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, linuxppc-dev@xxxxxxxxxxxxxxxx, Dan Williams <dan.j.williams@xxxxxxxxx>, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
- In-reply-to: <20200204131353.GJ22482@gate.crashing.org>
- Organization: Red Hat GmbH
- References: <20191006085646.5768-1-david@redhat.com> <20191006085646.5768-11-david@redhat.com> <20200204094652.GE6494@linux> <5d698f94-af18-0714-bc97-14b6c520572c@redhat.com> <20200204131353.GJ22482@gate.crashing.org>
- User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1
On 04.02.20 14:13, Segher Boessenkool wrote:
> On Tue, Feb 04, 2020 at 01:41:06PM +0100, David Hildenbrand wrote:
>> On 04.02.20 10:46, Oscar Salvador wrote:
>>> I have to confess that it took me while to wrap around my head
>>> with the new min() change, but looks ok:
>>
>> It's a pattern commonly used in compilers and emulators to calculate the
>> number of bytes to the next block/alignment. (we're missing a macro
>> (like we have ALIGN_UP/IS_ALIGNED) for that - but it's hard to come up
>> with a good name (e.g., SIZE_TO_NEXT_ALIGN) .
>
> You can just write the easy to understand
>
> ... ALIGN_UP(x) - x ...
you mean
ALIGN_UP(x, PAGES_PER_SECTION) - x
but ...
>
> which is better *without* having a separate name. Does that not
> generate good machine code for you?
1. There is no ALIGN_UP. "SECTION_ALIGN_UP(x) - x" would be possible
2. It would be wrong if x is already aligned.
e.g., let's use 4096 for simplicity as we all know that value by heart
(for both x and the block size).
a) -(4096 | -4096) -> 4096
b) #define ALIGN_UP(x, a) ((x + a - 1) & -(a))
ALIGN_UP(4096, 4096) - 4096 -> 0
Not as easy as it seems ...
--
Thanks,
David / dhildenb
[Index of Archives]
[Linux Kernel]
[Sparc Linux]
[DCCP]
[Linux ARM]
[Yosemite News]
[Linux SCSI]
[Linux x86_64]
[Linux for Ham Radio]