[PATCH v2 1/3] userfaultfd: UFFDIO_REMAP: rmap preparation

2023-09-22 Thread Suren Baghdasaryan
From: Andrea Arcangeli As far as the rmap code is concerned, UFFDIO_REMAP only alters the page->mapping and page->index. It does it while holding the page lock. However folio_referenced() is doing rmap walks without taking the folio lock first, so folio_lock_anon_vma_read() must be updated to re-

[PATCH v2 3/3] selftests/mm: add UFFDIO_REMAP ioctl test

2023-09-22 Thread Suren Baghdasaryan
Add a test for new UFFDIO_REMAP ioctl which uses uffd to remaps source into destination buffer while checking the contents of both after remapping. After the operation the content of the destination buffer should match the original source buffer's content while the source buffer should be zeroed.

[PATCH v2 2/3] userfaultfd: UFFDIO_REMAP uABI

2023-09-22 Thread Suren Baghdasaryan
From: Andrea Arcangeli This implements the uABI of UFFDIO_REMAP. Notably one mode bitflag is also forwarded (and in turn known) by the lowlevel remap_pages method. Signed-off-by: Andrea Arcangeli Signed-off-by: Suren Baghdasaryan --- Changes since v1: - add mmget_not_zero in userfaultfd_remap

[PATCH v2 0/3] userfaultfd remap option

2023-09-22 Thread Suren Baghdasaryan
This patch series introduces UFFDIO_REMAP feature to userfaultfd, which has long been implemented and maintained by Andrea in his local tree [1], but was not upstreamed due to lack of use cases where this approach would be better than allocating a new page and copying the contents. UFFDIO_COPY per

[PATCH v3] list: test: potential dereference of null pointer

2023-09-22 Thread Ma Ke
To avoid the failure of alloc, we could check the return value of kmalloc() and kzalloc(). Signed-off-by: Ma Ke --- lib/list-test.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/list-test.c b/lib/list-test.c index 0cc27de9cec8..a0b478042477 100644 --- a/lib/list-te

Re: [PATCH v2] list: test: potential dereference of null pointer

2023-09-22 Thread Daniel Latypov
On Fri, Sep 22, 2023 at 4:40 AM Ma Ke wrote: > > To avoid the failure of alloc, we could check the return value of > kmalloc() and kzalloc(). Thanks, that's a good point, some suggestions below. And also a question for David Gow whenever he sees this. > > Signed-off-by: Ma Ke > --- > lib/list-

Re: [PATCH v2] selftests/amd-pstate: Fix broken paths to run workloads in amd-pstate-ut

2023-09-22 Thread Mario Limonciello
On 9/19/2023 05:33, Swapnil Sapkal wrote: In selftests/amd-pstate, tbench and gitsource microbenchmarks are used to compare the performance with different governors. In Current implementation relative path to run `amd_pstate_tracer.py` broken. Fixed this by using absolute paths. Also selftests/am

[PATCH] kselftest/arm64: Validate SVCR in streaming SVE stress test

2023-09-22 Thread Mark Brown
In the ZA and ZT test programs we explicitly validate that PSTATE.ZA is as expected on each loop but we do not do the equivalent for our streaming SVE test, add a check that we are still in streaming mode on every loop in case that goes wrong. Signed-off-by: Mark Brown --- tools/testing/selftest

Re: [PATCH net-next v4 2/6] net: bridge: Set strict_start_type for br_policy

2023-09-22 Thread Johannes Nixdorf
On Thu, Sep 21, 2023 at 01:14:43PM +0300, Nikolay Aleksandrov wrote: > On 9/21/23 10:23, Johannes Nixdorf wrote: > > On Wed, Sep 20, 2023 at 01:46:02PM +0300, Nikolay Aleksandrov wrote: > > > On 9/19/23 11:12, Johannes Nixdorf wrote: > > > > Set any new attributes added to br_policy to be parsed st

[PATCH v2] list: test: potential dereference of null pointer

2023-09-22 Thread Ma Ke
To avoid the failure of alloc, we could check the return value of kmalloc() and kzalloc(). Signed-off-by: Ma Ke --- lib/list-test.c | 9 + 1 file changed, 9 insertions(+) diff --git a/lib/list-test.c b/lib/list-test.c index 0cc27de9cec8..70e898976dbf 100644 --- a/lib/list-test.c +++ b/l

[PATCH v3 08/10] iov_iter: Add benchmarking kunit tests

