Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

Merge branch 'akpm' (patches from Andrew)

Merge more updates from Andrew Morton:

 - a bit more MM

 - procfs updates

 - dynamic-debug fixes

 - lib/ updates

 - checkpatch

 - epoll

 - nilfs2

 - signals

 - rapidio

 - PID management cleanup and optimization

 - kcov updates

 - sysvipc updates

 - quite a few misc things all over the place

* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (94 commits)
  EXPERT Kconfig menu: fix broken EXPERT menu
  include/asm-generic/topology.h: remove unused parent_node() macro
  arch/tile/include/asm/topology.h: remove unused parent_node() macro
  arch/sparc/include/asm/topology_64.h: remove unused parent_node() macro
  arch/sh/include/asm/topology.h: remove unused parent_node() macro
  arch/ia64/include/asm/topology.h: remove unused parent_node() macro
  drivers/pcmcia/sa1111_badge4.c: avoid unused function warning
  mm: add infrastructure for get_user_pages_fast() benchmarking
  sysvipc: make get_maxid O(1) again
  sysvipc: properly name ipc_addid() limit parameter
  sysvipc: duplicate lock comments wrt ipc_addid()
  sysvipc: unteach ids->next_id for !CHECKPOINT_RESTORE
  initramfs: use time64_t timestamps
  drivers/watchdog: make use of devm_register_reboot_notifier()
  kernel/reboot.c: add devm_register_reboot_notifier()
  kcov: update documentation
  Makefile: support flag -fsanitizer-coverage=trace-cmp
  kcov: support comparison operands collection
  kcov: remove pointless current != NULL check
  kernel/panic.c: add TAINT_AUX
  ...
parents 2dcd9c71 d1b069f5
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -18,7 +18,7 @@ shortcut for ``print_hex_dump(KERN_DEBUG)``.


For ``print_hex_dump_debug()``/``print_hex_dump_bytes()``, format string is
For ``print_hex_dump_debug()``/``print_hex_dump_bytes()``, format string is
its ``prefix_str`` argument, if it is constant string; or ``hexdump``
its ``prefix_str`` argument, if it is constant string; or ``hexdump``
in case ``prefix_str`` is build dynamically.
in case ``prefix_str`` is built dynamically.


Dynamic debug has even more useful features:
Dynamic debug has even more useful features:


@@ -197,8 +197,8 @@ line
    line number matches the callsite line number exactly.  A
    line number matches the callsite line number exactly.  A
    range of line numbers matches any callsite between the first
    range of line numbers matches any callsite between the first
    and last line number inclusive.  An empty first number means
    and last line number inclusive.  An empty first number means
    the first line in the file, an empty line number means the
    the first line in the file, an empty last line number means the
    last number in the file.  Examples::
    last line number in the file.  Examples::


	line 1603           // exactly line 1603
	line 1603           // exactly line 1603
	line 1600-1605      // the six lines from line 1600 to line 1605
	line 1600-1605      // the six lines from line 1600 to line 1605
+7 −0
Original line number Original line Diff line number Diff line

WARN_ONCE / WARN_ON_ONCE only print a warning once.

echo 1 > /sys/kernel/debug/clear_warn_once

clears the state and allows the warnings to print once again.
This can be useful after test suite runs to reproduce problems.
+95 −4
Original line number Original line Diff line number Diff line
@@ -12,19 +12,30 @@ To achieve this goal it does not collect coverage in soft/hard interrupts
and instrumentation of some inherently non-deterministic parts of kernel is
and instrumentation of some inherently non-deterministic parts of kernel is
disabled (e.g. scheduler, locking).
disabled (e.g. scheduler, locking).


Usage
kcov is also able to collect comparison operands from the instrumented code
-----
(this feature currently requires that the kernel is compiled with clang).

Prerequisites
-------------


Configure the kernel with::
Configure the kernel with::


        CONFIG_KCOV=y
        CONFIG_KCOV=y


