Skip to content

Commit b9de6ef

Browse files
committed
Merge branch 'akpm' (patches from Andrew)
Merge misc fixes from Andrew Morton: "24 fixes" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (24 commits) autofs: fix error return in autofs_fill_super() autofs: drop dentry reference only when it is never used fs/drop_caches.c: avoid softlockups in drop_pagecache_sb() mm: migrate: don't rely on __PageMovable() of newpage after unlocking it psi: clarify the Kconfig text for the default-disable option mm, memory_hotplug: __offline_pages fix wrong locking mm: hwpoison: use do_send_sig_info() instead of force_sig() kasan: mark file common so ftrace doesn't trace it init/Kconfig: fix grammar by moving a closing parenthesis lib/test_kmod.c: potential double free in error handling mm, oom: fix use-after-free in oom_kill_process mm/hotplug: invalid PFNs from pfn_to_online_page() mm,memory_hotplug: fix scan_movable_pages() for gigantic hugepages psi: fix aggregation idle shut-off mm, memory_hotplug: test_pages_in_a_zone do not pass the end of zone mm, memory_hotplug: is_mem_section_removable do not pass the end of a zone oom, oom_reaper: do not enqueue same task twice mm: migrate: make buffer_migrate_page_norefs() actually succeed kernel/exit.c: release ptraced tasks before zap_pid_ns_processes x86_64: increase stack size for KASAN_EXTRA ...
2 parents cd984a5 + f585b28 commit b9de6ef

File tree

38 files changed

+304
-74
lines changed

38 files changed

+304
-74
lines changed

arch/c6x/include/asm/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ generic-y += pgalloc.h
3030
generic-y += preempt.h
3131
generic-y += segment.h
3232
generic-y += serial.h
33+
generic-y += shmparam.h
3334
generic-y += tlbflush.h
3435
generic-y += topology.h
3536
generic-y += trace_clock.h

arch/c6x/include/uapi/asm/Kbuild

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
include include/uapi/asm-generic/Kbuild.asm
22

33
generic-y += kvm_para.h
4-
generic-y += shmparam.h
54
generic-y += ucontext.h

arch/h8300/include/asm/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ generic-y += preempt.h
4040
generic-y += scatterlist.h
4141
generic-y += sections.h
4242
generic-y += serial.h
43+
generic-y += shmparam.h
4344
generic-y += sizes.h
4445
generic-y += spinlock.h
4546
generic-y += timex.h

arch/h8300/include/uapi/asm/Kbuild

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
include include/uapi/asm-generic/Kbuild.asm
22

33
generic-y += kvm_para.h
4-
generic-y += shmparam.h
54
generic-y += ucontext.h

arch/hexagon/include/asm/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ generic-y += rwsem.h
3030
generic-y += sections.h
3131
generic-y += segment.h
3232
generic-y += serial.h
33+
generic-y += shmparam.h
3334
generic-y += sizes.h
3435
generic-y += topology.h
3536
generic-y += trace_clock.h

arch/hexagon/include/uapi/asm/Kbuild

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
include include/uapi/asm-generic/Kbuild.asm
22

3-
generic-y += shmparam.h
43
generic-y += ucontext.h

arch/m68k/include/asm/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ generic-y += mm-arch-hooks.h
2020
generic-y += percpu.h
2121
generic-y += preempt.h
2222
generic-y += sections.h
23+
generic-y += shmparam.h
2324
generic-y += spinlock.h
2425
generic-y += topology.h
2526
generic-y += trace_clock.h

arch/m68k/include/uapi/asm/Kbuild

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ include include/uapi/asm-generic/Kbuild.asm
22

33
generated-y += unistd_32.h
44
generic-y += kvm_para.h
5-
generic-y += shmparam.h

arch/microblaze/include/asm/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ generic-y += parport.h
2626
generic-y += percpu.h
2727
generic-y += preempt.h
2828
generic-y += serial.h
29+
generic-y += shmparam.h
2930
generic-y += syscalls.h
3031
generic-y += topology.h
3132
generic-y += trace_clock.h

arch/microblaze/include/uapi/asm/Kbuild

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ include include/uapi/asm-generic/Kbuild.asm
22

33
generated-y += unistd_32.h
44
generic-y += kvm_para.h
5-
generic-y += shmparam.h
65
generic-y += ucontext.h

arch/openrisc/include/asm/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ generic-y += qrwlock_types.h
3434
generic-y += qrwlock.h
3535
generic-y += sections.h
3636
generic-y += segment.h
37+
generic-y += shmparam.h
3738
generic-y += string.h
3839
generic-y += switch_to.h
3940
generic-y += topology.h