2023-09-22 Thread David Howells
Add kunit tests to benchmark 256MiB copies to a KVEC iterator, a BVEC iterator, an XARRAY iterator and to a loop that allocates 256-page BVECs and fills them in (similar to a maximal bio struct being set up). Signed-off-by: David Howells cc: Christoph Hellwig cc: Christian Brauner cc: Jens Axbo

[PATCH v3 09/10] iov_iter: Add kunit to benchmark decanting of xarray to bvec

2023-09-22 Thread David Howells
Add a kunit test to benchmark an xarray containing 256MiB of data getting decanted into 256-page BVEC iterators that get copied from - modelling bufferage being drawn from the pagecache and batched up for I/O. Signed-off-by: David Howells cc: Christoph Hellwig cc: Christian Brauner cc: Jens Axb

[PATCH v3 10/10] iov_iter: Add benchmarking kunit tests for UBUF/IOVEC

2023-09-22 Thread David Howells
Add kunit tests to benchmark 256MiB copies to a UBUF iterator and an IOVEC iterator. This attaches a userspace VM with a mapped file in it temporarily to the test thread. Signed-off-by: David Howells cc: Andrew Morton cc: Christoph Hellwig cc: Christian Brauner cc: Jens Axboe cc: Al Viro cc

[PATCH v3 02/10] iov_iter: Consolidate some of the repeated code into helpers

2023-09-22 Thread David Howells
Consolidate some of the repeated code snippets into helper functions to reduce the line count. Signed-off-by: David Howells cc: Christoph Hellwig cc: Christian Brauner cc: Jens Axboe cc: Al Viro cc: David Hildenbrand cc: John Hubbard cc: Brendan Higgins cc: David Gow cc: linux-kselftest@v

[PATCH v3 07/10] iov_iter: Add extract kunit tests for ITER_UBUF and ITER_IOVEC

2023-09-22 Thread David Howells
Add extraction kunit tests for ITER_UBUF- and ITER_IOVEC-type iterators. This attaches a userspace VM with a mapped file in it temporarily to the test thread. [!] Note that this requires the kernel thread running the test to obtain and deploy an mm_struct so that a user-side buffer can be created

[PATCH v3 03/10] iov_iter: Consolidate the test vector struct in the kunit tests

2023-09-22 Thread David Howells
Consolidate the test vector struct in the kunit tests so that the bvec pattern check helpers can share with the kvec check helpers. Signed-off-by: David Howells cc: Christoph Hellwig cc: Christian Brauner cc: Jens Axboe cc: Al Viro cc: David Hildenbrand cc: John Hubbard cc: Brendan Higgins

[PATCH v3 06/10] iov_iter: Add copy kunit tests for ITER_UBUF and ITER_IOVEC

2023-09-22 Thread David Howells
Add copy kunit tests for ITER_UBUF- and ITER_IOVEC-type iterators. This attaches a userspace VM with a mapped file in it temporarily to the test thread. Signed-off-by: David Howells cc: Andrew Morton cc: Christoph Hellwig cc: Christian Brauner cc: Jens Axboe cc: Al Viro cc: Matthew Wilcox

[PATCH v3 05/10] iov_iter: Create a function to prepare userspace VM for UBUF/IOVEC tests

2023-09-22 Thread David Howells
Create a function to set up a userspace VM for the kunit testing thread and set up a buffer within it such that ITER_UBUF and ITER_IOVEC tests can be performed. Note that this requires current->mm to point to a sufficiently set up mm_struct. This is done by partially mirroring what execve does.

[PATCH v3 01/10] iov_iter: Fix some checkpatch complaints in kunit tests

2023-09-22 Thread David Howells
Fix some checkpatch complaints in the new iov_iter kunit tests: (1) Some lines had eight spaces instead of a tab at the start. (2) Checkpatch doesn't like (void*)(unsigned long)0xnULL, so switch to using POISON_POINTER_DELTA plus an offset instead. Reported-by: Johannes Thumshirn Sig

[PATCH v3 04/10] iov_iter: Consolidate bvec pattern checking

2023-09-22 Thread David Howells
Make the BVEC-testing functions use the consolidated pattern checking functions to reduce the amount of duplicated code. Signed-off-by: David Howells cc: Christoph Hellwig cc: Christian Brauner cc: Jens Axboe cc: Al Viro cc: David Hildenbrand cc: John Hubbard cc: Brendan Higgins cc: David

