From: Will Deacon <will@kernel.org>
To: Juergen Gross <jgross@suse.com>
Cc: Murali Nalajala <quic_mnalajal@quicinc.com>,
Elliot Berman <quic_eberman@quicinc.com>,
Catalin Marinas <catalin.marinas@arm.com>,
x86@kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org,
virtualization@lists.linux-foundation.org,
Alexey Makhalov <amakhalov@vmware.com>,
Prakruthi Deepak Heragu <quic_pheragu@quicinc.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2] arm64: paravirt: Use RCU read locks to guard stolen_time
Date: Wed, 4 May 2022 14:50:51 +0100 [thread overview]
Message-ID: <20220504135050.GA20470@willie-the-truck> (raw)
In-Reply-To: <c6689e42-e87c-0c0b-c7ff-40134406e080@suse.com>
On Wed, May 04, 2022 at 03:38:47PM +0200, Juergen Gross wrote:
> On 04.05.22 11:45, Will Deacon wrote:
> > On Thu, Apr 28, 2022 at 11:35:36AM -0700, Elliot Berman wrote:
> > > diff --git a/arch/arm64/kernel/paravirt.c b/arch/arm64/kernel/paravirt.c
> > > index 75fed4460407..e724ea3d86f0 100644
> > > --- a/arch/arm64/kernel/paravirt.c
> > > +++ b/arch/arm64/kernel/paravirt.c
> > > @@ -52,7 +52,9 @@ early_param("no-steal-acc", parse_no_stealacc);
> > > /* return stolen time in ns by asking the hypervisor */
> > > static u64 para_steal_clock(int cpu)
> > > {
> > > + struct pvclock_vcpu_stolen_time *kaddr = NULL;
> > > struct pv_time_stolen_time_region *reg;
> > > + u64 ret = 0;
> > > reg = per_cpu_ptr(&stolen_time_region, cpu);
> > > @@ -61,28 +63,38 @@ static u64 para_steal_clock(int cpu)
> > > * online notification callback runs. Until the callback
> > > * has run we just return zero.
> > > */
> > > - if (!reg->kaddr)
> > > + rcu_read_lock();
> > > + kaddr = rcu_dereference(reg->kaddr);
> > > + if (!kaddr) {
> > > + rcu_read_unlock();
> > > return 0;
> > > + }
> > > - return le64_to_cpu(READ_ONCE(reg->kaddr->stolen_time));
> > > + ret = le64_to_cpu(READ_ONCE(kaddr->stolen_time));
> >
> > Is this READ_ONCE() still required now?
>
> Yes, as it might be called for another cpu than the current one.
> stolen_time might just be updated, so you want to avoid load tearing.
Ah yes, thanks. The lifetime of the structure is one thing, but the
stolen time field is updated much more regularly than the kaddr pointer.
So:
Acked-by: Will Deacon <will@kernel.org>
Cheers,
Will
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next prev parent reply other threads:[~2022-05-04 13:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220428183536.2866667-1-quic_eberman@quicinc.com>
2022-05-04 9:45 ` [PATCH v2] arm64: paravirt: Use RCU read locks to guard stolen_time Will Deacon
2022-05-04 13:38 ` Juergen Gross via Virtualization
2022-05-04 13:50 ` Will Deacon [this message]
2022-05-04 13:40 ` Juergen Gross via Virtualization
2022-05-05 10:49 ` Will Deacon
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=20220504135050.GA20470@willie-the-truck \
--to=will@kernel.org \
--cc=amakhalov@vmware.com \
--cc=catalin.marinas@arm.com \
--cc=jgross@suse.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_eberman@quicinc.com \
--cc=quic_mnalajal@quicinc.com \
--cc=quic_pheragu@quicinc.com \
--cc=stable@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
--cc=x86@kernel.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