arch/openrisc/include/uapi/asm/Kbuild

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
include include/uapi/asm-generic/Kbuild.asm
22

33
generic-y += kvm_para.h
4-
generic-y += shmparam.h
54
generic-y += ucontext.h

arch/unicore32/include/asm/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ generic-y += preempt.h
2828
generic-y += sections.h
2929
generic-y += segment.h
3030
generic-y += serial.h
31+
generic-y += shmparam.h
3132
generic-y += sizes.h
3233
generic-y += syscalls.h
3334
generic-y += topology.h
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
include include/uapi/asm-generic/Kbuild.asm
22

33
generic-y += kvm_para.h
4-
generic-y += shmparam.h
54
generic-y += ucontext.h

arch/x86/include/asm/page_64_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
#endif
88

99
#ifdef CONFIG_KASAN
10+
#ifdef CONFIG_KASAN_EXTRA
11+
#define KASAN_STACK_ORDER 2
12+
#else
1013
#define KASAN_STACK_ORDER 1
14+
#endif
1115
#else
1216
#define KASAN_STACK_ORDER 0
1317
#endif

fs/autofs/expire.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,6 @@ int autofs_expire_run(struct super_block *sb,
596596
pkt.len = dentry->d_name.len;
597597
memcpy(pkt.name, dentry->d_name.name, pkt.len);
598598
pkt.name[pkt.len] = '\0';
599-
dput(dentry);
600599

601600
if (copy_to_user(pkt_p, &pkt, sizeof(struct autofs_packet_expire)))
602601
ret = -EFAULT;
@@ -609,6 +608,8 @@ int autofs_expire_run(struct super_block *sb,
609608
complete_all(&ino->expire_complete);
610609
spin_unlock(&sbi->fs_lock);
611610

611+
dput(dentry);
612+
612613
return ret;
613614
}
614615

fs/autofs/inode.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,10 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
266266
}
267267
root_inode = autofs_get_inode(s, S_IFDIR | 0755);
268268
root = d_make_root(root_inode);
269-
if (!root)
269+
if (!root) {
270+
ret = -ENOMEM;
270271
goto fail_ino;
272+
}
271273
pipe = NULL;
272274

273275
root->d_fsdata = ino;

fs/drop_caches.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,21 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused)
2121
spin_lock(&sb->s_inode_list_lock);
2222
list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
2323
spin_lock(&inode->i_lock);
24+
/*
25+
* We must skip inodes in unusual state. We may also skip
26+
* inodes without pages but we deliberately won't in case
27+
* we need to reschedule to avoid softlockups.
28+
*/
2429
if ((inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) ||
25-
(inode->i_mapping->nrpages == 0)) {
30+
(inode->i_mapping->nrpages == 0 && !need_resched())) {
2631
spin_unlock(&inode->i_lock);
2732
continue;
2833
}
2934
__iget(inode);
3035
spin_unlock(&inode->i_lock);
3136
spin_unlock(&sb->s_inode_list_lock);
3237

38+
cond_resched();
3339
invalidate_mapping_pages(inode->i_mapping, 0, -1);
3440
iput(toput_inode);
3541
toput_inode = inode;

fs/proc/generic.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ struct dentry *proc_lookup_de(struct inode *dir, struct dentry *dentry,
256256
inode = proc_get_inode(dir->i_sb, de);
257257
if (!inode)
258258
return ERR_PTR(-ENOMEM);
259-
d_set_d_op(dentry, &proc_misc_dentry_ops);
259+
d_set_d_op(dentry, de->proc_dops);
260260
return d_splice_alias(inode, dentry);
261261
}
262262
read_unlock(&proc_subdir_lock);
@@ -429,6 +429,8 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
429429
INIT_LIST_HEAD(&ent->pde_openers);
430430
proc_set_user(ent, (*parent)->uid, (*parent)->gid);
431431

432+
ent->proc_dops = &proc_misc_dentry_ops;
433+
432434
out:
433435
return ent;
434436
}