[PATCH v3 00/10] iov_iter: kunit: Cleanup, abstraction and more tests

2023-09-22 Thread David Howells
Hi Jens, Can you consider taking this through the block tree? These patches make some changes to the kunit tests previously added for iov_iter testing, in particular adding testing of UBUF/IOVEC iterators and some benchmarking: (1) Clean up a couple of checkpatch style complaints. (2) Consoli

Re: [PATCH v4 1/2] selftests/resctrl: Fix schemata write error check

2023-09-22 Thread Ilpo Järvinen
On Fri, 22 Sep 2023, Maciej Wieczor-Retman wrote: > Writing bitmasks to the schemata can fail when the bitmask doesn't > adhere to constraints defined by what a particular CPU supports. > Some example of constraints are max length or having contiguous bits. > The driver should properly return erro

Re: [PATCH v4 01/17] iommu: Add hwpt_type with user_data for domain_alloc_user op

2023-09-22 Thread Robin Murphy
On 2023-09-21 17:44, Jason Gunthorpe wrote: On Thu, Sep 21, 2023 at 08:12:03PM +0800, Baolu Lu wrote: On 2023/9/21 15:51, Yi Liu wrote: diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h index 4a7c5c8fdbb4..3c8660fe9bb1 100644 --- a/include/uapi/linux/iommufd.h +++ b/inclu

[PATCH v3 8/8] selftests/resctrl: Fix wrong format specifier

2023-09-22 Thread Maciej Wieczor-Retman
A long unsigned int variable is passed to the ksft_print_msg() and the format specifier used expects a variable of type int. Change the format specifier to match the passed variable. Reviewed-by: Ilpo Järvinen Signed-off-by: Maciej Wieczor-Retman --- Changelog v3: - Add Reviewed-by tag. (Ilpo)

[PATCH v3 7/8] selftests/mm: Substitute attribute with a macro

2023-09-22 Thread Maciej Wieczor-Retman
The mm selftest uses the printf attribute in its full form. Since the header file that uses it also includes kselftests.h it can use the macro defined there. Use __printf() included with kselftests.h instead of the full attribute. Fix a wrong format specifier in ksft_print_msg(). Signed-off-by:

[PATCH v3 6/8] selftests/kvm: Replace attribute with macro

2023-09-22 Thread Maciej Wieczor-Retman
The __printf() macro is used in many tools in the linux kernel to validate the format specifiers in functions that use printf. The kvm selftest uses it without putting it in a macro definition while it also imports the kselftests.h header. Use __printf() from kselftests.h instead of the full attri

[PATCH v3 5/8] selftests/sigaltstack: Fix wrong format specifier

