License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 15:07:57 +01:00
# SPDX-License-Identifier: GPL-2.0
2012-03-28 14:42:56 -07:00
# Makefile for vm selftests
selftests/vm: hmm-tests: remove the libhugetlbfs dependency
HMM selftests are incredibly useful, but they are only effective if people
actually build and run them. All the other tests in selftests/vm can be
built with very standard, always-available libraries: libpthread, librt.
The hmm-tests.c program, on the other hand, requires something that is
(much) less readily available: libhugetlbfs. And so the build will
typically fail for many developers.
A simple attempt to install libhugetlbfs will also run into complications
on some common distros these days: Fedora and Arch Linux (yes, Arch AUR
has it, but that's fragile, as always with AUR). The library is not
maintained actively enough at the moment, for distros to deal with it. I
had to build it from source, for Fedora, and that didn't go too smoothly
either.
It turns out that, out of 21 tests in hmm-tests.c, only 2 actually require
functionality from libhugetlbfs. Therefore, if libhugetlbfs is missing,
simply ifdef those two tests out and allow the developer to at least have
the other 19 tests, if they don't want to pause to work through the above
issues. Also issue a warning, so that it's clear that there is an
imperfection in the build.
In order to do that, a tiny shell script (check_config.sh) runs a quick
compile (not link, that's too prone to false failures with library paths),
and basically, if the compiler doesn't find hugetlbfs.h in its standard
locations, then the script concludes that libhugetlbfs is not available.
The output is in two files, one for inclusion in hmm-test.c
(local_config.h), and one for inclusion in the Makefile (local_config.mk).
Link: https://lkml.kernel.org/r/20201026064021.3545418-9-jhubbard@nvidia.com
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Cc: Ralph Campbell <rcampbell@nvidia.com>
Cc: Jérôme Glisse <jglisse@redhat.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-12-14 19:05:28 -08:00
i n c l u d e l o c a l _ c o n f i g . m k
2019-10-23 13:57:49 +09:00
uname_M := $( shell uname -m 2>/dev/null || echo not)
2020-12-29 15:14:22 -08:00
MACHINE ?= $( shell echo $( uname_M) | sed -e 's/aarch64.*/arm64/' -e 's/ppc64.*/ppc64/' )
2012-03-28 14:42:56 -07:00
selftests/vm: fix false build success on the second and later attempts
Patch series "selftests/vm: fix some minor aggravating factors in the Makefile".
This fixes a couple of minor aggravating factors that I ran across while
trying to do some changes in selftests/vm. These are simple things, but
like most things with GNU Make, it's rarely obvious what's wrong until you
understand *the entire Makefile and all of its includes*.
So while there is, of course, joy in learning those details, I thought I'd
fix these little things, so as to allow others to skip out on the Joy if
they so choose. :)
First of all, if you have an item (let's choose userfaultfd for an
example) that fails to build, you might do this:
$ make -j32
# ...you observe a failed item in the threaded output
# OK, let's get a closer look
$ make
# ...but now the build quietly "succeeds".
That's what Patch 0001 fixes.
Second, if you instead attempt this approach for your closer look (a casual
mistake, as it's not supported):
$ make userfaultfd
# ...userfaultfd fails to link, due to incomplete LDLIBS
That's what Patch 0002 fixes.
This patch (of 2):
If one or more of these selftest fail to build, then after the first
failure, subsequent invocations of "make" will make it appear that there
are no build failures, after all.
That's because the failed build products remain, with up-to-date
timestamps, thus tricking Make (and you!) into believing that there's
nothing else to build.
Fix this by telling Make to delete targets that didn't completely
succeed.
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Link: https://lkml.kernel.org/r/20200915012901.1655280-1-jhubbard@nvidia.com
Link: https://lkml.kernel.org/r/20200915012901.1655280-2-jhubbard@nvidia.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-10-13 16:53:16 -07:00
# Without this, failed build products remain, with up-to-date timestamps,
# thus tricking Make (and you!) into believing that All Is Well, in subsequent
# make invocations:
.DELETE_ON_ERROR :
2020-10-13 16:53:19 -07:00
# Avoid accidental wrong builds, due to built-in rules working just a little
# bit too well--but not quite as well as required for our situation here.
#
# In other words, "make userfaultfd" is supposed to fail to build at all,
# because this Makefile only supports either "make" (all), or "make /full/path".
# However, the built-in rules, if not suppressed, will pick up CFLAGS and the
# initial LDLIBS (but not the target-specific LDLIBS, because those are only
# set for the full path target!). This causes it to get pretty far into building
# things despite using incorrect values such as an *occasionally* incomplete
# LDLIBS.
MAKEFLAGS += --no-builtin-rules
2022-01-19 15:15:30 +05:00
CFLAGS = -Wall -I ../../../../usr/include $( EXTRA_CFLAGS) $( KHDR_INCLUDES)
2020-12-14 19:05:14 -08:00
LDLIBS = -lrt -lpthread
2016-11-29 19:55:47 +08:00
TEST_GEN_FILES = compaction_test
mm/gup_benchmark: rename to mm/gup_test
Patch series "selftests/vm: gup_test, hmm-tests, assorted improvements", v3.
Summary: This series provides two main things, and a number of smaller
supporting goodies. The two main points are:
1) Add a new sub-test to gup_test, which in turn is a renamed version
of gup_benchmark. This sub-test allows nicer testing of dump_pages(),
at least on user-space pages.
For quite a while, I was doing a quick hack to gup_test.c whenever I
wanted to try out changes to dump_page(). Then Matthew Wilcox asked me
what I meant when I said "I used my dump_page() unit test", and I
realized that it might be nice to check in a polished up version of
that.
Details about how it works and how to use it are in the commit
description for patch #6 ("selftests/vm: gup_test: introduce the
dump_pages() sub-test").
2) Fixes a limitation of hmm-tests: these tests are incredibly useful,
but only if people actually build and run them. And it turns out that
libhugetlbfs is a little too effective at throwing a wrench in the
works, there. So I've added a little configuration check that removes
just two of the 21 hmm-tests, if libhugetlbfs is not available.
Further details in the commit description of patch #8
("selftests/vm: hmm-tests: remove the libhugetlbfs dependency").
Other smaller things that this series does:
a) Remove code duplication by creating gup_test.h.
b) Clear up the sub-test organization, and their invocation within
run_vmtests.sh.
c) Other minor assorted improvements.
[1] v2 is here:
https://lore.kernel.org/linux-doc/20200929212747.251804-1-jhubbard@nvidia.com/
[2] https://lore.kernel.org/r/CAHk-=wgh-TMPHLY3jueHX7Y2fWh3D+nMBqVS__AZm6-oorquWA@mail.gmail.com
This patch (of 9):
Rename nearly every "gup_benchmark" reference and file name to "gup_test".
The one exception is for the actual gup benchmark test itself.
The current code already does a *little* bit more than benchmarking, and
definitely covers more than get_user_pages_fast(). More importantly,
however, subsequent patches are about to add some functionality that is
non-benchmark related.
Closely related changes:
* Kconfig: in addition to renaming the options from GUP_BENCHMARK to
GUP_TEST, update the help text to reflect that it's no longer a
benchmark-only test.
Link: https://lkml.kernel.org/r/20201026064021.3545418-1-jhubbard@nvidia.com
Link: https://lkml.kernel.org/r/20201026064021.3545418-2-jhubbard@nvidia.com
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Jérôme Glisse <jglisse@redhat.com>
Cc: Ralph Campbell <rcampbell@nvidia.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-12-14 19:05:05 -08:00
TEST_GEN_FILES += gup_test
2020-04-22 12:50:27 -07:00
TEST_GEN_FILES += hmm-tests
2016-11-29 19:55:47 +08:00
TEST_GEN_FILES += hugepage-mmap
2021-11-05 13:41:43 -07:00
TEST_GEN_FILES += hugepage-mremap
2016-11-29 19:55:47 +08:00
TEST_GEN_FILES += hugepage-shm
2020-12-14 19:05:14 -08:00
TEST_GEN_FILES += khugepaged
2021-06-30 18:52:39 -07:00
TEST_GEN_FILES += madv_populate
2018-10-26 15:10:48 -07:00
TEST_GEN_FILES += map_fixed_noreplace
2020-12-14 19:05:14 -08:00
TEST_GEN_FILES += map_hugetlb
2018-08-21 21:53:47 -07:00
TEST_GEN_FILES += map_populate
2021-07-07 18:08:15 -07:00
TEST_GEN_FILES += memfd_secret
2018-01-31 16:16:59 -08:00
TEST_GEN_FILES += mlock-random-test
2016-11-29 19:55:47 +08:00
TEST_GEN_FILES += mlock2-tests
2020-04-01 21:09:20 -07:00
TEST_GEN_FILES += mremap_dontunmap
2020-12-14 19:07:25 -08:00
TEST_GEN_FILES += mremap_test
2016-11-29 19:55:47 +08:00
TEST_GEN_FILES += on-fault-limit
TEST_GEN_FILES += thuge-gen
TEST_GEN_FILES += transhuge-stress
TEST_GEN_FILES += userfaultfd
2021-05-04 18:34:23 -07:00
TEST_GEN_FILES += split_huge_page_test
2021-09-02 15:00:39 -07:00
TEST_GEN_FILES += ksm_tests
2019-10-23 13:57:49 +09:00
2020-12-29 15:14:22 -08:00
i f e q ( $( MACHINE ) , x 8 6 _ 6 4 )
2020-06-04 16:52:54 -07:00
CAN_BUILD_I386 := $( shell ./../x86/check_cc.sh $( CC) ../x86/trivial_32bit_program.c -m32)
CAN_BUILD_X86_64 := $( shell ./../x86/check_cc.sh $( CC) ../x86/trivial_64bit_program.c)
CAN_BUILD_WITH_NOPIE := $( shell ./../x86/check_cc.sh $( CC) ../x86/trivial_program.c -no-pie)
TARGETS := protection_keys
BINARIES_32 := $( TARGETS:%= %_32)
BINARIES_64 := $( TARGETS:%= %_64)
i f e q ( $( CAN_BUILD_WITH_NOPIE ) , 1 )
CFLAGS += -no-pie
e n d i f
i f e q ( $( CAN_BUILD_I 386) , 1 )
TEST_GEN_FILES += $( BINARIES_32)
e n d i f
i f e q ( $( CAN_BUILD_X 86_ 64) , 1 )
TEST_GEN_FILES += $( BINARIES_64)
e n d i f
e l s e
2020-12-05 22:15:02 -08:00
2020-12-29 15:14:22 -08:00
i f n e q ( , $( findstring $ ( MACHINE ) ,ppc 64) )
2020-06-04 16:52:54 -07:00
TEST_GEN_FILES += protection_keys
e n d i f
2020-12-05 22:15:02 -08:00
e n d i f
2020-12-29 15:14:22 -08:00
i f n e q ( , $( filter $ ( MACHINE ) ,arm 64 ia 64 mips 64 parisc 64 ppc 64 riscv 64 s 390x sh 64 sparc 64 x 86_ 64) )
2018-01-31 16:16:59 -08:00
TEST_GEN_FILES += va_128TBswitch
2017-05-08 16:00:19 -07:00
TEST_GEN_FILES += virtual_address_range
2020-04-01 21:11:38 -07:00
TEST_GEN_FILES += write_to_hugetlbfs
2019-10-23 13:57:49 +09:00
e n d i f
2012-03-28 14:42:56 -07:00
2020-12-14 19:05:11 -08:00
TEST_PROGS := run_vmtests.sh
2015-03-11 15:05:59 +11:00
2019-05-28 13:18:09 +01:00
TEST_FILES := test_vmalloc.sh
2018-12-12 20:25:14 -07:00
KSFT_KHDR_INSTALL := 1
2015-03-11 15:05:59 +11:00
i n c l u d e . . / l i b . m k
2012-03-28 14:42:56 -07:00
2020-12-29 15:14:22 -08:00
i f e q ( $( MACHINE ) , x 8 6 _ 6 4 )
2020-06-04 16:52:54 -07:00
BINARIES_32 := $( patsubst %,$( OUTPUT) /%,$( BINARIES_32) )
BINARIES_64 := $( patsubst %,$( OUTPUT) /%,$( BINARIES_64) )
d e f i n e g e n - t a r g e t - r u l e - 3 2
$(1) $(1)_32 : $( OUTPUT ) /$( 1) _ 32
.PHONY : $( 1) $( 1) _ 32
e n d e f
d e f i n e g e n - t a r g e t - r u l e - 6 4
$(1) $(1)_64 : $( OUTPUT ) /$( 1) _ 64
.PHONY : $( 1) $( 1) _ 64
e n d e f
i f e q ( $( CAN_BUILD_I 386) , 1 )
2021-06-30 18:57:03 -07:00
$(BINARIES_32) : CFLAGS += -m 32 -mxsave
2020-06-04 16:52:54 -07:00
$(BINARIES_32) : LDLIBS += -lrt -ldl -lm
2021-03-24 21:37:26 -07:00
$(BINARIES_32) : $( OUTPUT ) /%_ 32: %.c
2020-06-04 16:52:54 -07:00
$( CC) $( CFLAGS) $( EXTRA_CFLAGS) $( notdir $^) $( LDLIBS) -o $@
$( foreach t ,$ ( TARGETS ) ,$ ( eval $ ( call gen -target -rule -32,$ ( t ) ) ) )
e n d i f
i f e q ( $( CAN_BUILD_X 86_ 64) , 1 )
2021-06-30 18:57:03 -07:00
$(BINARIES_64) : CFLAGS += -m 64 -mxsave
2020-06-04 16:52:54 -07:00
$(BINARIES_64) : LDLIBS += -lrt -ldl
2021-03-24 21:37:26 -07:00
$(BINARIES_64) : $( OUTPUT ) /%_ 64: %.c
2020-06-04 16:52:54 -07:00
$( CC) $( CFLAGS) $( EXTRA_CFLAGS) $( notdir $^) $( LDLIBS) -o $@
$( foreach t ,$ ( TARGETS ) ,$ ( eval $ ( call gen -target -rule -64,$ ( t ) ) ) )
e n d i f
# x86_64 users should be encouraged to install 32-bit libraries
i f e q ( $( CAN_BUILD_I 386) $( CAN_BUILD_X 86_ 64) , 0 1 )
all : warn_ 32bit_failure
warn_32bit_failure :
@echo "Warning: you seem to have a broken 32-bit build" 2>& 1; \
echo "environment. This will reduce test coverage of 64-bit" 2>& 1; \
echo "kernels. If you are using a Debian-like distribution," 2>& 1; \
echo "try:" ; 2>& 1; \
echo "" ; \
echo " apt-get install gcc-multilib libc6-i386 libc6-dev-i386" ; \
echo "" ; \
echo "If you are using a Fedora-like distribution, try:" ; \
echo "" ; \
echo " yum install glibc-devel.*i686" ; \
exit 0;
e n d i f
e n d i f
2021-07-07 18:08:15 -07:00
$(OUTPUT)/mlock-random-test $(OUTPUT)/memfd_secret : LDLIBS += -lcap
selftests/vm: use a common gup_test.h
Avoid the need to copy-paste the gup_test ioctl commands and the struct
gup_test definition, between the kernel and the user space application, by
providing a new header file for these. This allows easier and safer
adding of new ioctl calls, as well as reducing the overall line count.
Details: The header file has to be able to compile independently, because
of the arguably unfortunate way that the Makefile is written: the Makefile
tries to build all of its prerequisites, when really it should be only
building the .c files, and leaving the other prerequisites (LOCAL_HDRS) as
pure dependencies.
That Makefile limitation is probably not worth fixing, but it explains why
one of the includes had to be moved into the new header file.
Also: simplify the ioctl struct (struct gup_test), by deleting the unused
__expansion[10] field. This sort of thing is what you might see in a
stable ABI, but this low-level, kernel-developer-oriented selftests/vm
system is very much not subject to ABI stability. So "expansion" and
"reserved" fields are unnecessary here.
Link: https://lkml.kernel.org/r/20201026064021.3545418-3-jhubbard@nvidia.com
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Cc: Jérôme Glisse <jglisse@redhat.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Ralph Campbell <rcampbell@nvidia.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-12-14 19:05:08 -08:00
$(OUTPUT)/gup_test : ../../../../mm /gup_test .h
selftests/vm: hmm-tests: remove the libhugetlbfs dependency
HMM selftests are incredibly useful, but they are only effective if people
actually build and run them. All the other tests in selftests/vm can be
built with very standard, always-available libraries: libpthread, librt.
The hmm-tests.c program, on the other hand, requires something that is
(much) less readily available: libhugetlbfs. And so the build will
typically fail for many developers.
A simple attempt to install libhugetlbfs will also run into complications
on some common distros these days: Fedora and Arch Linux (yes, Arch AUR
has it, but that's fragile, as always with AUR). The library is not
maintained actively enough at the moment, for distros to deal with it. I
had to build it from source, for Fedora, and that didn't go too smoothly
either.
It turns out that, out of 21 tests in hmm-tests.c, only 2 actually require
functionality from libhugetlbfs. Therefore, if libhugetlbfs is missing,
simply ifdef those two tests out and allow the developer to at least have
the other 19 tests, if they don't want to pause to work through the above
issues. Also issue a warning, so that it's clear that there is an
imperfection in the build.
In order to do that, a tiny shell script (check_config.sh) runs a quick
compile (not link, that's too prone to false failures with library paths),
and basically, if the compiler doesn't find hugetlbfs.h in its standard
locations, then the script concludes that libhugetlbfs is not available.
The output is in two files, one for inclusion in hmm-test.c
(local_config.h), and one for inclusion in the Makefile (local_config.mk).
Link: https://lkml.kernel.org/r/20201026064021.3545418-9-jhubbard@nvidia.com
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Cc: Ralph Campbell <rcampbell@nvidia.com>
Cc: Jérôme Glisse <jglisse@redhat.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-12-14 19:05:28 -08:00
$(OUTPUT)/hmm-tests : local_config .h
# HMM_EXTRA_LIBS may get set in local_config.mk, or it may be left empty.
$(OUTPUT)/hmm-tests : LDLIBS += $( HMM_EXTRA_LIBS )
2021-09-02 15:00:48 -07:00
$(OUTPUT)/ksm_tests : LDLIBS += -lnuma
selftests/vm: hmm-tests: remove the libhugetlbfs dependency
HMM selftests are incredibly useful, but they are only effective if people
actually build and run them. All the other tests in selftests/vm can be
built with very standard, always-available libraries: libpthread, librt.
The hmm-tests.c program, on the other hand, requires something that is
(much) less readily available: libhugetlbfs. And so the build will
typically fail for many developers.
A simple attempt to install libhugetlbfs will also run into complications
on some common distros these days: Fedora and Arch Linux (yes, Arch AUR
has it, but that's fragile, as always with AUR). The library is not
maintained actively enough at the moment, for distros to deal with it. I
had to build it from source, for Fedora, and that didn't go too smoothly
either.
It turns out that, out of 21 tests in hmm-tests.c, only 2 actually require
functionality from libhugetlbfs. Therefore, if libhugetlbfs is missing,
simply ifdef those two tests out and allow the developer to at least have
the other 19 tests, if they don't want to pause to work through the above
issues. Also issue a warning, so that it's clear that there is an
imperfection in the build.
In order to do that, a tiny shell script (check_config.sh) runs a quick
compile (not link, that's too prone to false failures with library paths),
and basically, if the compiler doesn't find hugetlbfs.h in its standard
locations, then the script concludes that libhugetlbfs is not available.
The output is in two files, one for inclusion in hmm-test.c
(local_config.h), and one for inclusion in the Makefile (local_config.mk).
Link: https://lkml.kernel.org/r/20201026064021.3545418-9-jhubbard@nvidia.com
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Cc: Ralph Campbell <rcampbell@nvidia.com>
Cc: Jérôme Glisse <jglisse@redhat.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-12-14 19:05:28 -08:00
local_config.mk local_config.h : check_config .sh
/bin/sh ./check_config.sh $( CC)
EXTRA_CLEAN += local_config.mk local_config.h
i f e q ( $( HMM_EXTRA_LIBS ) , )
all : warn_missing_hugelibs
warn_missing_hugelibs :
@echo ; \
echo "Warning: missing libhugetlbfs support. Some HMM tests will be skipped." ; \
echo
e n d i f