From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F4B814D29A for ; Thu, 25 Apr 2024 16:26:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714062362; cv=none; b=TXwcjVJKNNkAV1gbb0cZTocBYferVGtYLK0kdK03Sg5S9icqiE9BXVxHsZ06jyX3R4QqMRdcjqoL/MMXFEfXZerO9Vr3agvQ+a6tZyu86OrYviBg25G9dfZoC4gWr2bkGhstuiBTiYAe/zZdi+e1XgvrV1mv9VtOH2/X+RCt4gk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714062362; c=relaxed/simple; bh=Wrp02xIa5F+jofcD0a3nI2LJ5ugmaidOo1ZiG5tjSKQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=YzJt+WNDeml/thZrmELP5MwAPkjRbXBeM+rdce2pvvIZeonQrVlXxX/JlZtVOKV/D/jyIG96ohmaGkfxwrFQ8dAH5fzytlrE0rJegyud5cWnjD78OfD8g/bRhCt04USTy36bNBLwvpBWOeNA0qC+QadAhhi23oNX7sAxlrCk9WM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=j934Hiki; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="j934Hiki" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-ddaf2f115f2so1955767276.3 for ; Thu, 25 Apr 2024 09:26:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1714062360; x=1714667160; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=EDuopDjXfunZvdvHof7XCisSrwKL98dOKzOYyljZ3x4=; b=j934HikiskWI9FzAuCV0l4fRFCKeEc8A44gBigsUOWIZBXl8drAZZ1jdnQhLX6GWMH xI74oB1ConEdZp33R79AlkXf56kqVFZS7oJozQklwFosSMqMYLtiMJIQdWouxmHks4QN LP2xf9pT/uD8ug6pg15BH9+RWQ2O9xI28VNHCetLqM1/MzsqORAuuoznA/T3HgJ3sITs fHg9t6dOuiVfmzDiYvrhfKL0z1hoIBkghUkFY5SHX6Yp801eRvNxRNfls6Kusqjk7x62 64qb7p8dTLInqSJrNncX2cGGudC6TGv3i5zkQjMLnBMhV0ENCr12sI5eotAIZVfoKZL2 7IeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714062360; x=1714667160; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=EDuopDjXfunZvdvHof7XCisSrwKL98dOKzOYyljZ3x4=; b=ecGo8GZxk6GW72zS2MAf7/iVZQi+P2347hfCFUIdBEtTI4r2fDLvjJ6F1RzHEtb8b7 FkYBMuTgPSXv1JKveWhAAi29UfUO2NdWwyj9I40CsXHSUh/MMgYOUVqGDOZGxRTtkev3 IV7GmgJpMChu08a9b1noH9L+4S6YOzSUsmLiNqN/Yo4Y6MYSfbRWwKX8aQxqoMrdTxQe nuiN0g6bGrtNpy6jsL/26Tc2Spf+zx+pEyak2FCbYKvcUKmv7DnjHk4L/4EINeY3lleC C8yzPOOe/VBSV31N2va9DeQuDJOiV9dJeHWDEXU8LTaJfLtdOAoopqd3NYuNG0Grmeof Vv4g== X-Forwarded-Encrypted: i=1; AJvYcCX4woDPu4pIyW2pEadOzulA89WSUthKchgsVHQxMKwU3ki9nU+WY2IqJ0KtWkX61sdguFx5LCbAgUBVFfm348u2wRZz X-Gm-Message-State: AOJu0YxVNMj/+Qu6eMaGwaaUOrfFIFmW+jwVs3nSgzEEa8V5YAANUCaf XrYnH7xpxMyHfPQw0+/U3svht7Iy9nPStA2LN7RsVz1JVcGHR1Y0QtBsDeejtfNK9xgGf/KQSQN 9sQ== X-Google-Smtp-Source: AGHT+IEedOG1ITFc/zgbrJigM9ClcijuGO4cXZcDhUXtjDilAJ+Dx8WyZUgqdGJWoCWT3uPPGbY93RgXIEE= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:8052:0:b0:de1:d49:7ff6 with SMTP id a18-20020a258052000000b00de10d497ff6mr4364ybn.7.1714062360352; Thu, 25 Apr 2024 09:26:00 -0700 (PDT) Date: Thu, 25 Apr 2024 09:25:58 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240423073952.2001989-1-chentao@kylinos.cn> <878bf83c-cd5b-48d0-8b4e-77223f1806dc@web.de> <20240423-0db9024011213dcffe815c5c@orel> <20240424-e31c64bda7872b0be52e4c16@orel> Message-ID: Subject: Re: [PATCH] KVM: selftests: Add 'malloc' failure check in test_vmx_nested_state From: Sean Christopherson To: Oliver Upton Cc: Andrew Jones , Markus Elfring , Kunwu Chan , linux-kselftest@vger.kernel.org, kvm@vger.kernel.org, kernel-janitors@vger.kernel.org, Muhammad Usama Anjum , Paolo Bonzini , Shuah Khan , LKML , Kunwu Chan , Anup Patel , Thomas Huth Content-Type: text/plain; charset="us-ascii" 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.