From: Sean Christopherson <seanjc@google.com>
To: Gavin Shan <gshan@redhat.com>
Cc: Robert Hoo <robert.hu@linux.intel.com>,
pbonzini@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:05:41 +0000 [thread overview]
Message-ID: <Y2RzdQVvZnS7wcMr@google.com> (raw)
In-Reply-To: <b7ae920f-dae0-b3f3-aba3-944cb73c19c2@redhat.com>
On Thu, Nov 03, 2022, Gavin Shan wrote:
> On 11/3/22 8:46 AM, Sean Christopherson wrote:
> > On Wed, Nov 02, 2022, Robert Hoo wrote:
> > > @@ -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.
> >
> > 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.
> >
> > Anyways, assuming there's no underlying problem that can be solved, the easier
> > solution is to just bump the delay in the migration thread. As per its gigantic
> > comment, the original bug reproduced with up to 500us delays, so bumping the min
> > delay to e.g. 5us is acceptable. If that doesn't guarantee the vCPU meets its
> > quota, then something else is definitely going on.
> >
>
> I doubt if it's still caused by busy system as mentioned previously [1]. At least,
> I failed to reproduce the issue on my ARM64 system until some workloads are enforced
> to hog CPUs.
Yeah, I suspect something else as well. My best guest at this point is mitigations,
I'll test that tomorrow to see if it makes any difference.
> Looking at the implementation syscall(NR_getcpu), it's simply to copy
> the per-cpu data from kernel to userspace. So I don't see it should consume lots
> of time. As system call is handled by interrupt/exception, the time consumed by
> the interrupt/exception handler should be architecture dependent. Besides, the time
> needed by ioctl(KVM_RUN) also differs on architectures.
Yes, but Robert is seeing problems on x86-64 that I have been unable to reproduce,
i.e. this isn't an architectural difference problem.
> [1] https://lore.kernel.org/kvm/d8290cbe-5d87-137a-0633-0ff5c69d57b0@redhat.com/
>
> I think Sean's suggestion to bump the delay to 5us would be the quick fix if it helps.
> However, more time will be needed to complete the test. Sean, do you mind to reduce
> NR_TASK_MIGRATIONS from 100000 to 20000 either?
I don't think the number of migrations needs to be cut by 5x, the +5us bump only
changes the average from ~5us (to ~7.5us).
But before we start mucking with the delay, I want to at least understand _why_
a lower bound of 1us is insufficient.
next prev parent reply other threads:[~2022-11-04 2:05 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 [this message]
2022-11-04 20:27 ` Sean Christopherson
2022-11-03 2:59 ` Robert Hoo
2022-11-04 2:07 ` Sean Christopherson
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=Y2RzdQVvZnS7wcMr@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 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.