2023-09-22 Thread Maciej Wieczor-Retman
The format specifier inside ksft printing function expects a long unsigned int but the passed variable is of unsigned int type. Fix the format specifier so it matches the passed variable. Reviewed-by: Ilpo Järvinen Signed-off-by: Maciej Wieczor-Retman --- Changelog v2: - Add Reviewed-by tag (Il

[PATCH v3 3/8] selftests/openat2: Fix wrong format specifier

2023-09-22 Thread Maciej Wieczor-Retman
Ksft_print_msg() inside test_openat2_flags() uses the wrong format specifier for printing test.how->flags variable. Change the format specifier to %llX so it matches the printed variable. Reviewed-by: Ilpo Järvinen Signed-off-by: Maciej Wieczor-Retman --- Changelog v2: - Add Reviewed-by tag (Il

[PATCH v3 4/8] selftests/pidfd: Fix ksft print formats

2023-09-22 Thread Maciej Wieczor-Retman
Many calls to ksft print functions have format strings that don't match with other passed arguments. One call expects a string but doesn't provide any argument after the format string. Fix format specifiers so they match the passed variables. Add a missing variable to ksft_test_result_pass() insi

[PATCH v3 2/8] selftests/cachestat: Fix print_cachestat format

2023-09-22 Thread Maciej Wieczor-Retman
The format specifier in printf() call expects long int variables and received long long int. Change format specifiers to long long int so they match passed variables. Acked-by: Nhat Pham Signed-off-by: Maciej Wieczor-Retman --- Changelog v2: - Add Acked-by tag (Nhat) tools/testing/selftests/c

[PATCH v3 1/8] selftests: Add printf attribute to ksefltest prints

2023-09-22 Thread Maciej Wieczor-Retman
Kselftest header defines multiple variadic functions that use printf along with other logic. There is no format checking for the variadic functions that use printing inside kselftest.h. Because of this the compiler won't be able to catch instances of mismatched printf formats and debugging tests m

[PATCH v3 0/8] Add printf attribute to kselftest functions

2023-09-22 Thread Maciej Wieczor-Retman
Kselftest.h declares many variadic functions that can print some formatted message while also executing selftest logic. These declarations don't have any compiler mechanism to verify if passed arguments are valid in comparison with format specifiers used in printf() calls. Attribute addition can m

[PATCH v4 1/2] selftests/resctrl: Fix schemata write error check

2023-09-22 Thread Maciej Wieczor-Retman
Writing bitmasks to the schemata can fail when the bitmask doesn't adhere to constraints defined by what a particular CPU supports. Some example of constraints are max length or having contiguous bits. The driver should properly return errors when any rule concerning bitmask format is broken. Resc

[PATCH v4 2/2] selftests/resctrl: Move run_benchmark() to a more fitting file

2023-09-22 Thread Maciej Wieczor-Retman
resctrlfs.c contains mostly functions that interact in some way with resctrl FS entries while functions inside resctrl_val.c deal with measurements and benchmarking. run_benchmark() is located in resctrlfs.c even though it's purpose is not interacting with the resctrl FS but to execute cache check

[PATCH v4 0/2] selftests/resctrl: Bug fix and optimization

2023-09-22 Thread Maciej Wieczor-Retman
Write_schemata() uses fprintf() to write a bitmask into a schemata file inside resctrl FS. It checks fprintf() return value but it doesn't check fclose() return value. Error codes from fprintf() such as write errors, are buffered and flushed back to the user only after fclose() is executed which me

Re: [PATCH v3 3/4] kunit: Fix possible memory leak in kunit_filter_suites()

2023-09-22 Thread David Gow
On Fri, 22 Sept 2023 at 15:11, 'Jinjie Ruan' via KUnit Development wrote: > > If the outer layer for loop is iterated more than once and it fails not > in the first iteration, the filtered_suite and filtered_suite->test_cases > allocated in the last kunit_filter_attr_tests() in last inner for loop

Re: [PATCH v3 1/4] kunit: Fix missed memory release in kunit_free_suite_set()

2023-09-22 Thread David Gow
On Fri, 22 Sept 2023 at 15:11, 'Jinjie Ruan' via KUnit Development wrote: > > modprobe cpumask_kunit and rmmod cpumask_kunit, kmemleak detect > a suspected memory leak as below. > > If kunit_filter_suites() in kunit_module_init() succeeds, the > suite_set.start will not be NULL and the kunit_free_

Re: [PATCH v3 2/4] kunit: Fix the wrong kfree of copy for kunit_filter_suites()

2023-09-22 Thread David Gow
On Fri, 22 Sept 2023 at 15:11, 'Jinjie Ruan' via KUnit Development wrote: > > If the outer layer for loop is iterated more than once and it fails not > in the first iteration, the copy pointer has been moved. So it should free > the original copy's backup copy_start. > > Fixes: abbf73816b6f ("kuni

Re: [PATCH v3 4/4] kunit: test: Fix the possible memory leak in executor_test

2023-09-22 Thread David Gow
On Fri, 22 Sept 2023 at 15:11, 'Jinjie Ruan' via KUnit Development wrote: > > When CONFIG_KUNIT_ALL_TESTS=y, making CONFIG_DEBUG_KMEMLEAK=y and > CONFIG_DEBUG_KMEMLEAK_AUTO_SCAN=y, the below memory leak is detected. > > If kunit_filter_suites() succeeds, not only copy but also filtered_suite > and

Re: [PATCH v2 4/4] kunit: test: Fix the possible memory leak in executor_test

2023-09-22 Thread Ruan Jinjie
On 2023/9/22 15:34, David Gow wrote: > On Thu, 21 Sept 2023 at 09:41, 'Jinjie Ruan' via KUnit Development > wrote: >> >> When CONFIG_KUNIT_ALL_TESTS=y, making CONFIG_DEBUG_KMEMLEAK=y and >> CONFIG_DEBUG_KMEMLEAK_AUTO_SCAN=y, the below memory leak is detected. >> >> If kunit_filter_suites() succ

Re: [PATCH v2 4/4] kunit: test: Fix the possible memory leak in executor_test

2023-09-22 Thread David Gow
On Thu, 21 Sept 2023 at 09:41, 'Jinjie Ruan' via KUnit Development wrote: > > When CONFIG_KUNIT_ALL_TESTS=y, making CONFIG_DEBUG_KMEMLEAK=y and > CONFIG_DEBUG_KMEMLEAK_AUTO_SCAN=y, the below memory leak is detected. > > If kunit_filter_suites() succeeds, not only copy but also filtered_suite > and

Re: [PATCH v2 3/4] kunit: Fix possible memory leak in kunit_filter_suites()

2023-09-22 Thread David Gow
On Thu, 21 Sept 2023 at 09:41, 'Jinjie Ruan' via KUnit Development wrote: > > If the outer layer for loop is iterated more than once and it fails not > in the first iteration, the filtered_suite and filtered_suite->test_cases > allocated in the last kunit_filter_attr_tests() in last inner for loop

Re: [PATCH v2 2/4] kunit: Fix the wrong kfree of copy for kunit_filter_suites()

2023-09-22 Thread David Gow
On Thu, 21 Sept 2023 at 09:41, 'Jinjie Ruan' via KUnit Development wrote: > > If the outer layer for loop is iterated more than once and it fails not > in the first iteration, the copy pointer has been moved. So it should free > the original copy's backup copy_start. > > Fixes: abbf73816b6f ("kuni

Re: [PATCH v2 1/4] kunit: Fix missed memory release in kunit_free_suite_set()

2023-09-22 Thread David Gow
On Thu, 21 Sept 2023 at 09:41, 'Jinjie Ruan' via KUnit Development wrote: > > modprobe cpumask_kunit and rmmod cpumask_kunit, kmemleak detect > a suspected memory leak as below. > > If kunit_filter_suites() in kunit_module_init() succeeds, the > suite_set.start will not be NULL and the kunit_free_

Re: [PATCH] list: test: potential dereference of null pointer

2023-09-22 Thread David Gow
On Thu, 21 Sept 2023 at 16:18, Ma Ke wrote: > > To avoid the failure of alloc, we could check the return value of > kmalloc() and kzalloc(). > > Signed-off-by: Ma Ke > --- Fair enough, though I'd want the test to fail in this case (or, at the very least, be skipped). Could we use KUNIT_ASSERT_N

[PATCH v3 4/4] kunit: test: Fix the possible memory leak in executor_test

2023-09-22 Thread Jinjie Ruan
When CONFIG_KUNIT_ALL_TESTS=y, making CONFIG_DEBUG_KMEMLEAK=y and CONFIG_DEBUG_KMEMLEAK_AUTO_SCAN=y, the below memory leak is detected. If kunit_filter_suites() succeeds, not only copy but also filtered_suite and filtered_suite->test_cases should be freed. So as Rae suggested, to avoid the suite

[PATCH v3 3/4] kunit: Fix possible memory leak in kunit_filter_suites()

2023-09-22 Thread Jinjie Ruan
If the outer layer for loop is iterated more than once and it fails not in the first iteration, the filtered_suite and filtered_suite->test_cases allocated in the last kunit_filter_attr_tests() in last inner for loop is leaked. So add a new free_filtered_suite err label and free the filtered_suite

[PATCH v3 2/4] kunit: Fix the wrong kfree of copy for kunit_filter_suites()

2023-09-22 Thread Jinjie Ruan
If the outer layer for loop is iterated more than once and it fails not in the first iteration, the copy pointer has been moved. So it should free the original copy's backup copy_start. Fixes: abbf73816b6f ("kunit: fix possible memory leak in kunit_filter_suites()") Signed-off-by: Jinjie Ruan Rev

[PATCH v3 0/4] kunit: Fix some bugs in kunit

2023-09-22 Thread Jinjie Ruan
The test_cases is not freed in kunit_free_suite_set(). And the copy pointer may be moved in kunit_filter_suites(). The filtered_suite and filtered_suite->test_cases allocated in the last kunit_filter_attr_tests() in last inner for loop may be leaked if kunit_filter_suites() fails. If kunit_filte

[PATCH v3 1/4] kunit: Fix missed memory release in kunit_free_suite_set()

2023-09-22 Thread Jinjie Ruan
modprobe cpumask_kunit and rmmod cpumask_kunit, kmemleak detect a suspected memory leak as below. If kunit_filter_suites() in kunit_module_init() succeeds, the suite_set.start will not be NULL and the kunit_free_suite_set() in kunit_module_exit() should free all the memory which has not been freed