From: Julien Grall <julien.grall@arm.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: xen-devel@lists.xenproject.org, lars.kurth@citrix.com,
george.dunlap@citrix.com, Andrii Anisov <andrii.anisov@gmail.com>
Subject: Re: [PATCH 4/8] xen/arm: Add support for read-only foreign mappings
Date: Thu, 15 Nov 2018 20:20:28 +0000 [thread overview]
Message-ID: <6d853e3b-1a5e-abc8-9b8a-3c40b080b0b4@arm.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1811151143500.22115@sstabellini-ThinkPad-X260>
Hi,
On 11/15/18 7:48 PM, Stefano Stabellini wrote:
> On Thu, 15 Nov 2018, Julien Grall wrote:
>> Hi Stefano,
>>
>> On 11/15/18 6:44 PM, Stefano Stabellini wrote:
>>> On Thu, 15 Nov 2018, Julien Grall wrote:
>>>> Hi,
>>>>
>>>> On 11/15/18 1:19 PM, Andrii Anisov wrote:
>>>>>> So I would prefer to stick with _t which is quite common within the
>>>>>> p2m
>>>>>> code base so far.
>>>>>
>>>>> I've found a similar code only in one place - p2m_get_entry()
>>>>> function. And it is, at least, somehow commented there:
>>>>> ...
>>>>> /* Allow t to be NULL */
>>>>> t = t ?: &_t;
>>>>>
>>>>> *t = p2m_invalid;
>>>>> ...
>>>>
>>>> And in x86 code...
>>>>
>>>>>
>>>>> But IMO, it is really confusing to write a code to calculate and store
>>>>> a value which clearly is not needed by a caller.
>>>>
>>>> I disagree, you directly know that t can be NULL. Although, I agree that a
>>>> comment would help to understand.
>>>>
>>>>> From another hand, I'm not sure if a compiler would be intelligent
>>>>> enough to factor out the odd code from execution pass on the incoming
>>>>> null pointer.
>>>>
>>>> You can't assume the compiler will inline even with the inline keyword.
>>>>
>>>>>
>>>>> I'm sorry, but I can't pass my RB for `_t`.
>>>>
>>>> I think this request is unreasonable because this is a matter of taste.
>>>>
>>>> While this is a nice feature to have in Xen 4.12 and address a long
>>>> standing
>>>> open issue on Arm. I don't require it and I am not inclined to address
>>>> bikeshedding.
>>>>
>>>> So I will keep aside for now until someone cares about it.
>>>
>>> Let's try to be reasonable and have constructive conversations. If we do
>>> have to disagree, let's disagree on meaningful design decisions, not
>>> silly code style issues :-)
>>>
>>> Andrii, when something can be done equally well in two different ways,
>>> especially when it is a matter of style, I think it is best to express
>>> our preference, but not to force a contributor in a particular
>>> direction, unless specifically stated in CODING_STYLE or equivalent
>>> docs. We don't have written rules about code reviews, but if we had,
>>> I think this should be one of them. (I would love to have written rulesAs
>>> about code reviews.)
>>>
>>> Julien, usually in situations like this, it is quicker to change the
>>> code than to argue. I personally don't care and wouldn't ask you to
>>> change it, but if a member of the community reads the code and has an
>>> adverse reaction, it is always worth reconsidering the approach, because
>>> others might find it antagonizing too. Given the choice, it is best to
>>> go for something obvious to most, so if a new contributor sends a patch
>>> to change, it is more likely to be correct from the start.
>>
>> I agree with your point here but this is also valid in the other way. If the
>> suggested alternative provokes an adverse reaction to the contributor, then
>> why should he use it?
>>
>> As I wrote earlier one trying to use ternary condition split over 2 lines is
>> not making the code more obvious. So I am not entirely sure why I should be
>> forced to write such code?
>
> I don't think you should be. You can find another way. For instance, the
> whole thing could be reduce to one more "if" condition:
>
> if ( t != NULL )
> {
> *t = p2m_invalid;
> if ( page->u.inuse.type_info & PGT_writable_page )
> *t = p2m_ram_rw;
> else
> *t = p2m_ram_ro;
> }
>
> be creative :-)
Well the code suggested is different from what I intended :). t should
be set to invalid before the check mfn_valid/get_page. So this needs at
least 2 checks. 2 places were t != NULL needs to be explained.
As you said this is a matter of taste. If someone disagree on the coding
style, then he should suggest an alternative way fitting the requirement.
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-11-15 20:20 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-06 19:14 [PATCH 0/8] xen/arm: Add xentrace support Julien Grall
2018-11-06 19:14 ` [PATCH 1/8] xen/page_alloc: Move get_pg_owner()/put_pg_owner() from x86 to common code Julien Grall
2018-11-07 9:28 ` Jan Beulich
2018-11-09 18:06 ` Julien Grall
2018-11-06 19:14 ` [PATCH 2/8] xen/arm: p2m: Introduce p2m_get_page_from_gfn Julien Grall
2018-11-15 13:31 ` Andrii Anisov
2018-11-15 13:35 ` Andrii Anisov
2018-11-15 15:22 ` Julien Grall
2018-12-20 11:20 ` Andrii Anisov
2018-11-06 19:14 ` [PATCH 3/8] xen/arm: Rename p2m_map_foreign to p2m_map_foreign_rw Julien Grall
2018-11-15 11:42 ` Andrii Anisov
2018-11-15 12:07 ` Julien Grall
2018-11-06 19:14 ` [PATCH 4/8] xen/arm: Add support for read-only foreign mappings Julien Grall
2018-11-15 11:33 ` Andrii Anisov
2018-11-15 11:40 ` Julien Grall
2018-11-15 12:02 ` Andrii Anisov
2018-11-15 12:09 ` Julien Grall
2018-11-15 13:19 ` Andrii Anisov
2018-11-15 15:05 ` Julien Grall
2018-11-15 18:44 ` Stefano Stabellini
2018-11-15 19:06 ` Julien Grall
2018-11-15 19:48 ` Stefano Stabellini
2018-11-15 20:20 ` Julien Grall [this message]
2018-11-16 9:05 ` Andrii Anisov
2018-11-16 8:37 ` Andrii Anisov
2018-11-20 15:27 ` Andrii Anisov
2018-12-20 11:21 ` Andrii Anisov
2018-11-06 19:14 ` [PATCH 5/8] xen/arm: Allow a privileged domain to map foreign page from DOMID_XEN Julien Grall
2018-11-15 13:45 ` Andrii Anisov
2018-11-06 19:14 ` [PATCH 6/8] xen/arm: Initialize trace buffer Julien Grall
2018-11-15 13:49 ` Andrii Anisov
2018-11-06 19:14 ` [PATCH 7/8] xenalyze: Build for Both ARM and x86 Platforms Julien Grall
2018-11-07 13:04 ` Wei Liu
2018-11-06 19:14 ` [PATCH 8/8] xen: Swich parameter in get_page_from_gfn to use typesafe gfn Julien Grall
2018-11-06 20:11 ` Andrew Cooper
2018-11-07 8:57 ` Paul Durrant
2018-11-07 13:08 ` Andrew Cooper
2018-11-07 13:08 ` Julien Grall
2018-11-07 9:24 ` Paul Durrant
2018-11-07 13:05 ` Julien Grall
2018-11-12 16:49 ` Andrii Anisov
2018-11-12 16:52 ` Julien Grall
2018-11-12 16:58 ` Andrii Anisov
2018-11-12 17:09 ` Julien Grall
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=6d853e3b-1a5e-abc8-9b8a-3c40b080b0b4@arm.com \
--to=julien.grall@arm.com \
--cc=andrii.anisov@gmail.com \
--cc=george.dunlap@citrix.com \
--cc=lars.kurth@citrix.com \
--cc=sstabellini@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).