* [PATCH] xen/x86: Use macro DIV_ROUND_UP
@ 2020-04-02 15:53 Simran Singhal
2020-04-02 16:20 ` Andrew Cooper
0 siblings, 1 reply; 2+ messages in thread
From: Simran Singhal @ 2020-04-02 15:53 UTC (permalink / raw)
To: xen-devel
Cc: Andrew Cooper, Lukasz Hawrylko, Wei Liu, Jan Beulich,
Roger Pau Monné
Use the DIV_ROUND_UP macro to replace open-coded divisor calculation
(((n) + (d) - 1) /(d)) to improve readability.
Signed-off-by: Simran Singhal <singhalsimran0@gmail.com>
---
xen/arch/x86/mm.c | 2 +-
xen/arch/x86/tboot.c | 2 +-
xen/arch/x86/x86_64/mm.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index c7617f80e8..a381eac81c 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -240,7 +240,7 @@ static void __init init_frametable_chunk(void *start, void *end)
void __init init_frametable(void)
{
unsigned int sidx, eidx, nidx;
- unsigned int max_idx = (max_pdx + PDX_GROUP_COUNT - 1) / PDX_GROUP_COUNT;
+ unsigned int max_idx = DIV_ROUND_UP(max_pdx, PDX_GROUP_COUNT);
struct page_info *end_pg, *top_pg;
BUILD_BUG_ON(XEN_VIRT_END > FRAMETABLE_VIRT_START);
diff --git a/xen/arch/x86/tboot.c b/xen/arch/x86/tboot.c
index 102c3cd203..320e06f129 100644
--- a/xen/arch/x86/tboot.c
+++ b/xen/arch/x86/tboot.c
@@ -310,7 +310,7 @@ static void tboot_gen_frametable_integrity(const uint8_t key[TB_KEY_SIZE],
vmac_t *mac)
{
unsigned int sidx, eidx, nidx;
- unsigned int max_idx = (max_pdx + PDX_GROUP_COUNT - 1)/PDX_GROUP_COUNT;
+ unsigned int max_idx = DIV_ROUND_UP(max_pdx, PDX_GROUP_COUNT);
uint8_t nonce[16] = {};
vmac_ctx_t ctx;
diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c
index b7ce833ffc..cee836ec37 100644
--- a/xen/arch/x86/x86_64/mm.c
+++ b/xen/arch/x86/x86_64/mm.c
@@ -801,7 +801,7 @@ static int extend_frame_table(struct mem_hotadd_info *info)
spfn = _mfn(info->spfn);
epfn = _mfn(info->epfn);
- eidx = (mfn_to_pdx(epfn) + PDX_GROUP_COUNT - 1) / PDX_GROUP_COUNT;
+ eidx = DIV_ROUND_UP(mfn_to_pdx(epfn), PDX_GROUP_COUNT);
nidx = cidx = mfn_to_pdx(spfn)/PDX_GROUP_COUNT;
ASSERT( mfn_to_pdx(epfn) <= (DIRECTMAP_SIZE >> PAGE_SHIFT) &&
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] xen/x86: Use macro DIV_ROUND_UP
2020-04-02 15:53 [PATCH] xen/x86: Use macro DIV_ROUND_UP Simran Singhal
@ 2020-04-02 16:20 ` Andrew Cooper
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cooper @ 2020-04-02 16:20 UTC (permalink / raw)
To: Simran Singhal, xen-devel
Cc: Lukasz Hawrylko, Wei Liu, Jan Beulich, Roger Pau Monné
On 02/04/2020 16:53, Simran Singhal wrote:
> Use the DIV_ROUND_UP macro to replace open-coded divisor calculation
> (((n) + (d) - 1) /(d)) to improve readability.
>
> Signed-off-by: Simran Singhal <singhalsimran0@gmail.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-02 16:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-02 15:53 [PATCH] xen/x86: Use macro DIV_ROUND_UP Simran Singhal
2020-04-02 16:20 ` Andrew Cooper
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.