-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'docs-4.19' of git://git.lwn.net/linux
Pull documentation update from Jonathan Corbet: "This was a moderately busy cycle for docs, with the usual collection of small fixes and updates. We also have new ktime_get_*() docs from Arnd, some kernel-doc fixes, a new set of Italian translations (non so se vale la pena, ma non fa male - speriamo bene), and some extensive early memory-management documentation improvements from Mike Rapoport" * tag 'docs-4.19' of git://git.lwn.net/linux: (52 commits) Documentation: corrections to console/console.txt Documentation: add ioctl number entry for v4l2-subdev.h Remove gendered language from management style documentation scripts/kernel-doc: Escape all literal braces in regexes docs/mm: add description of boot time memory management docs/mm: memblock: add overview documentation docs/mm: memblock: add kernel-doc description for memblock types docs/mm: memblock: add kernel-doc comments for memblock_add[_node] docs/mm: memblock: update kernel-doc comments mm/memblock: add a name for memblock flags enumeration docs/mm: bootmem: add overview documentation docs/mm: bootmem: add kernel-doc description of 'struct bootmem_data' docs/mm: bootmem: fix kernel-doc warnings docs/mm: nobootmem: fixup kernel-doc comments mm/bootmem: drop duplicated kernel-doc comments Documentation: vm.txt: Adding 'nr_hugepages_mempolicy' parameter description. doc:it_IT: translation for kernel-hacking docs: Fix the reference labels in Locking.rst doc: tracing: Fix a typo of trace_stat mm: Introduce new type vm_fault_t ...
- Loading branch information
Showing
57 changed files
with
5,101 additions
and
898 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.. _readme: | ||
|
||
Linux kernel release 4.x <http://kernel.org/> | ||
============================================= | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
=========================== | ||
Boot time memory management | ||
=========================== | ||
|
||
Early system initialization cannot use "normal" memory management | ||
simply because it is not set up yet. But there is still need to | ||
allocate memory for various data structures, for instance for the | ||
physical page allocator. To address this, a specialized allocator | ||
called the :ref:`Boot Memory Allocator <bootmem>`, or bootmem, was | ||
introduced. Several years later PowerPC developers added a "Logical | ||
Memory Blocks" allocator, which was later adopted by other | ||
architectures and renamed to :ref:`memblock <memblock>`. There is also | ||
a compatibility layer called `nobootmem` that translates bootmem | ||
allocation interfaces to memblock calls. | ||
|
||
The selection of the early allocator is done using | ||
``CONFIG_NO_BOOTMEM`` and ``CONFIG_HAVE_MEMBLOCK`` kernel | ||
configuration options. These options are enabled or disabled | ||
statically by the architectures' Kconfig files. | ||
|
||
* Architectures that rely only on bootmem select | ||
``CONFIG_NO_BOOTMEM=n && CONFIG_HAVE_MEMBLOCK=n``. | ||
* The users of memblock with the nobootmem compatibility layer set | ||
``CONFIG_NO_BOOTMEM=y && CONFIG_HAVE_MEMBLOCK=y``. | ||
* And for those that use both memblock and bootmem the configuration | ||
includes ``CONFIG_NO_BOOTMEM=n && CONFIG_HAVE_MEMBLOCK=y``. | ||
|
||
Whichever allocator is used, it is the responsibility of the | ||
architecture specific initialization to set it up in | ||
:c:func:`setup_arch` and tear it down in :c:func:`mem_init` functions. | ||
|
||
Once the early memory management is available it offers a variety of | ||
functions and macros for memory allocations. The allocation request | ||
may be directed to the first (and probably the only) node or to a | ||
particular node in a NUMA system. There are API variants that panic | ||
when an allocation fails and those that don't. And more recent and | ||
advanced memblock even allows controlling its own behaviour. | ||
|
||
.. _bootmem: | ||
|
||
Bootmem | ||
======= | ||
|
||
(mostly stolen from Mel Gorman's "Understanding the Linux Virtual | ||
Memory Manager" `book`_) | ||
|
||
.. _book: https://www.kernel.org/doc/gorman/ | ||
|
||
.. kernel-doc:: mm/bootmem.c | ||
:doc: bootmem overview | ||
|
||
.. _memblock: | ||
|
||
Memblock | ||
======== | ||
|
||
.. kernel-doc:: mm/memblock.c | ||
:doc: memblock overview | ||
|
||
|
||
Functions and structures | ||
======================== | ||
|
||
Common API | ||
---------- | ||
|
||
The functions that are described in this section are available | ||
regardless of what early memory manager is enabled. | ||
|
||
.. kernel-doc:: mm/nobootmem.c | ||
|
||
Bootmem specific API | ||
-------------------- | ||
|
||
These interfaces available only with bootmem, i.e when ``CONFIG_NO_BOOTMEM=n`` | ||
|
||
.. kernel-doc:: include/linux/bootmem.h | ||
.. kernel-doc:: mm/bootmem.c | ||
:nodocs: | ||
|
||
Memblock specific API | ||
--------------------- | ||
|
||
Here is the description of memblock data structures, functions and | ||
macros. Some of them are actually internal, but since they are | ||
documented it would be silly to omit them. Besides, reading the | ||
descriptions for the internal functions can help to understand what | ||
really happens under the hood. | ||
|
||
.. kernel-doc:: include/linux/memblock.h | ||
.. kernel-doc:: mm/memblock.c | ||
:nodocs: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
ktime accessors | ||
=============== | ||
|
||
Device drivers can read the current time using ktime_get() and the many | ||
related functions declared in linux/timekeeping.h. As a rule of thumb, | ||
using an accessor with a shorter name is preferred over one with a longer | ||
name if both are equally fit for a particular use case. | ||
|
||
Basic ktime_t based interfaces | ||
------------------------------ | ||
|
||
The recommended simplest form returns an opaque ktime_t, with variants | ||
that return time for different clock references: | ||
|
||
|
||
.. c:function:: ktime_t ktime_get( void ) | ||
CLOCK_MONOTONIC | ||
Useful for reliable timestamps and measuring short time intervals | ||
accurately. Starts at system boot time but stops during suspend. | ||
.. c:function:: ktime_t ktime_get_boottime( void ) | ||
CLOCK_BOOTTIME | ||
Like ktime_get(), but does not stop when suspended. This can be | ||
used e.g. for key expiration times that need to be synchronized | ||
with other machines across a suspend operation. | ||
.. c:function:: ktime_t ktime_get_real( void ) | ||
CLOCK_REALTIME | ||
Returns the time in relative to the UNIX epoch starting in 1970 | ||
using the Coordinated Universal Time (UTC), same as gettimeofday() | ||
user space. This is used for all timestamps that need to | ||
persist across a reboot, like inode times, but should be avoided | ||
for internal uses, since it can jump backwards due to a leap | ||
second update, NTP adjustment settimeofday() operation from user | ||
space. | ||
.. c:function:: ktime_t ktime_get_clocktai( void ) | ||
CLOCK_TAI | ||
Like ktime_get_real(), but uses the International Atomic Time (TAI) | ||
reference instead of UTC to avoid jumping on leap second updates. | ||
This is rarely useful in the kernel. | ||
.. c:function:: ktime_t ktime_get_raw( void ) | ||
CLOCK_MONOTONIC_RAW | ||
Like ktime_get(), but runs at the same rate as the hardware | ||
clocksource without (NTP) adjustments for clock drift. This is | ||
also rarely needed in the kernel. | ||
nanosecond, timespec64, and second output | ||
----------------------------------------- | ||
For all of the above, there are variants that return the time in a | ||
different format depending on what is required by the user: | ||
.. c:function:: u64 ktime_get_ns( void ) | ||
u64 ktime_get_boottime_ns( void ) | ||
u64 ktime_get_real_ns( void ) | ||
u64 ktime_get_tai_ns( void ) | ||
u64 ktime_get_raw_ns( void ) | ||
Same as the plain ktime_get functions, but returning a u64 number | ||
of nanoseconds in the respective time reference, which may be | ||
more convenient for some callers. | ||
.. c:function:: void ktime_get_ts64( struct timespec64 * ) | ||
void ktime_get_boottime_ts64( struct timespec64 * ) | ||
void ktime_get_real_ts64( struct timespec64 * ) | ||
void ktime_get_clocktai_ts64( struct timespec64 * ) | ||
void ktime_get_raw_ts64( struct timespec64 * ) | ||
Same above, but returns the time in a 'struct timespec64', split | ||
into seconds and nanoseconds. This can avoid an extra division | ||
when printing the time, or when passing it into an external | ||
interface that expects a 'timespec' or 'timeval' structure. | ||
.. c:function:: time64_t ktime_get_seconds( void ) | ||
time64_t ktime_get_boottime_seconds( void ) | ||
time64_t ktime_get_real_seconds( void ) | ||
time64_t ktime_get_clocktai_seconds( void ) | ||
time64_t ktime_get_raw_seconds( void ) | ||
Return a coarse-grained version of the time as a scalar | ||
time64_t. This avoids accessing the clock hardware and rounds | ||
down the seconds to the full seconds of the last timer tick | ||
using the respective reference. | ||
Coarse and fast_ns access | ||
------------------------- | ||
Some additional variants exist for more specialized cases: | ||
.. c:function:: ktime_t ktime_get_coarse_boottime( void ) | ||
ktime_t ktime_get_coarse_real( void ) | ||
ktime_t ktime_get_coarse_clocktai( void ) | ||
ktime_t ktime_get_coarse_raw( void ) | ||
.. c:function:: void ktime_get_coarse_ts64( struct timespec64 * ) | ||
void ktime_get_coarse_boottime_ts64( struct timespec64 * ) | ||
void ktime_get_coarse_real_ts64( struct timespec64 * ) | ||
void ktime_get_coarse_clocktai_ts64( struct timespec64 * ) | ||
void ktime_get_coarse_raw_ts64( struct timespec64 * ) | ||
These are quicker than the non-coarse versions, but less accurate, | ||
corresponding to CLOCK_MONONOTNIC_COARSE and CLOCK_REALTIME_COARSE | ||
in user space, along with the equivalent boottime/tai/raw | ||
timebase not available in user space. | ||
The time returned here corresponds to the last timer tick, which | ||
may be as much as 10ms in the past (for CONFIG_HZ=100), same as | ||
reading the 'jiffies' variable. These are only useful when called | ||
in a fast path and one still expects better than second accuracy, | ||
but can't easily use 'jiffies', e.g. for inode timestamps. | ||
Skipping the hardware clock access saves around 100 CPU cycles | ||
on most modern machines with a reliable cycle counter, but | ||
up to several microseconds on older hardware with an external | ||
clocksource. | ||
.. c:function:: u64 ktime_get_mono_fast_ns( void ) | ||
u64 ktime_get_raw_fast_ns( void ) | ||
u64 ktime_get_boot_fast_ns( void ) | ||
u64 ktime_get_real_fast_ns( void ) | ||
These variants are safe to call from any context, including from | ||
a non-maskable interrupt (NMI) during a timekeeper update, and | ||
while we are entering suspend with the clocksource powered down. | ||
This is useful in some tracing or debugging code as well as | ||
machine check reporting, but most drivers should never call them, | ||
since the time is allowed to jump under certain conditions. | ||
Deprecated time interfaces | ||
-------------------------- | ||
Older kernels used some other interfaces that are now being phased out | ||
but may appear in third-party drivers being ported here. In particular, | ||
all interfaces returning a 'struct timeval' or 'struct timespec' have | ||
been replaced because the tv_sec member overflows in year 2038 on 32-bit | ||
architectures. These are the recommended replacements: | ||
.. c:function:: void ktime_get_ts( struct timespec * ) | ||
Use ktime_get() or ktime_get_ts64() instead. | ||
.. c:function:: struct timeval do_gettimeofday( void ) | ||
struct timespec getnstimeofday( void ) | ||
struct timespec64 getnstimeofday64( void ) | ||
void ktime_get_real_ts( struct timespec * ) | ||
ktime_get_real_ts64() is a direct replacement, but consider using | ||
monotonic time (ktime_get_ts64()) and/or a ktime_t based interface | ||
(ktime_get()/ktime_get_real()). | ||
.. c:function:: struct timespec current_kernel_time( void ) | ||
struct timespec64 current_kernel_time64( void ) | ||
struct timespec get_monotonic_coarse( void ) | ||
struct timespec64 get_monotonic_coarse64( void ) | ||
These are replaced by ktime_get_coarse_real_ts64() and | ||
ktime_get_coarse_ts64(). However, A lot of code that wants | ||
coarse-grained times can use the simple 'jiffies' instead, while | ||
some drivers may actually want the higher resolution accessors | ||
these days. | ||
.. c:function:: struct timespec getrawmonotonic( void ) | ||
struct timespec64 getrawmonotonic64( void ) | ||
struct timespec timekeeping_clocktai( void ) | ||
struct timespec64 timekeeping_clocktai64( void ) | ||
struct timespec get_monotonic_boottime( void ) | ||
struct timespec64 get_monotonic_boottime64( void ) | ||
These are replaced by ktime_get_raw()/ktime_get_raw_ts64(), | ||
ktime_get_clocktai()/ktime_get_clocktai_ts64() as well | ||
as ktime_get_boottime()/ktime_get_boottime_ts64(). | ||
However, if the particular choice of clock source is not | ||
important for the user, consider converting to | ||
ktime_get()/ktime_get_ts64() instead for consistency. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.