All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tamas K Lengyel <tamas@tklengyel.com>
To: George Dunlap <george.dunlap@citrix.com>
Cc: "wei.liu2@citrix.com" <wei.liu2@citrix.com>,
	"rcojocaru@bitdefender.com" <rcojocaru@bitdefender.com>,
	"george.dunlap@eu.citrix.com" <george.dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	"jbeulich@suse.com" <jbeulich@suse.com>,
	Alexandru Stefan ISAILA <aisaila@bitdefender.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	"roger.pau@citrix.com" <roger.pau@citrix.com>
Subject: Re: [PATCH v5] x86/altp2m: Aggregate get entry and populate into common funcs
Date: Tue, 16 Apr 2019 08:25:52 -0600	[thread overview]
Message-ID: <CABfawhniLgxxid8Kw7mhmoN9m4zSxdHd10CK+HvvtTDQyFdBVQ@mail.gmail.com> (raw)
In-Reply-To: <92ff12b3-259f-d0d2-8ec7-e1554f5e4190@citrix.com>

On Tue, Apr 16, 2019 at 7:58 AM George Dunlap <george.dunlap@citrix.com> wrote:
>
> On 4/16/19 2:51 PM, Andrew Cooper wrote:
> > On 16/04/2019 14:44, Tamas K Lengyel wrote:
> >>
> >>> diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
> >>> index 2801a8ccca..8dc4353645 100644
> >>> --- a/xen/include/asm-x86/p2m.h
> >>> +++ b/xen/include/asm-x86/p2m.h
> >>> @@ -514,6 +514,23 @@ static inline unsigned long mfn_to_gfn(struct domain *d, mfn_t mfn)
> >>>          return mfn_x(mfn);
> >>>  }
> >>>
> >>> +int altp2m_get_entry(struct p2m_domain *ap2m, gfn_t gfn, mfn_t *mfn,
> >>> +                     p2m_type_t *t, p2m_access_t *a, bool prepopulate);
> >>> +
> >>> +static inline int altp2m_get_entry_direct(struct p2m_domain *ap2m,
> >>> +                                          gfn_t gfn, mfn_t *mfn,
> >>> +                                          p2m_type_t *t, p2m_access_t *a)
> >>> +{
> >>> +    return altp2m_get_entry(ap2m, gfn, mfn, t, a, false);
> >>> +}
> >>> +
> >>> +static inline int altp2m_get_entry_prepopulate(struct p2m_domain *ap2m,
> >>> +                                               gfn_t gfn, mfn_t *mfn,
> >>> +                                               p2m_type_t *t, p2m_access_t *a)
> >>> +{
> >>> +    return altp2m_get_entry(ap2m, gfn, mfn, t, a, true);
> >>> +}
> >> Are these wrappers really required? I don't think they add anything to
> >> readability, it's just yet another layer that does almost nothing.
> >
> > From a readability point of view, boolean parameters are about as opaque
> > as they come.  The same goes for all other scalar parameters which don't
> > have a mnemonic.
> >
> > For someone who is not an expert of the intricacies of the subsystem,
> > having the options spelt out in wrappers like this is extremely helpful
> > to reduce the cognitive load of trying to follow the code.
>
> This is exactly why I did it this way.
>
> The other pattern I think is tolerable is having a #define to use as an
> argument; for example:
>
> #define AP2MGET_prepopulate true
> #define AP2MGET_peek        false
>
> Then you get:
>
>   mfn = altp2m_get_entry(..., AP2MGET_prepopulate);
>
> But then you run into namespacing issues with the prefixes.
>
> I wouldn't object to doing it the above way, but I think the wrappers is
> probably simpler and clearer for this case.  I do object to passing in
> naked booleans.

Fair enough. I personally prefer the #define route though, it just
avoids creating lasagna code. With wrappers by the time I dig through
them trying to figure out where they actually land I tend to forget
why I was looking for it in the first place. Perhaps that's just me..

Tamas

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

WARNING: multiple messages have this Message-ID (diff)
From: Tamas K Lengyel <tamas@tklengyel.com>
To: George Dunlap <george.dunlap@citrix.com>
Cc: "wei.liu2@citrix.com" <wei.liu2@citrix.com>,
	"rcojocaru@bitdefender.com" <rcojocaru@bitdefender.com>,
	"george.dunlap@eu.citrix.com" <george.dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	"jbeulich@suse.com" <jbeulich@suse.com>,
	Alexandru Stefan ISAILA <aisaila@bitdefender.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	"roger.pau@citrix.com" <roger.pau@citrix.com>
Subject: Re: [Xen-devel] [PATCH v5] x86/altp2m: Aggregate get entry and populate into common funcs
Date: Tue, 16 Apr 2019 08:25:52 -0600	[thread overview]
Message-ID: <CABfawhniLgxxid8Kw7mhmoN9m4zSxdHd10CK+HvvtTDQyFdBVQ@mail.gmail.com> (raw)
Message-ID: <20190416142552.XWJivmSy8L00i5OmWPja-kYa_Bmw7TClyIL9lhylpTk@z> (raw)
In-Reply-To: <92ff12b3-259f-d0d2-8ec7-e1554f5e4190@citrix.com>

