Skip to content

Commit 5ecc9d1

Browse files
committed
Merge branch 'akpm' (patches from Andrew)
Merge more updates from Andrew Morton: "Most of the rest of MM and various other things. Some Kconfig rework still awaits merges of dependent trees from linux-next. Subsystems affected by this patch series: mm/hotfixes, mm/memcg, mm/vmstat, mm/thp, procfs, sysctl, misc, notifiers, core-kernel, bitops, lib, checkpatch, epoll, binfmt, init, rapidio, uaccess, kcov, ubsan, ipc, bitmap, mm/pagemap" * akpm: (86 commits) mm: remove __ARCH_HAS_4LEVEL_HACK and include/asm-generic/4level-fixup.h um: add support for folded p4d page tables um: remove unused pxx_offset_proc() and addr_pte() functions sparc32: use pgtable-nopud instead of 4level-fixup parisc/hugetlb: use pgtable-nopXd instead of 4level-fixup parisc: use pgtable-nopXd instead of 4level-fixup nds32: use pgtable-nopmd instead of 4level-fixup microblaze: use pgtable-nopmd instead of 4level-fixup m68k: mm: use pgtable-nopXd instead of 4level-fixup m68k: nommu: use pgtable-nopud instead of 4level-fixup c6x: use pgtable-nopud instead of 4level-fixup arm: nommu: use pgtable-nopud instead of 4level-fixup alpha: use pgtable-nopud instead of 4level-fixup gpio: pca953x: tighten up indentation gpio: pca953x: convert to use bitmap API gpio: pca953x: use input from regs structure in pca953x_irq_pending() gpio: pca953x: remove redundant variable and check in IRQ handler lib/bitmap: introduce bitmap_replace() helper lib/test_bitmap: fix comment about this file lib/test_bitmap: move exp1 and exp2 upper for others to use ...
2 parents 2f13437 + f949286 commit 5ecc9d1

File tree

154 files changed

+5252
-1342
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+5252
-1342
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
*.c diff=cpp
22
*.h diff=cpp
3+
*.dtsi diff=dts
4+
*.dts diff=dts

Documentation/core-api/genalloc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ writing of special-purpose memory allocators in the future.
129129
:functions: gen_pool_for_each_chunk
130130

131131
.. kernel-doc:: lib/genalloc.c
132-
:functions: addr_in_gen_pool
132+
:functions: gen_pool_has_addr
133133

134134
.. kernel-doc:: lib/genalloc.c
135135
:functions: gen_pool_avail

Documentation/dev-tools/kcov.rst

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Profiling data will only become accessible once debugfs has been mounted::
3434

3535
Coverage collection
3636
-------------------
37+
3738
The following program demonstrates coverage collection from within a test
3839
program using kcov:
3940

@@ -128,6 +129,7 @@ only need to enable coverage (disable happens automatically on thread end).
128129

129130
Comparison operands collection
130131
------------------------------
132+
131133
Comparison operands collection is similar to coverage collection:
132134

