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 17:07:57 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2005-04-17 02:20:36 +04:00
|
|
|
#ifndef _LINUX_VMALLOC_H
|
|
|
|
#define _LINUX_VMALLOC_H
|
|
|
|
|
|
|
|
#include <linux/spinlock.h>
|
mm: rewrite vmap layer
Rewrite the vmap allocator to use rbtrees and lazy tlb flushing, and
provide a fast, scalable percpu frontend for small vmaps (requires a
slightly different API, though).
The biggest problem with vmap is actually vunmap. Presently this requires
a global kernel TLB flush, which on most architectures is a broadcast IPI
to all CPUs to flush the cache. This is all done under a global lock. As
the number of CPUs increases, so will the number of vunmaps a scaled
workload will want to perform, and so will the cost of a global TLB flush.
This gives terrible quadratic scalability characteristics.
Another problem is that the entire vmap subsystem works under a single
lock. It is a rwlock, but it is actually taken for write in all the fast
paths, and the read locking would likely never be run concurrently anyway,
so it's just pointless.
This is a rewrite of vmap subsystem to solve those problems. The existing
vmalloc API is implemented on top of the rewritten subsystem.
The TLB flushing problem is solved by using lazy TLB unmapping. vmap
addresses do not have to be flushed immediately when they are vunmapped,
because the kernel will not reuse them again (would be a use-after-free)
until they are reallocated. So the addresses aren't allocated again until
a subsequent TLB flush. A single TLB flush then can flush multiple
vunmaps from each CPU.
XEN and PAT and such do not like deferred TLB flushing because they can't
always handle multiple aliasing virtual addresses to a physical address.
They now call vm_unmap_aliases() in order to flush any deferred mappings.
That call is very expensive (well, actually not a lot more expensive than
a single vunmap under the old scheme), however it should be OK if not
called too often.
The virtual memory extent information is stored in an rbtree rather than a
linked list to improve the algorithmic scalability.
There is a per-CPU allocator for small vmaps, which amortizes or avoids
global locking.
To use the per-CPU interface, the vm_map_ram / vm_unmap_ram interfaces
must be used in place of vmap and vunmap. Vmalloc does not use these
interfaces at the moment, so it will not be quite so scalable (although it
will use lazy TLB flushing).
As a quick test of performance, I ran a test that loops in the kernel,
linearly mapping then touching then unmapping 4 pages. Different numbers
of tests were run in parallel on an 4 core, 2 socket opteron. Results are
in nanoseconds per map+touch+unmap.
threads vanilla vmap rewrite
1 14700 2900
2 33600 3000
4 49500 2800
8 70631 2900
So with a 8 cores, the rewritten version is already 25x faster.
In a slightly more realistic test (although with an older and less
scalable version of the patch), I ripped the not-very-good vunmap batching
code out of XFS, and implemented the large buffer mapping with vm_map_ram
and vm_unmap_ram... along with a couple of other tricks, I was able to
speed up a large directory workload by 20x on a 64 CPU system. I believe
vmap/vunmap is actually sped up a lot more than 20x on such a system, but
I'm running into other locks now. vmap is pretty well blown off the
profiles.
Before:
1352059 total 0.1401
798784 _write_lock 8320.6667 <- vmlist_lock
529313 default_idle 1181.5022
15242 smp_call_function 15.8771 <- vmap tlb flushing
2472 __get_vm_area_node 1.9312 <- vmap
1762 remove_vm_area 4.5885 <- vunmap
316 map_vm_area 0.2297 <- vmap
312 kfree 0.1950
300 _spin_lock 3.1250
252 sn_send_IPI_phys 0.4375 <- tlb flushing
238 vmap 0.8264 <- vmap
216 find_lock_page 0.5192
196 find_next_bit 0.3603
136 sn2_send_IPI 0.2024
130 pio_phys_write_mmr 2.0312
118 unmap_kernel_range 0.1229
After:
78406 total 0.0081
40053 default_idle 89.4040
33576 ia64_spinlock_contention 349.7500
1650 _spin_lock 17.1875
319 __reg_op 0.5538
281 _atomic_dec_and_lock 1.0977
153 mutex_unlock 1.5938
123 iget_locked 0.1671
117 xfs_dir_lookup 0.1662
117 dput 0.1406
114 xfs_iget_core 0.0268
92 xfs_da_hashname 0.1917
75 d_alloc 0.0670
68 vmap_page_range 0.0462 <- vmap
58 kmem_cache_alloc 0.0604
57 memset 0.0540
52 rb_next 0.1625
50 __copy_user 0.0208
49 bitmap_find_free_region 0.2188 <- vmap
46 ia64_sn_udelay 0.1106
45 find_inode_fast 0.1406
42 memcmp 0.2188
42 finish_task_switch 0.1094
42 __d_lookup 0.0410
40 radix_tree_lookup_slot 0.1250
37 _spin_unlock_irqrestore 0.3854
36 xfs_bmapi 0.0050
36 kmem_cache_free 0.0256
35 xfs_vn_getattr 0.0322
34 radix_tree_lookup 0.1062
33 __link_path_walk 0.0035
31 xfs_da_do_buf 0.0091
30 _xfs_buf_find 0.0204
28 find_get_page 0.0875
27 xfs_iread 0.0241
27 __strncpy_from_user 0.2812
26 _xfs_buf_initialize 0.0406
24 _xfs_buf_lookup_pages 0.0179
24 vunmap_page_range 0.0250 <- vunmap
23 find_lock_page 0.0799
22 vm_map_ram 0.0087 <- vmap
20 kfree 0.0125
19 put_page 0.0330
18 __kmalloc 0.0176
17 xfs_da_node_lookup_int 0.0086
17 _read_lock 0.0885
17 page_waitqueue 0.0664
vmap has gone from being the top 5 on the profiles and flushing the crap
out of all TLBs, to using less than 1% of kernel time.
[akpm@linux-foundation.org: cleanups, section fix]
[akpm@linux-foundation.org: fix build on alpha]
Signed-off-by: Nick Piggin <npiggin@suse.de>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-10-19 07:27:03 +04:00
|
|
|
#include <linux/init.h>
|
2013-04-30 02:07:40 +04:00
|
|
|
#include <linux/list.h>
|
2016-05-21 02:57:38 +03:00
|
|
|
#include <linux/llist.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <asm/page.h> /* pgprot_t */
|
2013-04-30 02:07:40 +04:00
|
|
|
#include <linux/rbtree.h>
|
2018-05-08 22:55:26 +03:00
|
|
|
#include <linux/overflow.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-08-16 14:07:21 +04:00
|
|
|
struct vm_area_struct; /* vma defining user mapping in mm_types.h */
|
2016-04-04 16:46:42 +03:00
|
|
|
struct notifier_block; /* in notifier.h */
|
2006-06-23 13:03:20 +04:00
|
|
|
|
2008-08-16 14:07:21 +04:00
|
|
|
/* bits in flags of vmalloc's vm_struct below */
|
2013-07-09 02:59:58 +04:00
|
|
|
#define VM_IOREMAP 0x00000001 /* ioremap() and friends */
|
|
|
|
#define VM_ALLOC 0x00000002 /* vmalloc() */
|
|
|
|
#define VM_MAP 0x00000004 /* vmap()ed pages */
|
|
|
|
#define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
|
|
|
|
#define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
|
2015-02-14 01:40:03 +03:00
|
|
|
#define VM_NO_GUARD 0x00000040 /* don't add guard page */
|
2015-03-13 02:26:11 +03:00
|
|
|
#define VM_KASAN 0x00000080 /* has allocated kasan shadow memory */
|
2005-04-17 02:20:36 +04:00
|
|
|
/* bits [20..32] reserved for arch specific ioremap internals */
|
|
|
|
|
2005-09-04 02:54:58 +04:00
|
|
|
/*
|
|
|
|
* Maximum alignment for ioremap() regions.
|
|
|
|
* Can be overriden by arch-specific value.
|
|
|
|
*/
|
|
|
|
#ifndef IOREMAP_MAX_ORDER
|
|
|
|
#define IOREMAP_MAX_ORDER (7 + PAGE_SHIFT) /* 128 pages */
|
|
|
|
#endif
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
struct vm_struct {
|
2006-11-10 23:27:48 +03:00
|
|
|
struct vm_struct *next;
|
2005-04-17 02:20:36 +04:00
|
|
|
void *addr;
|
|
|
|
unsigned long size;
|
|
|
|
unsigned long flags;
|
|
|
|
struct page **pages;
|
|
|
|
unsigned int nr_pages;
|
2010-06-18 07:22:40 +04:00
|
|
|
phys_addr_t phys_addr;
|
2012-04-13 14:32:09 +04:00
|
|
|
const void *caller;
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
2013-04-30 02:07:40 +04:00
|
|
|
struct vmap_area {
|
|
|
|
unsigned long va_start;
|
|
|
|
unsigned long va_end;
|
|
|
|
unsigned long flags;
|
|
|
|
struct rb_node rb_node; /* address sorted rbtree */
|
|
|
|
struct list_head list; /* address sorted list */
|
2016-05-21 02:57:38 +03:00
|
|
|
struct llist_node purge_list; /* "lazy purge" list */
|
2013-04-30 02:07:40 +04:00
|
|
|
struct vm_struct *vm;
|
|
|
|
struct rcu_head rcu_head;
|
|
|
|
};
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* Highlevel APIs for driver use
|
|
|
|
*/
|
mm: rewrite vmap layer
Rewrite the vmap allocator to use rbtrees and lazy tlb flushing, and
provide a fast, scalable percpu frontend for small vmaps (requires a
slightly different API, though).
The biggest problem with vmap is actually vunmap. Presently this requires
a global kernel TLB flush, which on most architectures is a broadcast IPI
to all CPUs to flush the cache. This is all done under a global lock. As
the number of CPUs increases, so will the number of vunmaps a scaled
workload will want to perform, and so will the cost of a global TLB flush.
This gives terrible quadratic scalability characteristics.
Another problem is that the entire vmap subsystem works under a single
lock. It is a rwlock, but it is actually taken for write in all the fast
paths, and the read locking would likely never be run concurrently anyway,
so it's just pointless.
This is a rewrite of vmap subsystem to solve those problems. The existing
vmalloc API is implemented on top of the rewritten subsystem.
The TLB flushing problem is solved by using lazy TLB unmapping. vmap
addresses do not have to be flushed immediately when they are vunmapped,
because the kernel will not reuse them again (would be a use-after-free)
until they are reallocated. So the addresses aren't allocated again until
a subsequent TLB flush. A single TLB flush then can flush multiple
vunmaps from each CPU.
XEN and PAT and such do not like deferred TLB flushing because they can't
always handle multiple aliasing virtual addresses to a physical address.
They now call vm_unmap_aliases() in order to flush any deferred mappings.
That call is very expensive (well, actually not a lot more expensive than
a single vunmap under the old scheme), however it should be OK if not
called too often.
The virtual memory extent information is stored in an rbtree rather than a
linked list to improve the algorithmic scalability.
There is a per-CPU allocator for small vmaps, which amortizes or avoids
global locking.
To use the per-CPU interface, the vm_map_ram / vm_unmap_ram interfaces
must be used in place of vmap and vunmap. Vmalloc does not use these
interfaces at the moment, so it will not be quite so scalable (although it
will use lazy TLB flushing).
As a quick test of performance, I ran a test that loops in the kernel,
linearly mapping then touching then unmapping 4 pages. Different numbers
of tests were run in parallel on an 4 core, 2 socket opteron. Results are
in nanoseconds per map+touch+unmap.
threads vanilla vmap rewrite
1 14700 2900
2 33600 3000
4 49500 2800
8 70631 2900
So with a 8 cores, the rewritten version is already 25x faster.
In a slightly more realistic test (although with an older and less
scalable version of the patch), I ripped the not-very-good vunmap batching
code out of XFS, and implemented the large buffer mapping with vm_map_ram
and vm_unmap_ram... along with a couple of other tricks, I was able to
speed up a large directory workload by 20x on a 64 CPU system. I believe
vmap/vunmap is actually sped up a lot more than 20x on such a system, but
I'm running into other locks now. vmap is pretty well blown off the
profiles.
Before:
1352059 total 0.1401
798784 _write_lock 8320.6667 <- vmlist_lock
529313 default_idle 1181.5022
15242 smp_call_function 15.8771 <- vmap tlb flushing
2472 __get_vm_area_node 1.9312 <- vmap
1762 remove_vm_area 4.5885 <- vunmap
316 map_vm_area 0.2297 <- vmap
312 kfree 0.1950
300 _spin_lock 3.1250
252 sn_send_IPI_phys 0.4375 <- tlb flushing
238 vmap 0.8264 <- vmap
216 find_lock_page 0.5192
196 find_next_bit 0.3603
136 sn2_send_IPI 0.2024
130 pio_phys_write_mmr 2.0312
118 unmap_kernel_range 0.1229
After:
78406 total 0.0081
40053 default_idle 89.4040
33576 ia64_spinlock_contention 349.7500
1650 _spin_lock 17.1875
319 __reg_op 0.5538
281 _atomic_dec_and_lock 1.0977
153 mutex_unlock 1.5938
123 iget_locked 0.1671
117 xfs_dir_lookup 0.1662
117 dput 0.1406
114 xfs_iget_core 0.0268
92 xfs_da_hashname 0.1917
75 d_alloc 0.0670
68 vmap_page_range 0.0462 <- vmap
58 kmem_cache_alloc 0.0604
57 memset 0.0540
52 rb_next 0.1625
50 __copy_user 0.0208
49 bitmap_find_free_region 0.2188 <- vmap
46 ia64_sn_udelay 0.1106
45 find_inode_fast 0.1406
42 memcmp 0.2188
42 finish_task_switch 0.1094
42 __d_lookup 0.0410
40 radix_tree_lookup_slot 0.1250
37 _spin_unlock_irqrestore 0.3854
36 xfs_bmapi 0.0050
36 kmem_cache_free 0.0256
35 xfs_vn_getattr 0.0322
34 radix_tree_lookup 0.1062
33 __link_path_walk 0.0035
31 xfs_da_do_buf 0.0091
30 _xfs_buf_find 0.0204
28 find_get_page 0.0875
27 xfs_iread 0.0241
27 __strncpy_from_user 0.2812
26 _xfs_buf_initialize 0.0406
24 _xfs_buf_lookup_pages 0.0179
24 vunmap_page_range 0.0250 <- vunmap
23 find_lock_page 0.0799
22 vm_map_ram 0.0087 <- vmap
20 kfree 0.0125
19 put_page 0.0330
18 __kmalloc 0.0176
17 xfs_da_node_lookup_int 0.0086
17 _read_lock 0.0885
17 page_waitqueue 0.0664
vmap has gone from being the top 5 on the profiles and flushing the crap
out of all TLBs, to using less than 1% of kernel time.
[akpm@linux-foundation.org: cleanups, section fix]
[akpm@linux-foundation.org: fix build on alpha]
Signed-off-by: Nick Piggin <npiggin@suse.de>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-10-19 07:27:03 +04:00
|
|
|
extern void vm_unmap_ram(const void *mem, unsigned int count);
|
|
|
|
extern void *vm_map_ram(struct page **pages, unsigned int count,
|
|
|
|
int node, pgprot_t prot);
|
|
|
|
extern void vm_unmap_aliases(void);
|
|
|
|
|
|
|
|
#ifdef CONFIG_MMU
|
|
|
|
extern void __init vmalloc_init(void);
|
|
|
|
#else
|
|
|
|
static inline void vmalloc_init(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
extern void *vmalloc(unsigned long size);
|
2010-10-27 01:22:06 +04:00
|
|
|
extern void *vzalloc(unsigned long size);
|
2006-06-23 13:03:20 +04:00
|
|
|
extern void *vmalloc_user(unsigned long size);
|
2005-10-30 04:15:41 +03:00
|
|
|
extern void *vmalloc_node(unsigned long size, int node);
|
2010-10-27 01:22:06 +04:00
|
|
|
extern void *vzalloc_node(unsigned long size, int node);
|
2005-04-17 02:20:36 +04:00
|
|
|
extern void *vmalloc_exec(unsigned long size);
|
|
|
|
extern void *vmalloc_32(unsigned long size);
|
2006-06-23 13:03:20 +04:00
|
|
|
extern void *vmalloc_32_user(unsigned long size);
|
2005-10-07 10:46:04 +04:00
|
|
|
extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
|
2011-01-14 02:46:02 +03:00
|
|
|
extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
|
|
|
|
unsigned long start, unsigned long end, gfp_t gfp_mask,
|
2015-02-14 01:40:07 +03:00
|
|
|
pgprot_t prot, unsigned long vm_flags, int node,
|
|
|
|
const void *caller);
|
2017-05-09 01:57:12 +03:00
|
|
|
#ifndef CONFIG_MMU
|
2017-05-09 01:57:09 +03:00
|
|
|
extern void *__vmalloc_node_flags(unsigned long size, int node, gfp_t flags);
|
mm, vmalloc: fix vmalloc users tracking properly
Commit 1f5307b1e094 ("mm, vmalloc: properly track vmalloc users") has
pulled asm/pgtable.h include dependency to linux/vmalloc.h and that
turned out to be a bad idea for some architectures. E.g. m68k fails
with
In file included from arch/m68k/include/asm/pgtable_mm.h:145:0,
from arch/m68k/include/asm/pgtable.h:4,
from include/linux/vmalloc.h:9,
from arch/m68k/kernel/module.c:9:
arch/m68k/include/asm/mcf_pgtable.h: In function 'nocache_page':
>> arch/m68k/include/asm/mcf_pgtable.h:339:43: error: 'init_mm' undeclared (first use in this function)
#define pgd_offset_k(address) pgd_offset(&init_mm, address)
as spotted by kernel build bot. nios2 fails for other reason
In file included from include/asm-generic/io.h:767:0,
from arch/nios2/include/asm/io.h:61,
from include/linux/io.h:25,
from arch/nios2/include/asm/pgtable.h:18,
from include/linux/mm.h:70,
from include/linux/pid_namespace.h:6,
from include/linux/ptrace.h:9,
from arch/nios2/include/uapi/asm/elf.h:23,
from arch/nios2/include/asm/elf.h:22,
from include/linux/elf.h:4,
from include/linux/module.h:15,
from init/main.c:16:
include/linux/vmalloc.h: In function '__vmalloc_node_flags':
include/linux/vmalloc.h:99:40: error: 'PAGE_KERNEL' undeclared (first use in this function); did you mean 'GFP_KERNEL'?
which is due to the newly added #include <asm/pgtable.h>, which on nios2
includes <linux/io.h> and thus <asm/io.h> and <asm-generic/io.h> which
again includes <linux/vmalloc.h>.
Tweaking that around just turns out a bigger headache than necessary.
This patch reverts 1f5307b1e094 and reimplements the original fix in a
different way. __vmalloc_node_flags can stay static inline which will
cover vmalloc* functions. We only have one external user
(kvmalloc_node) and we can export __vmalloc_node_flags_caller and
provide the caller directly. This is much simpler and it doesn't really
need any games with header files.
[akpm@linux-foundation.org: coding-style fixes]
[mhocko@kernel.org: revert old comment]
Link: http://lkml.kernel.org/r/20170509211054.GB16325@dhcp22.suse.cz
Fixes: 1f5307b1e094 ("mm, vmalloc: properly track vmalloc users")
Link: http://lkml.kernel.org/r/20170509153702.GR6481@dhcp22.suse.cz
Signed-off-by: Michal Hocko <mhocko@suse.com>
Cc: Tobias Klauser <tklauser@distanz.ch>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-05-13 01:46:41 +03:00
|
|
|
static inline void *__vmalloc_node_flags_caller(unsigned long size, int node,
|
|
|
|
gfp_t flags, void *caller)
|
2017-05-09 01:57:12 +03:00
|
|
|
{
|
mm, vmalloc: fix vmalloc users tracking properly
Commit 1f5307b1e094 ("mm, vmalloc: properly track vmalloc users") has
pulled asm/pgtable.h include dependency to linux/vmalloc.h and that
turned out to be a bad idea for some architectures. E.g. m68k fails
with
In file included from arch/m68k/include/asm/pgtable_mm.h:145:0,
from arch/m68k/include/asm/pgtable.h:4,
from include/linux/vmalloc.h:9,
from arch/m68k/kernel/module.c:9:
arch/m68k/include/asm/mcf_pgtable.h: In function 'nocache_page':
>> arch/m68k/include/asm/mcf_pgtable.h:339:43: error: 'init_mm' undeclared (first use in this function)
#define pgd_offset_k(address) pgd_offset(&init_mm, address)
as spotted by kernel build bot. nios2 fails for other reason
In file included from include/asm-generic/io.h:767:0,
from arch/nios2/include/asm/io.h:61,
from include/linux/io.h:25,
from arch/nios2/include/asm/pgtable.h:18,
from include/linux/mm.h:70,
from include/linux/pid_namespace.h:6,
from include/linux/ptrace.h:9,
from arch/nios2/include/uapi/asm/elf.h:23,
from arch/nios2/include/asm/elf.h:22,
from include/linux/elf.h:4,
from include/linux/module.h:15,
from init/main.c:16:
include/linux/vmalloc.h: In function '__vmalloc_node_flags':
include/linux/vmalloc.h:99:40: error: 'PAGE_KERNEL' undeclared (first use in this function); did you mean 'GFP_KERNEL'?
which is due to the newly added #include <asm/pgtable.h>, which on nios2
includes <linux/io.h> and thus <asm/io.h> and <asm-generic/io.h> which
again includes <linux/vmalloc.h>.
Tweaking that around just turns out a bigger headache than necessary.
This patch reverts 1f5307b1e094 and reimplements the original fix in a
different way. __vmalloc_node_flags can stay static inline which will
cover vmalloc* functions. We only have one external user
(kvmalloc_node) and we can export __vmalloc_node_flags_caller and
provide the caller directly. This is much simpler and it doesn't really
need any games with header files.
[akpm@linux-foundation.org: coding-style fixes]
[mhocko@kernel.org: revert old comment]
Link: http://lkml.kernel.org/r/20170509211054.GB16325@dhcp22.suse.cz
Fixes: 1f5307b1e094 ("mm, vmalloc: properly track vmalloc users")
Link: http://lkml.kernel.org/r/20170509153702.GR6481@dhcp22.suse.cz
Signed-off-by: Michal Hocko <mhocko@suse.com>
Cc: Tobias Klauser <tklauser@distanz.ch>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-05-13 01:46:41 +03:00
|
|
|
return __vmalloc_node_flags(size, node, flags);
|
2017-05-09 01:57:12 +03:00
|
|
|
}
|
mm, vmalloc: fix vmalloc users tracking properly
Commit 1f5307b1e094 ("mm, vmalloc: properly track vmalloc users") has
pulled asm/pgtable.h include dependency to linux/vmalloc.h and that
turned out to be a bad idea for some architectures. E.g. m68k fails
with
In file included from arch/m68k/include/asm/pgtable_mm.h:145:0,
from arch/m68k/include/asm/pgtable.h:4,
from include/linux/vmalloc.h:9,
from arch/m68k/kernel/module.c:9:
arch/m68k/include/asm/mcf_pgtable.h: In function 'nocache_page':
>> arch/m68k/include/asm/mcf_pgtable.h:339:43: error: 'init_mm' undeclared (first use in this function)
#define pgd_offset_k(address) pgd_offset(&init_mm, address)
as spotted by kernel build bot. nios2 fails for other reason
In file included from include/asm-generic/io.h:767:0,
from arch/nios2/include/asm/io.h:61,
from include/linux/io.h:25,
from arch/nios2/include/asm/pgtable.h:18,
from include/linux/mm.h:70,
from include/linux/pid_namespace.h:6,
from include/linux/ptrace.h:9,
from arch/nios2/include/uapi/asm/elf.h:23,
from arch/nios2/include/asm/elf.h:22,
from include/linux/elf.h:4,
from include/linux/module.h:15,
from init/main.c:16:
include/linux/vmalloc.h: In function '__vmalloc_node_flags':
include/linux/vmalloc.h:99:40: error: 'PAGE_KERNEL' undeclared (first use in this function); did you mean 'GFP_KERNEL'?
which is due to the newly added #include <asm/pgtable.h>, which on nios2
includes <linux/io.h> and thus <asm/io.h> and <asm-generic/io.h> which
again includes <linux/vmalloc.h>.
Tweaking that around just turns out a bigger headache than necessary.
This patch reverts 1f5307b1e094 and reimplements the original fix in a
different way. __vmalloc_node_flags can stay static inline which will
cover vmalloc* functions. We only have one external user
(kvmalloc_node) and we can export __vmalloc_node_flags_caller and
provide the caller directly. This is much simpler and it doesn't really
need any games with header files.
[akpm@linux-foundation.org: coding-style fixes]
[mhocko@kernel.org: revert old comment]
Link: http://lkml.kernel.org/r/20170509211054.GB16325@dhcp22.suse.cz
Fixes: 1f5307b1e094 ("mm, vmalloc: properly track vmalloc users")
Link: http://lkml.kernel.org/r/20170509153702.GR6481@dhcp22.suse.cz
Signed-off-by: Michal Hocko <mhocko@suse.com>
Cc: Tobias Klauser <tklauser@distanz.ch>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-05-13 01:46:41 +03:00
|
|
|
#else
|
|
|
|
extern void *__vmalloc_node_flags_caller(unsigned long size,
|
|
|
|
int node, gfp_t flags, void *caller);
|
2017-05-09 01:57:12 +03:00
|
|
|
#endif
|
2015-02-14 01:40:07 +03:00
|
|
|
|
2008-02-05 09:28:32 +03:00
|
|
|
extern void vfree(const void *addr);
|
2016-12-13 03:44:10 +03:00
|
|
|
extern void vfree_atomic(const void *addr);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
extern void *vmap(struct page **pages, unsigned int count,
|
|
|
|
unsigned long flags, pgprot_t prot);
|
2008-02-05 09:28:32 +03:00
|
|
|
extern void vunmap(const void *addr);
|
2006-06-23 13:03:20 +04:00
|
|
|
|
2013-07-04 02:02:18 +04:00
|
|
|
extern int remap_vmalloc_range_partial(struct vm_area_struct *vma,
|
|
|
|
unsigned long uaddr, void *kaddr,
|
|
|
|
unsigned long size);
|
|
|
|
|
2006-06-23 13:03:20 +04:00
|
|
|
extern int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
|
|
|
|
unsigned long pgoff);
|
2007-05-08 11:27:03 +04:00
|
|
|
void vmalloc_sync_all(void);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Lowlevel-APIs (not for driver use!)
|
|
|
|
*/
|
2007-07-21 19:11:35 +04:00
|
|
|
|
|
|
|
static inline size_t get_vm_area_size(const struct vm_struct *area)
|
|
|
|
{
|
2015-02-14 01:40:03 +03:00
|
|
|
if (!(area->flags & VM_NO_GUARD))
|
|
|
|
/* return actual size without guard page */
|
|
|
|
return area->size - PAGE_SIZE;
|
|
|
|
else
|
|
|
|
return area->size;
|
|
|
|
|
2007-07-21 19:11:35 +04:00
|
|
|
}
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
extern struct vm_struct *get_vm_area(unsigned long size, unsigned long flags);
|
2008-04-28 13:12:42 +04:00
|
|
|
extern struct vm_struct *get_vm_area_caller(unsigned long size,
|
2012-04-13 14:32:09 +04:00
|
|
|
unsigned long flags, const void *caller);
|
2005-04-17 02:20:36 +04:00
|
|
|
extern struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
|
|
|
|
unsigned long start, unsigned long end);
|
2009-02-19 01:48:12 +03:00
|
|
|
extern struct vm_struct *__get_vm_area_caller(unsigned long size,
|
|
|
|
unsigned long flags,
|
|
|
|
unsigned long start, unsigned long end,
|
2012-04-13 14:32:09 +04:00
|
|
|
const void *caller);
|
2008-02-05 09:28:32 +03:00
|
|
|
extern struct vm_struct *remove_vm_area(const void *addr);
|
2012-07-30 11:11:33 +04:00
|
|
|
extern struct vm_struct *find_vm_area(const void *addr);
|
2007-06-04 09:15:35 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
extern int map_vm_area(struct vm_struct *area, pgprot_t prot,
|
2014-08-07 03:06:58 +04:00
|
|
|
struct page **pages);
|
2011-03-28 15:53:29 +04:00
|
|
|
#ifdef CONFIG_MMU
|
2009-02-20 10:29:08 +03:00
|
|
|
extern int map_kernel_range_noflush(unsigned long start, unsigned long size,
|
|
|
|
pgprot_t prot, struct page **pages);
|
|
|
|
extern void unmap_kernel_range_noflush(unsigned long addr, unsigned long size);
|
2007-06-04 09:15:35 +04:00
|
|
|
extern void unmap_kernel_range(unsigned long addr, unsigned long size);
|
2011-03-28 15:53:29 +04:00
|
|
|
#else
|
|
|
|
static inline int
|
|
|
|
map_kernel_range_noflush(unsigned long start, unsigned long size,
|
|
|
|
pgprot_t prot, struct page **pages)
|
|
|
|
{
|
|
|
|
return size >> PAGE_SHIFT;
|
|
|
|
}
|
|
|
|
static inline void
|
|
|
|
unmap_kernel_range_noflush(unsigned long addr, unsigned long size)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static inline void
|
|
|
|
unmap_kernel_range(unsigned long addr, unsigned long size)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-07-18 05:37:04 +04:00
|
|
|
/* Allocate/destroy a 'vmalloc' VM area. */
|
2011-09-29 19:53:32 +04:00
|
|
|
extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
|
2007-07-18 05:37:04 +04:00
|
|
|
extern void free_vm_area(struct vm_struct *area);
|
|
|
|
|
2009-01-07 01:39:46 +03:00
|
|
|
/* for /dev/kmem */
|
|
|
|
extern long vread(char *buf, char *addr, unsigned long count);
|
|
|
|
extern long vwrite(char *buf, char *addr, unsigned long count);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* Internals. Dont't use..
|
|
|
|
*/
|
2013-04-30 02:07:37 +04:00
|
|
|
extern struct list_head vmap_area_list;
|
2011-08-25 08:24:21 +04:00
|
|
|
extern __init void vm_area_add_early(struct vm_struct *vm);
|
2009-02-24 05:57:21 +03:00
|
|
|
extern __init void vm_area_register_early(struct vm_struct *vm, size_t align);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2010-09-03 20:22:47 +04:00
|
|
|
#ifdef CONFIG_SMP
|
2011-03-28 15:53:29 +04:00
|
|
|
# ifdef CONFIG_MMU
|
2009-08-14 10:00:52 +04:00
|
|
|
struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets,
|
|
|
|
const size_t *sizes, int nr_vms,
|
2011-01-14 02:46:01 +03:00
|
|
|
size_t align);
|
2009-08-14 10:00:52 +04:00
|
|
|
|
|
|
|
void pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms);
|
2011-03-28 15:53:29 +04:00
|
|
|
# else
|
|
|
|
static inline struct vm_struct **
|
|
|
|
pcpu_get_vm_areas(const unsigned long *offsets,
|
|
|
|
const size_t *sizes, int nr_vms,
|
|
|
|
size_t align)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
# endif
|
2010-09-03 20:22:47 +04:00
|
|
|
#endif
|
2009-08-14 10:00:52 +04:00
|
|
|
|
2013-04-30 02:07:28 +04:00
|
|
|
#ifdef CONFIG_MMU
|
|
|
|
#define VMALLOC_TOTAL (VMALLOC_END - VMALLOC_START)
|
|
|
|
#else
|
|
|
|
#define VMALLOC_TOTAL 0UL
|
|
|
|
#endif
|
|
|
|
|
2016-04-04 16:46:42 +03:00
|
|
|
int register_vmap_purge_notifier(struct notifier_block *nb);
|
|
|
|
int unregister_vmap_purge_notifier(struct notifier_block *nb);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#endif /* _LINUX_VMALLOC_H */
|