[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 1/7] cpu: use ROUND_UP() to define xxx_PAGE_ALIGN
From: |
Paolo Bonzini |
Subject: |
Re: [PATCH v2 1/7] cpu: use ROUND_UP() to define xxx_PAGE_ALIGN |
Date: |
Thu, 24 Oct 2019 16:14:04 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 |
On 24/10/19 16:06, Richard Henderson wrote:
> On 10/24/19 8:04 AM, Paolo Bonzini wrote:
>> On 24/10/19 13:52, Philippe Mathieu-Daudé wrote:
>>>> diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
>>>> index ad9ab85eb3..255bb186ac 100644
>>>> --- a/include/exec/cpu-all.h
>>>> +++ b/include/exec/cpu-all.h
>>>> @@ -220,7 +220,7 @@ extern int target_page_bits;
>>>> #define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS)
>>>> #define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1)
>>>> -#define TARGET_PAGE_ALIGN(addr) (((addr) + TARGET_PAGE_SIZE - 1) &
>>>> TARGET_PAGE_MASK)
>>>> +#define TARGET_PAGE_ALIGN(addr) ROUND_UP((addr), TARGET_PAGE_SIZE)
>>>> /* Using intptr_t ensures that qemu_*_page_mask is sign-extended even
>>>> * when intptr_t is 32-bit and we are aligning a long long.
>>>> @@ -228,9 +228,8 @@ extern int target_page_bits;
>>>> extern uintptr_t qemu_host_page_size;
>>>> extern intptr_t qemu_host_page_mask;
>>>> -#define HOST_PAGE_ALIGN(addr) (((addr) + qemu_host_page_size - 1) &
>>>> qemu_host_page_mask)
>>>> -#define REAL_HOST_PAGE_ALIGN(addr) (((addr) +
>>>> qemu_real_host_page_size - 1) & \
>>>> - qemu_real_host_page_mask)
>>>> +#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size)
>>>> +#define REAL_HOST_PAGE_ALIGN(addr) ROUND_UP((addr),
>>>> qemu_real_host_page_size)
>>>> /* same as PROT_xxx */
>>>> #define PAGE_READ 0x0001
>>>>
>>
>> Isn't this the patch where Richard pointed out that the compiler
>> generates worse code?
>
> Richard confused ROUND_UP with QEMU_ALIGN_UP.
Uh, those are both really badly named. Especially considering that
DIV_ROUND_UP divides the result of QEMU_ALIGN_UP. Should we consider
swapping them?!?
Paolo
[PATCH v2 6/7] exec: Promote TARGET_PAGE_MASK to target_long, Richard Henderson, 2019/10/23
[PATCH v2 5/7] exec: Restrict TARGET_PAGE_BITS_VARY assert to CONFIG_DEBUG_TCG, Richard Henderson, 2019/10/23
[PATCH v2 7/7] exec: Cache TARGET_PAGE_MASK for TARGET_PAGE_BITS_VARY, Richard Henderson, 2019/10/23
[PATCH v2 3/7] configure: Detect compiler support for __attribute__((alias)), Richard Henderson, 2019/10/23
[PATCH v2 2/7] exec: Split out variable page size support to exec-vary.c, Richard Henderson, 2019/10/23
[PATCH v2 4/7] exec: Use const alias for TARGET_PAGE_BITS_VARY, Richard Henderson, 2019/10/23