Message ID | 1465906027-16614-8-git-send-email-julien.grall@arm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
>>> On 14.06.16 at 14:07, <julien.grall@arm.com> wrote: > --- a/xen/include/xen/mm.h > +++ b/xen/include/xen/mm.h > @@ -70,6 +70,9 @@ TYPE_SAFE(unsigned long, gfn); > #undef gfn_t > #endif > > +#define max_gfn(x, y) _gfn(max(gfn_x(x), gfn_x(y))) > +#define min_gfn(x, y) _gfn(min(gfn_x(x), gfn_x(y))) With my reply to an earlier patch in mind I think these would better be gfn_min() and gfn_max() (to be extended with gfn_add() and mfn_add() and maybe some others). Jan
On 14/06/16 14:05, Jan Beulich wrote: >>>> On 14.06.16 at 14:07, <julien.grall@arm.com> wrote: >> --- a/xen/include/xen/mm.h >> +++ b/xen/include/xen/mm.h >> @@ -70,6 +70,9 @@ TYPE_SAFE(unsigned long, gfn); >> #undef gfn_t >> #endif >> >> +#define max_gfn(x, y) _gfn(max(gfn_x(x), gfn_x(y))) >> +#define min_gfn(x, y) _gfn(min(gfn_x(x), gfn_x(y))) > With my reply to an earlier patch in mind I think these would better > be gfn_min() and gfn_max() (to be extended with gfn_add() and > mfn_add() and maybe some others). +1 to the alternative naming suggestion. I would also suggest making these static inlines rather than defines. ~Andrew
diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index a22c4c2..6fddb6f 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -70,6 +70,9 @@ TYPE_SAFE(unsigned long, gfn); #undef gfn_t #endif +#define max_gfn(x, y) _gfn(max(gfn_x(x), gfn_x(y))) +#define min_gfn(x, y) _gfn(min(gfn_x(x), gfn_x(y))) + TYPE_SAFE(unsigned long, pfn); #define PRI_pfn "05lx" #define INVALID_PFN (~0UL)
Those helpers will be useful to find the maximum/minimum between two GFNs without having to unbox/box manually. 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> --- xen/include/xen/mm.h | 3 +++ 1 file changed, 3 insertions(+)