From: Sean Christopherson <seanjc@google.com>
To: Oliver Upton <oliver.upton@linux.dev>
Cc: Andrew Jones <ajones@ventanamicro.com>,
Markus Elfring <Markus.Elfring@web.de>,
Kunwu Chan <chentao@kylinos.cn>,
linux-kselftest@vger.kernel.org, kvm@vger.kernel.org,
kernel-janitors@vger.kernel.org,
Muhammad Usama Anjum <usama.anjum@collabora.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Shuah Khan <shuah@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Kunwu Chan <kunwu.chan@hotmail.com>,
Anup Patel <anup@brainfault.org>, Thomas Huth <thuth@redhat.com>
Subject: Re: [PATCH] KVM: selftests: Add 'malloc' failure check in test_vmx_nested_state
Date: Thu, 25 Apr 2024 09:25:58 -0700 [thread overview]
Message-ID: <ZiqEFqomGLmDR7dg@google.com> (raw)
In-Reply-To: <Zik_Aat5JJtWk0AM@linux.dev>
On Wed, Apr 24, 2024, Oliver Upton wrote:
> Hey,
>
> On Wed, Apr 24, 2024 at 07:51:44AM -0700, Sean Christopherson wrote:
> > On Wed, Apr 24, 2024, Andrew Jones wrote:
> > > On Tue, Apr 23, 2024 at 12:15:47PM -0700, Sean Christopherson wrote:
> > > ...
> > > > I almost wonder if we should just pick a prefix that's less obviously connected
> > > > to KVM and/or selftests, but unique and short.
> > > >
> > >
> > > How about kvmsft_ ? It's based on the ksft_ prefix of kselftest.h. Maybe
> > > it's too close to ksft though and would be confusing when using both in
> > > the same test?
> >
> > I would prefer something short, and for whatever reason I have a mental block
> > with ksft. I always read it as "k soft", which is completely nonsensical :-)
>
> I despise brevity in tests, so my strong preference is to use some form
> of 'namespaced' helper. Perhaps others have better memory than
> I do, but I'm quick to forget the selftests library and find the more
> verbose / obvious function names helpful for jogging my memory.
Hmm, I generally agree, but in this case I think there's value in having the
names *not* stand out, because they really are uninteresting and would ideally
blend in. I can't envision a scenario where we don't want to assert on an OOM,
i.e. there should never be a need to use a raw malloc(), and so I don't see much
value in making it obvious that the call sites are doing something special.
> > > I'm not a huge fan of capital letters, but we could also do something like
> > > MALLOC()/CALLOC().
> >
> > Hmm, I'm not usually a fan either, but that could actually work quite well in this
> > case. It would be quite intuitive, easy to visually parse whereas tmalloc() vs
> > malloc() kinda looks like a typo, and would more clearly communicate that they're
> > macros.
>
> Ooo, don't leave me out on the bikeshedding! How about TEST_MALLOC() /
> TEST_CALLOC(). It is vaguely similar to TEST_ASSERT(), which I'd hope
> would give the impression that an assertion is lurking below.
Yeah, but it could also give the false impression that the macro does something
fancier, e.g. this makes me want to peek at TEST_MALLOC() to see what it's doing
cpuid = TEST_MALLOC(kvm_cpuid2_size(nr_entries));
whereas this isn't quite enough to pique my curiosity.
cpuid = MALLOC(kvm_cpuid2_size(nr_entries));
So I have a slight preference for just MALLOC()/CALLOC(), but I'm also ok with a
TEST_ prefix, my brain can adapt. One of those two flavors has my vote.
next prev parent reply other threads:[~2024-04-25 16:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-23 7:39 [PATCH] KVM: selftests: Add 'malloc' failure check in test_vmx_nested_state Kunwu Chan
2024-04-23 8:49 ` Muhammad Usama Anjum
2024-04-23 10:45 ` Markus Elfring
2024-04-23 14:56 ` Sean Christopherson
2024-04-23 15:14 ` Andrew Jones
2024-04-23 19:15 ` Sean Christopherson
2024-04-24 2:59 ` Kunwu Chan
2024-04-24 5:41 ` Dan Carpenter
2024-04-24 14:47 ` Sean Christopherson
2024-04-24 7:50 ` Andrew Jones
2024-04-24 14:51 ` Sean Christopherson
2024-04-24 17:18 ` Oliver Upton
2024-04-25 16:25 ` Sean Christopherson [this message]
2024-05-10 8:40 ` Kunwu Chan
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=ZiqEFqomGLmDR7dg@google.com \
--to=seanjc@google.com \
--cc=Markus.Elfring@web.de \
--cc=ajones@ventanamicro.com \
--cc=anup@brainfault.org \
--cc=chentao@kylinos.cn \
--cc=kernel-janitors@vger.kernel.org \
--cc=kunwu.chan@hotmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=oliver.upton@linux.dev \
--cc=pbonzini@redhat.com \
--cc=shuah@kernel.org \
--cc=thuth@redhat.com \
--cc=usama.anjum@collabora.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