[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] xen/arm: p2m_set_entry duplicate calculation.



Hi,

On 21/04/2022 16:17, Paran Lee wrote:
It doesn't seem necessary to do that calculation of order shift again.

I think we need to weight that against increasing the number of local variables that do pretty much the same.

This is pretty much done to a matter of taste here. IMHO, the original version is better but I see Stefano reviewed it so I will not argue against it.

That said, given you already sent a few patches, can you explain why you are doing this? Is this optimization purpose? Is it clean-up?


Signed-off-by: Paran Lee <p4ranlee@xxxxxxxxx>
---
  xen/arch/arm/p2m.c | 9 +++++----
  1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 1d1059f7d2..533afc830a 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -1092,7 +1092,7 @@ int p2m_set_entry(struct p2m_domain *p2m,
      while ( nr )
      {
          unsigned long mask;
-        unsigned long order;
+        unsigned long order, pages;
/*
           * Don't take into account the MFN when removing mapping (i.e
@@ -1118,11 +1118,12 @@ int p2m_set_entry(struct p2m_domain *p2m,
          if ( rc )
              break;
- sgfn = gfn_add(sgfn, (1 << order));
+        pages = 1 << order;

Please take the opportunity to switch to 1UL.

+        sgfn = gfn_add(sgfn, pages);
          if ( !mfn_eq(smfn, INVALID_MFN) )
-           smfn = mfn_add(smfn, (1 << order));
+           smfn = mfn_add(smfn, pages);
- nr -= (1 << order);
+        nr -= pages;
      }
return rc;

Cheers,

--
Julien Grall



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.