133135
.. code-block:: c
@@ -202,3 +204,130 @@ Comparison operands collection is similar to coverage collection:
202204
203205
Note that the kcov modes (coverage collection or comparison operands) are
204206
mutually exclusive.
207+
208+
Remote coverage collection
209+
--------------------------
210+
211+
With KCOV_ENABLE coverage is collected only for syscalls that are issued
212+
from the current process. With KCOV_REMOTE_ENABLE it's possible to collect
213+
coverage for arbitrary parts of the kernel code, provided that those parts
214+
are annotated with kcov_remote_start()/kcov_remote_stop().
215+
216+
This allows to collect coverage from two types of kernel background
217+
threads: the global ones, that are spawned during kernel boot in a limited
218+
number of instances (e.g. one USB hub_event() worker thread is spawned per
219+
USB HCD); and the local ones, that are spawned when a user interacts with
220+
some kernel interface (e.g. vhost workers).
221+
222+
To enable collecting coverage from a global background thread, a unique
223+
global handle must be assigned and passed to the corresponding
224+
kcov_remote_start() call. Then a userspace process can pass a list of such
225+
handles to the KCOV_REMOTE_ENABLE ioctl in the handles array field of the
226+
kcov_remote_arg struct. This will attach the used kcov device to the code
227+
sections, that are referenced by those handles.
228+
229+
Since there might be many local background threads spawned from different
230+
userspace processes, we can't use a single global handle per annotation.
231+
Instead, the userspace process passes a non-zero handle through the
232+
common_handle field of the kcov_remote_arg struct. This common handle gets
233+
saved to the kcov_handle field in the current task_struct and needs to be
234+
passed to the newly spawned threads via custom annotations. Those threads
235+
should in turn be annotated with kcov_remote_start()/kcov_remote_stop().
236+
237+
Internally kcov stores handles as u64 integers. The top byte of a handle
238+
is used to denote the id of a subsystem that this handle belongs to, and
239+
the lower 4 bytes are used to denote the id of a thread instance within
240+
that subsystem. A reserved value 0 is used as a subsystem id for common
241+
handles as they don't belong to a particular subsystem. The bytes 4-7 are
242+
currently reserved and must be zero. In the future the number of bytes
243+
used for the subsystem or handle ids might be increased.
244+
245+
When a particular userspace proccess collects coverage by via a common
246+
handle, kcov will collect coverage for each code section that is annotated
247+
to use the common handle obtained as kcov_handle from the current
248+
task_struct. However non common handles allow to collect coverage
249+
selectively from different subsystems.
250+
251+
.. code-block:: c
252+
253+
struct kcov_remote_arg {
254+
unsigned trace_mode;
255+
unsigned area_size;
256+
unsigned num_handles;
257+
uint64_t common_handle;
258+
uint64_t handles[0];
259+
};
260+
261+
#define KCOV_INIT_TRACE _IOR('c', 1, unsigned long)
262+
#define KCOV_DISABLE _IO('c', 101)
263+
#define KCOV_REMOTE_ENABLE _IOW('c', 102, struct kcov_remote_arg)
264+
265+
#define COVER_SIZE (64 << 10)
266+
267+
#define KCOV_TRACE_PC 0
268+
269+
#define KCOV_SUBSYSTEM_COMMON (0x00ull << 56)
270+
#define KCOV_SUBSYSTEM_USB (0x01ull << 56)
271+
272+
#define KCOV_SUBSYSTEM_MASK (0xffull << 56)
273+
#define KCOV_INSTANCE_MASK (0xffffffffull)
274+
275+
static inline __u64 kcov_remote_handle(__u64 subsys, __u64 inst)
276+
{
277+
if (subsys & ~KCOV_SUBSYSTEM_MASK || inst & ~KCOV_INSTANCE_MASK)
278+
return 0;
279+
return subsys | inst;
280+
}
281+
282+
#define KCOV_COMMON_ID 0x42
283+
#define KCOV_USB_BUS_NUM 1
284+
285+
int main(int argc, char **argv)
286+
{
287+
int fd;
288+
unsigned long *cover, n, i;
289+
struct kcov_remote_arg *arg;
290+
291+
fd = open("/sys/kernel/debug/kcov", O_RDWR);
292+
if (fd == -1)
293+
perror("open"), exit(1);
294+
if (ioctl(fd, KCOV_INIT_TRACE, COVER_SIZE))
295+
perror("ioctl"), exit(1);
296+
cover = (unsigned long*)mmap(NULL, COVER_SIZE * sizeof(unsigned long),
297+
PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
298+
if ((void*)cover == MAP_FAILED)
299+
perror("mmap"), exit(1);
300+
301+
/* Enable coverage collection via common handle and from USB bus #1. */
302+
arg = calloc(1, sizeof(*arg) + sizeof(uint64_t));
303+
if (!arg)
304+
perror("calloc"), exit(1);
305+
arg->trace_mode = KCOV_TRACE_PC;
306+
arg->area_size = COVER_SIZE;
307+
arg->num_handles = 1;
308+
arg->common_handle = kcov_remote_handle(KCOV_SUBSYSTEM_COMMON,
309+
KCOV_COMMON_ID);
310+
arg->handles[0] = kcov_remote_handle(KCOV_SUBSYSTEM_USB,
311+
KCOV_USB_BUS_NUM);
312+
if (ioctl(fd, KCOV_REMOTE_ENABLE, arg))
313+
perror("ioctl"), free(arg), exit(1);
314+
free(arg);
315+
316+
/*
317+
* Here the user needs to trigger execution of a kernel code section
318+
* that is either annotated with the common handle, or to trigger some
319+
* activity on USB bus #1.
320+
*/
321+
sleep(2);
322+
323+
n = __atomic_load_n(&cover[0], __ATOMIC_RELAXED);
324+
for (i = 0; i < n; i++)
325+
printf("0x%lx\n", cover[i + 1]);
326+
if (ioctl(fd, KCOV_DISABLE, 0))
327+
perror("ioctl"), exit(1);
328+
if (munmap(cover, COVER_SIZE * sizeof(unsigned long)))
329+
perror("munmap"), exit(1);
330+
if (close(fd))
331+
perror("close"), exit(1);
332+
return 0;
333+
}

arch/Kconfig

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,19 @@ config KPROBES
7272
If in doubt, say "N".
7373

7474
config JUMP_LABEL
75-
bool "Optimize very unlikely/likely branches"
76-
depends on HAVE_ARCH_JUMP_LABEL
77-
depends on CC_HAS_ASM_GOTO
78-
help
79-
This option enables a transparent branch optimization that
75+
bool "Optimize very unlikely/likely branches"
76+
depends on HAVE_ARCH_JUMP_LABEL
77+
depends on CC_HAS_ASM_GOTO
78+
help
79+
This option enables a transparent branch optimization that
8080
makes certain almost-always-true or almost-always-false branch
8181
conditions even cheaper to execute within the kernel.
8282

8383
Certain performance-sensitive kernel code, such as trace points,
8484
scheduler functionality, networking code and KVM have such
8585
branches and include support for this optimization technique.
8686

87-
If it is detected that the compiler has support for "asm goto",
87+
If it is detected that the compiler has support for "asm goto",
8888
the kernel will compile such branches with just a nop
8989
instruction. When the condition flag is toggled to true, the
9090
nop will be converted to a jump instruction to execute the
@@ -151,8 +151,8 @@ config HAVE_EFFICIENT_UNALIGNED_ACCESS
151151
information on the topic of unaligned memory accesses.
152152

153153
config ARCH_USE_BUILTIN_BSWAP
154-
bool
155-
help
154+
bool
155+
help
156156
Modern versions of GCC (since 4.4) have builtin functions
157157
for handling byte-swapping. Using these, instead of the old
158158
inline assembler that the architecture code provides in the
@@ -221,10 +221,10 @@ config HAVE_DMA_CONTIGUOUS
221221
bool
222222

223223
config GENERIC_SMP_IDLE_THREAD
224-
bool
224+
bool
225225

226226
config GENERIC_IDLE_POLL_SETUP
227-
bool
227+
bool
228228

229229
config ARCH_HAS_FORTIFY_SOURCE
230230
bool
@@ -257,7 +257,7 @@ config ARCH_HAS_UNCACHED_SEGMENT
257257

258258
# Select if arch init_task must go in the __init_task_data section
259259
config ARCH_TASK_STRUCT_ON_STACK
260-
bool
260+
bool
261261

262262
# Select if arch has its private alloc_task_struct() function
263263
config ARCH_TASK_STRUCT_ALLOCATOR

arch/alpha/include/asm/mmzone.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ PLAT_NODE_DATA_LOCALNR(unsigned long p, int n)
7373
#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
7474

7575
#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> 32))
76-
#define pgd_page(pgd) (pfn_to_page(pgd_val(pgd) >> 32))
7776
#define pte_pfn(pte) (pte_val(pte) >> 32)
7877

7978
#define mk_pte(page, pgprot) \

arch/alpha/include/asm/pgalloc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)
2727
}
2828

