Re: [GIT pull] sched/urgent for 5.3-rc2

2019-07-27 Thread pr-tracker-bot
The pull request you sent on Sat, 27 Jul 2019 23:26:14 -:

> git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
> sched-urgent-for-linus

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/e24ce84e85abe50811f33caecbf104b7d9dffb03

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


[GIT pull] sched/urgent for 5.3-rc2

2019-07-27 Thread Thomas Gleixner
Linus,

please pull the latest sched-urgent-for-linus git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
sched-urgent-for-linus

up to:  cb361d8cdef6: sched/fair: Use RCU accessors consistently for 
->numa_group

Two fixes for the fair scheduling class:

 - Prevent freeing memory which is accessible by concurrent readers

 - Make the RCU annotations for numa groups consistent

Thanks,

tglx

-->
Jann Horn (2):
  sched/fair: Don't free p->numa_faults with concurrent readers
  sched/fair: Use RCU accessors consistently for ->numa_group


 fs/exec.c|   2 +-
 include/linux/sched.h|  10 ++-
 include/linux/sched/numa_balancing.h |   4 +-
 kernel/fork.c|   2 +-
 kernel/sched/fair.c  | 144 ---
 5 files changed, 114 insertions(+), 48 deletions(-)

diff --git a/fs/exec.c b/fs/exec.c
index c71cbfe6826a..f7f6a140856a 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1828,7 +1828,7 @@ static int __do_execve_file(int fd, struct filename 
*filename,
membarrier_execve(current);
rseq_execve(current);
acct_update_integrals(current);
-   task_numa_free(current);
+   task_numa_free(current, false);
free_bprm(bprm);
kfree(pathbuf);
if (filename)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 8dc1811487f5..9f51932bd543 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1092,7 +1092,15 @@ struct task_struct {
u64 last_sum_exec_runtime;
struct callback_headnuma_work;
 
-   struct numa_group   *numa_group;
+   /*
+* This pointer is only modified for current in syscall and
+* pagefault context (and for tasks being destroyed), so it can be read
+* from any of the following contexts:
+*  - RCU read-side critical section
+*  - current->numa_group from everywhere
+*  - task's runqueue locked, task not running
+*/
+   struct numa_group __rcu *numa_group;
 
/*
 * numa_faults is an array split into four regions:
diff --git a/include/linux/sched/numa_balancing.h 
b/include/linux/sched/numa_balancing.h
index e7dd04a84ba8..3988762efe15 100644
--- a/include/linux/sched/numa_balancing.h
+++ b/include/linux/sched/numa_balancing.h
@@ -19,7 +19,7 @@
 extern void task_numa_fault(int last_node, int node, int pages, int flags);
 extern pid_t task_numa_group_id(struct task_struct *p);
 extern void set_numabalancing_state(bool enabled);
-extern void task_numa_free(struct task_struct *p);
+extern void task_numa_free(struct task_struct *p, bool final);
 extern bool should_numa_migrate_memory(struct task_struct *p, struct page 
*page,
int src_nid, int dst_cpu);
 #else
@@ -34,7 +34,7 @@ static inline pid_t task_numa_group_id(struct task_struct *p)
 static inline void set_numabalancing_state(bool enabled)
 {
 }
-static inline void task_numa_free(struct task_struct *p)
+static inline void task_numa_free(struct task_struct *p, bool final)
 {
 }
 static inline bool should_numa_migrate_memory(struct task_struct *p,
diff --git a/kernel/fork.c b/kernel/fork.c
index d8ae0f1b4148..2852d0e76ea3 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -726,7 +726,7 @@ void __put_task_struct(struct task_struct *tsk)
WARN_ON(tsk == current);
 
cgroup_free(tsk);
-   task_numa_free(tsk);
+   task_numa_free(tsk, true);
security_task_free(tsk);
exit_creds(tsk);
delayacct_tsk_free(tsk);
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 036be95a87e9..bc9cfeaac8bd 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1086,6 +1086,21 @@ struct numa_group {
unsigned long faults[0];
 };
 
+/*
+ * For functions that can be called in multiple contexts that permit reading
+ * ->numa_group (see struct task_struct for locking rules).
+ */
+static struct numa_group *deref_task_numa_group(struct task_struct *p)
+{
+   return rcu_dereference_check(p->numa_group, p == current ||
+   (lockdep_is_held(_rq(p)->lock) && !READ_ONCE(p->on_cpu)));
+}
+
+static struct numa_group *deref_curr_numa_group(struct task_struct *p)
+{
+   return rcu_dereference_protected(p->numa_group, p == current);
+}
+
 static inline unsigned long group_faults_priv(struct numa_group *ng);
 static inline unsigned long group_faults_shared(struct numa_group *ng);
 
@@ -1129,10 +1144,12 @@ static unsigned int task_scan_start(struct task_struct 
*p)
 {
unsigned long smin = task_scan_min(p);
unsigned long period = smin;
+   struct numa_group *ng;
 
/* Scale the maximum scan period with the amount of shared memory. */
-   if (p->numa_group) {
-   struct numa_group *ng = p->numa_group;
+   rcu_read_lock();
+   ng = 

Re: [GIT pull] sched/urgent for 5.3-rc2

2019-07-22 Thread pr-tracker-bot
The pull request you sent on Mon, 22 Jul 2019 18:23:38 +0200 (CEST):

> git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
> sched-urgent-for-linus

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/7b5cf701ea9c395c792e2a7e3b7caf4c68b87721

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


[GIT pull] sched/urgent for 5.3-rc2

2019-07-22 Thread Thomas Gleixner
Linus,

please pull the latest sched-urgent-for-linus git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
sched-urgent-for-linus

up to:  b8d3349803ba: sched/rt, Kconfig: Unbreak def/oldconfig with 
CONFIG_PREEMPT=y

The PREEMPT_RT stub config renamed PREEMPT to PREEMPT_LL and defined
PREEMPT outside of the menu and made it selectable by both PREEMPT_LL and
PREEMPT_RT.

Stupid me missed that 114 defconfigs select CONFIG_PREEMPT which obviously
can't work anymore. oldconfig builds are affected as well, but it's more
obvious as the user gets asked. [old]defconfig silently fixes it up and
selects PREEMPT_NONE. Unbreak it by undoing the rename and adding a
intermediate config symbol which is selected by both PREEMPT and
PREEMPT_RT. That requires to chase down a few #ifdefs, but it's better than
tweaking 114 defconfigs and annoying users.

Sorry for the inconveniance.

Thanks,

tglx

-->
Thomas Gleixner (1):
  sched/rt, Kconfig: Unbreak def/oldconfig with CONFIG_PREEMPT=y


 kernel/Kconfig.preempt | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/Kconfig.preempt b/kernel/Kconfig.preempt
index fc020c09b7e8..deff97217496 100644
--- a/kernel/Kconfig.preempt
+++ b/kernel/Kconfig.preempt
@@ -35,10 +35,10 @@ config PREEMPT_VOLUNTARY
 
  Select this if you are building a kernel for a desktop system.
 
-config PREEMPT_LL
+config PREEMPT
bool "Preemptible Kernel (Low-Latency Desktop)"
depends on !ARCH_NO_PREEMPT
-   select PREEMPT
+   select PREEMPTION
select UNINLINE_SPIN_UNLOCK if !ARCH_INLINE_SPIN_UNLOCK
help
  This option reduces the latency of the kernel by making
@@ -58,7 +58,7 @@ config PREEMPT_LL
 config PREEMPT_RT
bool "Fully Preemptible Kernel (Real-Time)"
depends on EXPERT && ARCH_SUPPORTS_RT
-   select PREEMPT
+   select PREEMPTION
help
  This option turns the kernel into a real-time kernel by replacing
  various locking primitives (spinlocks, rwlocks, etc.) with
@@ -77,6 +77,6 @@ endchoice
 config PREEMPT_COUNT
bool
 
-config PREEMPT
+config PREEMPTION
bool
select PREEMPT_COUNT