Most messages were perfect and so this is a minor pretty print change
Signed-off-by: Anup K Parikh <parikhanupk.foss(a)gmail.com>
---
tools/testing/selftests/cpufreq/cpu.sh | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/cpufreq/cpu.sh b/tools/testing/selftests/cpufreq/cpu.sh
index 39fdcdfb8..fac318e8f 100755
--- a/tools/testing/selftests/cpufreq/cpu.sh
+++ b/tools/testing/selftests/cpufreq/cpu.sh
@@ -49,11 +49,22 @@ reboot_cpu()
online_cpu $1
}
+#$1: number
+prettyprint_number_times()
+{
+ if [ "x$1" = "x1" ]; then
+ echo "once"
+ else
+ echo "$1 times"
+ fi
+}
+
# Reboot CPUs
# param: number of times we want to run the loop
reboot_cpus()
{
- printf "** Test: Running ${FUNCNAME[0]} for $1 loops **\n\n"
+ local ptimes=`prettyprint_number_times $1`
+ printf "** Test: Running ${FUNCNAME[0]} $ptimes **\n\n"
for i in `seq 1 $1`; do
for_each_non_boot_cpu offline_cpu
--
2.35.1
If the execution is skipped due to "jq not installed" message then
the installation methods on different OS's have been provided with
this message.
Signed-off-by: Piyush Thange <pthange19(a)gmail.com>
---
tools/testing/selftests/net/forwarding/lib.sh | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index 37ae49d47853..c4121856fe06 100755
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -152,6 +152,14 @@ require_command()
if [[ ! -x "$(command -v "$cmd")" ]]; then
echo "SKIP: $cmd not installed"
+ if [[ $cmd == "jq" ]]; then
+ echo " Install on Debian based systems"
+ echo " sudo apt -y install jq"
+ echo " Install on RHEL based systems"
+ echo " sudo yum -y install jq"
+ echo " Install on Fedora based systems"
+ echo " sudo dnf -y install jq"
+ fi
exit $ksft_skip
fi
}
--
2.37.1
There are two issues in current rseq_test implementation and the
series intends to fix them:
- From glibc-2.35, rseq information is registered by TLS. It means
rseq_test is unable to register its own rseq information. PATCH[01]
fixes the issue by reusing "../rseq/rseq.c" to fetch TLS's rseq
information if possible.
- sched_getcpu() relies on glibc's implementation and it can simply
returns the CPU ID cached in the rseq information. In this case,
it's pointless to compare the return value from sched_getcpu()
and that fetched from rseq information. PATCH[02] fixes the issue
by replacing sched_getcpu() with getcpu().
v1: https://lore.kernel.org/lkml/8c1f33b4-a5a1-fcfa-4521-36253ffa22c8@redhat.co…
Changelog
=========
v2:
* Add "-ldl" to LDLIBS as Florian suggested.
* Reuse "../rseq/rseq.c" as Paolo/Mathieu/Sean suggested.
* Add comments to sys_getcpu() as Sean suggested.
Gavin Shan (2):
KVM: selftests: Make rseq compatible with glibc-2.35
KVM: selftests: Use getcpu() instead of sched_getcpu() in rseq_test
tools/testing/selftests/kvm/Makefile | 5 ++-
tools/testing/selftests/kvm/rseq_test.c | 60 ++++++++++++-------------
2 files changed, 33 insertions(+), 32 deletions(-)
--
2.23.0
There are two issues in current rseq_test implementation and the
series intends to fix them:
- From glibc-2.35, rseq information is registered by TLS. It means
rseq_test is unable to register its own rseq information. PATCH[01]
fixes the issue by reuse TLS's rseq information if needed.
- sched_getcpu() relies on glibc's implementation and it can simply
returns the CPU ID cached in the rseq information. In this case,
it's pointless to compare the return value from sched_getcpu()
and that fetched from rseq information. PATCH[02] fixes the issue
by replacing sched_getcpu() with getcpu().
Gavin Shan (2):
KVM: selftests: Make rseq compatible with glibc-2.35
KVM: selftests: Use getcpu() instead of sched_getcpu() in rseq_test
tools/testing/selftests/kvm/rseq_test.c | 62 ++++++++++++++++++-------
1 file changed, 44 insertions(+), 18 deletions(-)
--
2.23.0
With
$ kunit.py run --raw_output=all ...
you get the raw output from the kernel, e.g. something like
> TAP version 14
> 1..26
> # Subtest: time_test_cases
> 1..1
> ok 1 - time64_to_tm_test_date_range
> ok 1 - time_test_cases
But --raw_output=kunit or equivalently --raw_output, you get
> TAP version 14
> 1..26
> # Subtest: time_test_cases
> 1..1
> ok 1 - time64_to_tm_test_date_range
> ok 1 - time_test_cases
It looks less readable in my opinion, and it also isn't "raw output."
This is due to sharing code with kunit_parser.py, which wants to strip
leading whitespace since it uses anchored regexes.
We could update the kunit_parser.py code to tolerate leaading spaces,
but this patch takes the easier way out and adds a bool flag.
Signed-off-by: Daniel Latypov <dlatypov(a)google.com>
---
tools/testing/kunit/kunit.py | 2 +-
tools/testing/kunit/kunit_parser.py | 10 ++++++----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py
index e132b0654029..161a3b1b0217 100755
--- a/tools/testing/kunit/kunit.py
+++ b/tools/testing/kunit/kunit.py
@@ -206,7 +206,7 @@ def parse_tests(request: KunitParseRequest, metadata: kunit_json.Metadata, input
if request.raw_output == 'all':
pass
elif request.raw_output == 'kunit':
- output = kunit_parser.extract_tap_lines(output)
+ output = kunit_parser.extract_tap_lines(output, lstrip=False)
for line in output:
print(line.rstrip())
diff --git a/tools/testing/kunit/kunit_parser.py b/tools/testing/kunit/kunit_parser.py
index 12d3ec77f427..1ae873e3e341 100644
--- a/tools/testing/kunit/kunit_parser.py
+++ b/tools/testing/kunit/kunit_parser.py
@@ -218,7 +218,7 @@ TAP_START = re.compile(r'TAP version ([0-9]+)$')
KTAP_END = re.compile('(List of all partitions:|'
'Kernel panic - not syncing: VFS:|reboot: System halted)')
-def extract_tap_lines(kernel_output: Iterable[str]) -> LineStream:
+def extract_tap_lines(kernel_output: Iterable[str], lstrip=True) -> LineStream:
"""Extracts KTAP lines from the kernel output."""
def isolate_ktap_output(kernel_output: Iterable[str]) \
-> Iterator[Tuple[int, str]]:
@@ -244,9 +244,11 @@ def extract_tap_lines(kernel_output: Iterable[str]) -> LineStream:
# stop extracting KTAP lines
break
elif started:
- # remove prefix and any indention and yield
- # line with line number
- line = line[prefix_len:].lstrip()
+ # remove the prefix and optionally any leading
+ # whitespace. Our parsing logic relies on this.
+ line = line[prefix_len:]
+ if lstrip:
+ line = line.lstrip()
yield line_num, line
return LineStream(lines=isolate_ktap_output(kernel_output))
base-commit: aeb6e6ac18c73ec287b3b1e2c913520699358c13
--
2.37.1.559.g78731f0fdb-goog
Commit 49de12ba06ef ("selftests: drop KSFT_KHDR_INSTALL make target")
dropped from tools/testing/selftests/lib.mk the code related to KSFT_KHDR_INSTALL,
but in doing so it also dropped the definition of the ARCH variable. The ARCH
variable is used in several subdirectories, but kvm/ is the only one of these
that was using KSFT_KHDR_INSTALL.
As a result, kvm selftests cannot be built anymore:
In file included from include/x86_64/vmx.h:12,
from x86_64/vmx_pmu_caps_test.c:18:
include/x86_64/processor.h:15:10: fatal error: asm/msr-index.h: No such file or directory
15 | #include <asm/msr-index.h>
| ^~~~~~~~~~~~~~~~~
In file included from ../../../../tools/include/asm/atomic.h:6,
from ../../../../tools/include/linux/atomic.h:5,
from rseq_test.c:15:
../../../../tools/include/asm/../../arch/x86/include/asm/atomic.h:11:10: fatal error: asm/cmpxchg.h: No such file or directory
11 | #include <asm/cmpxchg.h>
| ^~~~~~~~~~~~~~~
Fix it by including the definition that was present in lib.mk.
Fixes: 49de12ba06ef ("selftests: drop KSFT_KHDR_INSTALL make target")
Cc: Guillaume Tucker <guillaume.tucker(a)collabora.com>
Cc: Anders Roxell <anders.roxell(a)linaro.org>
Cc: Shuah Khan <skhan(a)linuxfoundation.org>
Cc: linux-kselftest(a)vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini(a)redhat.com>
---
tools/testing/selftests/kvm/Makefile | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
index 89c9a8c52c5f..4c122f1b1737 100644
--- a/tools/testing/selftests/kvm/Makefile
+++ b/tools/testing/selftests/kvm/Makefile
@@ -4,6 +4,8 @@ include ../../../build/Build.include
all:
top_srcdir = ../../../..
+include $(top_srcdir)/scripts/subarch.include
+ARCH ?= $(SUBARCH)
# For cross-builds to work, UNAME_M has to map to ARCH and arch specific
# directories and targets in this Makefile. "uname -m" doesn't map to
--
2.31.1
Hello,
This patch series implements a new syscall, process_memwatch. Currently,
only the support to watch soft-dirty PTE bit is added. This syscall is
generic to watch the memory of the process. There is enough room to add
more operations like this to watch memory in the future.
Soft-dirty PTE bit of the memory pages can be viewed by using pagemap
procfs file. The soft-dirty PTE bit for the memory in a process can be
cleared by writing to the clear_refs file. This series adds features that
weren't possible through the Proc FS interface.
- There is no atomic get soft-dirty PTE bit status and clear operation
possible.
- The soft-dirty PTE bit of only a part of memory cannot be cleared.
Historically, soft-dirty PTE bit tracking has been used in the CRIU
project. The Proc FS interface is enough for that as I think the process
is frozen. We have the use case where we need to track the soft-dirty
PTE bit for running processes. We need this tracking and clear mechanism
of a region of memory while the process is running to emulate the
getWriteWatch() syscall of Windows. This syscall is used by games to keep
track of dirty pages and keep processing only the dirty pages. This
syscall can be used by the CRIU project and other applications which
require soft-dirty PTE bit information.
As in the current kernel there is no way to clear a part of memory (instead
of clearing the Soft-Dirty bits for the entire processi) and get+clear
operation cannot be performed atomically, there are other methods to mimic
this information entirely in userspace with poor performance:
- The mprotect syscall and SIGSEGV handler for bookkeeping
- The userfaultfd syscall with the handler for bookkeeping
long process_memwatch(int pidfd, unsigned long start, int len,
unsigned int flags, void *vec, int vec_len);
This syscall can be used by the CRIU project and other applications which
require soft-dirty PTE bit information. The following operations are
supported in this syscall:
- Get the pages that are soft-dirty.
- Clear the pages which are soft-dirty.
- The optional flag to ignore the VM_SOFTDIRTY and only track per page
soft-dirty PTE bit
There are two decisions which have been taken about how to get the output
from the syscall.
- Return offsets of the pages from the start in the vec
- Stop execution when vec is filled with dirty pages
These two arguments doesn't follow the mincore() philosophy where the
output array corresponds to the address range in one to one fashion, hence
the output buffer length isn't passed and only a flag is set if the page
is present. This makes mincore() easy to use with less control. We are
passing the size of the output array and putting return data consecutively
which is offset of dirty pages from the start. The user can convert these
offsets back into the dirty page addresses easily. Suppose, the user want
to get first 10 dirty pages from a total memory of 100 pages. He'll
allocate output buffer of size 10 and process_memwatch() syscall will
abort after finding the 10 pages. This behaviour is needed to support
Windows' getWriteWatch(). The behaviour like mincore() can be achieved by
passing output buffer of 100 size. This interface can be used for any
desired behaviour.
Regards,
Muhammad Usama Anjum
Muhammad Usama Anjum (5):
fs/proc/task_mmu: make functions global to be used in other files
mm: Implement process_memwatch syscall
mm: wire up process_memwatch syscall for x86
selftests: vm: add process_memwatch syscall tests
mm: add process_memwatch syscall documentation
Documentation/admin-guide/mm/soft-dirty.rst | 48 +-
arch/x86/entry/syscalls/syscall_32.tbl | 1 +
arch/x86/entry/syscalls/syscall_64.tbl | 1 +
fs/proc/task_mmu.c | 84 +--
include/linux/mm_inline.h | 99 +++
include/linux/syscalls.h | 3 +-
include/uapi/asm-generic/unistd.h | 5 +-
include/uapi/linux/memwatch.h | 12 +
kernel/sys_ni.c | 1 +
mm/Makefile | 2 +-
mm/memwatch.c | 285 ++++++++
tools/include/uapi/asm-generic/unistd.h | 5 +-
.../arch/x86/entry/syscalls/syscall_64.tbl | 1 +
tools/testing/selftests/vm/.gitignore | 1 +
tools/testing/selftests/vm/Makefile | 2 +
tools/testing/selftests/vm/memwatch_test.c | 635 ++++++++++++++++++
16 files changed, 1098 insertions(+), 87 deletions(-)
create mode 100644 include/uapi/linux/memwatch.h
create mode 100644 mm/memwatch.c
create mode 100644 tools/testing/selftests/vm/memwatch_test.c
--
2.30.2