2929
static inline void
30-
pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
30+
pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
3131
{
32-
pgd_set(pgd, pmd);
32+
pud_set(pud, pmd);
3333
}
3434

3535
extern pgd_t *pgd_alloc(struct mm_struct *mm);

arch/alpha/include/asm/pgtable.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#ifndef _ALPHA_PGTABLE_H
33
#define _ALPHA_PGTABLE_H
44

5-
#include <asm-generic/4level-fixup.h>
5+
#include <asm-generic/pgtable-nopud.h>
66

77
/*
88
* This file contains the functions and defines necessary to modify and use
@@ -226,8 +226,8 @@ extern inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
226226
extern inline void pmd_set(pmd_t * pmdp, pte_t * ptep)
227227
{ pmd_val(*pmdp) = _PAGE_TABLE | ((((unsigned long) ptep) - PAGE_OFFSET) << (32-PAGE_SHIFT)); }
228228

229-
extern inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
230-
{ pgd_val(*pgdp) = _PAGE_TABLE | ((((unsigned long) pmdp) - PAGE_OFFSET) << (32-PAGE_SHIFT)); }
229+
extern inline void pud_set(pud_t * pudp, pmd_t * pmdp)
230+
{ pud_val(*pudp) = _PAGE_TABLE | ((((unsigned long) pmdp) - PAGE_OFFSET) << (32-PAGE_SHIFT)); }
231231

232232

233233
extern inline unsigned long
@@ -238,11 +238,11 @@ pmd_page_vaddr(pmd_t pmd)
238238

239239
#ifndef CONFIG_DISCONTIGMEM
240240
#define pmd_page(pmd) (mem_map + ((pmd_val(pmd) & _PFN_MASK) >> 32))
241-
#define pgd_page(pgd) (mem_map + ((pgd_val(pgd) & _PFN_MASK) >> 32))
241+
#define pud_page(pud) (mem_map + ((pud_val(pud) & _PFN_MASK) >> 32))
242242
#endif
243243

244-
extern inline unsigned long pgd_page_vaddr(pgd_t pgd)
245-
{ return PAGE_OFFSET + ((pgd_val(pgd) & _PFN_MASK) >> (32-PAGE_SHIFT)); }
244+
extern inline unsigned long pud_page_vaddr(pud_t pgd)
245+
{ return PAGE_OFFSET + ((pud_val(pgd) & _PFN_MASK) >> (32-PAGE_SHIFT)); }
246246

247247
extern inline int pte_none(pte_t pte) { return !pte_val(pte); }
248248
extern inline int pte_present(pte_t pte) { return pte_val(pte) & _PAGE_VALID; }
@@ -256,10 +256,10 @@ extern inline int pmd_bad(pmd_t pmd) { return (pmd_val(pmd) & ~_PFN_MASK) != _P
256256
extern inline int pmd_present(pmd_t pmd) { return pmd_val(pmd) & _PAGE_VALID; }
257257
extern inline void pmd_clear(pmd_t * pmdp) { pmd_val(*pmdp) = 0; }
258258

259-
extern inline int pgd_none(pgd_t pgd) { return !pgd_val(pgd); }
260-
extern inline int pgd_bad(pgd_t pgd) { return (pgd_val(pgd) & ~_PFN_MASK) != _PAGE_TABLE; }
261-
extern inline int pgd_present(pgd_t pgd) { return pgd_val(pgd) & _PAGE_VALID; }
262-
extern inline void pgd_clear(pgd_t * pgdp) { pgd_val(*pgdp) = 0; }
259+
extern inline int pud_none(pud_t pud) { return !pud_val(pud); }
260+
extern inline int pud_bad(pud_t pud) { return (pud_val(pud) & ~_PFN_MASK) != _PAGE_TABLE; }
261+
extern inline int pud_present(pud_t pud) { return pud_val(pud) & _PAGE_VALID; }
262+
extern inline void pud_clear(pud_t * pudp) { pud_val(*pudp) = 0; }
263263

264264
/*
265265
* The following only work if pte_present() is true.
@@ -301,9 +301,9 @@ extern inline pte_t pte_mkspecial(pte_t pte) { return pte; }
301301
*/
302302

