All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien@xen.org>
To: Andrew Cooper <andrew.cooper3@citrix.com>,
	Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Jan Beulich" <JBeulich@suse.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>,
	"George Dunlap" <george.dunlap@citrix.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>
Subject: Re: [PATCH] xen: Fold exit paths in find_text_region()
Date: Thu, 13 Apr 2023 21:13:32 +0100	[thread overview]
Message-ID: <bd8f0ed2-586f-02f6-1f16-dc3b3b9c82a8@xen.org> (raw)
In-Reply-To: <20230413192201.3255984-1-andrew.cooper3@citrix.com>

Hi Andrew,

You may want to update your runes to find the maintainers as you are 
CCing the x86 folks but not the REST (the patch modifies common/ after all).

On 13/04/2023 20:22, Andrew Cooper wrote:
> Despite rcu_read_unlock() being fully inlineable, the optimiser cannot fold
> these exit paths, because of the various compiler barriers providing RCU
> safety.  Help the compiler out.

Please mention which compiler(s) (including version) you used.

> 
> This compiles to marginally better code in all cases.
So the code itself is fine with me. But this raises a few questions. If 
this is marginal, then why are you doing it? What's your end goal?

Lastly what do you mean by "all cases"? Is it all arch? All compilers?

Anyway, if this pattern is important (TBD why), then I think we should 
update the CODING_STYLE with some guidance. Otherwise, we may introduce 
similar patterns (we already have some).

> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Roger Pau Monné <roger.pau@citrix.com>
> CC: Wei Liu <wl@xen.org>
> ---
>   xen/common/virtual_region.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/xen/common/virtual_region.c b/xen/common/virtual_region.c
> index 30b0b4ab9c85..5ecdba9c08ed 100644
> --- a/xen/common/virtual_region.c
> +++ b/xen/common/virtual_region.c
> @@ -40,20 +40,20 @@ static DEFINE_RCU_READ_LOCK(rcu_virtual_region_lock);
>   
>   const struct virtual_region *find_text_region(unsigned long addr)
>   {
> -    const struct virtual_region *region;
> +    const struct virtual_region *iter, *region = NULL;
>   
>       rcu_read_lock(&rcu_virtual_region_lock);
> -    list_for_each_entry_rcu( region, &virtual_region_list, list )
> +    list_for_each_entry_rcu ( iter, &virtual_region_list, list )
>       {
> -        if ( (void *)addr >= region->start && (void *)addr < region->end )
> +        if ( (void *)addr >= iter->start && (void *)addr < iter->end )
>           {
> -            rcu_read_unlock(&rcu_virtual_region_lock);
> -            return region;
> +            region = iter;
> +            break;
>           }
>       }
>       rcu_read_unlock(&rcu_virtual_region_lock);
>   
> -    return NULL;
> +    return region;
>   }
>   
>   void register_virtual_region(struct virtual_region *r)

Cheers,

-- 
Julien Grall


  reply	other threads:[~2023-04-13 20:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-13 19:22 [PATCH] xen: Fold exit paths in find_text_region() Andrew Cooper
2023-04-13 20:13 ` Julien Grall [this message]
2023-04-13 22:09   ` Andrew Cooper
2023-04-13 23:01     ` Stefano Stabellini
2023-04-17  9:00 ` Jan Beulich

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=bd8f0ed2-586f-02f6-1f16-dc3b3b9c82a8@xen.org \
    --to=julien@xen.org \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.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 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.