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 14:07:57 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2008-06-12 11:56:40 +00:00
|
|
|
#ifndef LINUX_MM_DEBUG_H
|
|
|
|
|
#define LINUX_MM_DEBUG_H 1
|
|
|
|
|
|
2015-12-18 22:22:07 +00:00
|
|
|
#include <linux/bug.h>
|
2014-06-04 23:07:02 +00:00
|
|
|
#include <linux/stringify.h>
|
|
|
|
|
|
2014-01-23 23:52:54 +00:00
|
|
|
struct page;
|
2014-10-09 22:28:06 +00:00
|
|
|
struct vm_area_struct;
|
2014-10-09 22:28:37 +00:00
|
|
|
struct mm_struct;
|
2023-05-18 14:55:26 +00:00
|
|
|
struct vma_iterator;
|
mm/debug: introduce VM_WARN_ON_VMG() to dump VMA merge state
Patch series "mm/debug: introduce and use VM_WARN_ON_VMG()".
We use a number of asserts, enabled only when CONFIG_DEBUG_VM is set,
during VMA merge operations to ensure state is as expected.
However, when syzkaller or the like encounters these asserts, often the
information provided by the report is insufficient to narrow down what the
problem is.
We noticed this recently in [0], where a non-repro issue resisted
debugging due to simply not having sufficient information to go on.
This series improves the situation by providing VM_WARN_ON_VMG() which
acts like VM_WARN_ON() (i.e. only actually being invoked if
CONFIG_DEBUG_VM is set), while dumping significant information about the
VMA merge state, the mm_struct describing the virtual address space, all
associated VMAs and, if CONFIG_DEBUG_VM_MAPLE_TREE is set, the associated
maple tree.
[0]:https://lore.kernel.org/all/6774c98f.050a0220.25abdd.0991.GAE@google.com/
This patch (of 2):
We use a number of asserts, enabled only when CONFIG_DEBUG_VM is set,
during VMA merge operations to ensure state is as expected.
However, when syzkaller or the like encounters these asserts, often the
information provided by the report is insufficient to narrow down what the
problem is.
This might not be so much of an issue if the reported problem is
reproducible, but if it is a rarely encountered race or some other case
which precludes a repro, it is a very big problem (see [0] for the
motivating case).
It is therefore sensible to provide a means by which we can easily and
conveniently dump a lot more information in these circumstances.
The aggregation of merge state into a single struct threaded through the
operation makes this trivial - we can simply introduce a variant on
VM_WARN_ON() which takes the VMA merge state object (vmg) and use that to
dump information.
This patch therefore introduces VM_WARN_ON_VMG() which provides this
functionality.
It additionally dumps full mm state, VMA state for each of the three VMAs
the vmg contains (prev, next, vma) and if CONFIG_DEBUG_VM_MAPLE_TREE is
enabled, dumps the maple tree from the provided VMA iterator if non-NULL.
This patch has no functional impact if CONFIG_DEBUG_VM is not set.
[0]:https://lore.kernel.org/all/6774c98f.050a0220.25abdd.0991.GAE@google.com/
Link: https://lkml.kernel.org/r/cover.1735932169.git.lorenzo.stoakes@oracle.com
Link: https://lkml.kernel.org/r/13b09b52d4d103ee86acaf0ae612539648ae29e0.1735932169.git.lorenzo.stoakes@oracle.com
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jann Horn <jannh@google.com>
Cc: Liam R. Howlett <Liam.Howlett@Oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2025-01-03 19:35:35 +00:00
|
|
|
struct vma_merge_struct;
|
2014-01-23 23:52:54 +00:00
|
|
|
|
2024-02-27 19:23:32 +00:00
|
|
|
void dump_page(const struct page *page, const char *reason);
|
2014-10-09 22:28:06 +00:00
|
|
|
void dump_vma(const struct vm_area_struct *vma);
|
2014-10-09 22:28:37 +00:00
|
|
|
void dump_mm(const struct mm_struct *mm);
|
mm/debug: introduce VM_WARN_ON_VMG() to dump VMA merge state
Patch series "mm/debug: introduce and use VM_WARN_ON_VMG()".
We use a number of asserts, enabled only when CONFIG_DEBUG_VM is set,
during VMA merge operations to ensure state is as expected.
However, when syzkaller or the like encounters these asserts, often the
information provided by the report is insufficient to narrow down what the
problem is.
We noticed this recently in [0], where a non-repro issue resisted
debugging due to simply not having sufficient information to go on.
This series improves the situation by providing VM_WARN_ON_VMG() which
acts like VM_WARN_ON() (i.e. only actually being invoked if
CONFIG_DEBUG_VM is set), while dumping significant information about the
VMA merge state, the mm_struct describing the virtual address space, all
associated VMAs and, if CONFIG_DEBUG_VM_MAPLE_TREE is set, the associated
maple tree.
[0]:https://lore.kernel.org/all/6774c98f.050a0220.25abdd.0991.GAE@google.com/
This patch (of 2):
We use a number of asserts, enabled only when CONFIG_DEBUG_VM is set,
during VMA merge operations to ensure state is as expected.
However, when syzkaller or the like encounters these asserts, often the
information provided by the report is insufficient to narrow down what the
problem is.
This might not be so much of an issue if the reported problem is
reproducible, but if it is a rarely encountered race or some other case
which precludes a repro, it is a very big problem (see [0] for the
motivating case).
It is therefore sensible to provide a means by which we can easily and
conveniently dump a lot more information in these circumstances.
The aggregation of merge state into a single struct threaded through the
operation makes this trivial - we can simply introduce a variant on
VM_WARN_ON() which takes the VMA merge state object (vmg) and use that to
dump information.
This patch therefore introduces VM_WARN_ON_VMG() which provides this
functionality.
It additionally dumps full mm state, VMA state for each of the three VMAs
the vmg contains (prev, next, vma) and if CONFIG_DEBUG_VM_MAPLE_TREE is
enabled, dumps the maple tree from the provided VMA iterator if non-NULL.
This patch has no functional impact if CONFIG_DEBUG_VM is not set.
[0]:https://lore.kernel.org/all/6774c98f.050a0220.25abdd.0991.GAE@google.com/
Link: https://lkml.kernel.org/r/cover.1735932169.git.lorenzo.stoakes@oracle.com
Link: https://lkml.kernel.org/r/13b09b52d4d103ee86acaf0ae612539648ae29e0.1735932169.git.lorenzo.stoakes@oracle.com
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jann Horn <jannh@google.com>
Cc: Liam R. Howlett <Liam.Howlett@Oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2025-01-03 19:35:35 +00:00
|
|
|
void dump_vmg(const struct vma_merge_struct *vmg, const char *reason);
|
2023-05-18 14:55:26 +00:00
|
|
|
void vma_iter_dump_tree(const struct vma_iterator *vmi);
|
2014-01-23 23:52:54 +00:00
|
|
|
|
2008-06-12 11:56:40 +00:00
|
|
|
#ifdef CONFIG_DEBUG_VM
|
|
|
|
|
#define VM_BUG_ON(cond) BUG_ON(cond)
|
2014-06-04 23:07:02 +00:00
|
|
|
#define VM_BUG_ON_PAGE(cond, page) \
|
|
|
|
|
do { \
|
|
|
|
|
if (unlikely(cond)) { \
|
|
|
|
|
dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\
|
|
|
|
|
BUG(); \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
2021-01-15 15:52:37 +00:00
|
|
|
#define VM_BUG_ON_FOLIO(cond, folio) \
|
|
|
|
|
do { \
|
|
|
|
|
if (unlikely(cond)) { \
|
|
|
|
|
dump_page(&folio->page, "VM_BUG_ON_FOLIO(" __stringify(cond)")");\
|
|
|
|
|
BUG(); \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
2014-10-09 22:28:08 +00:00
|
|
|
#define VM_BUG_ON_VMA(cond, vma) \
|
|
|
|
|
do { \
|
|
|
|
|
if (unlikely(cond)) { \
|
|
|
|
|
dump_vma(vma); \
|
|
|
|
|
BUG(); \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
2014-10-09 22:28:37 +00:00
|
|
|
#define VM_BUG_ON_MM(cond, mm) \
|
|
|
|
|
do { \
|
|
|
|
|
if (unlikely(cond)) { \
|
|
|
|
|
dump_mm(mm); \
|
|
|
|
|
BUG(); \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
2020-12-18 22:01:31 +00:00
|
|
|
#define VM_WARN_ON_ONCE_PAGE(cond, page) ({ \
|
2024-11-06 16:14:41 +00:00
|
|
|
static bool __section(".data..once") __warned; \
|
2020-12-18 22:01:31 +00:00
|
|
|
int __ret_warn_once = !!(cond); \
|
|
|
|
|
\
|
|
|
|
|
if (unlikely(__ret_warn_once && !__warned)) { \
|
|
|
|
|
dump_page(page, "VM_WARN_ON_ONCE_PAGE(" __stringify(cond)")");\
|
|
|
|
|
__warned = true; \
|
|
|
|
|
WARN_ON(1); \
|
|
|
|
|
} \
|
|
|
|
|
unlikely(__ret_warn_once); \
|
|
|
|
|
})
|
2022-06-10 15:40:13 +00:00
|
|
|
#define VM_WARN_ON_FOLIO(cond, folio) ({ \
|
|
|
|
|
int __ret_warn = !!(cond); \
|
|
|
|
|
\
|
|
|
|
|
if (unlikely(__ret_warn)) { \
|
|
|
|
|
dump_page(&folio->page, "VM_WARN_ON_FOLIO(" __stringify(cond)")");\
|
|
|
|
|
WARN_ON(1); \
|
|
|
|
|
} \
|
|
|
|
|
unlikely(__ret_warn); \
|
|
|
|
|
})
|
2021-01-15 15:52:37 +00:00
|
|
|
#define VM_WARN_ON_ONCE_FOLIO(cond, folio) ({ \
|
2024-11-06 16:14:41 +00:00
|
|
|
static bool __section(".data..once") __warned; \
|
2021-01-15 15:52:37 +00:00
|
|
|
int __ret_warn_once = !!(cond); \
|
|
|
|
|
\
|
|
|
|
|
if (unlikely(__ret_warn_once && !__warned)) { \
|
|
|
|
|
dump_page(&folio->page, "VM_WARN_ON_ONCE_FOLIO(" __stringify(cond)")");\
|
|
|
|
|
__warned = true; \
|
|
|
|
|
WARN_ON(1); \
|
|
|
|
|
} \
|
|
|
|
|
unlikely(__ret_warn_once); \
|
|
|
|
|
})
|
2023-05-18 14:55:26 +00:00
|
|
|
#define VM_WARN_ON_ONCE_MM(cond, mm) ({ \
|
2024-11-06 16:14:41 +00:00
|
|
|
static bool __section(".data..once") __warned; \
|
2023-05-18 14:55:26 +00:00
|
|
|
int __ret_warn_once = !!(cond); \
|
|
|
|
|
\
|
|
|
|
|
if (unlikely(__ret_warn_once && !__warned)) { \
|
|
|
|
|
dump_mm(mm); \
|
|
|
|
|
__warned = true; \
|
|
|
|
|
WARN_ON(1); \
|
|
|
|
|
} \
|
|
|
|
|
unlikely(__ret_warn_once); \
|
|
|
|
|
})
|
2025-06-04 14:05:44 +00:00
|
|
|
#define VM_WARN_ON_ONCE_VMA(cond, vma) ({ \
|
|
|
|
|
static bool __section(".data..once") __warned; \
|
|
|
|
|
int __ret_warn_once = !!(cond); \
|
|
|
|
|
\
|
|
|
|
|
if (unlikely(__ret_warn_once && !__warned)) { \
|
|
|
|
|
dump_vma(vma); \
|
|
|
|
|
__warned = true; \
|
|
|
|
|
WARN_ON(1); \
|
|
|
|
|
} \
|
|
|
|
|
unlikely(__ret_warn_once); \
|
|
|
|
|
})
|
mm/debug: introduce VM_WARN_ON_VMG() to dump VMA merge state
Patch series "mm/debug: introduce and use VM_WARN_ON_VMG()".
We use a number of asserts, enabled only when CONFIG_DEBUG_VM is set,
during VMA merge operations to ensure state is as expected.
However, when syzkaller or the like encounters these asserts, often the
information provided by the report is insufficient to narrow down what the
problem is.
We noticed this recently in [0], where a non-repro issue resisted
debugging due to simply not having sufficient information to go on.
This series improves the situation by providing VM_WARN_ON_VMG() which
acts like VM_WARN_ON() (i.e. only actually being invoked if
CONFIG_DEBUG_VM is set), while dumping significant information about the
VMA merge state, the mm_struct describing the virtual address space, all
associated VMAs and, if CONFIG_DEBUG_VM_MAPLE_TREE is set, the associated
maple tree.
[0]:https://lore.kernel.org/all/6774c98f.050a0220.25abdd.0991.GAE@google.com/
This patch (of 2):
We use a number of asserts, enabled only when CONFIG_DEBUG_VM is set,
during VMA merge operations to ensure state is as expected.
However, when syzkaller or the like encounters these asserts, often the
information provided by the report is insufficient to narrow down what the
problem is.
This might not be so much of an issue if the reported problem is
reproducible, but if it is a rarely encountered race or some other case
which precludes a repro, it is a very big problem (see [0] for the
motivating case).
It is therefore sensible to provide a means by which we can easily and
conveniently dump a lot more information in these circumstances.
The aggregation of merge state into a single struct threaded through the
operation makes this trivial - we can simply introduce a variant on
VM_WARN_ON() which takes the VMA merge state object (vmg) and use that to
dump information.
This patch therefore introduces VM_WARN_ON_VMG() which provides this
functionality.
It additionally dumps full mm state, VMA state for each of the three VMAs
the vmg contains (prev, next, vma) and if CONFIG_DEBUG_VM_MAPLE_TREE is
enabled, dumps the maple tree from the provided VMA iterator if non-NULL.
This patch has no functional impact if CONFIG_DEBUG_VM is not set.
[0]:https://lore.kernel.org/all/6774c98f.050a0220.25abdd.0991.GAE@google.com/
Link: https://lkml.kernel.org/r/cover.1735932169.git.lorenzo.stoakes@oracle.com
Link: https://lkml.kernel.org/r/13b09b52d4d103ee86acaf0ae612539648ae29e0.1735932169.git.lorenzo.stoakes@oracle.com
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jann Horn <jannh@google.com>
Cc: Liam R. Howlett <Liam.Howlett@Oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2025-01-03 19:35:35 +00:00
|
|
|
#define VM_WARN_ON_VMG(cond, vmg) ({ \
|
|
|
|
|
int __ret_warn = !!(cond); \
|
|
|
|
|
\
|
|
|
|
|
if (unlikely(__ret_warn)) { \
|
|
|
|
|
dump_vmg(vmg, "VM_WARN_ON_VMG(" __stringify(cond)")"); \
|
|
|
|
|
WARN_ON(1); \
|
|
|
|
|
} \
|
|
|
|
|
unlikely(__ret_warn); \
|
|
|
|
|
})
|
2020-12-18 22:01:31 +00:00
|
|
|
|
2018-04-05 23:25:30 +00:00
|
|
|
#define VM_WARN_ON(cond) (void)WARN_ON(cond)
|
|
|
|
|
#define VM_WARN_ON_ONCE(cond) (void)WARN_ON_ONCE(cond)
|
|
|
|
|
#define VM_WARN_ONCE(cond, format...) (void)WARN_ONCE(cond, format)
|
|
|
|
|
#define VM_WARN(cond, format...) (void)WARN(cond, format)
|
2008-06-12 11:56:40 +00:00
|
|
|
#else
|
2012-05-29 22:06:28 +00:00
|
|
|
#define VM_BUG_ON(cond) BUILD_BUG_ON_INVALID(cond)
|
2014-01-23 23:52:54 +00:00
|
|
|
#define VM_BUG_ON_PAGE(cond, page) VM_BUG_ON(cond)
|
2021-01-15 15:52:37 +00:00
|
|
|
#define VM_BUG_ON_FOLIO(cond, folio) VM_BUG_ON(cond)
|
2014-10-09 22:28:08 +00:00
|
|
|
#define VM_BUG_ON_VMA(cond, vma) VM_BUG_ON(cond)
|
2014-10-09 22:28:37 +00:00
|
|
|
#define VM_BUG_ON_MM(cond, mm) VM_BUG_ON(cond)
|
2014-06-04 23:06:59 +00:00
|
|
|
#define VM_WARN_ON(cond) BUILD_BUG_ON_INVALID(cond)
|
|
|
|
|
#define VM_WARN_ON_ONCE(cond) BUILD_BUG_ON_INVALID(cond)
|
2020-12-18 22:01:31 +00:00
|
|
|
#define VM_WARN_ON_ONCE_PAGE(cond, page) BUILD_BUG_ON_INVALID(cond)
|
2022-06-10 15:40:13 +00:00
|
|
|
#define VM_WARN_ON_FOLIO(cond, folio) BUILD_BUG_ON_INVALID(cond)
|
2021-01-15 15:52:37 +00:00
|
|
|
#define VM_WARN_ON_ONCE_FOLIO(cond, folio) BUILD_BUG_ON_INVALID(cond)
|
2023-05-18 14:55:26 +00:00
|
|
|
#define VM_WARN_ON_ONCE_MM(cond, mm) BUILD_BUG_ON_INVALID(cond)
|
2025-06-04 14:05:44 +00:00
|
|
|
#define VM_WARN_ON_ONCE_VMA(cond, vma) BUILD_BUG_ON_INVALID(cond)
|
mm/debug: introduce VM_WARN_ON_VMG() to dump VMA merge state
Patch series "mm/debug: introduce and use VM_WARN_ON_VMG()".
We use a number of asserts, enabled only when CONFIG_DEBUG_VM is set,
during VMA merge operations to ensure state is as expected.
However, when syzkaller or the like encounters these asserts, often the
information provided by the report is insufficient to narrow down what the
problem is.
We noticed this recently in [0], where a non-repro issue resisted
debugging due to simply not having sufficient information to go on.
This series improves the situation by providing VM_WARN_ON_VMG() which
acts like VM_WARN_ON() (i.e. only actually being invoked if
CONFIG_DEBUG_VM is set), while dumping significant information about the
VMA merge state, the mm_struct describing the virtual address space, all
associated VMAs and, if CONFIG_DEBUG_VM_MAPLE_TREE is set, the associated
maple tree.
[0]:https://lore.kernel.org/all/6774c98f.050a0220.25abdd.0991.GAE@google.com/
This patch (of 2):
We use a number of asserts, enabled only when CONFIG_DEBUG_VM is set,
during VMA merge operations to ensure state is as expected.
However, when syzkaller or the like encounters these asserts, often the
information provided by the report is insufficient to narrow down what the
problem is.
This might not be so much of an issue if the reported problem is
reproducible, but if it is a rarely encountered race or some other case
which precludes a repro, it is a very big problem (see [0] for the
motivating case).
It is therefore sensible to provide a means by which we can easily and
conveniently dump a lot more information in these circumstances.
The aggregation of merge state into a single struct threaded through the
operation makes this trivial - we can simply introduce a variant on
VM_WARN_ON() which takes the VMA merge state object (vmg) and use that to
dump information.
This patch therefore introduces VM_WARN_ON_VMG() which provides this
functionality.
It additionally dumps full mm state, VMA state for each of the three VMAs
the vmg contains (prev, next, vma) and if CONFIG_DEBUG_VM_MAPLE_TREE is
enabled, dumps the maple tree from the provided VMA iterator if non-NULL.
This patch has no functional impact if CONFIG_DEBUG_VM is not set.
[0]:https://lore.kernel.org/all/6774c98f.050a0220.25abdd.0991.GAE@google.com/
Link: https://lkml.kernel.org/r/cover.1735932169.git.lorenzo.stoakes@oracle.com
Link: https://lkml.kernel.org/r/13b09b52d4d103ee86acaf0ae612539648ae29e0.1735932169.git.lorenzo.stoakes@oracle.com
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jann Horn <jannh@google.com>
Cc: Liam R. Howlett <Liam.Howlett@Oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2025-01-03 19:35:35 +00:00
|
|
|
#define VM_WARN_ON_VMG(cond, vmg) BUILD_BUG_ON_INVALID(cond)
|
2014-08-06 23:06:30 +00:00
|
|
|
#define VM_WARN_ONCE(cond, format...) BUILD_BUG_ON_INVALID(cond)
|
2016-07-26 22:22:36 +00:00
|
|
|
#define VM_WARN(cond, format...) BUILD_BUG_ON_INVALID(cond)
|
mm/debug: introduce VM_WARN_ON_VMG() to dump VMA merge state
Patch series "mm/debug: introduce and use VM_WARN_ON_VMG()".
We use a number of asserts, enabled only when CONFIG_DEBUG_VM is set,
during VMA merge operations to ensure state is as expected.
However, when syzkaller or the like encounters these asserts, often the
information provided by the report is insufficient to narrow down what the
problem is.
We noticed this recently in [0], where a non-repro issue resisted
debugging due to simply not having sufficient information to go on.
This series improves the situation by providing VM_WARN_ON_VMG() which
acts like VM_WARN_ON() (i.e. only actually being invoked if
CONFIG_DEBUG_VM is set), while dumping significant information about the
VMA merge state, the mm_struct describing the virtual address space, all
associated VMAs and, if CONFIG_DEBUG_VM_MAPLE_TREE is set, the associated
maple tree.
[0]:https://lore.kernel.org/all/6774c98f.050a0220.25abdd.0991.GAE@google.com/
This patch (of 2):
We use a number of asserts, enabled only when CONFIG_DEBUG_VM is set,
during VMA merge operations to ensure state is as expected.
However, when syzkaller or the like encounters these asserts, often the
information provided by the report is insufficient to narrow down what the
problem is.
This might not be so much of an issue if the reported problem is
reproducible, but if it is a rarely encountered race or some other case
which precludes a repro, it is a very big problem (see [0] for the
motivating case).
It is therefore sensible to provide a means by which we can easily and
conveniently dump a lot more information in these circumstances.
The aggregation of merge state into a single struct threaded through the
operation makes this trivial - we can simply introduce a variant on
VM_WARN_ON() which takes the VMA merge state object (vmg) and use that to
dump information.
This patch therefore introduces VM_WARN_ON_VMG() which provides this
functionality.
It additionally dumps full mm state, VMA state for each of the three VMAs
the vmg contains (prev, next, vma) and if CONFIG_DEBUG_VM_MAPLE_TREE is
enabled, dumps the maple tree from the provided VMA iterator if non-NULL.
This patch has no functional impact if CONFIG_DEBUG_VM is not set.
[0]:https://lore.kernel.org/all/6774c98f.050a0220.25abdd.0991.GAE@google.com/
Link: https://lkml.kernel.org/r/cover.1735932169.git.lorenzo.stoakes@oracle.com
Link: https://lkml.kernel.org/r/13b09b52d4d103ee86acaf0ae612539648ae29e0.1735932169.git.lorenzo.stoakes@oracle.com
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jann Horn <jannh@google.com>
Cc: Liam R. Howlett <Liam.Howlett@Oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2025-01-03 19:35:35 +00:00
|
|
|
#endif /* CONFIG_DEBUG_VM */
|
2008-06-12 11:56:40 +00:00
|
|
|
|
2022-08-25 16:41:27 +00:00
|
|
|
#ifdef CONFIG_DEBUG_VM_IRQSOFF
|
|
|
|
|
#define VM_WARN_ON_IRQS_ENABLED() WARN_ON_ONCE(!irqs_disabled())
|
|
|
|
|
#else
|
|
|
|
|
#define VM_WARN_ON_IRQS_ENABLED() do { } while (0)
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-06-12 11:56:40 +00:00
|
|
|
#ifdef CONFIG_DEBUG_VIRTUAL
|
|
|
|
|
#define VIRTUAL_BUG_ON(cond) BUG_ON(cond)
|
|
|
|
|
#else
|
2008-06-19 11:28:11 +00:00
|
|
|
#define VIRTUAL_BUG_ON(cond) do { } while (0)
|
2008-06-12 11:56:40 +00:00
|
|
|
#endif
|
|
|
|
|
|
2016-01-16 00:51:21 +00:00
|
|
|
#ifdef CONFIG_DEBUG_VM_PGFLAGS
|
|
|
|
|
#define VM_BUG_ON_PGFLAGS(cond, page) VM_BUG_ON_PAGE(cond, page)
|
|
|
|
|
#else
|
|
|
|
|
#define VM_BUG_ON_PGFLAGS(cond, page) BUILD_BUG_ON_INVALID(cond)
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-06-12 11:56:40 +00:00
|
|
|
#endif
|