From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Xu Subject: Re: [kvm-unit-tests PATCH 05/14] page: add page alignment checker Date: Mon, 24 Oct 2016 17:58:23 +0800 Message-ID: <20161024095823.GV15168@pxdev.xzpeter.org> References: <1476448852-30062-1-git-send-email-peterx@redhat.com> <1476448852-30062-6-git-send-email-peterx@redhat.com> <20161020122314.wp3cgpueprgz2mwf@kamzik.brq.redhat.com> <20161020123026.y3isudr22e3bkr4l@kamzik.brq.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Cc: kvm@vger.kernel.org, jan.kiszka@web.de, agordeev@redhat.com, rkrcmar@redhat.com, pbonzini@redhat.com To: Andrew Jones Return-path: Received: from mx1.redhat.com ([209.132.183.28]:45954 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755264AbcJXJ6Y (ORCPT ); Mon, 24 Oct 2016 05:58:24 -0400 Content-Disposition: inline In-Reply-To: <20161020123026.y3isudr22e3bkr4l@kamzik.brq.redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, Oct 20, 2016 at 02:30:26PM +0200, Andrew Jones wrote: > On Thu, Oct 20, 2016 at 02:23:14PM +0200, Andrew Jones wrote: > > On Fri, Oct 14, 2016 at 08:40:43PM +0800, Peter Xu wrote: > > > Signed-off-by: Peter Xu > > > --- > > > lib/asm-generic/page.h | 5 +++++ > > > 1 file changed, 5 insertions(+) > > > > > > diff --git a/lib/asm-generic/page.h b/lib/asm-generic/page.h > > > index 7b8a08b..cbdc8f6 100644 > > > --- a/lib/asm-generic/page.h > > > +++ b/lib/asm-generic/page.h > > Another comment. IS_ALIGNED shouldn't be here, it should be > in lib/libcflat.h under the definition of ALIGN there. Moving over. > > drew > > > > @@ -19,6 +19,11 @@ > > > > > > #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE) > > > > > > +#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0) > > > +#define PAGE_ALIGNED_4K(x) IS_ALIGNED((x), (0x1000)) > > > +#define PAGE_ALIGNED_2M(x) IS_ALIGNED((x), (0x200000)) > > > +#define PAGE_ALIGNED_1G(x) IS_ALIGNED((x), (0x40000000)) > > > > I like IS_ALIGNED, but not the others. The others are strangely > > named because it's half asking if an address is page aligned and > > half asking if it's aligned to a given boundary. Why not just > > ask the boundary, like ALIGNED_2M(x)? Anyway, my preference would > > be to replace them with SZ_4K, SZ_2M, SZ_1G definitions. Users would > > then do > > > > IS_ALIGNED(addr, SZ_2M) > > > > or whatever, which isn't much more typing. Yeah these looks more clean. Will take them. Thanks! -- peterx