From mboxrd@z Thu Jan 1 00:00:00 1970 From: George Dunlap Subject: Re: [PATCH v4] x86/arm/mm: use gfn instead of pfn in p2m_get_mem_access/p2m_set_mem_access Date: Thu, 2 Jul 2015 14:01:00 +0100 Message-ID: <5595360C.3000904@eu.citrix.com> References: <1435592708-26456-1-git-send-email-vkuznets@redhat.com> <559516F9.8050402@eu.citrix.com> <55951BDC.7010002@citrix.com> <20150702112549.GA87948@deinos.phlegethon.org> <55952138.3070501@eu.citrix.com> <87wpyirbj9.fsf@vitty.brq.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <87wpyirbj9.fsf@vitty.brq.redhat.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Vitaly Kuznetsov Cc: Keir Fraser , Ian Campbell , Razvan Cojocaru , Andrew Cooper , Tim Deegan , xen-devel@lists.xen.org, Stefano Stabellini , Jan Beulich , Tamas K Lengyel List-Id: xen-devel@lists.xenproject.org On 07/02/2015 01:26 PM, Vitaly Kuznetsov wrote: > George Dunlap writes: > >> On 07/02/2015 12:25 PM, Tim Deegan wrote: >>> At 12:09 +0100 on 02 Jul (1435838956), Andrew Cooper wrote: >>>> On 02/07/15 11:48, George Dunlap wrote: >>>>> Now in p2m_set_mem_access(), rather than just using an unsigned long in >>>>> the loop iterating over gfns, you do this thing where you convert gfn_t >>>>> to unsigned long, add one, and then convert it back to gfn_t again. >>>>> >>>>> I can't see any comments in v3 that suggest you doing that, and it seems >>>>> a bit clunky. Is that really necessary? Wouldn't it be better to >>>>> declare a local variable? >>>>> >>>>> I'm not strongly opinionated on this one, it just seems a bit strange. >>>>> >>>>> Everything else looks good, thanks. >>>> >>>> Looping over {g,m,p}fn_t's is indeed awkward, as the compiler tricks for >>>> typesafety don't allow for simply adding 1 to a typesafe variable. >>>> >>>> In a cases like this, I think it is acceptable to keep a unsigned long >>>> shadow variable and manipulate it is a plain integer. The eventual >>>> _gfn() required to pass it further down the callchain will help to >>>> visually re-enforce the appropriate type. >>>> >>>> After all, the entire point of these typesafes are to try and avoid >>>> accidentally mixing up the different address spaces, but a function >>>> which takes a typesafe, loops over a subset and passes the same typesafe >>>> further down can probably be trusted to DTRT, catching errors at review >>>> time. >>>> >>>> Off the top of my head, the only functions which would normally expect >>>> to mix and match the typesafes are the pagetable walking ones. >>> >>> It should be easy enough to extend the macros to define a >>> gfn_inc(&gfn_t) operator for this kind of thing. >> >> I was thinking that -- although in this case you'd still need to un-pack >> it to do the loop exit conditional. To really make things pretty you'd >> want a for_gfn_range() macro or something like that that takes a start >> gfn and a number. >> >> But that's really starting to be feature creep for this patch, which is >> why I didn't want to suggest it on v4. :-) > > Well, if you look at what I was fixing in v1 ... :-) > > I suggest we add a local unsigned long here and close the deal, when > {g,m,p}fn_{inc,dec} macros are available we'll get rid of it. +1 -G