From: Sean Christopherson <seanjc@google.com>
To: Robert Hoo <robert.hu@linux.intel.com>
Cc: pbonzini@redhat.com, gshan@redhat.com, kvm@vger.kernel.org
Subject: Re: [RFC 1/1] KVM: selftests: rseq_test: use vdso_getcpu() instead of syscall()
Date: Fri, 4 Nov 2022 02:07:08 +0000 [thread overview]
Message-ID: <Y2RzzDUD8r17k+1i@google.com> (raw)
In-Reply-To: <b1279d088165d195ee22ce02ec869f9ae33248d8.camel@linux.intel.com>
On Thu, Nov 03, 2022, Robert Hoo wrote:
> On Thu, 2022-11-03 at 00:46 +0000, Sean Christopherson wrote:
> > On Wed, Nov 02, 2022, Robert Hoo wrote:
> > > vDSO getcpu() has been in Kernel since 2.6.19, which we can assume
> > > generally available.
> > > Use vDSO getcpu() to reduce the overhead, so that vcpu thread
> > > stalls less
> > > therefore can have more odds to hit the race condition.
> > >
> > > Fixes: 0fcc102923de ("KVM: selftests: Use getcpu() instead of
> > > sched_getcpu() in rseq_test")
> > > Signed-off-by: Robert Hoo <robert.hu@linux.intel.com>
> > > ---
> >
> > ...
> >
> > > @@ -253,7 +269,7 @@ int main(int argc, char *argv[])
> > > * across the seq_cnt reads.
> > > */
> > > smp_rmb();
> > > - sys_getcpu(&cpu);
> > > + vdso_getcpu(&cpu, NULL, NULL);
> > > rseq_cpu = rseq_current_cpu_raw();
> > > smp_rmb();
> > > } while (snapshot != atomic_read(&seq_cnt));
> >
> > Something seems off here. Half of the iterations in the migration
> > thread have a
> > delay of 5+us, which should be more than enough time to complete a
> > few getcpu()
> > syscalls to stabilize the CPU.
> >
> The migration thread delay time is for the whole vcpu thread loop, not
> just vcpu_run(), I think.
Yes, but if switching to vdso_getcpu() makes the issues go away, that suggests
that the task migration is causing the tight do-while loop to get stuck.
> for (i = 0; !done; i++) {
> vcpu_run(vcpu);
> TEST_ASSERT(get_ucall(vcpu, NULL) == UCALL_SYNC,
> "Guest failed?");
> ...
> do {
> ...
> vdso_getcpu(&cpu, NULL, NULL);
> rseq_cpu = rseq_current_cpu_raw();
> ...
> } while (snapshot != atomic_read(&seq_cnt));
>
> ...
> }
>
> > Has anyone tried to figure out why the vCPU thread is apparently running
> > slow? E.g. is KVM_RUN itself taking a long time, is the task not getting
> > scheduled in, etc... I can see how using vDSO would make the vCPU more
> > efficient, but I'm curious as to why that's a problem in the first place.
>
> Yes, it should be the first-place problem.
> But firstly, it's the whole for(){} loop taking more time than before,
Do you have actual performance numbers? If so, can you share them?
prev parent reply other threads:[~2022-11-04 2:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-02 2:01 [RFC 0/1] KVM: selftests: rseq_test: use vdso_getcpu() instead of syscall() Robert Hoo
2022-11-02 2:01 ` [RFC 1/1] " Robert Hoo
2022-11-02 4:24 ` Gavin Shan
2022-11-02 12:46 ` Robert Hoo
2022-11-03 0:46 ` Sean Christopherson
2022-11-03 1:16 ` Gavin Shan
2022-11-04 2:05 ` Sean Christopherson
2022-11-04 20:27 ` Sean Christopherson
2022-11-03 2:59 ` Robert Hoo
2022-11-04 2:07 ` Sean Christopherson [this message]
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=Y2RzzDUD8r17k+1i@google.com \
--to=seanjc@google.com \
--cc=gshan@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=robert.hu@linux.intel.com \
/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