Skip to content

Commit e24ce84

Browse files
committed
Merge branch 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull scheduler fixes from Thomas Gleixner: "Two fixes for the fair scheduling class: - Prevent freeing memory which is accessible by concurrent readers - Make the RCU annotations for numa groups consistent" * 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: sched/fair: Use RCU accessors consistently for ->numa_group sched/fair: Don't free p->numa_faults with concurrent readers
2 parents 750991f + cb361d8 commit e24ce84

File tree

5 files changed

+114
-48
lines changed

5 files changed

+114
-48
lines changed

fs/exec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1828,7 +1828,7 @@ static int __do_execve_file(int fd, struct filename *filename,
18281828
membarrier_execve(current);
18291829
rseq_execve(current);
18301830
acct_update_integrals(current);
1831-
task_numa_free(current);
1831+
task_numa_free(current, false);
18321832
free_bprm(bprm);
18331833
kfree(pathbuf);
18341834
if (filename)

include/linux/sched.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,15 @@ struct task_struct {
10921092
u64 last_sum_exec_runtime;
10931093
struct callback_head numa_work;
10941094

1095-
struct numa_group *numa_group;
1095+
/*
1096+
* This pointer is only modified for current in syscall and
1097+
* pagefault context (and for tasks being destroyed), so it can be read
1098+
* from any of the following contexts:
1099+
* - RCU read-side critical section
1100+
* - current->numa_group from everywhere
1101+
* - task's runqueue locked, task not running
1102+
*/
1103+
struct numa_group __rcu *numa_group;
10961104

10971105
/*
10981106
* numa_faults is an array split into four regions:

include/linux/sched/numa_balancing.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
extern void task_numa_fault(int last_node, int node, int pages, int flags);
2020
extern pid_t task_numa_group_id(struct task_struct *p);
2121
extern void set_numabalancing_state(bool enabled);
22-
extern void task_numa_free(struct task_struct *p);
22+
extern void task_numa_free(struct task_struct *p, bool final);
2323
extern bool should_numa_migrate_memory(struct task_struct *p, struct page *page,
2424
int src_nid, int dst_cpu);
2525
#else
@@ -34,7 +34,7 @@ static inline pid_t task_numa_group_id(struct task_struct *p)
3434
static inline void set_numabalancing_state(bool enabled)
3535
{
3636
}
37-
static inline void task_numa_free(struct task_struct *p)
37+
static inline void task_numa_free(struct task_struct *p, bool final)
3838
{
3939
}
4040
static inline bool should_numa_migrate_memory(struct task_struct *p,

kernel/fork.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ void __put_task_struct(struct task_struct *tsk)
726726
WARN_ON(tsk == current);
727727

728728
cgroup_free(tsk);
729-
task_numa_free(tsk);
729+
task_numa_free(tsk, true);
730730
security_task_free(tsk);
731731
exit_creds(tsk);
732732
delayacct_tsk_free(tsk);

0 commit comments

Comments
 (0)