fs/proc/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ struct proc_dir_entry {
4444
struct completion *pde_unload_completion;
4545
const struct inode_operations *proc_iops;
4646
const struct file_operations *proc_fops;
47+
const struct dentry_operations *proc_dops;
4748
union {
4849
const struct seq_operations *seq_ops;
4950
int (*single_show)(struct seq_file *, void *);

fs/proc/proc_net.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ static struct net *get_proc_net(const struct inode *inode)
3838
return maybe_get_net(PDE_NET(PDE(inode)));
3939
}
4040

41+
static int proc_net_d_revalidate(struct dentry *dentry, unsigned int flags)
42+
{
43+
return 0;
44+
}
45+
46+
static const struct dentry_operations proc_net_dentry_ops = {
47+
.d_revalidate = proc_net_d_revalidate,
48+
.d_delete = always_delete_dentry,
49+
};
50+
51+
static void pde_force_lookup(struct proc_dir_entry *pde)
52+
{
53+
/* /proc/net/ entries can be changed under us by setns(CLONE_NEWNET) */
54+
pde->proc_dops = &proc_net_dentry_ops;
55+
}
56+
4157
static int seq_open_net(struct inode *inode, struct file *file)
4258
{
4359
unsigned int state_size = PDE(inode)->state_size;
@@ -90,6 +106,7 @@ struct proc_dir_entry *proc_create_net_data(const char *name, umode_t mode,
90106
p = proc_create_reg(name, mode, &parent, data);
91107
if (!p)
92108
return NULL;
109+
pde_force_lookup(p);
93110
p->proc_fops = &proc_net_seq_fops;
94111
p->seq_ops = ops;
95112
p->state_size = state_size;
@@ -133,6 +150,7 @@ struct proc_dir_entry *proc_create_net_data_write(const char *name, umode_t mode
133150
p = proc_create_reg(name, mode, &parent, data);
134151
if (!p)
135152
return NULL;
153+
pde_force_lookup(p);
136154
p->proc_fops = &proc_net_seq_fops;
137155
p->seq_ops = ops;
138156
p->state_size = state_size;
@@ -181,6 +199,7 @@ struct proc_dir_entry *proc_create_net_single(const char *name, umode_t mode,
181199
p = proc_create_reg(name, mode, &parent, data);
182200
if (!p)
183201
return NULL;
202+
pde_force_lookup(p);
184203
p->proc_fops = &proc_net_single_fops;
185204
p->single_show = show;
186205
return proc_register(parent, p);
@@ -223,6 +242,7 @@ struct proc_dir_entry *proc_create_net_single_write(const char *name, umode_t mo
223242
p = proc_create_reg(name, mode, &parent, data);
224243
if (!p)
225244
return NULL;
245+
pde_force_lookup(p);
226246
p->proc_fops = &proc_net_single_fops;
227247
p->single_show = show;
228248
p->write = write;

include/linux/memory_hotplug.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@ struct vmem_altmap;
2121
* walkers which rely on the fully initialized page->flags and others
2222
* should use this rather than pfn_valid && pfn_to_page
2323
*/
24-
#define pfn_to_online_page(pfn) \
25-
({ \
26-
struct page *___page = NULL; \
27-
unsigned long ___nr = pfn_to_section_nr(pfn); \
28-
\
29-
if (___nr < NR_MEM_SECTIONS && online_section_nr(___nr))\
30-
___page = pfn_to_page(pfn); \
31-
___page; \
24+
#define pfn_to_online_page(pfn) \
25+
({ \
26+
struct page *___page = NULL; \
27+
unsigned long ___pfn = pfn; \
28+
unsigned long ___nr = pfn_to_section_nr(___pfn); \
29+
\
30+
if (___nr < NR_MEM_SECTIONS && online_section_nr(___nr) && \
31+
pfn_valid_within(___pfn)) \
32+
___page = pfn_to_page(___pfn); \
33+
___page; \
3234
})
3335

3436
/*

include/linux/sched/coredump.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ static inline int get_dumpable(struct mm_struct *mm)
7171
#define MMF_HUGE_ZERO_PAGE 23 /* mm has ever used the global huge zero page */
7272
#define MMF_DISABLE_THP 24 /* disable THP for all VMAs */
7373
#define MMF_OOM_VICTIM 25 /* mm is the oom victim */
74+
#define MMF_OOM_REAP_QUEUED 26 /* mm was queued for oom_reaper */
7475
#define MMF_DISABLE_THP_MASK (1 << MMF_DISABLE_THP)
7576

7677
#define MMF_INIT_MASK (MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK |\

init/Kconfig

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,17 @@ config PSI_DEFAULT_DISABLED
512512
per default but can be enabled through passing psi=1 on the
513513
kernel commandline during boot.
514514

515+
This feature adds some code to the task wakeup and sleep
516+
paths of the scheduler. The overhead is too low to affect
517+
common scheduling-intense workloads in practice (such as
518+
webservers, memcache), but it does show up in artificial
519+
scheduler stress tests, such as hackbench.
520+
521+
If you are paranoid and not sure what the kernel will be
522+
used for, say Y.
523+
524+
Say N if unsure.
525+
515526
endmenu # "CPU/Task time and stats accounting"
516527

517528
config CPU_ISOLATION
@@ -825,7 +836,7 @@ config CGROUP_PIDS
825836
PIDs controller is designed to stop this from happening.
826837

827838
It should be noted that organisational operations (such as attaching
828-
to a cgroup hierarchy will *not* be blocked by the PIDs controller),
839+
to a cgroup hierarchy) will *not* be blocked by the PIDs controller,
829840
since the PIDs limit only affects a process's ability to fork, not to
830841
attach to a cgroup.
831842

kernel/exit.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,12 +558,14 @@ static struct task_struct *find_alive_thread(struct task_struct *p)
558558
return NULL;
559559
}
560560

561-
static struct task_struct *find_child_reaper(struct task_struct *father)
561+
static struct task_struct *find_child_reaper(struct task_struct *father,
562+
struct list_head *dead)
562563
__releases(&tasklist_lock)
563564
__acquires(&tasklist_lock)
564565
{
565566
struct pid_namespace *pid_ns = task_active_pid_ns(father);
566567
struct task_struct *reaper = pid_ns->child_reaper;
568+
struct task_struct *p, *n;
567569

568570
if (likely(reaper != father))
569571
return reaper;
@@ -579,6 +581,12 @@ static struct task_struct *find_child_reaper(struct task_struct *father)
579581
panic("Attempted to kill init! exitcode=0x%08x\n",
580582
father->signal->group_exit_code ?: father->exit_code);
581583
}
584+
585+
list_for_each_entry_safe(p, n, dead, ptrace_entry) {
586+
list_del_init(&p->ptrace_entry);
587+
release_task(p);
588+
}
589+
582590
zap_pid_ns_processes(pid_ns);
583591
write_lock_irq(&tasklist_lock);
584592

@@ -668,7 +676,7 @@ static void forget_original_parent(struct task_struct *father,
668676
exit_ptrace(father, dead);
669677

670678
/* Can drop and reacquire tasklist_lock */
671-
reaper = find_child_reaper(father);
679+
reaper = find_child_reaper(father, dead);
672680
if (list_empty(&father->children))
673681
return;
674682

kernel/sched/psi.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
* sampling of the aggregate task states would be.
125125
*/
126126

127+
#include "../workqueue_internal.h"
127128
#include <linux/sched/loadavg.h>
128129
#include <linux/seq_file.h>
129130
#include <linux/proc_fs.h>
@@ -480,9 +481,6 @@ static void psi_group_change(struct psi_group *group, int cpu,
480481
groupc->tasks[t]++;
481482

482483
write_seqcount_end(&groupc->seq);
483-
484-
if (!delayed_work_pending(&group->clock_work))
485-
schedule_delayed_work(&group->clock_work, PSI_FREQ);
486484
}
487485

488486
static struct psi_group *iterate_groups(struct task_struct *task, void **iter)
@@ -513,6 +511,7 @@ void psi_task_change(struct task_struct *task, int clear, int set)
513511
{
514512
int cpu = task_cpu(task);
515513
struct psi_group *group;
514+
bool wake_clock = true;
516515
void *iter = NULL;
517516

518517
if (!task->pid)
@@ -530,8 +529,22 @@ void psi_task_change(struct task_struct *task, int clear, int set)
530529
task->psi_flags &= ~clear;
531530
task->psi_flags |= set;
532531

533-
while ((group = iterate_groups(task, &iter)))
532+
/*
533+
* Periodic aggregation shuts off if there is a period of no
534+
* task changes, so we wake it back up if necessary. However,
535+
* don't do this if the task change is the aggregation worker
536+
* itself going to sleep, or we'll ping-pong forever.
537+
*/
538+
if (unlikely((clear & TSK_RUNNING) &&
539+
(task->flags & PF_WQ_WORKER) &&
540+
wq_worker_last_func(task) == psi_update_work))
541+
wake_clock = false;
542+
543+
while ((group = iterate_groups(task, &iter))) {
534544
psi_group_change(group, cpu, clear, set);
545+
if (wake_clock && !delayed_work_pending(&group->clock_work))
546+
schedule_delayed_work(&group->clock_work, PSI_FREQ);
547+
}
535548
}
536549

537550
void psi_memstall_tick(struct task_struct *task, int cpu)

0 commit comments

Comments
 (0)