Getting a clean BPF selftests run involves ensuring latest trunk LLVM/clang
are used, pahole is recent (>=1.16) and config matches the specified
config file as closely as possible. Document all of this in the general
README.rst file. Also note how to work around timeout failures.
Signed-off-by: Alan Maguire <alan.maguire(a)oracle.com>
---
tools/testing/selftests/bpf/README.rst | 46 ++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/tools/testing/selftests/bpf/README.rst b/tools/testing/selftests/bpf/README.rst
index 0f67f1b..b00eebb 100644
--- a/tools/testing/selftests/bpf/README.rst
+++ b/tools/testing/selftests/bpf/README.rst
@@ -1,6 +1,52 @@
==================
BPF Selftest Notes
==================
+First verify the built kernel config options match the config options
+specified in the config file in this directory. Test failures for
+unknown helpers, inability to find BTF etc will be observed otherwise.
+
+To ensure the maximum number of tests pass, it is best to use the latest
+trunk LLVM/clang, i.e.
+
+git clone https://github.com/llvm/llvm-project
+
+Build/install trunk LLVM:
+
+.. code-block:: bash
+ git clone https://github.com/llvm/llvm-project
+ cd llvm-project
+ mkdir build/llvm
+ cd build/llvm
+ cmake ../../llvm/
+ make
+ sudo make install
+ cd ../../
+
+Build/install trunk clang:
+
+.. code-block:: bash
+ mkdir -p build/clang
+ cd build/clang
+ cmake ../../clang
+ make
+ sudo make install
+
+When building the kernel with CONFIG_DEBUG_INFO_BTF, pahole
+version 16 or later is also required for BTF function
+support. pahole can be built from the source at
+
+https://github.com/acmel/dwarves
+
+It is often available in "dwarves/libdwarves" packages also,
+but be aware that versions prior to 1.16 will fail with
+errors that functions cannot be found in BTF.
+
+When running selftests, the default timeout of 45 seconds
+can be exceeded by some tests. We can override the default
+timeout via a "settings" file; for example:
+
+.. code-block:: bash
+ echo "timeout=120" > tools/testing/selftests/bpf/settings
Additional information about selftest failures are
documented here.
--
1.8.3.1
The gen_kselftest_tar.sh always packages *all* selftests and doesn't
pass along any variables to `make install` to influence what should be
built. This can result in an early error on the command line ("Unknown
tarball format TARGETS=XXX"), or unexpected test failures as the
tarball contains tests people wanted to skip on purpose.
Since the makefile already contains all the logic, we can add a target
for packaging. Keep the default .gz target the script uses, and actually
extend the supported formats by using tar's autodetection.
To not break current workflows, keep the gen_kselftest_tar.sh script as
it is, with an added suggestion to use the makefile target instead.
Signed-off-by: Veronika Kabatova <vkabatov(a)redhat.com>
---
v2: overriden -> overridden, sent from the matching email address
Documentation/dev-tools/kselftest.rst | 23 ++++++++++++++++++++
tools/testing/selftests/Makefile | 9 +++++++-
tools/testing/selftests/gen_kselftest_tar.sh | 5 +++++
3 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/Documentation/dev-tools/kselftest.rst b/Documentation/dev-tools/kselftest.rst
index 61ae13c44f91..3fc559bcb597 100644
--- a/Documentation/dev-tools/kselftest.rst
+++ b/Documentation/dev-tools/kselftest.rst
@@ -151,6 +151,29 @@ note some tests will require root privileges::
$ cd kselftest
$ ./run_kselftest.sh
+Packaging selftests
+===================
+
+In some cases packaging is desired, such as when tests need to run on a
+different system. To package selftests, run::
+
+ $ make -C tools/testing/selftests gen_tar
+
+This generates a tarball in the `INSTALL_PATH/kselftest-packages` directory. By
+default, `.gz` format is used. The tar format can be overridden by specifying
+a `FORMAT` make variable. Any value recognized by `tar's auto-compress`_ option
+is supported, such as::
+
+ $ make -C tools/testing/selftests gen_tar FORMAT=.xz
+
+`make gen_tar` invokes `make install` so you can use it to package a subset of
+tests by using variables specified in `Running a subset of selftests`_
+section::
+
+ $ make -C tools/testing/selftests gen_tar TARGETS="bpf" FORMAT=.xz
+
+.. _tar's auto-compress: https://www.gnu.org/software/tar/manual/html_node/gzip.html#auto_002dcompre…
+
Contributing new tests
======================
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 2ff68702fd41..1195bd85af38 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -249,10 +249,17 @@ else
$(error Error: set INSTALL_PATH to use install)
endif
+FORMAT ?= .gz
+TAR_PATH = $(abspath ${INSTALL_PATH}/kselftest-packages/kselftest.tar${FORMAT})
+gen_tar: install
+ @mkdir -p ${INSTALL_PATH}/kselftest-packages/
+ @tar caf ${TAR_PATH} --exclude=kselftest-packages -C ${INSTALL_PATH} .
+ @echo "Created ${TAR_PATH}"
+
clean:
@for TARGET in $(TARGETS); do \
BUILD_TARGET=$$BUILD/$$TARGET; \
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
done;
-.PHONY: khdr all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean
+.PHONY: khdr all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean gen_tar
diff --git a/tools/testing/selftests/gen_kselftest_tar.sh b/tools/testing/selftests/gen_kselftest_tar.sh
index 8b2b6088540d..4a974bc03385 100755
--- a/tools/testing/selftests/gen_kselftest_tar.sh
+++ b/tools/testing/selftests/gen_kselftest_tar.sh
@@ -49,6 +49,11 @@ main()
# directory
./kselftest_install.sh "$install_dir"
(cd "$install_work"; tar $copts "$dest"/kselftest${ext} $install_name)
+
+ # Don't put the message at the actual end as people may be parsing the
+ # "archive created" line in their scripts.
+ echo -e "\nConsider using 'make gen_tar' instead of this script\n"
+
echo "Kselftest archive kselftest${ext} created!"
# clean up top-level install work directory
--
2.25.1
The gen_kselftest_tar.sh always packages *all* selftests and doesn't
pass along any variables to `make install` to influence what should be
built. This can result in an early error on the command line ("Unknown
tarball format TARGETS=XXX"), or unexpected test failures as the
tarball contains tests people wanted to skip on purpose.
Since the makefile already contains all the logic, we can add a target
for packaging. Keep the default .gz target the script uses, and actually
extend the supported formats by using tar's autodetection.
To not break current workflows, keep the gen_kselftest_tar.sh script as
it is, with an added suggestion to use the makefile target instead.
Signed-off-by: Veronika Kabatova <vkabatov(a)redhat.com>
Reviewed-by: Stefano Brivio <sbrivio(a)redhat.com>
---
Documentation/dev-tools/kselftest.rst | 23 ++++++++++++++++++++
tools/testing/selftests/Makefile | 9 +++++++-
tools/testing/selftests/gen_kselftest_tar.sh | 5 +++++
3 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/Documentation/dev-tools/kselftest.rst b/Documentation/dev-tools/kselftest.rst
index 61ae13c44f91..3fc559bcb597 100644
--- a/Documentation/dev-tools/kselftest.rst
+++ b/Documentation/dev-tools/kselftest.rst
@@ -151,6 +151,29 @@ note some tests will require root privileges::
$ cd kselftest
$ ./run_kselftest.sh
+Packaging selftests
+===================
+
+In some cases packaging is desired, such as when tests need to run on a
+different system. To package selftests, run::
+
+ $ make -C tools/testing/selftests gen_tar
+
+This generates a tarball in the `INSTALL_PATH/kselftest-packages` directory. By
+default, `.gz` format is used. The tar format can be overriden by specifying
+a `FORMAT` make variable. Any value recognized by `tar's auto-compress`_ option
+is supported, such as::
+
+ $ make -C tools/testing/selftests gen_tar FORMAT=.xz
+
+`make gen_tar` invokes `make install` so you can use it to package a subset of
+tests by using variables specified in `Running a subset of selftests`_
+section::
+
+ $ make -C tools/testing/selftests gen_tar TARGETS="bpf" FORMAT=.xz
+
+.. _tar's auto-compress: https://www.gnu.org/software/tar/manual/html_node/gzip.html#auto_002dcompre…
+
Contributing new tests
======================
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 2ff68702fd41..1195bd85af38 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -249,10 +249,17 @@ else
$(error Error: set INSTALL_PATH to use install)
endif
+FORMAT ?= .gz
+TAR_PATH = $(abspath ${INSTALL_PATH}/kselftest-packages/kselftest.tar${FORMAT})
+gen_tar: install
+ @mkdir -p ${INSTALL_PATH}/kselftest-packages/
+ @tar caf ${TAR_PATH} --exclude=kselftest-packages -C ${INSTALL_PATH} .
+ @echo "Created ${TAR_PATH}"
+
clean:
@for TARGET in $(TARGETS); do \
BUILD_TARGET=$$BUILD/$$TARGET; \
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
done;
-.PHONY: khdr all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean
+.PHONY: khdr all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean gen_tar
diff --git a/tools/testing/selftests/gen_kselftest_tar.sh b/tools/testing/selftests/gen_kselftest_tar.sh
index 8b2b6088540d..4a974bc03385 100755
--- a/tools/testing/selftests/gen_kselftest_tar.sh
+++ b/tools/testing/selftests/gen_kselftest_tar.sh
@@ -49,6 +49,11 @@ main()
# directory
./kselftest_install.sh "$install_dir"
(cd "$install_work"; tar $copts "$dest"/kselftest${ext} $install_name)
+
+ # Don't put the message at the actual end as people may be parsing the
+ # "archive created" line in their scripts.
+ echo -e "\nConsider using 'make gen_tar' instead of this script\n"
+
echo "Kselftest archive kselftest${ext} created!"
# clean up top-level install work directory
--
2.25.1
The test driver uses an xa_array to store virtual to physical address
translations for a simulated hardware device. The MMU notifier
invalidation callback is used to keep the table consistent with the CPU
page table and is frequently called only for a page or two. However, if
the test process exits unexpectedly or is killed, the range can be
[0..ULONG_MAX] in which case calling xa_erase() for every possible PFN
results in CPU timeouts.
Use xa_for_each_range() to efficiently erase entries in the range.
Signed-off-by: Ralph Campbell <rcampbell(a)nvidia.com>
---
This patch is based on Jason Gunthorpe's hmm tree and should be folded
into the ("mm/hmm/test: add selftest driver for HMM") patch once this
patch is reviewed, etc.
v1 -> v2:
Use xa_for_each_range() instead of special casing [0..ULONG_MAX].
lib/test_hmm.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/test_hmm.c b/lib/test_hmm.c
index 8b36c26b717b..5c1858e325ba 100644
--- a/lib/test_hmm.c
+++ b/lib/test_hmm.c
@@ -196,13 +196,15 @@ static void dmirror_do_update(struct dmirror *dmirror, unsigned long start,
unsigned long end)
{
unsigned long pfn;
+ void *entry;
/*
* The XArray doesn't hold references to pages since it relies on
* the mmu notifier to clear page pointers when they become stale.
* Therefore, it is OK to just clear the entry.
*/
- for (pfn = start >> PAGE_SHIFT; pfn < (end >> PAGE_SHIFT); pfn++)
+ xa_for_each_range(&dmirror->pt, pfn, entry, start >> PAGE_SHIFT,
+ end >> PAGE_SHIFT)
xa_erase(&dmirror->pt, pfn);
}
--
2.20.1
Here's a couple of tiny fixes, just so we can cleanly build
selftests/vm. These apply to today's linux.git. Some merge notes:
* The .gitignore fix is appropriate for linux.git, but it is a subset of
what's required for linux-next and mmotm. In order to fix things now
in linux.git, and keep it fixed in mmotm and linux-next, but without
manual intervention required in git merges, I'm adding the missing
item ("mremap_dontunmap") to the *top* of .gitignore for this patch.
And then I'll send a separate patch to be applied to mmotm and
linux-next, that will also add a different item ("khugepaged") to the
*bottom* of .gitignore.
* The write_to_hugetlbfs.c fix is already applied to linux-next, but
doesn't seem to be getting picked up for linux.git. Maybe it's in
the merge pipeline, but if not, let's fix it here, before the -rc
cycle is over.
John Hubbard (2):
selftests/vm/write_to_hugetlbfs.c: fix unused variable warning
selftests/vm/.gitignore: add mremap_dontunmap
tools/testing/selftests/vm/.gitignore | 1 +
tools/testing/selftests/vm/write_to_hugetlbfs.c | 2 --
2 files changed, 1 insertion(+), 2 deletions(-)
base-commit: 3d1c1e5931ce45b3a3f309385bbc00c78e9951c6
--
2.26.2
These apply to today's mmotm. Some merge notes:
* The missing item ("mremap_dontunmap") at the *top* of .gitignore
for this patch will also being applied to linux.git in a separate
patch [1].
The other missing item ("khugepaged") is added to *bottom* of
.gitignore. This approach allows merging to work without manual
intervention in this case.
[1] https://lore.kernel.org/r/20200517001245.361762-3-jhubbard@nvidia.com
John Hubbard (1):
selftests/vm/.gitignore: add khugepaged, mremap_dontunmap
tools/testing/selftests/vm/.gitignore | 2 ++
1 file changed, 2 insertions(+)
base-commit: 2bbf0589bfeb27800c730b76eacf34528eee5418
--
2.26.2
Please consider this version series ready for upstream acceptance.
This patch series adds partial read support in request_firmware_into_buf.
In order to accept the enhanced API it has been requested that kernel
selftests and upstreamed driver utilize the API enhancement and so
are included in this patch series.
Also in this patch series is the addition of a new Broadcom VK driver
utilizing the new request_firmware_into_buf enhanced API.
Changes from v4:
- handle reset issues if card crashes
- allow driver to have min required msix
- add card utilization information
Changes from v3:
- fix sparse warnings
- fix printf format specifiers for size_t
- fix 32-bit cross-compiling reports 32-bit shifts
- use readl/writel,_relaxed to access pci ioremap memory,
removed memory barriers and volatile keyword with such change
- driver optimizations for interrupt/poll functionalities
Changes from v2:
- remove unnecessary code and mutex locks in lib/test_firmware.c
- remove VK_IOCTL_ACCESS_BAR support from driver and use pci sysfs instead
- remove bitfields
- remove Kconfig default m
- adjust formatting and some naming based on feedback
- fix error handling conditions
- use appropriate return codes
- use memcpy_toio instead of direct access to PCIE bar
Scott Branden (7):
fs: introduce kernel_pread_file* support
firmware: add offset to request_firmware_into_buf
test_firmware: add partial read support for request_firmware_into_buf
firmware: test partial file reads of request_firmware_into_buf
bcm-vk: add bcm_vk UAPI
misc: bcm-vk: add Broadcom VK driver
MAINTAINERS: bcm-vk: add maintainer for Broadcom VK Driver
MAINTAINERS | 7 +
drivers/base/firmware_loader/firmware.h | 5 +
drivers/base/firmware_loader/main.c | 52 +-
drivers/misc/Kconfig | 1 +
drivers/misc/Makefile | 1 +
drivers/misc/bcm-vk/Kconfig | 29 +
drivers/misc/bcm-vk/Makefile | 12 +
drivers/misc/bcm-vk/bcm_vk.h | 435 +++++
drivers/misc/bcm-vk/bcm_vk_dev.c | 1256 +++++++++++++++
drivers/misc/bcm-vk/bcm_vk_legacy.c | 89 +
drivers/misc/bcm-vk/bcm_vk_msg.c | 1425 +++++++++++++++++
drivers/misc/bcm-vk/bcm_vk_msg.h | 196 +++
drivers/misc/bcm-vk/bcm_vk_sg.c | 271 ++++
drivers/misc/bcm-vk/bcm_vk_sg.h | 60 +
drivers/misc/bcm-vk/bcm_vk_tty.c | 352 ++++
drivers/soc/qcom/mdt_loader.c | 7 +-
fs/exec.c | 96 +-
include/linux/firmware.h | 8 +-
include/linux/fs.h | 20 +
include/uapi/linux/misc/bcm_vk.h | 99 ++
lib/test_firmware.c | 144 +-
.../selftests/firmware/fw_filesystem.sh | 80 +
22 files changed, 4596 insertions(+), 49 deletions(-)
create mode 100644 drivers/misc/bcm-vk/Kconfig
create mode 100644 drivers/misc/bcm-vk/Makefile
create mode 100644 drivers/misc/bcm-vk/bcm_vk.h
create mode 100644 drivers/misc/bcm-vk/bcm_vk_dev.c
create mode 100644 drivers/misc/bcm-vk/bcm_vk_legacy.c
create mode 100644 drivers/misc/bcm-vk/bcm_vk_msg.c
create mode 100644 drivers/misc/bcm-vk/bcm_vk_msg.h
create mode 100644 drivers/misc/bcm-vk/bcm_vk_sg.c
create mode 100644 drivers/misc/bcm-vk/bcm_vk_sg.h
create mode 100644 drivers/misc/bcm-vk/bcm_vk_tty.c
create mode 100644 include/uapi/linux/misc/bcm_vk.h
--
2.17.1