Commit d5660df4 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'akpm' (patches from Andrew)

Merge misc updates from Andrew Morton:
 "181 patches.

  Subsystems affected by this patch series: kbuild, scripts, ntfs,
  ocfs2, vfs, mm (slab, slub, kmemleak, dax, debug, pagecache, fadvise,
  gup, swap, memremap, memcg, selftests, pagemap, mincore, hmm, dma,
  memory-failure, vmallo and migration)"

* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (181 commits)
  mm/migrate: remove obsolete comment about device public
  mm/migrate: remove cpages-- in migrate_vma_finalize()
  mm, oom_adj: don't loop through tasks in __set_oom_adj when not necessary
  memblock: use separate iterators for memory and reserved regions
  memblock: implement for_each_reserved_mem_region() using __next_mem_region()
  memblock: remove unused memblock_mem_size()
  x86/setup: simplify reserve_crashkernel()
  x86/setup: simplify initrd relocation and reservation
  arch, drivers: replace for_each_membock() with for_each_mem_range()
  arch, mm: replace for_each_memblock() with for_each_mem_pfn_range()
  memblock: reduce number of parameters in for_each_mem_range()
  memblock: make memblock_debug and related functionality private
  memblock: make for_each_memblock_type() iterator private
  mircoblaze: drop unneeded NUMA and sparsemem initializations
  riscv: drop unneeded node initialization
  h8300, nds32, openrisc: simplify detection of memory extents
  arm64: numa: simplify dummy_numa_init()
  arm, xtensa: simplify initialization of high memory pages
  dma-contiguous: simplify cma_early_percent_memory()
  KVM: PPC: Book3S HV: simplify kvm_cma_reserve()
  ...
parents b5fc7a89 f1f4f3ab
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -203,11 +203,13 @@ ForEachMacros:
  - 'for_each_matching_node'
  - 'for_each_matching_node_and_match'
  - 'for_each_member'
  - 'for_each_memblock'
  - 'for_each_mem_region'
  - 'for_each_memblock_type'
  - 'for_each_memcg_cache_index'
  - 'for_each_mem_pfn_range'
  - '__for_each_mem_range'
  - 'for_each_mem_range'
  - '__for_each_mem_range_rev'
  - 'for_each_mem_range_rev'
  - 'for_each_migratetype_order'
  - 'for_each_msi_entry'
@@ -271,6 +273,7 @@ ForEachMacros:
  - 'for_each_registered_fb'
  - 'for_each_requested_gpio'
  - 'for_each_requested_gpio_in_range'
  - 'for_each_reserved_mem_range'
  - 'for_each_reserved_mem_region'
  - 'for_each_rtd_codec_dais'
  - 'for_each_rtd_codec_dais_rollback'
+49 −20
Original line number Diff line number Diff line
@@ -1259,6 +1259,10 @@ PAGE_SIZE multiple when read back.
	can show up in the middle. Don't rely on items remaining in a
	fixed position; use the keys to look up specific values!

	If the entry has no per-node counter(or not show in the
	mempry.numa_stat). We use 'npn'(non-per-node) as the tag
	to indicate that it will not show in the mempry.numa_stat.

	  anon
		Amount of memory used in anonymous mappings such as
		brk(), sbrk(), and mmap(MAP_ANONYMOUS)
@@ -1270,15 +1274,11 @@ PAGE_SIZE multiple when read back.
	  kernel_stack
		Amount of memory allocated to kernel stacks.

	  slab
		Amount of memory used for storing in-kernel data
		structures.

	  percpu
	  percpu(npn)
		Amount of memory used for storing per-cpu kernel
		data structures.

	  sock
	  sock(npn)
		Amount of memory used in network transmission buffers

	  shmem
@@ -1318,11 +1318,9 @@ PAGE_SIZE multiple when read back.
		Part of "slab" that cannot be reclaimed on memory
		pressure.

	  pgfault
		Total number of page faults incurred

	  pgmajfault
		Number of major page faults incurred
	  slab(npn)
		Amount of memory used for storing in-kernel data
		structures.

	  workingset_refault_anon
		Number of refaults of previously evicted anonymous pages.
@@ -1348,37 +1346,68 @@ PAGE_SIZE multiple when read back.
	  workingset_nodereclaim
		Number of times a shadow node has been reclaimed

	  pgrefill
	  pgfault(npn)
		Total number of page faults incurred

	  pgmajfault(npn)
		Number of major page faults incurred

	  pgrefill(npn)
		Amount of scanned pages (in an active LRU list)

	  pgscan
	  pgscan(npn)
		Amount of scanned pages (in an inactive LRU list)

	  pgsteal
	  pgsteal(npn)
		Amount of reclaimed pages

	  pgactivate
	  pgactivate(npn)
		Amount of pages moved to the active LRU list

	  pgdeactivate
	  pgdeactivate(npn)
		Amount of pages moved to the inactive LRU list

	  pglazyfree
	  pglazyfree(npn)
		Amount of pages postponed to be freed under memory pressure

	  pglazyfreed
	  pglazyfreed(npn)
		Amount of reclaimed lazyfree pages

	  thp_fault_alloc
	  thp_fault_alloc(npn)
		Number of transparent hugepages which were allocated to satisfy
		a page fault. This counter is not present when CONFIG_TRANSPARENT_HUGEPAGE
                is not set.

	  thp_collapse_alloc
	  thp_collapse_alloc(npn)
		Number of transparent hugepages which were allocated to allow
		collapsing an existing range of pages. This counter is not
		present when CONFIG_TRANSPARENT_HUGEPAGE is not set.

  memory.numa_stat
	A read-only nested-keyed file which exists on non-root cgroups.

	This breaks down the cgroup's memory footprint into different
	types of memory, type-specific details, and other information
	per node on the state of the memory management system.

	This is useful for providing visibility into the NUMA locality
	information within an memcg since the pages are allowed to be
	allocated from any physical node. One of the use case is evaluating
	application performance by combining this information with the
	application's CPU allocation.

	All memory amounts are in bytes.

	The output format of memory.numa_stat is::

	  type N0=<bytes in node 0> N1=<bytes in node 1> ...

	The entries are ordered to be human readable, and new entries
	can show up in the middle. Don't rely on items remaining in a
	fixed position; use the keys to look up specific values!

	The entries can refer to the memory.stat.

  memory.swap.current
	A read-only single value file which exists on non-root
	cgroups.