On Tue, Apr 16, 2019 at 7:58 AM George Dunlap <george.dunlap@citrix.com> wrote:
>
> On 4/16/19 2:51 PM, Andrew Cooper wrote:
> > On 16/04/2019 14:44, Tamas K Lengyel wrote:
> >>
> >>> diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
> >>> index 2801a8ccca..8dc4353645 100644
> >>> --- a/xen/include/asm-x86/p2m.h
> >>> +++ b/xen/include/asm-x86/p2m.h
> >>> @@ -514,6 +514,23 @@ static inline unsigned long mfn_to_gfn(struct domain *d, mfn_t mfn)
> >>>          return mfn_x(mfn);
> >>>  }
> >>>
> >>> +int altp2m_get_entry(struct p2m_domain *ap2m, gfn_t gfn, mfn_t *mfn,
> >>> +                     p2m_type_t *t, p2m_access_t *a, bool prepopulate);
> >>> +
> >>> +static inline int altp2m_get_entry_direct(struct p2m_domain *ap2m,
> >>> +                                          gfn_t gfn, mfn_t *mfn,
> >>> +                                          p2m_type_t *t, p2m_access_t *a)
> >>> +{
> >>> +    return altp2m_get_entry(ap2m, gfn, mfn, t, a, false);
> >>> +}
> >>> +
> >>> +static inline int altp2m_get_entry_prepopulate(struct p2m_domain *ap2m,
> >>> +                                               gfn_t gfn, mfn_t *mfn,
> >>> +                                               p2m_type_t *t, p2m_access_t *a)
> >>> +{
> >>> +    return altp2m_get_entry(ap2m, gfn, mfn, t, a, true);
> >>> +}
> >> Are these wrappers really required? I don't think they add anything to
> >> readability, it's just yet another layer that does almost nothing.
> >
> > From a readability point of view, boolean parameters are about as opaque
> > as they come.  The same goes for all other scalar parameters which don't
> > have a mnemonic.
> >
> > For someone who is not an expert of the intricacies of the subsystem,
> > having the options spelt out in wrappers like this is extremely helpful
> > to reduce the cognitive load of trying to follow the code.
>
> This is exactly why I did it this way.
>
> The other pattern I think is tolerable is having a #define to use as an
> argument; for example:
>
> #define AP2MGET_prepopulate true
> #define AP2MGET_peek        false
>
> Then you get:
>
>   mfn = altp2m_get_entry(..., AP2MGET_prepopulate);
>
> But then you run into namespacing issues with the prefixes.
>
> I wouldn't object to doing it the above way, but I think the wrappers is
> probably simpler and clearer for this case.  I do object to passing in
> naked booleans.

Fair enough. I personally prefer the #define route though, it just
avoids creating lasagna code. With wrappers by the time I dig through
them trying to figure out where they actually land I tend to forget
why I was looking for it in the first place. Perhaps that's just me..

Tamas

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2019-04-16 14:26 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-16  8:45 [PATCH v5] x86/altp2m: Aggregate get entry and populate into common funcs Alexandru Stefan ISAILA
2019-04-16  8:45 ` [Xen-devel] " Alexandru Stefan ISAILA
2019-04-16 13:44 ` Tamas K Lengyel
2019-04-16 13:44   ` [Xen-devel] " Tamas K Lengyel
2019-04-16 13:51   ` Andrew Cooper
2019-04-16 13:51     ` [Xen-devel] " Andrew Cooper
2019-04-16 13:58     ` George Dunlap
2019-04-16 13:58       ` [Xen-devel] " George Dunlap
2019-04-16 14:25       ` Tamas K Lengyel [this message]
2019-04-16 14:25         ` Tamas K Lengyel
2019-04-16 14:01   ` George Dunlap
2019-04-16 14:01     ` [Xen-devel] " George Dunlap
2019-04-16 14:19     ` Tamas K Lengyel
2019-04-16 14:19       ` [Xen-devel] " Tamas K Lengyel
2019-04-16 15:07       ` George Dunlap
2019-04-16 15:07         ` [Xen-devel] " George Dunlap
2019-04-17  7:15         ` Alexandru Stefan ISAILA
2019-04-17  7:15           ` [Xen-devel] " Alexandru Stefan ISAILA
2019-04-17 18:22           ` Tamas K Lengyel
2019-04-17 18:22             ` [Xen-devel] " Tamas K Lengyel
2019-04-18  9:53             ` George Dunlap
2019-04-18  9:53               ` [Xen-devel] " George Dunlap
2019-04-18 13:59               ` Tamas K Lengyel
2019-04-18 13:59                 ` [Xen-devel] " Tamas K Lengyel
2019-04-18 17:02                 ` George Dunlap
2019-04-18 17:02                   ` [Xen-devel] " George Dunlap
2019-04-18 18:42                   ` Tamas K Lengyel
2019-04-18 18:42                     ` [Xen-devel] " Tamas K Lengyel
2019-04-19  8:32                     ` Alexandru Stefan ISAILA
2019-04-19  8:32                       ` [Xen-devel] " Alexandru Stefan ISAILA
2019-04-23 10:49                       ` Alexandru Stefan ISAILA
2019-04-23 10:49                         ` [Xen-devel] " Alexandru Stefan ISAILA
2019-04-23 11:44                       ` George Dunlap
2019-04-23 11:44                         ` [Xen-devel] " George Dunlap
2019-04-23 13:26                         ` Tamas K Lengyel
2019-04-23 13:26                           ` [Xen-devel] " Tamas K Lengyel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CABfawhniLgxxid8Kw7mhmoN9m4zSxdHd10CK+HvvtTDQyFdBVQ@mail.gmail.com \
    --to=tamas@tklengyel.com \
    --cc=aisaila@bitdefender.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=rcojocaru@bitdefender.com \
    --cc=roger.pau@citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.