This patchset uses kpageflags to get after-split folio orders for a better
split_huge_page_test result check[1]. The added
gather_after_split_folio_orders() scans through a VPN range and collects
the numbers of folios at different orders. check_after_split_folio_orders()
compares the result of gather_after_split_folio_orders() to a given list of
numbers of different orders.
This patchset also added new order and in folio offset to the split huge
page debugfs's pr_debug()s;
Changelog
===
From V4[5]:
1. Rebased on mm-new.
2. Changed is_backed_by_folio() type to bool.
3. Renamed get_pfn_flags() to pageflags_get().
4. Removed file descriptor checked in is_backed_by_folio().
5. Renamed get_page_flags() to vaddr_pageflags_get() to clarify its use.
From V3[4]:
1. Renamed {gather,check}_folio_orders() to
{gather,check}_after_split_folio_orders() and moved them to
split_huge_page_test.c, since both functions are not general enough for
arbitrary folio order checks in any virtual address range. Comments
are added to clarify the purpose of these functions.
2. Fixed file descriptor error check.
3. Removed unnecessary statements.
4. Fixed is_backed_by_folio() tail PFN off-by-one check issue.
5. Added a check in is_backed_by_folio() to detect if the order of the
backing large folio is larger than the given order.
6. Moved misplaced comments in is_backed_by_folio().
7. Added a comment and a commit message to clarify why the split range
of folio_split() tests is changed.
From V2[3]:
1. Added two missing free()s in check_folio_orders().
2. Reimplemented is_backed_by_thp() to use kpageflags to get precise
folio order information and renamed it to is_backed_by_folio() in new
Patch 3.
3. Renamed *_file to *_fd in Patch 2.
4. Indentation fixes.
5. Fixed vaddr stepping issue in gather_folio_orders() when a compound
tail page is encountered.
6. Used pmd_order in place of max_order in split_huge_page_test.c.
7. Documented gather_folio_orders().
From V1[2]:
1. Dropped split_huge_pages_pid() for loop step change to avoid messing
up with PTE-mapped THP handling. split_huge_page_test.c is changed to
perform split at [addr, addr + pagesize) range to limit one
folio_split() per folio.
2. Moved pr_debug changes in Patch 2 to Patch 1.
3. Moved KPF_* to vm_util.h and used PAGEMAP_PFN instead of local PFN_MASK.
4. Used pagemap_get_pfn() helper.
5. Used char *vaddr and size_t len as inputs to gather_folio_orders() and
check_folio_orders() instead of vpn and nr_pages.
6. Removed variable length variables and used malloc instead.
Link: https://lore.kernel.org/linux-mm/e2f32bdb-e4a4-447c-867c-31405cbba151@redha… [1]
Link: https://lore.kernel.org/linux-mm/20250806022045.342824-1-ziy@nvidia.com/ [2]
Link: https://lore.kernel.org/linux-mm/20250808190144.797076-1-ziy@nvidia.com/ [3]
Link: https://lore.kernel.org/linux-mm/20250812155512.926011-1-ziy@nvidia.com/ [4]
Link: https://lore.kernel.org/linux-mm/20250815023915.1394655-1-ziy@nvidia.com/ [5]
Zi Yan (5):
mm/huge_memory: add new_order and offset to split_huge_pages*()
pr_debug.
selftests/mm: mark all functions static in split_huge_page_test.c
selftests/mm: reimplement is_backed_by_thp() with more precise check
selftests/mm: add check_after_split_folio_orders() helper.
selftests/mm: check after-split folio orders in split_huge_page_test.
mm/huge_memory.c | 8 +-
.../selftests/mm/split_huge_page_test.c | 342 +++++++++++++++---
tools/testing/selftests/mm/vm_util.c | 13 +
tools/testing/selftests/mm/vm_util.h | 4 +
4 files changed, 308 insertions(+), 59 deletions(-)
--
2.50.1
When using GCC on x86-64 to compile an usdt prog with -O1 or higher
optimization, the compiler will generate SIB addressing mode for global
array and PC-relative addressing mode for global variable,
e.g. "1@-96(%rbp,%rax,8)" and "-1@4+t1(%rip)".
The current USDT implementation in libbpf cannot parse these two formats,
causing `bpf_program__attach_usdt()` to fail with -ENOENT
(unrecognized register).
This patch series adds support for SIB addressing mode in USDT probes.
The main changes include:
- add correct handling logic for SIB-addressed arguments in
`parse_usdt_arg`.
- add an usdt_o2 test case to cover SIB addressing mode.
Testing shows that the SIB probe correctly generates 8@(%rcx,%rax,8)
argument spec and passes all validation checks.
The modification history of this patch series:
Change since v1:
- refactor the code to make it more readable
- modify the commit message to explain why and how
Change since v2:
- fix the `scale` uninitialized error
Change since v3:
- force -O2 optimization for usdt.test.o to generate SIB addressing usdt
and pass all test cases.
Change since v4:
- split the patch into two parts, one for the fix and the other for the
test
Change since v5:
- Only enable optimization for x86 architecture to generate SIB addressing
usdt argument spec.
Change since v6:
- Add an usdt_o2 test case to cover SIB addressing mode.
- Reinstate the usdt.c test case.
Change since v7:
- Refactor modifications to __bpf_usdt_arg_spec to avoid increasing its size,
achieving better compatibility
- Fix some minor code style issues
- Refactor the usdt_o2 test case, removing semaphore and adding GCC attribute
to force -O2 optimization
Change since v8:
- Refactor the usdt_o2 test case, using assembly to force SIB addressing mode.
Change since v9:
- Only enable the usdt_o2 test case on x86_64 and i386 architectures since the
SIB addressing mode is only supported on x86_64 and i386.
Change since v10:
- Replace `__attribute__((optimize("O2")))` with `#pragma GCC optimize("O1")`
to fix the issue where the optimized compilation condition works improperly.
- Renamed test case usdt_o2 and relevant files name to usdt_o1 in that O1
level optimization is enough to generate SIB addressing usdt argument spec.
Jiawei Zhao (3):
libbpf: fix USDT SIB argument handling causing unrecognized register
error
selftests/bpf: Add an usdt_o1 test case in selftests to cover SIB
handling logic
selftests/bpf: make usdt_o1 reliably generate SIB USDT arg spec
tools/lib/bpf/usdt.bpf.h | 54 +++++++++++-
tools/lib/bpf/usdt.c | 61 ++++++++++++--
.../selftests/bpf/prog_tests/usdt_o1.c | 82 +++++++++++++++++++
.../selftests/bpf/progs/test_usdt_o1.c | 37 +++++++++
4 files changed, 227 insertions(+), 7 deletions(-)
create mode 100644 tools/testing/selftests/bpf/prog_tests/usdt_o1.c
create mode 100644 tools/testing/selftests/bpf/progs/test_usdt_o1.c
--
2.43.0
Add "extern" to the glibc-defined weak rseq symbols to convert the rseq
selftest's usage from weak symbol definitions to weak symbol _references_.
Effectively re-defining the glibc symbols wreaks havoc when building with
-fno-common, e.g. generates segfaults when running multi-threaded programs,
as dynamically linked applications end up with multiple versions of the
symbols.
Building with -fcommon, which until recently has the been the default for
GCC and clang, papers over the bug by allowing the linker to resolve the
weak/tentative definition to glibc's "real" definition.
Note, the symbol itself (or rather its address), not the value of the
symbol, is set to 0/NULL for unresolved weak symbol references, as the
symbol doesn't exist and thus can't have a value. Check for a NULL rseq
size pointer to handle the scenario where the test is statically linked
against a libc that doesn't support rseq in any capacity.
Fixes: 3bcbc20942db ("selftests/rseq: Play nice with binaries statically linked against glibc 2.35+")
Cc: stable(a)vger.kernel.org
Suggested-by: Florian Weimer <fweimer(a)redhat.com>
Reported-by: Thomas Gleixner <tglx(a)linutronix.de>
Closes: https://lore.kernel.org/all/87frdoybk4.ffs@tglx
Signed-off-by: Sean Christopherson <seanjc(a)google.com>
---
tools/testing/selftests/rseq/rseq.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/rseq/rseq.c b/tools/testing/selftests/rseq/rseq.c
index 663a9cef1952..dcac5cbe7933 100644
--- a/tools/testing/selftests/rseq/rseq.c
+++ b/tools/testing/selftests/rseq/rseq.c
@@ -40,9 +40,9 @@
* Define weak versions to play nice with binaries that are statically linked
* against a libc that doesn't support registering its own rseq.
*/
-__weak ptrdiff_t __rseq_offset;
-__weak unsigned int __rseq_size;
-__weak unsigned int __rseq_flags;
+extern __weak ptrdiff_t __rseq_offset;
+extern __weak unsigned int __rseq_size;
+extern __weak unsigned int __rseq_flags;
static const ptrdiff_t *libc_rseq_offset_p = &__rseq_offset;
static const unsigned int *libc_rseq_size_p = &__rseq_size;
@@ -209,7 +209,7 @@ void rseq_init(void)
* libc not having registered a restartable sequence. Try to find the
* symbols if that's the case.
*/
- if (!*libc_rseq_size_p) {
+ if (!libc_rseq_size_p || !*libc_rseq_size_p) {
libc_rseq_offset_p = dlsym(RTLD_NEXT, "__rseq_offset");
libc_rseq_size_p = dlsym(RTLD_NEXT, "__rseq_size");
libc_rseq_flags_p = dlsym(RTLD_NEXT, "__rseq_flags");
base-commit: c17b750b3ad9f45f2b6f7e6f7f4679844244f0b9
--
2.51.0.rc1.167.g924127e9c0-goog
Fix spelling mistakes:
tmp_trap.c:94 te -> the
tmp_trap.c:96 tread -> treated
reported by: codespell
Signed-off-by: Moktar SELLAMI <smokthar925(a)gmail.com>
---
tools/testing/selftests/powerpc/tm/tm-trap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/powerpc/tm/tm-trap.c b/tools/testing/selftests/powerpc/tm/tm-trap.c
index 97cb74768e30..298bd09c55bb 100644
--- a/tools/testing/selftests/powerpc/tm/tm-trap.c
+++ b/tools/testing/selftests/powerpc/tm/tm-trap.c
@@ -91,9 +91,9 @@ void trap_signal_handler(int signo, siginfo_t *si, void *uc)
* LE endianness does in effect nothing, instruction (2)
* is then executed again as 'trap', generating a second
* trap event (note that in that case 'trap' is caught
- * not in transacional mode). On te other hand, if after
+ * not in transacional mode). On the other hand, if after
* the return from the signal handler the endianness in-
- * advertently flipped, instruction (1) is tread as a
+ * advertently flipped, instruction (1) is treated as a
* branch instruction, i.e. b .+8, hence instruction (3)
* and (4) are executed (tbegin.; trap;) and we get sim-
* ilaly on the trap signal handler, but now in TM mode.
--
2.34.1
This patch corrects minor spelling mistake and adjusts comment style,
such as capitalizing the first letter for consistency.
In addition, "error: failed to find available memory address for mapping\n"
message replaces a not-quite-suitable one:"error: mmap doesn't like you\n".
No functional changes are introduced
Signed-off-by: Sunday Adelodun <adelodunolaoluwa(a)yahoo.com>
---
tools/testing/selftests/proc/fd-001-lookup.c | 4 ++--
tools/testing/selftests/proc/proc-maps-race.c | 22 +++++++++----------
.../selftests/proc/proc-self-map-files-002.c | 2 +-
tools/testing/selftests/proc/read.c | 2 +-
tools/testing/selftests/proc/setns-dcache.c | 2 +-
tools/testing/selftests/proc/setns-sysvipc.c | 2 +-
6 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/tools/testing/selftests/proc/fd-001-lookup.c b/tools/testing/selftests/proc/fd-001-lookup.c
index 60d7948e7124..2f5949593ad4 100644
--- a/tools/testing/selftests/proc/fd-001-lookup.c
+++ b/tools/testing/selftests/proc/fd-001-lookup.c
@@ -60,7 +60,7 @@ static void test_lookup(unsigned int fd)
snprintf(buf, sizeof(buf), "/proc/self/fd/%u", fd);
test_lookup_pass(buf);
- /* leading junk */
+ /* Leading junk */
for (c = 1; c <= 255; c++) {
if (c == '/')
continue;
@@ -68,7 +68,7 @@ static void test_lookup(unsigned int fd)
test_lookup_fail(buf);
}
- /* trailing junk */
+ /* Trailing junk */
for (c = 1; c <= 255; c++) {
if (c == '/')
continue;
diff --git a/tools/testing/selftests/proc/proc-maps-race.c b/tools/testing/selftests/proc/proc-maps-race.c
index 94bba4553130..2e730b70b171 100644
--- a/tools/testing/selftests/proc/proc-maps-race.c
+++ b/tools/testing/selftests/proc/proc-maps-race.c
@@ -138,10 +138,10 @@ static void copy_last_line(struct page_content *page, char *last_line)
{
/* Get the last line in the first page */
const char *end = page->data + page->size - 1;
- /* skip last newline */
+ /* Skip last newline */
const char *pos = end - 1;
- /* search previous newline */
+ /* Search previous newline */
while (pos[-1] != '\n')
pos--;
strncpy(last_line, pos, end - pos);
@@ -412,7 +412,7 @@ FIXTURE_SETUP(proc_maps_race)
self->vma_count = self->page_size / 32 + 1;
self->shared_mem_size = sizeof(struct vma_modifier_info) + self->vma_count * sizeof(void *);
- /* map shared memory for communication with the child process */
+ /* Map shared memory for communication with the child process */
self->mod_info = (struct vma_modifier_info *)mmap(NULL, self->shared_mem_size,
PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
ASSERT_NE(self->mod_info, MAP_FAILED);
@@ -439,7 +439,7 @@ FIXTURE_SETUP(proc_maps_race)
mod_info->child_mapped_addr[i] = mmap(NULL, self->page_size * 3, prot,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
ASSERT_NE(mod_info->child_mapped_addr[i], MAP_FAILED);
- /* change protection in adjacent maps to prevent merging */
+ /* Change protection in adjacent maps to prevent merging */
prot ^= PROT_WRITE;
}
signal_state(mod_info, CHILD_READY);
@@ -536,7 +536,7 @@ TEST_F(proc_maps_race, test_maps_tearing_from_split)
wait_for_state(mod_info, SETUP_READY);
- /* re-read the file to avoid using stale data from previous test */
+ /* Re-read the file to avoid using stale data from previous test */
ASSERT_TRUE(read_boundary_lines(self, &self->last_line, &self->first_line));
mod_info->vma_modify = split_vma;
@@ -600,7 +600,7 @@ TEST_F(proc_maps_race, test_maps_tearing_from_split)
} while (end_ts.tv_sec - start_ts.tv_sec < self->duration_sec);
end_test_loop(self->verbose);
- /* Signal the modifyer thread to stop and wait until it exits */
+ /* Signal the modifier thread to stop and wait until it exits */
signal_state(mod_info, TEST_DONE);
}
@@ -615,7 +615,7 @@ TEST_F(proc_maps_race, test_maps_tearing_from_resize)
wait_for_state(mod_info, SETUP_READY);
- /* re-read the file to avoid using stale data from previous test */
+ /* Re-read the file to avoid using stale data from previous test */
ASSERT_TRUE(read_boundary_lines(self, &self->last_line, &self->first_line));
mod_info->vma_modify = shrink_vma;
@@ -653,7 +653,7 @@ TEST_F(proc_maps_race, test_maps_tearing_from_resize)
strcmp(new_first_line.text, restored_last_line.text),
"Shrink result invalid", self));
} else {
- /* The vmas should be consistent with the original/resored state */
+ /* The vmas should be consistent with the original/restored state */
ASSERT_FALSE(print_boundaries_on(
strcmp(new_last_line.text, restored_last_line.text),
"Expand result invalid", self));
@@ -667,7 +667,7 @@ TEST_F(proc_maps_race, test_maps_tearing_from_resize)
} while (end_ts.tv_sec - start_ts.tv_sec < self->duration_sec);
end_test_loop(self->verbose);
- /* Signal the modifyer thread to stop and wait until it exits */
+ /* Signal the modifier thread to stop and wait until it exits */
signal_state(mod_info, TEST_DONE);
}
@@ -682,7 +682,7 @@ TEST_F(proc_maps_race, test_maps_tearing_from_remap)
wait_for_state(mod_info, SETUP_READY);
- /* re-read the file to avoid using stale data from previous test */
+ /* Re-read the file to avoid using stale data from previous test */
ASSERT_TRUE(read_boundary_lines(self, &self->last_line, &self->first_line));
mod_info->vma_modify = remap_vma;
@@ -734,7 +734,7 @@ TEST_F(proc_maps_race, test_maps_tearing_from_remap)
} while (end_ts.tv_sec - start_ts.tv_sec < self->duration_sec);
end_test_loop(self->verbose);
- /* Signal the modifyer thread to stop and wait until it exits */
+ /* Signal the modifier thread to stop and wait until it exits */
signal_state(mod_info, TEST_DONE);
}
diff --git a/tools/testing/selftests/proc/proc-self-map-files-002.c b/tools/testing/selftests/proc/proc-self-map-files-002.c
index e6aa00a183bc..ac05b0b127cd 100644
--- a/tools/testing/selftests/proc/proc-self-map-files-002.c
+++ b/tools/testing/selftests/proc/proc-self-map-files-002.c
@@ -67,7 +67,7 @@ int main(void)
break;
}
if (va == va_max) {
- fprintf(stderr, "error: mmap doesn't like you\n");
+ fprintf(stderr, "error: failed to find available memory address for mapping\n");
return 1;
}
diff --git a/tools/testing/selftests/proc/read.c b/tools/testing/selftests/proc/read.c
index 35ee78dff144..84f6f2e01150 100644
--- a/tools/testing/selftests/proc/read.c
+++ b/tools/testing/selftests/proc/read.c
@@ -41,7 +41,7 @@ static void f_reg(DIR *d, const char *filename)
int fd;
ssize_t rv;
- /* read from /proc/kmsg can block */
+ /* Read from /proc/kmsg can block */
fd = openat(dirfd(d), filename, O_RDONLY|O_NONBLOCK);
if (fd == -1)
return;
diff --git a/tools/testing/selftests/proc/setns-dcache.c b/tools/testing/selftests/proc/setns-dcache.c
index 60ab197a73fc..70389832dd22 100644
--- a/tools/testing/selftests/proc/setns-dcache.c
+++ b/tools/testing/selftests/proc/setns-dcache.c
@@ -50,7 +50,7 @@ int main(void)
atexit(f);
- /* Check for priviledges and syscall availability straight away. */
+ /* Check for privileges and syscall availability straight away. */
if (unshare(CLONE_NEWNET) == -1) {
if (errno == ENOSYS || errno == EPERM) {
return 4;
diff --git a/tools/testing/selftests/proc/setns-sysvipc.c b/tools/testing/selftests/proc/setns-sysvipc.c
index 903890c5e587..d03aa4838f0f 100644
--- a/tools/testing/selftests/proc/setns-sysvipc.c
+++ b/tools/testing/selftests/proc/setns-sysvipc.c
@@ -49,7 +49,7 @@ int main(void)
atexit(f);
- /* Check for priviledges and syscall availability straight away. */
+ /* Check for privileges and syscall availability straight away. */
if (unshare(CLONE_NEWIPC) == -1) {
if (errno == ENOSYS || errno == EPERM) {
return 4;
--
2.43.0
Currently it is not possible to disable streaming mode via ptrace on SME
only systems, the interface for doing this is to write via NT_ARM_SVE but
such writes will be rejected on a system without SVE support. Enable this
functionality by allowing userspace to write SVE_PT_REGS_FPSIMD format data
via NT_ARM_SVE with the vector length set to 0 on SME only systems. Such
writes currently error since we require that a vector length is specified
which should minimise the risk that existing software is relying on current
behaviour.
Reads are not supported since I am not aware of any use case for this and
there is some risk that an existing userspace application may be confused if
it reads NT_ARM_SVE on a system without SVE. Existing kernels will return
FPSIMD formatted register state from NT_ARM_SVE if full SVE state is not
stored, for example if the task has not used SVE. Returning a vector length
of 0 would create a risk that software could try to do things like allocate
space for register state with zero sizes, while returning a vector length of
128 bits would look like SVE is supported. It seems safer to just not make
the changes to add read support.
It remains possible for userspace to detect a SME only system via the ptrace
interface only since reads of NT_ARM_SSVE and NT_ARM_ZA will suceed while
reads of NT_ARM_SVE will fail. Read/write access to the FPSIMD registers in
non-streaming mode is available via REGSET_FPR.
The aim is is to make a minimally invasive change, no operation that would
previously have succeeded will be affected, and we use a previously defined
interface in new circumstances rather than define completely new ABI.
The series starts with some enhancements to sve-ptrace to cover some
further corners of existing behaviours in order to reduce the risk of
inadvertent changes, implements the proposed new ABI, then extends both
sve-ptrace and fp-ptrace to exercise it.
Signed-off-by: Mark Brown <broonie(a)kernel.org>
---
Mark Brown (5):
kselftest/arm64: Verify that we reject out of bounds VLs in sve-ptrace
kselftest/arm64: Check that unsupported regsets fail in sve-ptrace
arm64/sme: Support disabling streaming mode via ptrace on SME only systems
kselftst/arm64: Test NT_ARM_SVE FPSIMD format writes on non-SVE systems
kselftest/arm64: Cover disabling streaming mode without SVE in fp-ptrace
Documentation/arch/arm64/sve.rst | 5 +
arch/arm64/kernel/ptrace.c | 40 ++++++--
tools/testing/selftests/arm64/fp/fp-ptrace.c | 5 +-
tools/testing/selftests/arm64/fp/sve-ptrace.c | 139 +++++++++++++++++++++++++-
4 files changed, 177 insertions(+), 12 deletions(-)
---
base-commit: 768361ab16ce943ef3577cea204dc81aa4a47517
change-id: 20250717-arm64-sme-ptrace-sme-only-1fb850600ea0
prerequisite-change-id: 20250808-arm64-fp-trace-macro-02ede083da51
Best regards,
--
Mark Brown <broonie(a)kernel.org>
Correct spelling of 'occurrence' in uretprobe_stack.c comment. This
patch fixes a minor typo in the BPF selftest.
Signed-off-by: Kathara Sasikumar <katharasasikumar007(a)gmail.com>
---
tools/testing/selftests/bpf/progs/uretprobe_stack.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/bpf/progs/uretprobe_stack.c b/tools/testing/selftests/bpf/progs/uretprobe_stack.c
index 9fdcf396b8f4..cbc428a80744 100644
--- a/tools/testing/selftests/bpf/progs/uretprobe_stack.c
+++ b/tools/testing/selftests/bpf/progs/uretprobe_stack.c
@@ -27,7 +27,7 @@ SEC("uprobe//proc/self/exe:target_1")
int BPF_UPROBE(uprobe_1)
{
/* target_1 is recursive wit depth of 2, so we capture two separate
- * stack traces, depending on which occurence it is
+ * stack traces, depending on which occurrence it is
*/
static bool recur = false;
--
2.47.2
Correct spelling of address in conntrack_icmp_related.sh comment. This
patch fixes a minor typo in the selftest script for netfilter.
Signed-off-by: Kathara Sasikumar <katharasasikumar007(a)gmail.com>
---
tools/testing/selftests/net/netfilter/conntrack_icmp_related.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/netfilter/conntrack_icmp_related.sh b/tools/testing/selftests/net/netfilter/conntrack_icmp_related.sh
index c63d840ead61..f63b7f12b36a 100755
--- a/tools/testing/selftests/net/netfilter/conntrack_icmp_related.sh
+++ b/tools/testing/selftests/net/netfilter/conntrack_icmp_related.sh
@@ -171,7 +171,7 @@ table inet filter {
}
EOF
-# make sure NAT core rewrites adress of icmp error if nat is used according to
+# make sure NAT core rewrites address of icmp error if nat is used according to
# conntrack nat information (icmp error will be directed at nsrouter1 address,
# but it needs to be routed to nsclient1 address).
ip netns exec "$nsrouter1" nft -f - <<EOF
--
2.47.2