From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.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 DC08230149C for ; Wed, 26 Nov 2025 23:17:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764199065; cv=none; b=mfuz6sdv7SI5dwzm3xBz5tJNqHvBQBGEGPtEwP/nSAqnn9ftqu2BgGgtaSGb83BmxT+9nOxbpNlHGJdLX6Lz8x4Whlv4HrtTJ8dfSKNAMHQ0Lq09OHrLkq88AbWQuNw+WPkLy6AV/i505mVctQ0T4DZUSZFnxeZWEJ8cKMCrpr0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764199065; c=relaxed/simple; bh=fAal4CbC565T8AukEvsx1Y6yN5vA0dvGqZqu9gFQxDs=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=dDJbYO+KuY9Xb+nB9NouRa9Eu6kEAEJyok7IO9pg8YYt5tWEqP3LISJjDcbSVkHjft1ImAEBC34UuiaUfoOg8nYMrUsgidcEU/20ZwxrUNJ/YaST71VcIsOIPvLLA2ajI45jIU+zs1AMANdlDTJ46BNyNoor0xKAWZWC5KY4Ll4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=I1+ajg7g; arc=none smtp.client-ip=209.85.214.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--dmatlack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="I1+ajg7g" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-295952a4dd6so14825385ad.1 for ; Wed, 26 Nov 2025 15:17:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764199062; x=1764803862; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=rewarsz5lHkyJG1w0S/5e9AJ4dOqmqfJKq6P5FJmAK8=; b=I1+ajg7gLu0C1JXsCc+MEYUEfw+D96YOi9fi0syPMTkydsI9LQP7SHJ9eFIau40I9k 8Bx1rkfUydkydIor6toNBmDY5nhnvsb9ctRQXMifl5dD+OFIoyZxNWVX3IcEOwvQ3+Wp rvbqDJanoIuEMu1vkeJW9PeLGR8KrpiPjZ/egOrb9EUQMwCkndiSqxMoI1XzHdJqee8/ UaWqhVy13UBZsIfRTFcqzKsEKmGvHmbCU/GYNujBsQJM35PX/SpP7fB9A4Sx3c+CIKk1 a7fHTCqv3KMDlYjMbCrLqVtfCOnT0AJJ6j2uV0T8n+bmQLi1eN/X2RFOUhm5WF08p1pf IwAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764199062; x=1764803862; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=rewarsz5lHkyJG1w0S/5e9AJ4dOqmqfJKq6P5FJmAK8=; b=Ni79F/GN0n8FgE8BqMZXEYNp7VeIJHSW1+GZ814TrFbccNSeyIipz7DBUAaPZQ6HQX w6b2mgKAVkEA8MkN6OylLoUJlyPHGwFH0qVir7ozoTWW7KB6fc1sliaa0eEIFJ4f3r43 MZsNyACIbAjmWECqA9nHpQ9p2XUEg7BdxOWtD+g+LAlfhZKTgb+S9XSdnV8FBzQEUDzq 7zMeBQ2D9zlCYlPUqIwPNOWO27Jz35HFDAuFKmGLAldYp60bqixGID7up6ZPYb0LbXXV 4W+OyCAxYPFeJxrRG0dEa0XVo68yM7pzOAU14OLwh68qEeMbJh3n1hu2k7gGm6oDVIcO USoQ== X-Forwarded-Encrypted: i=1; AJvYcCX+a1JpuWVE56G/1TmNgWeqEzHPIQ0xaRyeYbM+NtcBD78L0rak1Z3JbzIZohFr132kGw2RVBfrD/s9BcI=@vger.kernel.org X-Gm-Message-State: AOJu0Yw7zWZFZhhhsjG+DV2soOQ2KAIodQrW26KpiRajaBNigrQmY+VR 3iYXr/vMisl7qharFNfpbegFH0jMjQZlheYA0RAYqGkJCgZJ5JzpIjWTJaeGUkz3myhEvt7KPZP a4k2lrABxA3yF9w== X-Google-Smtp-Source: AGHT+IGl4ix+WUhNbfT6GuNED+PoTbz7h6VtC9pC+cMM5HkCe/+8ngbNnsgCrJsl2QHM7TWeuuvo+gqpPhueqw== X-Received: from pjvl19.prod.google.com ([2002:a17:90a:dd93:b0:340:b503:505f]) (user=dmatlack job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:4f8a:b0:343:78ed:8d19 with SMTP id 98e67ed59e1d1-3472985089cmr27137255a91.7.1764199062081; Wed, 26 Nov 2025 15:17:42 -0800 (PST) Date: Wed, 26 Nov 2025 23:17:15 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.52.0.487.g5c8c507ade-goog Message-ID: <20251126231733.3302983-1-dmatlack@google.com> Subject: [PATCH v4 00/18] vfio: selftests: Support for multi-device tests From: David Matlack To: Alex Williamson Cc: Alex Mastro , David Matlack , Jason Gunthorpe , Josh Hilke , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Raghavendra Rao Ananta , Vipin Sharma Content-Type: text/plain; charset="UTF-8" This series adds support for tests that use multiple devices, and adds one new test, vfio_pci_device_init_perf_test, which measures parallel device initialization time to demonstrate the improvement from commit e908f58b6beb ("vfio/pci: Separate SR-IOV VF dev_set"). This series also breaks apart the monolithic vfio_util.h and vfio_pci_device.c into separate files, to account for all the new code. This required quite a bit of code motion so the diffstat looks large. The final layout is more granular and provides a better separation of the IOMMU code from the device code. Final layout: C files: - tools/testing/selftests/vfio/lib/libvfio.c - tools/testing/selftests/vfio/lib/iommu.c - tools/testing/selftests/vfio/lib/iova_allocator.c - tools/testing/selftests/vfio/lib/vfio_pci_device.c - tools/testing/selftests/vfio/lib/vfio_pci_driver.c H files: - tools/testing/selftests/vfio/lib/include/libvfio.h - tools/testing/selftests/vfio/lib/include/libvfio/assert.h - tools/testing/selftests/vfio/lib/include/libvfio/iommu.h - tools/testing/selftests/vfio/lib/include/libvfio/iova_allocator.h - tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_device.h - tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_driver.h Notably, vfio_util.h is now gone and replaced with libvfio.h. This series is based on vfio/next plus Alex Mastro's series to add the IOVA allocator [1]. It should apply cleanly to vfio/next once Alex's series makes its way to vfio/next via Linus' tree. This series can be found on GitHub: https://github.com/dmatlack/linux/tree/vfio/selftests/init_perf_test/v4 [1] https://lore.kernel.org/kvm/20251111-iova-ranges-v3-0-7960244642c5@fb.com/ Cc: Alex Mastro Cc: Jason Gunthorpe Cc: Josh Hilke Cc: Raghavendra Rao Ananta Cc: Vipin Sharma v4: - Collect Reviewed-bys from Raghavendra - Check iommu is not null in vfio_pci_device_init() (Raghavendra) - Do not include any fixes for the kernel-test-robot errors on riscv. These issues also exist when building the VFIO selftests without this series using kernel-test-robot's cross compiler. The issue appears to be that the cross compiler used by ktr does not have libc, which the selftests depend on. v3: https://lore.kernel.org/kvm/20251121181429.1421717-1-dmatlack@google.com/ - Replace literal with NSEC_PER_SEC (Alex Mastro) - Fix Makefile accumulate vs. assignment (Alex Mastro) v2: https://lore.kernel.org/kvm/20251112192232.442761-1-dmatlack@google.com/ - Require tests to call iommu_init() and manage struct iommu objects rather than implicitly doing it in vfio_pci_device_init(). - Drop all the device wrappers for IOMMU methods and require tests to interact with the iommu_*() helper functions directly. - Add a commit to eliminate INVALID_IOVA. This is a simple cleanup I've been meaning to make. - Upgrade some driver logging to error (Raghavendra) - Remove plurality from helper function that fetches BDF from environment variable (Raghavendra) - Fix cleanup.sh to only delete the device directory when cleaning up all devices (Raghavendra) v1: https://lore.kernel.org/kvm/20251008232531.1152035-1-dmatlack@google.com/ David Matlack (18): vfio: selftests: Move run.sh into scripts directory vfio: selftests: Split run.sh into separate scripts vfio: selftests: Allow passing multiple BDFs on the command line vfio: selftests: Rename struct vfio_iommu_mode to iommu_mode vfio: selftests: Introduce struct iommu vfio: selftests: Support multiple devices in the same container/iommufd vfio: selftests: Eliminate overly chatty logging vfio: selftests: Prefix logs with device BDF where relevant vfio: selftests: Upgrade driver logging to dev_err() vfio: selftests: Rename struct vfio_dma_region to dma_region vfio: selftests: Move IOMMU library code into iommu.c vfio: selftests: Move IOVA allocator into iova_allocator.c vfio: selftests: Stop passing device for IOMMU operations vfio: selftests: Rename vfio_util.h to libvfio.h vfio: selftests: Move vfio_selftests_*() helpers into libvfio.c vfio: selftests: Split libvfio.h into separate header files vfio: selftests: Eliminate INVALID_IOVA vfio: selftests: Add vfio_pci_device_init_perf_test tools/testing/selftests/vfio/Makefile | 10 +- .../selftests/vfio/lib/drivers/dsa/dsa.c | 36 +- .../selftests/vfio/lib/drivers/ioat/ioat.c | 18 +- .../selftests/vfio/lib/include/libvfio.h | 26 + .../vfio/lib/include/libvfio/assert.h | 54 ++ .../vfio/lib/include/libvfio/iommu.h | 76 +++ .../vfio/lib/include/libvfio/iova_allocator.h | 23 + .../lib/include/libvfio/vfio_pci_device.h | 125 ++++ .../lib/include/libvfio/vfio_pci_driver.h | 97 +++ .../selftests/vfio/lib/include/vfio_util.h | 331 ----------- tools/testing/selftests/vfio/lib/iommu.c | 465 +++++++++++++++ .../selftests/vfio/lib/iova_allocator.c | 94 +++ tools/testing/selftests/vfio/lib/libvfio.c | 78 +++ tools/testing/selftests/vfio/lib/libvfio.mk | 5 +- .../selftests/vfio/lib/vfio_pci_device.c | 556 +----------------- .../selftests/vfio/lib/vfio_pci_driver.c | 16 +- tools/testing/selftests/vfio/run.sh | 109 ---- .../testing/selftests/vfio/scripts/cleanup.sh | 41 ++ tools/testing/selftests/vfio/scripts/lib.sh | 42 ++ tools/testing/selftests/vfio/scripts/run.sh | 16 + tools/testing/selftests/vfio/scripts/setup.sh | 48 ++ .../selftests/vfio/vfio_dma_mapping_test.c | 46 +- .../selftests/vfio/vfio_iommufd_setup_test.c | 2 +- .../vfio/vfio_pci_device_init_perf_test.c | 168 ++++++ .../selftests/vfio/vfio_pci_device_test.c | 12 +- .../selftests/vfio/vfio_pci_driver_test.c | 51 +- 26 files changed, 1482 insertions(+), 1063 deletions(-) create mode 100644 tools/testing/selftests/vfio/lib/include/libvfio.h create mode 100644 tools/testing/selftests/vfio/lib/include/libvfio/assert.h create mode 100644 tools/testing/selftests/vfio/lib/include/libvfio/iommu.h create mode 100644 tools/testing/selftests/vfio/lib/include/libvfio/iova_allocator.h create mode 100644 tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_device.h create mode 100644 tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_driver.h delete mode 100644 tools/testing/selftests/vfio/lib/include/vfio_util.h create mode 100644 tools/testing/selftests/vfio/lib/iommu.c create mode 100644 tools/testing/selftests/vfio/lib/iova_allocator.c create mode 100644 tools/testing/selftests/vfio/lib/libvfio.c delete mode 100755 tools/testing/selftests/vfio/run.sh create mode 100755 tools/testing/selftests/vfio/scripts/cleanup.sh create mode 100755 tools/testing/selftests/vfio/scripts/lib.sh create mode 100755 tools/testing/selftests/vfio/scripts/run.sh create mode 100755 tools/testing/selftests/vfio/scripts/setup.sh create mode 100644 tools/testing/selftests/vfio/vfio_pci_device_init_perf_test.c base-commit: fa804aa4ac1b091ef2ec2981f08a1c28aaeba8e7 prerequisite-patch-id: dcf23dcc1198960bda3102eefaa21df60b2e4c54 prerequisite-patch-id: e32e56d5bf7b6c7dd40d737aa3521560407e00f5 prerequisite-patch-id: 4f79a41bf10a4c025ba5f433551b46035aa15878 prerequisite-patch-id: f903a45f0c32319138cd93a007646ab89132b18c -- 2.52.0.487.g5c8c507ade-goog