]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.4-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 21 May 2020 15:51:04 +0000 (17:51 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 21 May 2020 15:51:04 +0000 (17:51 +0200)
added patches:
padata-ensure-padata_do_serial-runs-on-the-correct-cpu.patch
padata-ensure-the-reorder-timer-callback-runs-on-the-correct-cpu.patch
padata-get_next-is-never-null.patch
padata-remove-unused-but-set-variables.patch

queue-4.4/padata-ensure-padata_do_serial-runs-on-the-correct-cpu.patch [new file with mode: 0644]
queue-4.4/padata-ensure-the-reorder-timer-callback-runs-on-the-correct-cpu.patch [new file with mode: 0644]
queue-4.4/padata-get_next-is-never-null.patch [new file with mode: 0644]
queue-4.4/padata-remove-unused-but-set-variables.patch [new file with mode: 0644]
queue-4.4/series

diff --git a/queue-4.4/padata-ensure-padata_do_serial-runs-on-the-correct-cpu.patch b/queue-4.4/padata-ensure-padata_do_serial-runs-on-the-correct-cpu.patch
new file mode 100644 (file)
index 0000000..a50cfa5
--- /dev/null
@@ -0,0 +1,95 @@
+From 350ef88e7e922354f82a931897ad4a4ce6c686ff Mon Sep 17 00:00:00 2001
+From: Mathias Krause <minipli@googlemail.com>
+Date: Fri, 8 Sep 2017 20:57:11 +0200
+Subject: padata: ensure padata_do_serial() runs on the correct CPU
+
+From: Mathias Krause <minipli@googlemail.com>
+
+commit 350ef88e7e922354f82a931897ad4a4ce6c686ff upstream.
+
+If the algorithm we're parallelizing is asynchronous we might change
+CPUs between padata_do_parallel() and padata_do_serial(). However, we
+don't expect this to happen as we need to enqueue the padata object into
+the per-cpu reorder queue we took it from, i.e. the same-cpu's parallel
+queue.
+
+Ensure we're not switching CPUs for a given padata object by tracking
+the CPU within the padata object. If the serial callback gets called on
+the wrong CPU, defer invoking padata_reorder() via a kernel worker on
+the CPU we're expected to run on.
+
+Signed-off-by: Mathias Krause <minipli@googlemail.com>
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+Cc: Ben Hutchings <ben@decadent.org.uk>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ include/linux/padata.h |    2 ++
+ kernel/padata.c        |   20 +++++++++++++++++++-
+ 2 files changed, 21 insertions(+), 1 deletion(-)
+
+--- a/include/linux/padata.h
++++ b/include/linux/padata.h
+@@ -37,6 +37,7 @@
+  * @list: List entry, to attach to the padata lists.
+  * @pd: Pointer to the internal control structure.
+  * @cb_cpu: Callback cpu for serializatioon.
++ * @cpu: Cpu for parallelization.
+  * @seq_nr: Sequence number of the parallelized data object.
+  * @info: Used to pass information from the parallel to the serial function.
+  * @parallel: Parallel execution function.
+@@ -46,6 +47,7 @@ struct padata_priv {
+       struct list_head        list;
+       struct parallel_data    *pd;
+       int                     cb_cpu;
++      int                     cpu;
+       int                     info;
+       void                    (*parallel)(struct padata_priv *padata);
+       void                    (*serial)(struct padata_priv *padata);
+--- a/kernel/padata.c
++++ b/kernel/padata.c
+@@ -132,6 +132,7 @@ int padata_do_parallel(struct padata_ins
+       padata->cb_cpu = cb_cpu;
+       target_cpu = padata_cpu_hash(pd);
++      padata->cpu = target_cpu;
+       queue = per_cpu_ptr(pd->pqueue, target_cpu);
+       spin_lock(&queue->parallel.lock);
+@@ -375,10 +376,21 @@ void padata_do_serial(struct padata_priv
+       int cpu;
+       struct padata_parallel_queue *pqueue;
+       struct parallel_data *pd;
++      int reorder_via_wq = 0;
+       pd = padata->pd;
+       cpu = get_cpu();
++
++      /* We need to run on the same CPU padata_do_parallel(.., padata, ..)
++       * was called on -- or, at least, enqueue the padata object into the
++       * correct per-cpu queue.
++       */
++      if (cpu != padata->cpu) {
++              reorder_via_wq = 1;
++              cpu = padata->cpu;
++      }
++
+       pqueue = per_cpu_ptr(pd->pqueue, cpu);
+       spin_lock(&pqueue->reorder.lock);
+@@ -395,7 +407,13 @@ void padata_do_serial(struct padata_priv
+       put_cpu();
+-      padata_reorder(pd);
++      /* If we're running on the wrong CPU, call padata_reorder() via a
++       * kernel worker.
++       */
++      if (reorder_via_wq)
++              queue_work_on(cpu, pd->pinst->wq, &pqueue->reorder_work);
++      else
++              padata_reorder(pd);
+ }
+ EXPORT_SYMBOL(padata_do_serial);
diff --git a/queue-4.4/padata-ensure-the-reorder-timer-callback-runs-on-the-correct-cpu.patch b/queue-4.4/padata-ensure-the-reorder-timer-callback-runs-on-the-correct-cpu.patch
new file mode 100644 (file)
index 0000000..45dc003
--- /dev/null
@@ -0,0 +1,110 @@
+From cf5868c8a22dc2854b96e9569064bb92365549ca Mon Sep 17 00:00:00 2001
+From: Mathias Krause <minipli@googlemail.com>
+Date: Fri, 8 Sep 2017 20:57:10 +0200
+Subject: padata: ensure the reorder timer callback runs on the correct CPU
+
+From: Mathias Krause <minipli@googlemail.com>
+
+commit cf5868c8a22dc2854b96e9569064bb92365549ca upstream.
+
+The reorder timer function runs on the CPU where the timer interrupt was
+handled which is not necessarily one of the CPUs of the 'pcpu' CPU mask
+set.
+
+Ensure the padata_reorder() callback runs on the correct CPU, which is
+one in the 'pcpu' CPU mask set and, preferrably, the next expected one.
+Do so by comparing the current CPU with the expected target CPU. If they
+match, call padata_reorder() right away. If they differ, schedule a work
+item on the target CPU that does the padata_reorder() call for us.
+
+Signed-off-by: Mathias Krause <minipli@googlemail.com>
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+Cc: Ben Hutchings <ben@decadent.org.uk>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ include/linux/padata.h |    2 ++
+ kernel/padata.c        |   43 ++++++++++++++++++++++++++++++++++++++++++-
+ 2 files changed, 44 insertions(+), 1 deletion(-)
+
+--- a/include/linux/padata.h
++++ b/include/linux/padata.h
+@@ -85,6 +85,7 @@ struct padata_serial_queue {
+  * @swork: work struct for serialization.
+  * @pd: Backpointer to the internal control structure.
+  * @work: work struct for parallelization.
++ * @reorder_work: work struct for reordering.
+  * @num_obj: Number of objects that are processed by this cpu.
+  * @cpu_index: Index of the cpu.
+  */
+@@ -93,6 +94,7 @@ struct padata_parallel_queue {
+        struct padata_list    reorder;
+        struct parallel_data *pd;
+        struct work_struct    work;
++       struct work_struct    reorder_work;
+        atomic_t              num_obj;
+        int                   cpu_index;
+ };
+--- a/kernel/padata.c
++++ b/kernel/padata.c
+@@ -281,11 +281,51 @@ static void padata_reorder(struct parall
+       return;
+ }
++static void invoke_padata_reorder(struct work_struct *work)
++{
++      struct padata_parallel_queue *pqueue;
++      struct parallel_data *pd;
++
++      local_bh_disable();
++      pqueue = container_of(work, struct padata_parallel_queue, reorder_work);
++      pd = pqueue->pd;
++      padata_reorder(pd);
++      local_bh_enable();
++}
++
+ static void padata_reorder_timer(unsigned long arg)
+ {
+       struct parallel_data *pd = (struct parallel_data *)arg;
++      unsigned int weight;
++      int target_cpu, cpu;
+-      padata_reorder(pd);
++      cpu = get_cpu();
++
++      /* We don't lock pd here to not interfere with parallel processing
++       * padata_reorder() calls on other CPUs. We just need any CPU out of
++       * the cpumask.pcpu set. It would be nice if it's the right one but
++       * it doesn't matter if we're off to the next one by using an outdated
++       * pd->processed value.
++       */
++      weight = cpumask_weight(pd->cpumask.pcpu);
++      target_cpu = padata_index_to_cpu(pd, pd->processed % weight);
++
++      /* ensure to call the reorder callback on the correct CPU */
++      if (cpu != target_cpu) {
++              struct padata_parallel_queue *pqueue;
++              struct padata_instance *pinst;
++
++              /* The timer function is serialized wrt itself -- no locking
++               * needed.
++               */
++              pinst = pd->pinst;
++              pqueue = per_cpu_ptr(pd->pqueue, target_cpu);
++              queue_work_on(target_cpu, pinst->wq, &pqueue->reorder_work);
++      } else {
++              padata_reorder(pd);
++      }
++
++      put_cpu();
+ }
+ static void padata_serial_worker(struct work_struct *serial_work)
+@@ -412,6 +452,7 @@ static void padata_init_pqueues(struct p
+               __padata_list_init(&pqueue->reorder);
+               __padata_list_init(&pqueue->parallel);
+               INIT_WORK(&pqueue->work, padata_parallel_worker);
++              INIT_WORK(&pqueue->reorder_work, invoke_padata_reorder);
+               atomic_set(&pqueue->num_obj, 0);
+       }
+ }
diff --git a/queue-4.4/padata-get_next-is-never-null.patch b/queue-4.4/padata-get_next-is-never-null.patch
new file mode 100644 (file)
index 0000000..bb68e07
--- /dev/null
@@ -0,0 +1,61 @@
+From 69b348449bda0f9588737539cfe135774c9939a7 Mon Sep 17 00:00:00 2001
+From: "Jason A. Donenfeld" <Jason@zx2c4.com>
+Date: Wed, 12 Apr 2017 10:40:19 +0200
+Subject: padata: get_next is never NULL
+
+From: Jason A. Donenfeld <Jason@zx2c4.com>
+
+commit 69b348449bda0f9588737539cfe135774c9939a7 upstream.
+
+Per Dan's static checker warning, the code that returns NULL was removed
+in 2010, so this patch updates the comments and fixes the code
+assumptions.
+
+Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
+Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
+Acked-by: Steffen Klassert <steffen.klassert@secunet.com>
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+Cc: Ben Hutchings <ben@decadent.org.uk>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ kernel/padata.c |   13 ++++---------
+ 1 file changed, 4 insertions(+), 9 deletions(-)
+
+--- a/kernel/padata.c
++++ b/kernel/padata.c
+@@ -155,8 +155,6 @@ EXPORT_SYMBOL(padata_do_parallel);
+  * A pointer to the control struct of the next object that needs
+  * serialization, if present in one of the percpu reorder queues.
+  *
+- * NULL, if all percpu reorder queues are empty.
+- *
+  * -EINPROGRESS, if the next object that needs serialization will
+  *  be parallel processed by another cpu and is not yet present in
+  *  the cpu's reorder queue.
+@@ -183,8 +181,6 @@ static struct padata_priv *padata_get_ne
+       cpu = padata_index_to_cpu(pd, next_index);
+       next_queue = per_cpu_ptr(pd->pqueue, cpu);
+-      padata = NULL;
+-
+       reorder = &next_queue->reorder;
+       spin_lock(&reorder->lock);
+@@ -236,12 +232,11 @@ static void padata_reorder(struct parall
+               padata = padata_get_next(pd);
+               /*
+-               * All reorder queues are empty, or the next object that needs
+-               * serialization is parallel processed by another cpu and is
+-               * still on it's way to the cpu's reorder queue, nothing to
+-               * do for now.
++               * If the next object that needs serialization is parallel
++               * processed by another cpu and is still on it's way to the
++               * cpu's reorder queue, nothing to do for now.
+                */
+-              if (!padata || PTR_ERR(padata) == -EINPROGRESS)
++              if (PTR_ERR(padata) == -EINPROGRESS)
+                       break;
+               /*
diff --git a/queue-4.4/padata-remove-unused-but-set-variables.patch b/queue-4.4/padata-remove-unused-but-set-variables.patch
new file mode 100644 (file)
index 0000000..463983b
--- /dev/null
@@ -0,0 +1,48 @@
+From 119a0798dc42ed4c4f96d39b8b676efcea73aec6 Mon Sep 17 00:00:00 2001
+From: Tobias Klauser <tklauser@distanz.ch>
+Date: Mon, 17 Oct 2016 12:16:08 +0200
+Subject: padata: Remove unused but set variables
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Tobias Klauser <tklauser@distanz.ch>
+
+commit 119a0798dc42ed4c4f96d39b8b676efcea73aec6 upstream.
+
+Remove the unused but set variable pinst in padata_parallel_worker to
+fix the following warning when building with 'W=1':
+
+  kernel/padata.c: In function ‘padata_parallel_worker’:
+  kernel/padata.c:68:26: warning: variable ‘pinst’ set but not used [-Wunused-but-set-variable]
+
+Also remove the now unused variable pd which is only used to set pinst.
+
+Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
+Acked-by: Steffen Klassert <steffen.klassert@secunet.com>
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+Cc: Ben Hutchings <ben@decadent.org.uk>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ kernel/padata.c |    4 ----
+ 1 file changed, 4 deletions(-)
+
+--- a/kernel/padata.c
++++ b/kernel/padata.c
+@@ -65,15 +65,11 @@ static int padata_cpu_hash(struct parall
+ static void padata_parallel_worker(struct work_struct *parallel_work)
+ {
+       struct padata_parallel_queue *pqueue;
+-      struct parallel_data *pd;
+-      struct padata_instance *pinst;
+       LIST_HEAD(local_list);
+       local_bh_disable();
+       pqueue = container_of(parallel_work,
+                             struct padata_parallel_queue, work);
+-      pd = pqueue->pd;
+-      pinst = pd->pinst;
+       spin_lock(&pqueue->parallel.lock);
+       list_replace_init(&pqueue->parallel.list, &local_list);
index 531cdbf5b807839b71abf1d5fae0f89d7d5fc1df..c23410066881921881cb2e7a54f92f5de2b3e7cc 100644 (file)
@@ -1 +1,5 @@
 igb-use-igb_adapter-io_addr-instead-of-e1000_hw-hw_addr.patch
+padata-remove-unused-but-set-variables.patch
+padata-get_next-is-never-null.patch
+padata-ensure-the-reorder-timer-callback-runs-on-the-correct-cpu.patch
+padata-ensure-padata_do_serial-runs-on-the-correct-cpu.patch