CONFIG_KCOV requires gcc built on revision 231296 or later.
CONFIG_KCOV requires gcc built on revision 231296 or later.

If the comparison operands need to be collected, set::

	CONFIG_KCOV_ENABLE_COMPARISONS=y

Profiling data will only become accessible once debugfs has been mounted::
Profiling data will only become accessible once debugfs has been mounted::


        mount -t debugfs none /sys/kernel/debug
        mount -t debugfs none /sys/kernel/debug


The following program demonstrates kcov usage from within a test program:
Coverage collection
-------------------
The following program demonstrates coverage collection from within a test
program using kcov:


.. code-block:: c
.. code-block:: c


@@ -44,6 +55,9 @@ The following program demonstrates kcov usage from within a test program:
    #define KCOV_DISABLE			_IO('c', 101)
    #define KCOV_DISABLE			_IO('c', 101)
    #define COVER_SIZE			(64<<10)
    #define COVER_SIZE			(64<<10)


    #define KCOV_TRACE_PC  0
    #define KCOV_TRACE_CMP 1

    int main(int argc, char **argv)
    int main(int argc, char **argv)
    {
    {
	int fd;
	int fd;
@@ -64,7 +78,7 @@ The following program demonstrates kcov usage from within a test program:
	if ((void*)cover == MAP_FAILED)
	if ((void*)cover == MAP_FAILED)
		perror("mmap"), exit(1);
		perror("mmap"), exit(1);
	/* Enable coverage collection on the current thread. */
	/* Enable coverage collection on the current thread. */
	if (ioctl(fd, KCOV_ENABLE, 0))
	if (ioctl(fd, KCOV_ENABLE, KCOV_TRACE_PC))
		perror("ioctl"), exit(1);
		perror("ioctl"), exit(1);
	/* Reset coverage from the tail of the ioctl() call. */
	/* Reset coverage from the tail of the ioctl() call. */
	__atomic_store_n(&cover[0], 0, __ATOMIC_RELAXED);
	__atomic_store_n(&cover[0], 0, __ATOMIC_RELAXED);
@@ -111,3 +125,80 @@ The interface is fine-grained to allow efficient forking of test processes.
That is, a parent process opens /sys/kernel/debug/kcov, enables trace mode,
That is, a parent process opens /sys/kernel/debug/kcov, enables trace mode,
mmaps coverage buffer and then forks child processes in a loop. Child processes
mmaps coverage buffer and then forks child processes in a loop. Child processes
only need to enable coverage (disable happens automatically on thread end).
only need to enable coverage (disable happens automatically on thread end).

Comparison operands collection
------------------------------
Comparison operands collection is similar to coverage collection:

.. code-block:: c

    /* Same includes and defines as above. */

    /* Number of 64-bit words per record. */
    #define KCOV_WORDS_PER_CMP 4

    /*
     * The format for the types of collected comparisons.
     *
     * Bit 0 shows whether one of the arguments is a compile-time constant.
     * Bits 1 & 2 contain log2 of the argument size, up to 8 bytes.
     */

    #define KCOV_CMP_CONST          (1 << 0)
    #define KCOV_CMP_SIZE(n)        ((n) << 1)
    #define KCOV_CMP_MASK           KCOV_CMP_SIZE(3)

    int main(int argc, char **argv)
    {
	int fd;
	uint64_t *cover, type, arg1, arg2, is_const, size;
	unsigned long n, i;

	fd = open("/sys/kernel/debug/kcov", O_RDWR);
	if (fd == -1)
		perror("open"), exit(1);
	if (ioctl(fd, KCOV_INIT_TRACE, COVER_SIZE))
		perror("ioctl"), exit(1);
	/*
	* Note that the buffer pointer is of type uint64_t*, because all
	* the comparison operands are promoted to uint64_t.
	*/
	cover = (uint64_t *)mmap(NULL, COVER_SIZE * sizeof(unsigned long),
				     PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
	if ((void*)cover == MAP_FAILED)
		perror("mmap"), exit(1);
	/* Note KCOV_TRACE_CMP instead of KCOV_TRACE_PC. */
	if (ioctl(fd, KCOV_ENABLE, KCOV_TRACE_CMP))
		perror("ioctl"), exit(1);
	__atomic_store_n(&cover[0], 0, __ATOMIC_RELAXED);
	read(-1, NULL, 0);
	/* Read number of comparisons collected. */
	n = __atomic_load_n(&cover[0], __ATOMIC_RELAXED);
	for (i = 0; i < n; i++) {
		type = cover[i * KCOV_WORDS_PER_CMP + 1];
		/* arg1 and arg2 - operands of the comparison. */
		arg1 = cover[i * KCOV_WORDS_PER_CMP + 2];
		arg2 = cover[i * KCOV_WORDS_PER_CMP + 3];
		/* ip - caller address. */
		ip = cover[i * KCOV_WORDS_PER_CMP + 4];
		/* size of the operands. */
		size = 1 << ((type & KCOV_CMP_MASK) >> 1);
		/* is_const - true if either operand is a compile-time constant.*/
		is_const = type & KCOV_CMP_CONST;
		printf("ip: 0x%lx type: 0x%lx, arg1: 0x%lx, arg2: 0x%lx, "
			"size: %lu, %s\n",
			ip, type, arg1, arg2, size,
		is_const ? "const" : "non-const");
	}
	if (ioctl(fd, KCOV_DISABLE, 0))
		perror("ioctl"), exit(1);
	/* Free resources. */
	if (munmap(cover, COVER_SIZE * sizeof(unsigned long)))
		perror("munmap"), exit(1);
	if (close(fd))
		perror("close"), exit(1);
	return 0;
    }

Note that the kcov modes (coverage collection or comparison operands) are
mutually exclusive.
+3 −0
Original line number Original line Diff line number Diff line
@@ -181,6 +181,7 @@ read the file /proc/PID/status:
  VmPTE:        20 kb
  VmPTE:        20 kb
  VmSwap:        0 kB
  VmSwap:        0 kB
  HugetlbPages:          0 kB
  HugetlbPages:          0 kB
  CoreDumping:    0
  Threads:        1
  Threads:        1
  SigQ:   0/28578
  SigQ:   0/28578
  SigPnd: 0000000000000000
  SigPnd: 0000000000000000
@@ -253,6 +254,8 @@ Table 1-2: Contents of the status files (as of 4.8)
 VmSwap                      amount of swap used by anonymous private data
 VmSwap                      amount of swap used by anonymous private data
                             (shmem swap usage is not included)
                             (shmem swap usage is not included)
 HugetlbPages                size of hugetlb memory portions
 HugetlbPages                size of hugetlb memory portions
 CoreDumping                 process's memory is currently being dumped
                             (killing the process may lead to a corrupted core)
 Threads                     number of threads
 Threads                     number of threads
 SigQ                        number of signals queued/max. number for queue
 SigQ                        number of signals queued/max. number for queue
 SigPnd                      bitmap of pending signals for the thread
 SigPnd                      bitmap of pending signals for the thread
+1 −1
Original line number Original line Diff line number Diff line
@@ -818,7 +818,7 @@ tooling to work, you can do:
swappiness
swappiness


This control is used to define how aggressive the kernel will swap
This control is used to define how aggressive the kernel will swap
memory pages.  Higher values will increase agressiveness, lower values
memory pages.  Higher values will increase aggressiveness, lower values
decrease the amount of swap.  A value of 0 instructs the kernel not to
decrease the amount of swap.  A value of 0 instructs the kernel not to
initiate swap until the amount of free and file-backed pages is less
initiate swap until the amount of free and file-backed pages is less
than the high water mark in a zone.
than the high water mark in a zone.
Loading