+1 −1
Original line number Diff line number Diff line
@@ -131,7 +131,7 @@ hugepages
	parameter is preceded by an invalid hugepagesz parameter, it will
	be ignored.
default_hugepagesz
	pecify the default huge page size.  This parameter can
	Specify the default huge page size.  This parameter can
	only be specified once on the command line.  default_hugepagesz can
	optionally be followed by the hugepages parameter to preallocate a
	specific number of huge pages of default size.  The number of default
+72 −2
Original line number Diff line number Diff line
@@ -13,10 +13,10 @@ KASAN uses compile-time instrumentation to insert validity checks before every
memory access, and therefore requires a compiler version that supports that.

Generic KASAN is supported in both GCC and Clang. With GCC it requires version
8.3.0 or later. With Clang it requires version 7.0.0 or later, but detection of
8.3.0 or later. Any supported Clang version is compatible, but detection of
out-of-bounds accesses for global variables is only supported since Clang 11.

Tag-based KASAN is only supported in Clang and requires version 7.0.0 or later.
Tag-based KASAN is only supported in Clang.

Currently generic KASAN is supported for the x86_64, arm64, xtensa, s390 and
riscv architectures, and tag-based KASAN is supported only for arm64.
@@ -281,3 +281,73 @@ unmapped. This will require changes in arch-specific code.

This allows ``VMAP_STACK`` support on x86, and can simplify support of
architectures that do not have a fixed module region.

CONFIG_KASAN_KUNIT_TEST & CONFIG_TEST_KASAN_MODULE
--------------------------------------------------

``CONFIG_KASAN_KUNIT_TEST`` utilizes the KUnit Test Framework for testing.
This means each test focuses on a small unit of functionality and
there are a few ways these tests can be run.

Each test will print the KASAN report if an error is detected and then
print the number of the test and the status of the test:

pass::

        ok 28 - kmalloc_double_kzfree
or, if kmalloc failed::

        # kmalloc_large_oob_right: ASSERTION FAILED at lib/test_kasan.c:163
        Expected ptr is not null, but is
        not ok 4 - kmalloc_large_oob_right
or, if a KASAN report was expected, but not found::

        # kmalloc_double_kzfree: EXPECTATION FAILED at lib/test_kasan.c:629
        Expected kasan_data->report_expected == kasan_data->report_found, but
        kasan_data->report_expected == 1
        kasan_data->report_found == 0
        not ok 28 - kmalloc_double_kzfree

All test statuses are tracked as they run and an overall status will
be printed at the end::

        ok 1 - kasan

or::

        not ok 1 - kasan

(1) Loadable Module
~~~~~~~~~~~~~~~~~~~~

With ``CONFIG_KUNIT`` enabled, ``CONFIG_KASAN_KUNIT_TEST`` can be built as
a loadable module and run on any architecture that supports KASAN
using something like insmod or modprobe. The module is called ``test_kasan``.

(2) Built-In
~~~~~~~~~~~~~

With ``CONFIG_KUNIT`` built-in, ``CONFIG_KASAN_KUNIT_TEST`` can be built-in
on any architecure that supports KASAN. These and any other KUnit
tests enabled will run and print the results at boot as a late-init
call.

(3) Using kunit_tool
~~~~~~~~~~~~~~~~~~~~~

With ``CONFIG_KUNIT`` and ``CONFIG_KASAN_KUNIT_TEST`` built-in, we can also
use kunit_tool to see the results of these along with other KUnit
tests in a more readable way. This will not print the KASAN reports
of tests that passed. Use `KUnit documentation <https://www.kernel.org/doc/html/latest/dev-tools/kunit/index.html>`_ for more up-to-date
information on kunit_tool.

.. _KUnit: https://www.kernel.org/doc/html/latest/dev-tools/kunit/index.html

``CONFIG_TEST_KASAN_MODULE`` is a set of KASAN tests that could not be
converted to KUnit. These tests can be run only as a module with
``CONFIG_TEST_KASAN_MODULE`` built as a loadable module and
``CONFIG_KASAN`` built-in. The type of error expected and the
function being run is printed before the expression expected to give
an error. Then the error is printed, if found, and that test
should be interpretted to pass only if the error was the one expected
by the test.
+1 −1
Original line number Diff line number Diff line
@@ -229,7 +229,7 @@ Testing with kmemleak-test

To check if you have all set up to use kmemleak, you can use the kmemleak-test
module, a module that deliberately leaks memory. Set CONFIG_DEBUG_KMEMLEAK_TEST
as module (it can't be used as bult-in) and boot the kernel with kmemleak
as module (it can't be used as built-in) and boot the kernel with kmemleak
enabled. Load the module and perform a scan with::

        # modprobe kmemleak-test
Loading