From: Sean Christopherson <seanjc@google.com>
To: Vipin Sharma <vipinsh@google.com>
Cc: pbonzini@redhat.com, dmatlack@google.com, andrew.jones@linux.dev,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 4/4] KVM: selftests: Run dirty_log_perf_test on specific CPUs
Date: Thu, 6 Oct 2022 20:26:57 +0000 [thread overview]
Message-ID: <Yz86ETKxsCGb7s+u@google.com> (raw)
In-Reply-To: <Yz8xdJEMjcfdrcWC@google.com>
On Thu, Oct 06, 2022, Sean Christopherson wrote:
> On Thu, Oct 06, 2022, Vipin Sharma wrote:
> > +{
> > + cpu_set_t cpuset;
> > + int err;
> > +
> > + CPU_ZERO(&cpuset);
> > + CPU_SET(pcpu, &cpuset);
>
> To save user pain:
>
> r = sched_getaffinity(0, sizeof(allowed_mask), &allowed_mask);
> TEST_ASSERT(!r, "sched_getaffinity failed, errno = %d (%s)", errno,
> strerror(errno));
Forgot TEST_ASSERT() already provides errno, this can just be:
TEST_ASSERT(!r, "sched_getaffinity() failed");
>
> TEST_ASSERT(CPU_ISSET(pcpu, &allowed_mask),
> "Task '%d' not allowed to run on pCPU '%d'\n");
>
> CPU_ZERO(&allowed_mask);
> CPU_SET(cpu, &allowed_mask);
>
> that way the user will get an explicit error message if they try to pin a vCPU/task
> that has already been affined by something else. And then, in theory,
> sched_setaffinity() should never fail.
>
> Or you could have two cpu_set_t objects and use CPU_AND(), but that seems
> unnecessarily complex.
>
> > + err = sched_setaffinity(0, sizeof(cpu_set_t), &cpuset);
> > + TEST_ASSERT(err == 0, "sched_setaffinity() errored out for pcpu: %d\n", pcpu);
>
> !err is the preferred style, though I vote to use "r" instead of "err". And print
> the errno so that the user can debug.
As above, ignore the last, forgot TEST_ASSERT() provides errno.
>
> r = sched_setaffinity(0, sizeof(allowed_mask), &allowed_mask);
> TEST_ASSERT(!r, "sched_setaffinity failed, errno = %d (%s)",
> errno, strerror(errno));
next prev parent reply other threads:[~2022-10-06 20:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-06 17:11 [PATCH v4 0/4] dirty_log_perf_test CPU pinning Vipin Sharma
2022-10-06 17:11 ` [PATCH v4 1/4] KVM: selftests: Add missing break between 'e' and 'g' option in dirty_log_perf_test Vipin Sharma
2022-10-06 17:11 ` [PATCH v4 2/4] KVM: selftests: Put command line options in alphabetical order " Vipin Sharma
2022-10-06 17:11 ` [PATCH v4 3/4] KVM: selftests: Add atoi_paranoid() to catch errors missed by atoi() Vipin Sharma
2022-10-06 19:58 ` Sean Christopherson
2022-10-06 22:39 ` Vipin Sharma
2022-10-06 23:54 ` Sean Christopherson
2022-10-06 17:11 ` [PATCH v4 4/4] KVM: selftests: Run dirty_log_perf_test on specific CPUs Vipin Sharma
2022-10-06 19:50 ` Sean Christopherson
2022-10-06 20:26 ` Sean Christopherson [this message]
2022-10-06 23:25 ` Vipin Sharma
2022-10-07 0:14 ` Sean Christopherson
2022-10-07 17:39 ` Vipin Sharma
2022-10-08 0:46 ` Vipin Sharma
2022-10-10 16:22 ` 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=Yz86ETKxsCGb7s+u@google.com \
--to=seanjc@google.com \
--cc=andrew.jones@linux.dev \
--cc=dmatlack@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=vipinsh@google.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