diff mbox

[v2,2/8] xen/mm: Introduce a bunch of helpers for the typesafes mfn and gfn

Message ID 1466429845-28240-3-git-send-email-julien.grall@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Julien Grall June 20, 2016, 1:37 p.m. UTC
Those helpers will be useful to do common operations without having to
unbox/box manually the GFNs/MFNs.

Signed-off-by: Julien Grall <julien.grall@arm.com>

---
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <george.dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wei.liu2@citrix.com>

    Changes in v2:
        - Rename min_gfn/max_gfn to gfn_min/gfn_max
        - Add more helpers for gfn and mfn
---
 xen/include/xen/mm.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Jan Beulich June 20, 2016, 2:25 p.m. UTC | #1
>>> On 20.06.16 at 15:37, <julien.grall@arm.com> wrote:
> Those helpers will be useful to do common operations without having to
> unbox/box manually the GFNs/MFNs.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>

Acked-by: Jan Beulich <jbeulich@suse.com>

But - since iirc Andrew asked for it during v1 review - any particular
reason you made these macros rather than inline functions?

Jan
Julien Grall June 20, 2016, 2:26 p.m. UTC | #2
On 20/06/16 15:25, Jan Beulich wrote:
>>>> On 20.06.16 at 15:37, <julien.grall@arm.com> wrote:
>> Those helpers will be useful to do common operations without having to
>> unbox/box manually the GFNs/MFNs.
>>
>> Signed-off-by: Julien Grall <julien.grall@arm.com>
>
> Acked-by: Jan Beulich <jbeulich@suse.com>
>
> But - since iirc Andrew asked for it during v1 review - any particular
> reason you made these macros rather than inline functions?

No. I just forgot to address Andrew's comment. Sorry for that.

I will resend a new version of this patch.

Cheers,
diff mbox

Patch

diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h
index 3cf646a..58b5c75 100644
--- a/xen/include/xen/mm.h
+++ b/xen/include/xen/mm.h
@@ -61,6 +61,11 @@  TYPE_SAFE(unsigned long, mfn);
 #undef mfn_t
 #endif
 
+#define mfn_add(mfn, i) _mfn(mfn_x(mfn) + (i))
+#define mfn_max(x, y)   _mfn(max(mfn_x(x), mfn_x(y)))
+#define mfn_min(x, y)   _mfn(min(mfn_x(x), mfn_x(y)))
+#define mfn_eq(x, y)    (mfn_x(x) == mfn_x(y))
+
 TYPE_SAFE(unsigned long, gfn);
 #define PRI_gfn          "05lx"
 #define INVALID_GFN      (~0UL)
@@ -70,6 +75,11 @@  TYPE_SAFE(unsigned long, gfn);
 #undef gfn_t
 #endif
 
+#define gfn_add(gfn, i) _gfn(gfn_x(gfn) + (i))
+#define gfn_max(x, y)   _gfn(max(gfn_x(x), gfn_x(y)))
+#define gfn_min(x, y)   _gfn(min(gfn_x(x), gfn_x(y)))
+#define gfn_eq(x, y)    (gfn_x(x) == gfn_x(y))
+
 TYPE_SAFE(unsigned long, pfn);
 #define PRI_pfn          "05lx"
 #define INVALID_PFN      (~0UL)