303303
/* Find an entry in the second-level page table.. */
304-
extern inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address)
304+
extern inline pmd_t * pmd_offset(pud_t * dir, unsigned long address)
305305
{
306-
pmd_t *ret = (pmd_t *) pgd_page_vaddr(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PAGE - 1));
306+
pmd_t *ret = (pmd_t *) pud_page_vaddr(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PAGE - 1));
307307
smp_read_barrier_depends(); /* see above */
308308
return ret;
309309
}

arch/alpha/mm/init.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ callback_init(void * kernel_end)
146146
{
147147
struct crb_struct * crb;
148148
pgd_t *pgd;
149+
p4d_t *p4d;
150+
pud_t *pud;
149151
pmd_t *pmd;
150152
void *two_pages;
151153

@@ -184,8 +186,10 @@ callback_init(void * kernel_end)
184186
memset(two_pages, 0, 2*PAGE_SIZE);
185187

186188
pgd = pgd_offset_k(VMALLOC_START);
187-
pgd_set(pgd, (pmd_t *)two_pages);
188-
pmd = pmd_offset(pgd, VMALLOC_START);
189+
p4d = p4d_offset(pgd, VMALLOC_START);
190+
pud = pud_offset(p4d, VMALLOC_START);
191+
pud_set(pud, (pmd_t *)two_pages);
192+
pmd = pmd_offset(pud, VMALLOC_START);
189193
pmd_set(pmd, (pte_t *)(two_pages + PAGE_SIZE));
190194

191195
if (alpha_using_srm) {
@@ -214,9 +218,9 @@ callback_init(void * kernel_end)
214218
/* Newer consoles (especially on larger
215219
systems) may require more pages of
216220
PTEs. Grab additional pages as needed. */
217-
if (pmd != pmd_offset(pgd, vaddr)) {
221+
if (pmd != pmd_offset(pud, vaddr)) {
218222
memset(kernel_end, 0, PAGE_SIZE);
219-
pmd = pmd_offset(pgd, vaddr);
223+
pmd = pmd_offset(pud, vaddr);
220224
pmd_set(pmd, (pte_t *)kernel_end);
221225
kernel_end += PAGE_SIZE;
222226
}

arch/arm/include/asm/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#ifndef CONFIG_MMU
1414

15-
#include <asm-generic/4level-fixup.h>
15+
#include <asm-generic/pgtable-nopud.h>
1616
#include <asm/pgtable-nommu.h>
1717

1818
#else

arch/arm/mm/dma-mapping.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ static void *__alloc_from_pool(size_t size, struct page **ret_page)
529529

530530
static bool __in_atomic_pool(void *start, size_t size)
531531
{
532-
return addr_in_gen_pool(atomic_pool, (unsigned long)start, size);
532+
return gen_pool_has_addr(atomic_pool, (unsigned long)start, size);
533533
}
534534

535535
static int __free_from_pool(void *start, size_t size)

0 commit comments

Comments
 (0)