RE: [PATCH v6 04/10] iommufd/device: Wrap IOMMUFD_OBJ_HWPT_PAGING-only configurations

2023-10-24 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Tuesday, October 24, 2023 11:06 PM > + > +static int iommufd_group_do_replace_paging(struct iommufd_group > *igroup, > +struct iommufd_hw_pagetable > *hwpt) > +{ > + struct iommufd_hw_pagetable *old_hwpt = igroup->hwpt; > +

Re: [PATCH bpf-next] selftests/bpf: Convert CHECK macros to ASSERT_* macros in bpf_iter

2023-10-24 Thread Yonghong Song
On 10/24/23 3:43 PM, Yuran Pereira wrote: As it was pointed out by Yonghong Song [1], in the bpf selftests the use of the ASSERT_* series of macros is preferred over the CHECK macro. This patch replaces all CHECK calls in bpf_iter with the appropriate ASSERT_* macros. [1] https://lore.kernel.o

Re: [PATCH bpf-next] selftests/bpf: Add malloc failure checks in bpf_iter

2023-10-24 Thread Yonghong Song
On 10/24/23 7:28 PM, Kui-Feng Lee wrote: Thank you for the patches. I found you have two patches in this set. You can generate both patch at once with git format-patch. format-patch will give each patch a number in their order. For example, the subject of this message will be   [PATCH bpf-nex

Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-24 Thread Yi Liu
On 2023/10/25 02:19, Nicolin Chen wrote: On Tue, Oct 24, 2023 at 03:00:49PM -0300, Jason Gunthorpe wrote: On Tue, Oct 24, 2023 at 10:50:58AM -0700, Nicolin Chen wrote: The point is for the user_data to always be available, the driver needs to check it if it is passed. This should all be plumb

Re: [PATCH v4 2/5] zswap: make shrinking memcg-aware

2023-10-24 Thread Yosry Ahmed
On Tue, Oct 24, 2023 at 1:33 PM Nhat Pham wrote: > > From: Domenico Cerasuolo > > Currently, we only have a single global LRU for zswap. This makes it > impossible to perform worload-specific shrinking - an memcg cannot > determine which pages in the pool it owns, and often ends up writing > page

Re: [PATCH bpf-next] selftests/bpf: Add malloc failure checks in bpf_iter

2023-10-24 Thread Kui-Feng Lee
Thank you for the patches. I found you have two patches in this set. You can generate both patch at once with git format-patch. format-patch will give each patch a number in their order. For example, the subject of this message will be [PATCH bpf-next 2/2] selftest/bpf: Add malloc And, y

[PATCH bpf-next] selftests/bpf: Add malloc failure checks in bpf_iter

2023-10-24 Thread Yuran Pereira
Since some malloc calls in bpf_iter may at times fail, this patch adds the appropriate fail checks, and ensures that any previously allocated resource is appropriately destroyed before returning the function. This is patch 2 in the sequence should be applied after d1a88d37cecc "selftests/bpf: Conv

Re: [PATCH] iommu/vt-d: Enhance capability check for nested parent domain allocation

2023-10-24 Thread Baolu Lu
On 10/24/23 11:00 PM, Yi Liu wrote: This adds the scalable mode check before allocating the nested parent domain as checking nested capability is not enough. User may turn off scalable mode which also means no nested support even if the hardware supports it. Fixes: c97d1b20d383 ("iommu/vt-d: Add

Re: [PATCH] selftests/net: give more time to udpgro nat tests

2023-10-24 Thread Jakub Kicinski
On Mon, 23 Oct 2023 15:50:33 -0400 Lucas Karpinski wrote: > This is the same issue and the same fix as posted by Adrien Therry. > Link: https://lore.kernel.org/all/20221101184809.50013-1-athie...@redhat.com/ Let's not let the hacks spread. We suggested two options in the linked thread. Another on

Re: [PATCH v7 7/8] iommu/vt-d: Add nested domain allocation

2023-10-24 Thread Jason Gunthorpe
On Tue, Oct 24, 2023 at 08:14:11AM -0700, Yi Liu wrote: > From: Lu Baolu > > This adds the support for IOMMU_HWPT_DATA_VTD_S1 type. And 'nested_parent' > is added to mark the nested parent domain to sanitize the input parent domain. > > Signed-off-by: Lu Baolu > Signed-off-by: Yi Liu > --- >

[PATCH bpf-next] selftests/bpf: Convert CHECK macros to ASSERT_* macros in bpf_iter

2023-10-24 Thread Yuran Pereira
As it was pointed out by Yonghong Song [1], in the bpf selftests the use of the ASSERT_* series of macros is preferred over the CHECK macro. This patch replaces all CHECK calls in bpf_iter with the appropriate ASSERT_* macros. [1] https://lore.kernel.org/lkml/0a142924-633c-44e6-9a92-2dc019656...@l

[RFC PATCH 2/2] kselftest: devices: Add board file for google,spherion

2023-10-24 Thread Nícolas F . R . A . Prado
Add the list of devices expected to be probed from the USB and PCI busses on the google,spherion machine. The USB host controller at 1120 is shared between two busses, for USB2 and USB3, so an additional match is used to select the USB2 bus. Signed-off-by: Nícolas F. R. A. Prado --- tools/t

[RFC PATCH 1/2] kselftest: Add test to verify probe of devices from discoverable busses

2023-10-24 Thread Nícolas F . R . A . Prado
Add a new test to verify that all expected devices from discoverable busses (ie USB, PCI) on a given Devicetree-based platform have been successfully instantiated and probed by a driver. The per-platform list of expected devices is selected based on compatible and stored under the boards/ director

[RFC PATCH 0/2] Add test to verify probe of devices from discoverable busses on DT platforms

2023-10-24 Thread Nícolas F . R . A . Prado
This is part of an effort to improve detection of regressions impacting device probe on all platforms. The recently merged DT kselftest [1] detects probe issues for all devices described statically in the DT. That leaves out devices discovered at run-time from discoverable busses. This is where

Re: [PATCH v2] selftests:net change ifconfig with ip command

2023-10-24 Thread patchwork-bot+netdevbpf
Hello: This patch was applied to netdev/net-next.git (main) by Jakub Kicinski : On Mon, 23 Oct 2023 18:04:22 +0530 you wrote: > Change ifconfig with ip command, > on a system where ifconfig is > not used this script will not > work correcly. > > Test result with this patchset: > > [...] Here i

[PATCH v4 5/5] zswap: shrinks zswap pool based on memory pressure

2023-10-24 Thread Nhat Pham
Currently, we only shrink the zswap pool when the user-defined limit is hit. This means that if we set the limit too high, cold data that are unlikely to be used again will reside in the pool, wasting precious memory. It is hard to predict how much zswap space will be needed ahead of time, as this

[PATCH v4 2/5] zswap: make shrinking memcg-aware

2023-10-24 Thread Nhat Pham
From: Domenico Cerasuolo Currently, we only have a single global LRU for zswap. This makes it impossible to perform worload-specific shrinking - an memcg cannot determine which pages in the pool it owns, and often ends up writing pages from other memcgs. This issue has been previously observed in

[PATCH v4 4/5] selftests: cgroup: update per-memcg zswap writeback selftest

2023-10-24 Thread Nhat Pham
From: Domenico Cerasuolo The memcg-zswap self test is updated to adjust to the behavior change implemented by commit 87730b165089 ("zswap: make shrinking memcg-aware"), where zswap performs writeback for specific memcg. Signed-off-by: Domenico Cerasuolo Signed-off-by: Nhat Pham --- tools/test

[PATCH v4 3/5] mm: memcg: add per-memcg zswap writeback stat

2023-10-24 Thread Nhat Pham
From: Domenico Cerasuolo Since zswap now writes back pages from memcg-specific LRUs, we now need a new stat to show writebacks count for each memcg. Suggested-by: Nhat Pham Signed-off-by: Domenico Cerasuolo Signed-off-by: Nhat Pham --- include/linux/vm_event_item.h | 1 + mm/memcontrol.c

[PATCH v4 1/5] list_lru: allows explicit memcg and NUMA node selection

2023-10-24 Thread Nhat Pham
The interface of list_lru is based on the assumption that the list node and the data it represents belong to the same allocated on the correct node/memcg. While this assumption is valid for existing slab objects LRU such as dentries and inodes, it is undocumented, and rather inflexible for certain

[PATCH v4 0/5] workload-specific and memory pressure-driven zswap writeback

2023-10-24 Thread Nhat Pham
Changelog: v4: * Rename list_lru_add to list_lru_add_obj and __list_lru_add to list_lru_add (patch 1) (suggested by Johannes Weiner and Yosry Ahmed) * Some cleanups on the memcg aware LRU patch (patch 2) (suggested by Yosry Ahmed) * Use event interface for the new per-cg

Re: [PATCH v2] kunit: Warn if tests are slow

2023-10-24 Thread Rae Moar
On Wed, Sep 20, 2023 at 4:49 AM Maxime Ripard wrote: > > Kunit recently gained support to setup attributes, the first one being > the speed of a given test, then allowing to filter out slow tests. > > A slow test is defined in the documentation as taking more than one > second. There's an another

RE: Purpose of gen_tar

2023-10-24 Thread Bird, Tim
> -Original Message- > From: Marcos Paulo de Souza > ... > Per the kselftests documentation[1], the gen_tar target is used to package the > tests to run "on different systems". But what if the different system has > different libraries/library versions? Wouldn't it be a problem? > ...

Purpose of gen_tar

2023-10-24 Thread Marcos Paulo de Souza
Hi, while testing a new patch on the livepatch kselftests, I was testing the gen_tar target and I figured that we only copy the resulting binaries to the final tar file. Per the kselftests documentation[1], the gen_tar target is used to package the tests to run "on different systems". But what if

Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-24 Thread Nicolin Chen
On Tue, Oct 24, 2023 at 03:00:49PM -0300, Jason Gunthorpe wrote: > On Tue, Oct 24, 2023 at 10:50:58AM -0700, Nicolin Chen wrote: > > > > The point is for the user_data to always be available, the driver > > > needs to check it if it is passed. > > > > > > This should all be plumbed to allow drive

Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-24 Thread Jason Gunthorpe
On Tue, Oct 24, 2023 at 10:50:58AM -0700, Nicolin Chen wrote: > > The point is for the user_data to always be available, the driver > > needs to check it if it is passed. > > > > This should all be plumbed to allow drivers to also customize their > > paging domains too. > > We don't have a use c

Re: [PATCH v6 00/10] iommufd: Add nesting infrastructure (part 1/2)

2023-10-24 Thread Jason Gunthorpe
On Tue, Oct 24, 2023 at 08:05:59AM -0700, Yi Liu wrote: > Jason Gunthorpe (2): > iommufd: Rename IOMMUFD_OBJ_HW_PAGETABLE to IOMMUFD_OBJ_HWPT_PAGING > iommufd/device: Wrap IOMMUFD_OBJ_HWPT_PAGING-only configurations > > Lu Baolu (1): > iommu: Add IOMMU_DOMAIN_NESTED > > Nicolin Chen (6): >

Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-24 Thread Nicolin Chen
On Tue, Oct 24, 2023 at 02:31:39PM -0300, Jason Gunthorpe wrote: > On Tue, Oct 24, 2023 at 10:28:45AM -0700, Nicolin Chen wrote: > > On Tue, Oct 24, 2023 at 02:18:10PM -0300, Jason Gunthorpe wrote: > > > On Tue, Oct 24, 2023 at 08:06:06AM -0700, Yi Liu wrote: > > > > @@ -195,6 +279,10 @@ int iommuf

Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-24 Thread Jason Gunthorpe
On Tue, Oct 24, 2023 at 08:06:06AM -0700, Yi Liu wrote: > static inline void iommufd_hw_pagetable_put(struct iommufd_ctx *ictx, > struct iommufd_hw_pagetable *hwpt) > { > - struct iommufd_hwpt_paging *hwpt_paging = to_hwpt_paging(hwpt); > + if (WA

Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-24 Thread Jason Gunthorpe
On Tue, Oct 24, 2023 at 10:28:45AM -0700, Nicolin Chen wrote: > On Tue, Oct 24, 2023 at 02:18:10PM -0300, Jason Gunthorpe wrote: > > On Tue, Oct 24, 2023 at 08:06:06AM -0700, Yi Liu wrote: > > > @@ -195,6 +279,10 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd) > > > if (pt_obj->type == IOMMU

Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-24 Thread Jason Gunthorpe
On Tue, Oct 24, 2023 at 02:18:10PM -0300, Jason Gunthorpe wrote: > On Tue, Oct 24, 2023 at 08:06:06AM -0700, Yi Liu wrote: > > @@ -195,6 +279,10 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd) > > if (pt_obj->type == IOMMUFD_OBJ_IOAS) { > > struct iommufd_hwpt_paging *hwpt_pagi

Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-24 Thread Nicolin Chen
On Tue, Oct 24, 2023 at 02:18:10PM -0300, Jason Gunthorpe wrote: > On Tue, Oct 24, 2023 at 08:06:06AM -0700, Yi Liu wrote: > > @@ -195,6 +279,10 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd) > > if (pt_obj->type == IOMMUFD_OBJ_IOAS) { > > struct iommufd_hwpt_paging *hwpt_pagi

Re: [PATCH v6 02/10] iommu: Pass in parent domain with user_data to domain_alloc_user op

2023-10-24 Thread Jason Gunthorpe
On Tue, Oct 24, 2023 at 08:06:01AM -0700, Yi Liu wrote: > domain_alloc_user op already accepts user flags for domain allocation, add > a parent domain pointer and a driver specific user data support as well. > > Add a struct iommu_user_data as a bundle of data_ptr/data_len/type from an > iommufd c

Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-24 Thread Jason Gunthorpe
On Tue, Oct 24, 2023 at 08:06:06AM -0700, Yi Liu wrote: > @@ -195,6 +279,10 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd) > if (pt_obj->type == IOMMUFD_OBJ_IOAS) { > struct iommufd_hwpt_paging *hwpt_paging; > > + if (cmd->data_type != IOMMU_HWPT_DATA_NONE) {

Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-24 Thread Jason Gunthorpe
On Tue, Oct 24, 2023 at 08:06:06AM -0700, Yi Liu wrote: > +static struct iommufd_hwpt_nested * > +iommufd_hwpt_nested_alloc(struct iommufd_ctx *ictx, > + struct iommufd_hwpt_paging *parent, > + struct iommufd_device *idev, u32 flags, > +

Re: # Toplevel Makefile doesn't process module build correctly on recursive make calls

2023-10-24 Thread Marcos Paulo de Souza
On Fri, Oct 20, 2023 at 06:21:40AM +0200, Nicolas Schier wrote: > On Thu, Oct 19, 2023 at 03:50:05PM -0300, Marcos Paulo de Souza wrote: > > On Sat, Oct 14, 2023 at 05:35:55PM +0900, Masahiro Yamada wrote: > > > On Tue, Oct 10, 2023 at 5:43 AM Marcos Paulo de Souza > > > wrote: > > > > > > > > Hi

Re: [PATCH v6 05/10] iommufd: Derive iommufd_hwpt_paging from iommufd_hw_pagetable

2023-10-24 Thread Jason Gunthorpe
On Tue, Oct 24, 2023 at 08:06:04AM -0700, Yi Liu wrote: > static int iommufd_group_do_replace_paging(struct iommufd_group *igroup, > -struct iommufd_hw_pagetable *hwpt) > +struct iommufd_hwpt_paging > *hwpt_paging) >

Re: [PATCH 5/5] selftests/nolibc: generate config automatically

2023-10-24 Thread Thomas Weißschuh
Oct 22, 2023 11:37:05 Willy Tarreau : > On Tue, Oct 10, 2023 at 02:34:00PM +0200, Thomas Weißschuh wrote: >> This new target generates a .config if none exists yet. >> >> Also drop the defconfig target with its hidden call to 'mrproper' which >> is fairly invasive. >> If users want to overwrite th

Re: [PATCH 2/5] selftests/nolibc: use EFI -bios for LoongArch qemu

2023-10-24 Thread Willy Tarreau
On Tue, Oct 24, 2023 at 06:06:11PM +0200, Thomas Weißschuh wrote: > Oct 22, 2023 11:21:16 Willy Tarreau : > > > On Tue, Oct 10, 2023 at 02:33:57PM +0200, Thomas Weißschuh wrote: > >> qemu for LoongArch does not work properly with direct kernel boot. > >> The kernel will panic during initializatio

Re: [PATCH v6 02/10] iommu: Pass in parent domain with user_data to domain_alloc_user op

2023-10-24 Thread Yi Liu
On 2023/10/24 23:56, Joao Martins wrote: On 24/10/2023 16:06, Yi Liu wrote: domain_alloc_user op already accepts user flags for domain allocation, add a parent domain pointer and a driver specific user data support as well. Add a struct iommu_user_data as a bundle of data_ptr/data_len/type from

Re: [PATCH 4/5] selftests/nolibc: support out-of-tree builds

2023-10-24 Thread Thomas Weißschuh
Oct 22, 2023 11:31:32 Willy Tarreau : > On Tue, Oct 10, 2023 at 02:33:59PM +0200, Thomas Weißschuh wrote: >> Out of tree builds are much more convenient when building for multiple >> architectures or configurations in parallel. >> >> Only absolute O= parameters are supported as Makefile.include wi

Re: [PATCH 2/5] selftests/nolibc: use EFI -bios for LoongArch qemu

2023-10-24 Thread Thomas Weißschuh
Oct 22, 2023 11:21:16 Willy Tarreau : > On Tue, Oct 10, 2023 at 02:33:57PM +0200, Thomas Weißschuh wrote: >> qemu for LoongArch does not work properly with direct kernel boot. >> The kernel will panic during initialization and hang without any output. >> >> When booting in EFI mode everything work

Re: [PATCH v6 02/10] iommu: Pass in parent domain with user_data to domain_alloc_user op

2023-10-24 Thread Joao Martins
On 24/10/2023 16:06, Yi Liu wrote: > domain_alloc_user op already accepts user flags for domain allocation, add > a parent domain pointer and a driver specific user data support as well. > > Add a struct iommu_user_data as a bundle of data_ptr/data_len/type from an > iommufd core uAPI structure. M

Re: [PATCH v2 3/4] selftests: core: remove duplicate defines

2023-10-24 Thread Muhammad Usama Anjum
Hi Aishwarya, On 10/24/23 5:43 PM, Aishwarya TCV wrote: > > > On 06/10/2023 11:07, Muhammad Usama Anjum wrote: >> Remove duplicate defines which are already defined in kernel headers and >> re-definition isn't required. >> >> Signed-off-by: Muhammad Usama Anjum >> --- > > Hi Muhammad, > > Cur

[PATCH] selftests: core: include linux/close_range.h for CLOSE_RANGE_* macros

2023-10-24 Thread Muhammad Usama Anjum
Correct header file is needed for getting CLOSE_RANGE_* macros. Previously it was tested with newer glibc which didn't show the need to include the header which was a mistake. Fixes: ec54424923cf ("selftests: core: remove duplicate defines") Reported-by: Aishwarya TCV Link: https://lore.kernel.or

[PATCH v7 3/8] iommu/vt-d: Add helper for nested domain allocation

2023-10-24 Thread Yi Liu
From: Lu Baolu This adds helper for accepting user parameters and allocate a nested domain. Reviewed-by: Kevin Tian Signed-off-by: Jacob Pan Signed-off-by: Lu Baolu Signed-off-by: Yi Liu --- drivers/iommu/intel/Makefile | 2 +- drivers/iommu/intel/iommu.h | 2 ++ drivers/iommu/intel/nest

[PATCH v7 1/8] iommufd: Add data structure for Intel VT-d stage-1 domain allocation

2023-10-24 Thread Yi Liu
This adds IOMMU_HWPT_DATA_VTD_S1 for stage-1 hw_pagetable of Intel VT-d and the corressponding data structure for userspace specified parameter for the domain allocation. Reviewed-by: Kevin Tian Signed-off-by: Yi Liu --- include/uapi/linux/iommufd.h | 30 ++ 1 file c

[PATCH v7 2/8] iommu/vt-d: Extend dmar_domain to support nested domain

2023-10-24 Thread Yi Liu
From: Lu Baolu The nested domain fields are exclusive to those that used for a DMA remapping domain. Use union to avoid memory waste. Reviewed-by: Kevin Tian Signed-off-by: Lu Baolu Signed-off-by: Yi Liu --- drivers/iommu/intel/iommu.h | 36 ++-- 1 file change

[PATCH v7 6/8] iommu/vt-d: Set the nested domain to a device

2023-10-24 Thread Yi Liu
This adds the helper for setting the nested domain to a device hence enable nested domain usage on Intel VT-d. Signed-off-by: Jacob Pan Signed-off-by: Lu Baolu Signed-off-by: Yi Liu --- drivers/iommu/intel/nested.c | 54 1 file changed, 54 insertions(+) di

[PATCH v7 5/8] iommu/vt-d: Make domain attach helpers to be extern

2023-10-24 Thread Yi Liu
This makes the helpers visible to nested.c. Suggested-by: Lu Baolu Reviewed-by: Kevin Tian Reviewed-by: Lu Baolu Signed-off-by: Yi Liu --- drivers/iommu/intel/iommu.c | 15 ++- drivers/iommu/intel/iommu.h | 7 +++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git

[PATCH v7 8/8] iommu/vt-d: Disallow read-only mappings to nest parent domain

2023-10-24 Thread Yi Liu
From: Lu Baolu When remapping hardware is configured by system software in scalable mode as Nested (PGTT=011b) and with PWSNP field Set in the PASID-table-entry, it may Set Accessed bit and Dirty bit (and Extended Access bit if enabled) in first-stage page-table entries even when second-stage map

[PATCH v7 7/8] iommu/vt-d: Add nested domain allocation

2023-10-24 Thread Yi Liu
From: Lu Baolu This adds the support for IOMMU_HWPT_DATA_VTD_S1 type. And 'nested_parent' is added to mark the nested parent domain to sanitize the input parent domain. Signed-off-by: Lu Baolu Signed-off-by: Yi Liu --- drivers/iommu/intel/iommu.c | 67 + dr

[PATCH v7 4/8] iommu/vt-d: Add helper to setup pasid nested translation

2023-10-24 Thread Yi Liu
From: Lu Baolu The configurations are passed in from the user when the user domain is allocated. This helper interprets these configurations according to the data structure defined in uapi/linux/iommufd.h. The EINVAL error will be returned if any of configurations are not compatible with the hard

[PATCH v7 0/8] Add Intel VT-d nested translation (part 1/2)

2023-10-24 Thread Yi Liu
This is the first part to add Intel VT-d nested translation based on IOMMUFD nesting infrastructure. As the iommufd nesting infrastructure series[1], iommu core supports new ops to allocate domains with user data. For nesting, the user data is vendor-specific, IOMMU_HWPT_DATA_VTD_S1 is defined for

[PATCH v6 09/10] iommufd/selftest: Add nested domain allocation for mock domain

2023-10-24 Thread Yi Liu
From: Nicolin Chen Add nested domain support in the ->domain_alloc_user op with some proper sanity checks. Then, add a domain_nested_ops for all nested domains and split the get_md_pagetable helper into paging and nested helpers. Also, add an iotlb as a testing property of a nested domain. Sign

[PATCH v6 05/10] iommufd: Derive iommufd_hwpt_paging from iommufd_hw_pagetable

2023-10-24 Thread Yi Liu
From: Nicolin Chen To prepare for IOMMUFD_OBJ_HWPT_NESTED, derive struct iommufd_hwpt_paging from struct iommufd_hw_pagetable, by leaving the common members in struct iommufd_hw_pagetable. Add a __iommufd_object_alloc and to_hwpt_paging() helpers for the new structure. Then, update "hwpt" to "hw

[PATCH v6 06/10] iommufd: Share iommufd_hwpt_alloc with IOMMUFD_OBJ_HWPT_NESTED

2023-10-24 Thread Yi Liu
From: Nicolin Chen Allow iommufd_hwpt_alloc() to have a common routine but jump to different allocators corresponding to different user input pt_obj types, either an IOMMUFD_OBJ_IOAS for a PAGING hwpt or an IOMMUFD_OBJ_HWPT_PAGING as the parent for a NESTED hwpt. Also, move the "flags" validatio

[PATCH v6 08/10] iommu: Add iommu_copy_struct_from_user helper

2023-10-24 Thread Yi Liu
From: Nicolin Chen Wrap up the data type/pointer/len sanity and a copy_struct_from_user call for iommu drivers to copy driver specific data via struct iommu_user_data. And expect it to be used in the domain_alloc_user op for example. Signed-off-by: Nicolin Chen Co-developed-by: Yi Liu Signed-o

[PATCH v6 07/10] iommufd: Add a nested HW pagetable object

2023-10-24 Thread Yi Liu
From: Nicolin Chen IOMMU_HWPT_ALLOC already supports iommu_domain allocation for usersapce. But it can only allocate a hw_pagetable that associates to a given IOAS, i.e. only a kernel-managed hw_pagetable of IOMMUFD_OBJ_HWPT_PAGING type. IOMMU drivers can now support user-managed hw_pagetables,

[PATCH v6 04/10] iommufd/device: Wrap IOMMUFD_OBJ_HWPT_PAGING-only configurations

2023-10-24 Thread Yi Liu
From: Jason Gunthorpe Some of the configurations during the attach/replace() should only apply to IOMMUFD_OBJ_HWPT_PAGING. Once IOMMUFD_OBJ_HWPT_NESTED gets introduced in a following patch, keeping them unconditionally in the common routine will not work. Wrap all of those PAGING-only configurat

[PATCH v6 10/10] iommufd/selftest: Add coverage for IOMMU_HWPT_ALLOC with nested HWPTs

2023-10-24 Thread Yi Liu
From: Nicolin Chen The IOMMU_HWPT_ALLOC ioctl now supports passing user_data to allocate a user-managed domain for nested HWPTs. Add its coverage for that. Also, update _test_cmd_hwpt_alloc() and add test_cmd/err_hwpt_alloc_nested(). Signed-off-by: Nicolin Chen Signed-off-by: Yi Liu --- tools

[PATCH v6 02/10] iommu: Pass in parent domain with user_data to domain_alloc_user op

2023-10-24 Thread Yi Liu
domain_alloc_user op already accepts user flags for domain allocation, add a parent domain pointer and a driver specific user data support as well. Add a struct iommu_user_data as a bundle of data_ptr/data_len/type from an iommufd core uAPI structure. Make the user data opaque to the core, since a

[PATCH v6 03/10] iommufd: Rename IOMMUFD_OBJ_HW_PAGETABLE to IOMMUFD_OBJ_HWPT_PAGING

2023-10-24 Thread Yi Liu
From: Jason Gunthorpe To add a new IOMMUFD_OBJ_HWPT_NESTED, rename the HWPT object to confine it to PAGING hwpts/domains. The following patch will separate the hwpt structure as well. Signed-off-by: Jason Gunthorpe Signed-off-by: Nicolin Chen Signed-off-by: Yi Liu --- drivers/iommu/iommufd/d

[PATCH v6 01/10] iommu: Add IOMMU_DOMAIN_NESTED

2023-10-24 Thread Yi Liu
From: Lu Baolu Introduce a new domain type for a user I/O page table, which is nested on top of another user space address represented by a PAGING domain. This new domain can be allocated by the domain_alloc_user op, and attached to a device through the existing iommu_attach_device/group() interf

[PATCH v6 00/10] iommufd: Add nesting infrastructure (part 1/2)

2023-10-24 Thread Yi Liu
Nested translation is a hardware feature that is supported by many modern IOMMU hardwares. It has two stages of address translations to get access to the physical address. A stage-1 translation table is owned by userspace (e.g. by a guest OS), while a stage-2 is owned by kernel. Any change to a sta

[PATCH] iommu/vt-d: Enhance capability check for nested parent domain allocation

2023-10-24 Thread Yi Liu
This adds the scalable mode check before allocating the nested parent domain as checking nested capability is not enough. User may turn off scalable mode which also means no nested support even if the hardware supports it. Fixes: c97d1b20d383 ("iommu/vt-d: Add domain_alloc_user op") Signed-off-by:

Re: [PATCH v3 2/3] userfaultfd: UFFDIO_MOVE uABI

2023-10-24 Thread Suren Baghdasaryan
On Tue, Oct 24, 2023 at 7:27 AM David Hildenbrand wrote: > > On 23.10.23 20:56, Suren Baghdasaryan wrote: > > On Mon, Oct 23, 2023 at 5:29 AM David Hildenbrand wrote: > >> > >> Focusing on validate_remap_areas(): > >> > >>> + > >>> +static int validate_remap_areas(struct vm_area_struct *src_vma,

Re: [PATCH v3 2/3] userfaultfd: UFFDIO_MOVE uABI

2023-10-24 Thread David Hildenbrand
On 23.10.23 20:56, Suren Baghdasaryan wrote: On Mon, Oct 23, 2023 at 5:29 AM David Hildenbrand wrote: Focusing on validate_remap_areas(): + +static int validate_remap_areas(struct vm_area_struct *src_vma, + struct vm_area_struct *dst_vma) +{ + /* Only allow re

Re: [PATCH v2] kunit: Warn if tests are slow

2023-10-24 Thread Maxime Ripard
On Wed, Sep 20, 2023 at 10:49:03AM +0200, Maxime Ripard wrote: > Kunit recently gained support to setup attributes, the first one being > the speed of a given test, then allowing to filter out slow tests. > > A slow test is defined in the documentation as taking more than one > second. There's an

Re: [PATCH v2 3/4] selftests: core: remove duplicate defines

2023-10-24 Thread Aishwarya TCV
On 06/10/2023 11:07, Muhammad Usama Anjum wrote: > Remove duplicate defines which are already defined in kernel headers and > re-definition isn't required. > > Signed-off-by: Muhammad Usama Anjum > --- Hi Muhammad, Currently when building kselftest against next-master with arm64 arch and def

Re: [RFC PATCH v1 0/8] Introduce mseal() syscall

2023-10-24 Thread Stephen Röttger
> The problem you seem to have with fully locked mseal() in chrome seems > to be here: > > > about permission changes but sometimes we do need to mprotect data only > > pages. > > Does that data have to be in the same region? Can your allocator not > put the non-code pieces of the JIT elsewhere, w

[PATCH 22/24] selftests/resctrl: Add test groups and name L3 CAT test L3_CAT

2023-10-24 Thread Ilpo Järvinen
To select test to run -t parameter can be used. However, -t cat currently maps to L3 CAT test which is confusing after L2 CAT test is be the next change. Allow selecting tests as groups and call L3 CAT test L3_CAT, "CAT" group will enable to both L3 and L2 CAT tests. Signed-off-by: Ilpo Järvinen

[PATCH 23/24] selftests/resctrl: Add L2 CAT test

2023-10-24 Thread Ilpo Järvinen
CAT selftests only cover L3 but some newer CPUs come also with L2 CAT support. Add L2 CAT selftest. As measuring L2 misses is not easily available with perf, use L3 accesses as a proxy for L2 CAT working or not. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cat_test.c| 68

[PATCH 24/24] selftests/resctrl: Ignore failures from L2 CAT test with <= 2 bits

2023-10-24 Thread Ilpo Järvinen
L2 CAT test with low number of bits tends to occasionally fail because of what seems random variation. The margin is quite small to begin with for <= 2 bits in CBM. At times, the result can even become negative. While it would be possible to allow negative values for those cases, it would be more c

[PATCH 21/24] selftests/resctrl: Get resource id from cache id

2023-10-24 Thread Ilpo Järvinen
Resource id is acquired differently depending on CPU. AMD tests use id from L3 cache, whereas CPUs from other vendors base the id on topology package id. In order to support L2 CAT test, this has to be generalized. The driver side code seems to get the resource ids from cache ids so the approach u

[PATCH 20/24] selftests/resctrl: Add helper to convert L2/3 to integer

2023-10-24 Thread Ilpo Järvinen
"L2"/"L3" conversion to integer in embedded into get_cache_size() which prevents reuse. Create a helper for the cache string to integer conversion to make it reusable. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/resctrlfs.c | 28 +++-- 1 file changed, 20 ins

[PATCH 09/24] selftests/resctrl: Remove unnecessary __u64 -> unsigned long conversion

2023-10-24 Thread Ilpo Järvinen
Perf counters are __u64 but the code converts them to unsigned long before printing them out. Remove unnecessary type conversion and the potential loss of meaningful bits due to different sizes of types. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cache.c| 21 --

[PATCH 16/24] selftests/resctrl: Rewrite Cache Allocation Technology (CAT) test

2023-10-24 Thread Ilpo Järvinen
CAT test spawns two processes into two different control groups with exclusive schemata. Both the processes alloc a buffer from memory matching their allocated LLC block size and flush the entire buffer out of caches. Since the processes are reading through the buffer only once during the measureme

[PATCH 19/24] selftests/resctrl: Pass write_schemata() resource instead of test name

2023-10-24 Thread Ilpo Järvinen
write_schemata() currently takes the test name as an argument and determines the relevant resource based on the test name. L2 CAT test needs to set schemata for both L3 and L2 CAT which would get complicated using the current approach. Pass a resource instead of test name to write_schemata() to al

[PATCH 18/24] selftests/resctrl: Introduce generalized test framework

2023-10-24 Thread Ilpo Järvinen
Each test currently has a "run test" function in per test file and another resctrl_tests.c. The functions in resctrl_tests.c are almost identical. Generalize the one in resctrl_tests.c such that it can be shared between all of the tests. It makes adding new tests easier and removes the per test if

[PATCH 17/24] selftests/resctrl: Create struct for input parameter

2023-10-24 Thread Ilpo Järvinen
resctrl_tests reads a set of parameters and passes them individually for each tests. The way the parameters passed varies between tests. Add struct input_params to hold are input parameters. It can be easily passed to every test without varying the call signature. Signed-off-by: Ilpo Järvinen --

[PATCH 15/24] selftests/resctrl: Read in less obvious order to defeat prefetch optimizations

2023-10-24 Thread Ilpo Järvinen
When reading memory in order, HW prefetching optimizations will interfere with measuring how caches and memory are being accessed. This adds noise into the results. Change the fill_buf reading loop to not use an obvious in-order access using multiply by a prime and modulo. Using a prime multiplie

[PATCH 14/24] selftests/resctrl: Move cat_val() to cat_test.c and rename to cat_test()

2023-10-24 Thread Ilpo Järvinen
The main CAT test function is called cat_val() and resides in cache.c which is illogical. Rename the function to cat_test() and move it into cat_test.c. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cache.c| 90 ++ tools/testing/selftests/resctrl/cat_t

[PATCH 13/24] selftests/resctrl: Convert perf related globals to locals

2023-10-24 Thread Ilpo Järvinen
Perf related variables pea_llc_miss, pe_read, and pe_fd are globals in cache.c. Convert them to locals for better scoping and make pea_llc_miss simpler by renaming it to pea. Make close(pe_fd) handling easier to understand by doing it inside cat_val(). Make also sizeof()s use safer way determine

[PATCH 12/24] selftests/resctrl: Improve perf init

2023-10-24 Thread Ilpo Järvinen
struct perf_event_attr initialization is spread into perf_event_initialize() and perf_event_attr_initialize() and setting ->config is hardcoded by the deepest level. perf_event_attr init belongs to perf_event_attr_initialize() so move it entirely there. Rename the other function perf_event_initial

[PATCH 11/24] selftests/resctrl: Consolidate naming of perf event related things

2023-10-24 Thread Ilpo Järvinen
Naming for perf event related functions, types, and variables is currently inconsistent. Make struct read_format and all functions related to perf events start with perf_event. Adjust variable names towards the same direction but use shorter names for variables where appropriate (pe prefix). Sign

[PATCH 10/24] selftests/resctrl: Remove nested calls in perf event handling

2023-10-24 Thread Ilpo Järvinen
Perf event handling has functions that are the sole caller of another perf event handling related function: - reset_enable_llc_perf() calls perf_event_open_llc_miss() - reset_enable_llc_perf() calls ioctl_perf_event_ioc_reset_enable() - measure_llc_perf() calls get_llc_perf() Remove the extr

[PATCH 08/24] selftests/resctrl: Split show_cache_info() to test specific and generic parts

2023-10-24 Thread Ilpo Järvinen
show_cache_info() calculates results and provides generic cache information. This makes it hard to alter pass/fail conditions. Separate the test specific checks into CAT and CMT test files and leave only the generic information part into show_cache_info(). Signed-off-by: Ilpo Järvinen --- tools

[PATCH 07/24] selftests/resctrl: Split measure_cache_vals() function

2023-10-24 Thread Ilpo Järvinen
The measure_cache_vals() function does a different thing depending on the test case that called it: - For CAT, it measures LLC perf misses. - For CMT, it measures LLC occupancy through resctrl. Split these two functionalities into own functions the CAT and CMT tests can call directly. Co-deve

[PATCH 06/24] selftests/resctrl: Exclude shareable bits from schemata in CAT test

2023-10-24 Thread Ilpo Järvinen
CAT test doesn't take shareable bits into account, i.e., the test might be sharing cache with some devices (e.g., graphics). Introduce get_mask_no_shareable() and use it to provision an environment for CAT test where the allocated LLC is isolated better. Excluding shareable_bits may create hole(s)

[PATCH 05/24] selftests/resctrl: Create cache_size() helper

2023-10-24 Thread Ilpo Järvinen
CAT and CMT tests calculate the span size from the n-bits cache allocation on their own. Add cache_size() helper which calculates size of the cache portion for the given number of bits and use it to replace the existing span calculations. This also prepares for the new CAT test that will need to d

[PATCH 04/24] selftests/resctrl: Mark get_cache_size() cache_type const

2023-10-24 Thread Ilpo Järvinen
get_cache_size() does not modify cache_type so it could be const. Mark cache_type const so that const char * can be passed to it. This prevents warnings once many of the test parameters are marked const. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/resctrl.h | 2 +- tools/

[PATCH 03/24] selftests/resctrl: Refactor get_cbm_mask()

2023-10-24 Thread Ilpo Järvinen
Callers of get_cbm_mask() are required to pass a string into which the CBM bit mask is read. Neither CAT nor CMT tests need the mask as string but just convert it into an unsigned long value. The bit mask reader can only read .../cbm_mask files. Generalize the bit mask reading function into get_b

[PATCH 02/24] selftests/resctrl: Refactor fill_buf functions

2023-10-24 Thread Ilpo Järvinen
There are unnecessary nested calls in fill_buf.c: - run_fill_buf() calls fill_cache() - alloc_buffer() calls malloc_and_init_memory() Simplify the code flow and remove those unnecessary call levels by moving the called code inside the calling function. Resolve the difference in run_fill_buf()

[PATCH 01/24] selftests/resctrl: Split fill_buf to allow tests finer-grained control

2023-10-24 Thread Ilpo Järvinen
MBM, MBA and CMT test cases use run_fill_buf() to loop indefinitely around the buffer. CAT test case is different and doesn't want to loop around the buffer continuously. Split fill_cache() so that both the use cases are easier to control by creating separate functions for buffer allocation and lo

[PATCH 00/24] selftests/resctrl: CAT test improvements & generalized test framework

2023-10-24 Thread Ilpo Järvinen
Hi all, Here's a series to improve resctrl selftests. It contains following improvements: - Excludes shareable bits from CAT test allocation to avoid interference - Alters read pattern to defeat HW prefetcher optimizations - Rewrites CAT test to make the CAT test reliable and truly measure if C