Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp359400lqo; Fri, 10 May 2024 01:59:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXppjXL+XnESdzPf9624JkgmPCDxbBNq2VBmZw80gd/ZEkr9vjhpZSDAtKtwb7HxUV71nrZ3a8d6BQwwIu0wSKNo8W6U5btKhA5rxjtXQ== X-Google-Smtp-Source: AGHT+IEgeh7FDGoNZyUYjGEJ2yqclIIh23/CJNxDMOIqJhMSTnw3HOoOJFEp8gsx6c1wPvQ6yWfx X-Received: by 2002:a17:903:234f:b0:1e2:6165:8086 with SMTP id d9443c01a7336-1ef441a68f2mr24396435ad.61.1715331568816; Fri, 10 May 2024 01:59:28 -0700 (PDT) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0c267cabsi32640965ad.569.2024.05.10.01.59.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 01:59:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175455-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@hotmail.com header.s=selector1 header.b=DLL4VGX0; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-175455-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175455-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hotmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7F9DF285CC8 for ; Fri, 10 May 2024 08:41:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 048CA161319; Fri, 10 May 2024 08:40:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=hotmail.com header.i=@hotmail.com header.b="DLL4VGX0" Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11olkn2080.outbound.protection.outlook.com [40.92.19.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F34EA15F322; Fri, 10 May 2024 08:40:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.19.80 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715330443; cv=fail; b=Gz3/rz2pb3PBJbnQPc+6RWuHXbWcK/62M8flIBc6qxoeLAfektljYITgvlMXmX7tf9O6lV5Ht/kfqWXFTrmYYMsDBfsef0+anX+LNSqE2UTAoPuNbKPu/T3SPI4qJv+qm7zjAb/+SQmOmKdqwW99DekmReESZoFls6F2mRzl+gM= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715330443; c=relaxed/simple; bh=GNGk/GfuFG78DxLRXoXKIe9xrnlyICBPCFXJ06m10WQ=; h=Message-ID:Date:Subject:To:Cc:References:From:In-Reply-To: Content-Type:MIME-Version; b=bD3mnRPQcvFSEJqLFKNO+v4NsHy+KnGKr5pPZ2mOCU0cxpElYYN45nBw+bAdMD13gNIZ6wgOuX26qsFX2jNE+yvuqWshd1CahPxA4SQVFioB7RRGBeKiez+1zds2Og94BZYIVbIutR3CsPMUDHBLxoSlNzhHf1fH2oB4I6Og8w0= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hotmail.com; spf=pass smtp.mailfrom=hotmail.com; dkim=pass (2048-bit key) header.d=hotmail.com header.i=@hotmail.com header.b=DLL4VGX0; arc=fail smtp.client-ip=40.92.19.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hotmail.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D6goZZHiag1gH4odHoC9LU26qu+nXqjmhg8usAs1gNHEegqvTavxZ2fcXhwu4ppL7YHDanoHe32kiSfcYN0NFDobr5e9yqjsCLeAtmCGe/a6UOWnzjXxpl5TFTvUwpQE9Sc+GuTKup2mq16yY6FG7mzo9pvs3aNIZXlTF9zQW98EmctIlLQoIgkM5qoU/+3SJpCcDOg2CCA4o2uHPWTAI8dFh/pzn3rqb3Py6kBT85CJefA3GZQ5GoP+8xLdBHIQ6Cufi48XbtkV9UwSE6sx9fDmodQ+foE5egfmRPXhOlymOjPQ2EbXlgOQBQtK9Ec6OsmyU1+j7bXJV9P8j9yQAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LJamwaEH7nd2OCAr9ujkttRmD+eEpB5DydR4Ywn+qPQ=; b=RG9pIufZWPBfssBEhVclPFJ9vn5LfXbS5cx+W52JxBSRXSzWPmNZQbOZGDEqmcow54UtwqZp65FV4GIoCOI4OQAXADBp6CDqz6oAHn/IPY4wKneawcxcYY7T+lHFaolWR5TqqjngN83N4lonnnJF/wVt6peATZGiauyqSC9NFiRAfVyAxgQiCHAQ0Oa9b9dhm//r0YBBgpxMrAsKOfh880wz3Ua7nrjb6ZjjIxcZYKC76czupTFTKw7+L+RWcY3oFyJJH8puY5+Pv50db2ykr5R6qxtTIRegF5UCkMkY2pQmoP9A1O5YoLuUsw5SBrms0fmSVZ8Kk4cUc/E58pKw5A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LJamwaEH7nd2OCAr9ujkttRmD+eEpB5DydR4Ywn+qPQ=; b=DLL4VGX0oT4wqebxMeJjwPqDkeRAvQxg7OCO9OWM8ShC6OnpaW7yDt3ibgmvJx513948Sg0XyPUZDCseUPwuwT5Ntf+gtAUC7TSHHSbY7aryUrSz4wdB526s0AilvrlDNhsVZGUmJZsv+ri3aKTYzyBRiNKVPANFwpHLVo419QmTUdVln59AbVXb48qoVugMDO18d6sEhIdjHUchZnvEulbrl5etYh9+O5IGfMoJK5ajut5BuiE3Yp44sWJEbWFqChM9NmRvD87LI4cy9Dj4aeFVYQSO9UQS88s2eSLQJmeQ9avt9DRmlTycIZqypxJ0abrgD9YwUzGnA6Kfj9vhsQ== Received: from CY8PR11MB7779.namprd11.prod.outlook.com (2603:10b6:930:77::22) by LV8PR11MB8606.namprd11.prod.outlook.com (2603:10b6:408:1f7::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.49; Fri, 10 May 2024 08:40:39 +0000 Received: from CY8PR11MB7779.namprd11.prod.outlook.com ([fe80::9aa5:422d:f716:1402]) by CY8PR11MB7779.namprd11.prod.outlook.com ([fe80::9aa5:422d:f716:1402%4]) with mapi id 15.20.7544.048; Fri, 10 May 2024 08:40:38 +0000 Message-ID: Date: Fri, 10 May 2024 16:40:30 +0800 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] KVM: selftests: Add 'malloc' failure check in test_vmx_nested_state Content-Language: en-US To: Sean Christopherson , 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 , Anup Patel , Thomas Huth References: <20240423073952.2001989-1-chentao@kylinos.cn> <878bf83c-cd5b-48d0-8b4e-77223f1806dc@web.de> <20240423-0db9024011213dcffe815c5c@orel> <20240424-e31c64bda7872b0be52e4c16@orel> From: Kunwu Chan In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TMN: [HoJQAhhZY1jHxCy6948iISefv/aRSyMANkZIURfhIkg=] X-ClientProxiedBy: SI2PR02CA0022.apcprd02.prod.outlook.com (2603:1096:4:195::23) To CY8PR11MB7779.namprd11.prod.outlook.com (2603:10b6:930:77::22) X-Microsoft-Original-Message-ID: <54505156-c27f-44a3-8420-ec1e5e6e687a@hotmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR11MB7779:EE_|LV8PR11MB8606:EE_ X-MS-Office365-Filtering-Correlation-Id: 92cbe149-3663-40b7-edb1-08dc70ccde11 X-Microsoft-Antispam: BCL:0;ARA:14566002|461199019|56899024|440099019|3412199016; X-Microsoft-Antispam-Message-Info: y41/ccBnYJ6AOy6vMqVzHl43hlrfwjFIqJZqE17gNBrTYK12b9y0jEjPd8LikJBa++p1G8Cx54XhEyMfgm6C6G8iovv9e+lmEZlEHzrSZo9V7dBDj5Vi9eyEDlb2gzzrGMKoL111bN2CWoXbb/ZfJOXJD3uwi+otoGL1EiMnv6V7VEtczkgSsOLcdqKcQiXado+6rZ8LSjKwOqhwzPPD0wOhLXtiMAT8b3dKaNyNKfu3ZazwjxzdX8MOLg3WsaksZvMN0aNnnRkTD3R8M7qwQLiqloP4GoJKF1T+zL6+0sEevHHJSSkoRs1z888Z2cyN+SxpXvJM/SHfIsWxuaE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IRmlZSnY0bWNXa3lBaDd5dEZmVVkw?= =?utf-8?B?VDdOd1UrY0ZYZkF2UTdqejRqNlhuL0k3UGJwaHRJR2VTK0JsaityNS9xcFJu?= =?utf-8?B?MUd2T0hzNU1Sb3ZTblhsK0k0RjBST0ZLZHpYZ0pYTVpiTG9RakVkdFQwK1RE?= =?utf-8?Q?2/hi3fodrsWGkwoAknTu?= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-e8f36.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 92cbe149-3663-40b7-edb1-08dc70ccde11 X-MS-Exchange-CrossTenant-AuthSource: CY8PR11MB7779.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2024 08:40:38.3479 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR11MB8606 Thanks for reply. On 2024/4/26 00:25, Sean Christopherson wrote: > 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. According to the previous discussion, so which method do we need to use now? If you have a consensus, if necessary, I can continue to do this work. We had many different way in selftests to check the null pointer or fail state, such as 'ksft_exit_fail_*' 'ASSERT_*' 'CHECK*' or just use if statement. If we add a new macro, whether these old usage should be changed as well.