From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793826546; b=djK0oacPgerkkKJUbm1U68zuIJy/VrvcDmqiyURL637RljLeYjf/o3qczcbLe+JRLdGT rSZGZr4e7L/NzQNYyemiGTbsGHweczNRkqcGMdj5DJGbblveztV+75fI2/d8cpgu/QzJ2 iACEIQeNfwFT5dbSUvCbw3D+xiIhSjiP6DxO/VauNWgmy9cBYFoctAn9iPQ7Wi/3Y+Wq6 8gJ7sKCn8pf/Y8G/Ql7V53HuwrPqgiXJN6t2Q4dEocVg+x+5CC/L3v4M01QXsejTRniJK Uyd7cLbStfHXlisPLKhUWlNBkeoRRGp0MlxgtWtsAyM4zkKMyQyDsSwbALcG3rp6PRw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793826546; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=yDPvcxyyAFu2o0bBlGBxdTvgOqGA8W9gBnR8fryqjt4=; b=Yrs/i1GBKmiuGIkzMS8fLLVKIpBOu8jjaxykPmUQubvanvIfz50JKh+AvcREeA0942Xu /beXnxo0Ua+DELHibP2TU5k84+kTmrbf2Yr0iADbNKM64GraNWOP94dGqtx+HX4mcoDYY tiCXmHuaENv5UG4pJB9R3l+xJgAVDSP+Biotc0Stg4GRMvY0nOQ0KRi6dEUnSBS9sOSrN /WPEesjnC6r/y70tuUPVFdV7/c1NIG6FjkTgHtGT22yCk0XVgBIRqrXYaMR0rnN2/uBXJ QIQBCvgj89y237y2uYD6NhrqPbjWOY1AYjDoSu9sHEXcUwhbN+QKuJEY46uAQNR6qqQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Pr6A0HKM; arc=none smtp.remote-ip=209.85.216.49 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7715A60A16C9 for ; Wed, 4 Nov 2026 21:09:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7715A60A16C9 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=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Pr6A0HKM Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-3b09a83d12aso607381a91.2 for ; Wed, 04 Nov 2026 13:09:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1793826546; x=1794431346; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=yDPvcxyyAFu2o0bBlGBxdTvgOqGA8W9gBnR8fryqjt4=; b=Pr6A0HKMR+uacVoDnXqObCt7qtZxWvHFtdVrtZp/Hzd2nIVLH9iN4ZoAMZQJx452RL yb1CrGhUxcRSrysdnqKgt+cJcwB1t9GaqEu+plJDv9PLO/k9h6aaFGOb+XpuyMZCmbxz u9tVCymVpq3MZFEfnyb04nwaJd8pMf5vCSIKrzRCh5gl8LPnKig9qdtExSW+JGSavch6 SVwYcqt8THLnEU7mpwJPtPzxGwqCkdzVZwBlQx+sIWghElVmdyWN9sa/htWBxJuJAyLr AjI4n96YJJ0FeU6f/5rDHlght4AY5M7c0WHNXkEMeMTW2BYhGAtay3zKpI9aJdNvpjci 8njw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793826546; x=1794431346; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=yDPvcxyyAFu2o0bBlGBxdTvgOqGA8W9gBnR8fryqjt4=; b=pSaOx4aPVxJH26V6Q5BALC7I/ghoWbNhbZnBBfd5vAf+bcRkBDMNjTOFQbUhHWEbtl +GJpZVM94lHNKP98jAcjkep71FjS/glzBOIPCyZXA32ED1jN8c+ZNoKBd9x9mBzmXR+g r7H8LNL0F1ab/9jFvZ95slSu0xTebLY6ZiLMyiLSmhePVSBd3rTBW8MNLXYbIBCR5zJ4 52mO8qFy9P40dRa7tYi/9lOPPfHaBSAaEWV+ZvrGZTTgxC1Q5c1Jgq7oOoA7gue9wKeD yY/RcEm0qgIJw1irkId5L4feBl0Hzvxp2w9ZoG/xlWtwEMYRDE18GDhX/0kB7flX2oKI jatA== X-Forwarded-Encrypted: i=1; AKwUvBwG5mJRX5A151QAulsq5TAHfjE0zCVcYHptawf36FOokjwqu21bLTvni7hupfg7uwEgNW8Yf3r9Np1Ck8vqHCE=@vger.kernel.org X-Gm-Message-State: APuU4Z+71ZCZTHeLWEWsmrBnjLX3OtsPEEvQex9vF49+ERoY/SCfWeye /YwnYYD1P8qVkRabRdQJ0IQQhDC4zYIDhA2UztvRE6ZxkTT6GP3S5KhNgahwA8OvURS16S1Ouyd rUDj6uw== X-Gm-Gg: AYBFou1esdRUhqePBWWG+35Z38MKgs0tg4aeLNX8ZEvNBK2C/ywJb+D+Fqo6hhr1aaJ dJ0eXOAu528/DFXX632LQZbcDLKcFGB90P8azAWy3hEzbMDWGX2jGqD2HnTOz56UGrMol/1a233 FQ1difnhEjglVgDubJTUobcYMh/6tOkMsvtF8NvGfupGiBhOpK7U8fyoXEX935Da2hTB05ROXJ3 WFY76SLxmstZcii6AvxzLcewj9wBqZOmfMFvT48kKDAH0LtMb/WDsdrUqi18+WUJXD0XTdF4dRv eAOxRvEj6/+RZtmX4bNmUZ6M2BGEk2kNUbnSiz1USfsL9MwJDuLF7IVoFvIqFgFo+++ld6WslTv KdGagfFzcrnZLcW6xqKAf287LxK73lBt17qEs7rCtXTjkWSaz37NbWS0wMtSEsmU/BbtJ5d/1in p5sN2xGq/POUtljQu5ME421djCVmmCTsQsTEeuqCa/rVpHKQToPev88PeEXNzgd3P2xsnGOlyiF rc9ocmcQAjK54wv2m56tKok20294mDat1pyo6dHjPOxheUWVzD9MxuzmZyHgmnmBXhbSraRTehk YZD1p6AsJn9U9RvyWeSkh0jBb6XQpBFa3fzz0RxPXqIO7C3trLomJv16gwj2p9Fp X-Received: by 2002:a17:90b:4c81:b0:3ab:188b:c5bf with SMTP id 98e67ed59e1d1-3ae897c85e6mr14503462a91.18.1793826545271; Wed, 04 Nov 2026 13:09:05 -0800 (PST) Received: from google.com (33.79.127.34.bc.googleusercontent.com. [34.127.79.33]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b0b312e45dsm668723a91.3.2026.11.04.13.09.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2026 13:09:04 -0800 (PST) Date: Wed, 4 Nov 2026 21:09:01 +0000 From: David Matlack To: Sean Christopherson Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Alex Williamson , Paolo Bonzini , Shuah Khan Subject: Re: [PATCH v2 5/5] KVM: selftests: List the known IOMMU modes in irq_test's help output Message-ID: References: <20261103002205.3348519-1-dmatlack@google.com> <20261103002205.3348519-6-dmatlack@google.com> X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On 2026-11-04 06:53 AM, Sean Christopherson wrote: > On Tue, Nov 03, 2026, David Matlack wrote: > > @@ -159,7 +159,8 @@ static void help(const char *name) > > If you're going to do s/type/mode below, then the initial help lines should also > use iommu_mode. Will do. I'll also rename the iommu_type variable in main() to iommu_mode. > > - printf("-t Override the IOMMU type to use (vfio_type1_iommu or iommufd)\n"); > > + printf("-t Override the IOMMU mode to use instead of auto-detecting it (%s)\n", > > IMO, the "auto-detecting" blurb does more harm than good. It makes the code harder > to read, and for me at least it's just extra noise in understanding what the '-t' > option does. It also makes the line reaaaaaaally long. > > I know the parentheses are pre-existing, but that was somewhat ok when there were > only two options. With a big list, it's again noisy to reach the end and have to > think about that the closing ')' is terminating. Agreed that the auto-detect blurb and the parentheses are just noise. I went with a slight variation, see below. > This really should spit out only the available modes. For the internal assert, > it makes sense to print all modes since that's just doing a lookup, but it's > annoying to have to manually probe to see what's available. > > Juggling all vs. available is mildly tricky to avoid having to dynamically > allocate, but not that hard in the end. And IMO, it's totally ok to print a > misleading message if a mode becomes (un)available mid-test, especially since > this helper is unlikely to be used except in terminal situations. > > E.g. > > static const char *__iommu_mode_names(bool include_unavailable) > { > static char all_names[256]; > static char avl_names[sizeof(all_names)]; > char *names = include_unavailable ? all_names : avl_names; > int i, len = 0; > > if (names[0]) > return names; > > for (i = 0; i < ARRAY_SIZE(iommu_modes); i++) { > if (!include_unavailable && !iommu_mode_probe(&iommu_modes[i])) > continue; > > len += snprintf(names + len, sizeof(all_names) - len, "%s%s", > names[0] ? ", " : "", iommu_modes[i].name); > VFIO_ASSERT_LT(len, (int)sizeof(all_names)); > } > > if (!names[0]) > return NO_IOMMU_MODE_AVAILABLE_MSG; > > return names; > } > > const char *iommu_mode_names(void) > { > return __iommu_mode_names(false); > } How about listing both? That keeps -h consistent with how other KVM selftests list the options for their arguments (e.g. backing_src_help() lists every backing src type), while also showing which modes can actually be used. e.g. on a system with only the legacy VFIO container: # ./irq_test -h ... -t Override the IOMMU mode to use Options: iommufd, vfio_type1v2_iommu, vfio_type1_iommu, iommufd_compat_type1v2, iommufd_compat_type1 Available: vfio_type1v2_iommu, vfio_type1_iommu The available modes also get printed when the requested mode is not available, i.e. when the __TEST_REQUIRE() fails: # ./irq_test -d 0000:01:00.0 -t iommufd 1..0 # SKIP - IOMMU mode 'iommufd' is not available. Available modes: vfio_type1v2_iommu, vfio_type1_iommu. libvfio exposes iommu_mode_names_all() and iommu_mode_names_available() for this, built on your helper for juggling all vs. available. > Coupled with the above, how about this: > > VFIO_FAIL("Unrecognized IOMMU mode '%s'. Known modes: %s.\n", > iommu_mode, __iommu_mode_names(true)); Will do. Thanks!