]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
3.18-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 5 May 2017 17:17:34 +0000 (10:17 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 5 May 2017 17:17:34 +0000 (10:17 -0700)
added patches:
cpumask_set_cpu_local_first-cpumask_local_spread-lament.patch
e1000e-fix-call-to-do_div-to-use-u64-arg.patch
modpost-don-t-emit-section-mismatch-warnings-for-compiler-optimizations.patch
modpost-expand-pattern-matching-to-support-substring-matches.patch

queue-3.18/cpumask_set_cpu_local_first-cpumask_local_spread-lament.patch [new file with mode: 0644]
queue-3.18/e1000e-fix-call-to-do_div-to-use-u64-arg.patch [new file with mode: 0644]
queue-3.18/modpost-don-t-emit-section-mismatch-warnings-for-compiler-optimizations.patch [new file with mode: 0644]
queue-3.18/modpost-expand-pattern-matching-to-support-substring-matches.patch [new file with mode: 0644]
queue-3.18/series

diff --git a/queue-3.18/cpumask_set_cpu_local_first-cpumask_local_spread-lament.patch b/queue-3.18/cpumask_set_cpu_local_first-cpumask_local_spread-lament.patch
new file mode 100644 (file)
index 0000000..137812d
--- /dev/null
@@ -0,0 +1,207 @@
+From f36963c9d3f6f415732710da3acdd8608a9fa0e5 Mon Sep 17 00:00:00 2001
+From: Rusty Russell <rusty@rustcorp.com.au>
+Date: Sat, 9 May 2015 03:14:13 +0930
+Subject: cpumask_set_cpu_local_first => cpumask_local_spread, lament
+
+From: Rusty Russell <rusty@rustcorp.com.au>
+
+commit f36963c9d3f6f415732710da3acdd8608a9fa0e5 upstream.
+
+da91309e0a7e (cpumask: Utility function to set n'th cpu...) created a
+genuinely weird function.  I never saw it before, it went through DaveM.
+(He only does this to make us other maintainers feel better about our own
+mistakes.)
+
+cpumask_set_cpu_local_first's purpose is say "I need to spread things
+across N online cpus, choose the ones on this numa node first"; you call
+it in a loop.
+
+It can fail.  One of the two callers ignores this, the other aborts and
+fails the device open.
+
+It can fail in two ways: allocating the off-stack cpumask, or through a
+convoluted codepath which AFAICT can only occur if cpu_online_mask
+changes.  Which shouldn't happen, because if cpu_online_mask can change
+while you call this, it could return a now-offline cpu anyway.
+
+It contains a nonsensical test "!cpumask_of_node(numa_node)".  This was
+drawn to my attention by Geert, who said this causes a warning on Sparc.
+It sets a single bit in a cpumask instead of returning a cpu number,
+because that's what the callers want.
+
+It could be made more efficient by passing the previous cpu rather than
+an index, but that would be more invasive to the callers.
+
+[backporting for 3.18: only two callers exist, otherwise no change.
+ The same warning shows up for "!cpumask_of_node()", and I thought
+ about just addressing the warning, but using the whole fix seemed
+ better in the end as one of the two callers also lacks the error
+ handling]
+
+Fixes: da91309e0a7e8966d916a74cce42ed170fde06bf
+Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (then rebased)
+Tested-by: Amir Vadai <amirv@mellanox.com>
+Acked-by: Amir Vadai <amirv@mellanox.com>
+Acked-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/ethernet/mellanox/mlx4/en_netdev.c |   10 +--
+ drivers/net/ethernet/mellanox/mlx4/en_tx.c     |    6 +-
+ include/linux/cpumask.h                        |    6 --
+ lib/cpumask.c                                  |   72 ++++++++-----------------
+ 4 files changed, 33 insertions(+), 61 deletions(-)
+
+--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
++++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+@@ -1500,17 +1500,13 @@ static int mlx4_en_init_affinity_hint(st
+ {
+       struct mlx4_en_rx_ring *ring = priv->rx_ring[ring_idx];
+       int numa_node = priv->mdev->dev->numa_node;
+-      int ret = 0;
+       if (!zalloc_cpumask_var(&ring->affinity_mask, GFP_KERNEL))
+               return -ENOMEM;
+-      ret = cpumask_set_cpu_local_first(ring_idx, numa_node,
+-                                        ring->affinity_mask);
+-      if (ret)
+-              free_cpumask_var(ring->affinity_mask);
+-
+-      return ret;
++      cpumask_set_cpu(cpumask_local_spread(ring_idx, numa_node),
++                      ring->affinity_mask);
++      return 0;
+ }
+ static void mlx4_en_free_affinity_hint(struct mlx4_en_priv *priv, int ring_idx)
+--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
++++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+@@ -139,9 +139,9 @@ int mlx4_en_create_tx_ring(struct mlx4_e
+       ring->queue_index = queue_index;
+       if (queue_index < priv->num_tx_rings_p_up)
+-              cpumask_set_cpu_local_first(queue_index,
+-                                          priv->mdev->dev->numa_node,
+-                                          &ring->affinity_mask);
++              cpumask_set_cpu(cpumask_local_spread(queue_index,
++                                                   priv->mdev->dev->numa_node),
++                              &ring->affinity_mask);
+       *pring = ring;
+       return 0;
+--- a/include/linux/cpumask.h
++++ b/include/linux/cpumask.h
+@@ -142,10 +142,8 @@ static inline unsigned int cpumask_any_b
+       return 1;
+ }
+-static inline int cpumask_set_cpu_local_first(int i, int numa_node, cpumask_t *dstp)
++static inline unsigned int cpumask_local_spread(unsigned int i, int node)
+ {
+-      set_bit(0, cpumask_bits(dstp));
+-
+       return 0;
+ }
+@@ -199,7 +197,7 @@ static inline unsigned int cpumask_next_
+ int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
+ int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
+-int cpumask_set_cpu_local_first(int i, int numa_node, cpumask_t *dstp);
++unsigned int cpumask_local_spread(unsigned int i, int node);
+ /**
+  * for_each_cpu - iterate over every cpu in a mask
+--- a/lib/cpumask.c
++++ b/lib/cpumask.c
+@@ -166,64 +166,42 @@ void __init free_bootmem_cpumask_var(cpu
+ #endif
+ /**
+- * cpumask_set_cpu_local_first - set i'th cpu with local numa cpu's first
+- *
++ * cpumask_local_spread - select the i'th cpu with local numa cpu's first
+  * @i: index number
+- * @numa_node: local numa_node
+- * @dstp: cpumask with the relevant cpu bit set according to the policy
++ * @node: local numa_node
+  *
+- * This function sets the cpumask according to a numa aware policy.
+- * cpumask could be used as an affinity hint for the IRQ related to a
+- * queue. When the policy is to spread queues across cores - local cores
+- * first.
++ * This function selects an online CPU according to a numa aware policy;
++ * local cpus are returned first, followed by non-local ones, then it
++ * wraps around.
+  *
+- * Returns 0 on success, -ENOMEM for no memory, and -EAGAIN when failed to set
+- * the cpu bit and need to re-call the function.
++ * It's not very efficient, but useful for setup.
+  */
+-int cpumask_set_cpu_local_first(int i, int numa_node, cpumask_t *dstp)
++unsigned int cpumask_local_spread(unsigned int i, int node)
+ {
+-      cpumask_var_t mask;
+       int cpu;
+-      int ret = 0;
+-
+-      if (!zalloc_cpumask_var(&mask, GFP_KERNEL))
+-              return -ENOMEM;
++      /* Wrap: we always want a cpu. */
+       i %= num_online_cpus();
+-      if (numa_node == -1 || !cpumask_of_node(numa_node)) {
+-              /* Use all online cpu's for non numa aware system */
+-              cpumask_copy(mask, cpu_online_mask);
++      if (node == -1) {
++              for_each_cpu(cpu, cpu_online_mask)
++                      if (i-- == 0)
++                              return cpu;
+       } else {
+-              int n;
+-
+-              cpumask_and(mask,
+-                          cpumask_of_node(numa_node), cpu_online_mask);
++              /* NUMA first. */
++              for_each_cpu_and(cpu, cpumask_of_node(node), cpu_online_mask)
++                      if (i-- == 0)
++                              return cpu;
++
++              for_each_cpu(cpu, cpu_online_mask) {
++                      /* Skip NUMA nodes, done above. */
++                      if (cpumask_test_cpu(cpu, cpumask_of_node(node)))
++                              continue;
+-              n = cpumask_weight(mask);
+-              if (i >= n) {
+-                      i -= n;
+-
+-                      /* If index > number of local cpu's, mask out local
+-                       * cpu's
+-                       */
+-                      cpumask_andnot(mask, cpu_online_mask, mask);
++                      if (i-- == 0)
++                              return cpu;
+               }
+       }
+-
+-      for_each_cpu(cpu, mask) {
+-              if (--i < 0)
+-                      goto out;
+-      }
+-
+-      ret = -EAGAIN;
+-
+-out:
+-      free_cpumask_var(mask);
+-
+-      if (!ret)
+-              cpumask_set_cpu(cpu, dstp);
+-
+-      return ret;
++      BUG();
+ }
+-EXPORT_SYMBOL(cpumask_set_cpu_local_first);
++EXPORT_SYMBOL(cpumask_local_spread);
diff --git a/queue-3.18/e1000e-fix-call-to-do_div-to-use-u64-arg.patch b/queue-3.18/e1000e-fix-call-to-do_div-to-use-u64-arg.patch
new file mode 100644 (file)
index 0000000..81eb09b
--- /dev/null
@@ -0,0 +1,58 @@
+From 30544af5483755b11bb5924736e9e0b45ef0644a Mon Sep 17 00:00:00 2001
+From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
+Date: Sat, 2 May 2015 01:20:04 -0700
+Subject: e1000e: fix call to do_div() to use u64 arg
+
+From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
+
+commit 30544af5483755b11bb5924736e9e0b45ef0644a upstream.
+
+We were using s64 for lat_ns (latency nano-second value) since in
+our calculations a negative value could be a resultant.  For negative
+values, we then assign lat_ns to be zero, so the value passed to
+do_div() was never negative, but do_div() expects the argument type
+to be u64, so do a cast to resolve a compile warning seen on
+PowerPC.
+
+CC: Yanjiang Jin <yanjiang.jin@windriver.com>
+CC: Yanir Lubetkin <yanirx.lubetkin@intel.com>
+Reported-by: Yanjiang Jin <yanjiang.jin@windriver.com>
+Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
+Tested-by: Aaron Brown <aaron.f.brown@intel.com>
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/net/ethernet/intel/e1000e/ich8lan.c |   13 +++++++------
+ 1 file changed, 7 insertions(+), 6 deletions(-)
+
+--- a/drivers/net/ethernet/intel/e1000e/ich8lan.c
++++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c
+@@ -983,7 +983,7 @@ static s32 e1000_platform_pm_pch_lpt(str
+               u16 max_snoop, max_nosnoop;
+               u16 max_ltr_enc;        /* max LTR latency encoded */
+               s64 lat_ns;     /* latency (ns) */
+-              s64 value;
++              u64 value;
+               u32 rxa;
+               if (!hw->adapter->max_frame_size) {
+@@ -1010,12 +1010,13 @@ static s32 e1000_platform_pm_pch_lpt(str
+                */
+               lat_ns = ((s64)rxa * 1024 -
+                         (2 * (s64)hw->adapter->max_frame_size)) * 8 * 1000;
+-              if (lat_ns < 0)
+-                      lat_ns = 0;
+-              else
+-                      do_div(lat_ns, speed);
++              if (lat_ns < 0) {
++                      value = 0;
++              } else {
++                      value = lat_ns;
++                      do_div(value, speed);
++              }
+-              value = lat_ns;
+               while (value > PCI_LTR_VALUE_MASK) {
+                       scale++;
+                       value = DIV_ROUND_UP(value, (1 << 5));
diff --git a/queue-3.18/modpost-don-t-emit-section-mismatch-warnings-for-compiler-optimizations.patch b/queue-3.18/modpost-don-t-emit-section-mismatch-warnings-for-compiler-optimizations.patch
new file mode 100644 (file)
index 0000000..80d5767
--- /dev/null
@@ -0,0 +1,89 @@
+From 4a3893d069b788f3570c19c12d9e986e8e15870f Mon Sep 17 00:00:00 2001
+From: Paul Gortmaker <paul.gortmaker@windriver.com>
+Date: Mon, 20 Apr 2015 10:20:40 +0930
+Subject: modpost: don't emit section mismatch warnings for compiler optimizations
+
+From: Paul Gortmaker <paul.gortmaker@windriver.com>
+
+commit 4a3893d069b788f3570c19c12d9e986e8e15870f upstream.
+
+Currently an allyesconfig build [gcc-4.9.1] can generate the following:
+
+   WARNING: vmlinux.o(.text.unlikely+0x3864): Section mismatch in
+   reference from the function cpumask_empty.constprop.3() to the
+   variable .init.data:nmi_ipi_mask
+
+which comes from the cpumask_empty usage in arch/x86/kernel/nmi_selftest.c.
+
+Normally we would not see a symbol entry for cpumask_empty since it is:
+
+       static inline bool cpumask_empty(const struct cpumask *srcp)
+
+however in this case, the variant of the symbol gets emitted when GCC does
+constant propagation optimization.
+
+Fix things up so that any locally optimized constprop variants don't warn
+when accessing variables that live in the __init sections.
+
+[arnd: adapted text_sections definition to 3.18]
+
+Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
+Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ scripts/mod/modpost.c |   22 ++++++++++++++++++++++
+ 1 file changed, 22 insertions(+)
+
+--- a/scripts/mod/modpost.c
++++ b/scripts/mod/modpost.c
+@@ -902,6 +902,10 @@ static const char *const init_sections[]
+ static const char *const init_exit_sections[] =
+       {ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL };
++/* all text sections */
++static const char *const text_sections[] = { ALL_INIT_TEXT_SECTIONS,
++                              ALL_EXIT_TEXT_SECTIONS, TEXT_SECTIONS, NULL };
++
+ /* data section */
+ static const char *const data_sections[] = { DATA_SECTIONS, NULL };
+@@ -920,6 +924,7 @@ static const char *const data_sections[]
+ static const char *const head_sections[] = { ".head.text*", NULL };
+ static const char *const linker_symbols[] =
+       { "__init_begin", "_sinittext", "_einittext", NULL };
++static const char *const optim_symbols[] = { "*.constprop.*", NULL };
+ enum mismatch {
+       TEXT_TO_ANY_INIT,
+@@ -1077,6 +1082,17 @@ static const struct sectioncheck *sectio
+  *   This pattern is identified by
+  *   refsymname = __init_begin, _sinittext, _einittext
+  *
++ * Pattern 5:
++ *   GCC may optimize static inlines when fed constant arg(s) resulting
++ *   in functions like cpumask_empty() -- generating an associated symbol
++ *   cpumask_empty.constprop.3 that appears in the audit.  If the const that
++ *   is passed in comes from __init, like say nmi_ipi_mask, we get a
++ *   meaningless section warning.  May need to add isra symbols too...
++ *   This pattern is identified by
++ *   tosec   = init section
++ *   fromsec = text section
++ *   refsymname = *.constprop.*
++ *
+  **/
+ static int secref_whitelist(const struct sectioncheck *mismatch,
+                           const char *fromsec, const char *fromsym,
+@@ -1109,6 +1125,12 @@ static int secref_whitelist(const struct
+       if (match(tosym, linker_symbols))
+               return 0;
++      /* Check for pattern 5 */
++      if (match(fromsec, text_sections) &&
++          match(tosec, init_sections) &&
++          match(fromsym, optim_symbols))
++              return 0;
++
+       return 1;
+ }
diff --git a/queue-3.18/modpost-expand-pattern-matching-to-support-substring-matches.patch b/queue-3.18/modpost-expand-pattern-matching-to-support-substring-matches.patch
new file mode 100644 (file)
index 0000000..383b9a3
--- /dev/null
@@ -0,0 +1,56 @@
+From 09c20c032b0f753969ae778d9783d946f054d7fe Mon Sep 17 00:00:00 2001
+From: Paul Gortmaker <paul.gortmaker@windriver.com>
+Date: Mon, 20 Apr 2015 10:20:26 +0930
+Subject: modpost: expand pattern matching to support substring matches
+
+From: Paul Gortmaker <paul.gortmaker@windriver.com>
+
+commit 09c20c032b0f753969ae778d9783d946f054d7fe upstream.
+
+Currently the match() function supports a leading * to match any
+prefix and a trailing * to match any suffix.  However there currently
+is not a combination of both that can be used to target matches of
+whole families of functions that share a common substring.
+
+Here we expand the *foo and foo* match to also support *foo* with
+the goal of targeting compiler generated symbol names that contain
+strings like ".constprop." and ".isra."
+
+Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
+Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ scripts/mod/modpost.c |   12 +++++++++++-
+ 1 file changed, 11 insertions(+), 1 deletion(-)
+
+--- a/scripts/mod/modpost.c
++++ b/scripts/mod/modpost.c
+@@ -776,6 +776,7 @@ static const char *sech_name(struct elf_
+  * "foo" will match an exact string equal to "foo"
+  * "*foo" will match a string that ends with "foo"
+  * "foo*" will match a string that begins with "foo"
++ * "*foo*" will match a string that contains "foo"
+  */
+ static int match(const char *sym, const char * const pat[])
+ {
+@@ -784,8 +785,17 @@ static int match(const char *sym, const
+               p = *pat++;
+               const char *endp = p + strlen(p) - 1;
++              /* "*foo*" */
++              if (*p == '*' && *endp == '*') {
++                      char *here, *bare = strndup(p + 1, strlen(p) - 2);
++
++                      here = strstr(sym, bare);
++                      free(bare);
++                      if (here != NULL)
++                              return 1;
++              }
+               /* "*foo" */
+-              if (*p == '*') {
++              else if (*p == '*') {
+                       if (strrcmp(sym, p + 1) == 0)
+                               return 1;
+               }
index ad9d8490291e0c3062675e3ca1623a97b59ab5ab..0143a2bb5b3dfbe8dab61b92fdef280960ac86e3 100644 (file)
@@ -60,3 +60,7 @@ mips-elf2ecoff-fix-warning-due-to-dead-code.patch
 staging-unisys-fix-build-warning-in-periodic_work.patch
 message-i2o-fix-64bit-build-warnings.patch
 scsi-advansys.c-remove-dma-build-warning-message.patch
+modpost-expand-pattern-matching-to-support-substring-matches.patch
+modpost-don-t-emit-section-mismatch-warnings-for-compiler-optimizations.patch
+cpumask_set_cpu_local_first-cpumask_local_spread-lament.patch
+e1000e-fix-call-to-do_div-to-use-u64-arg.patch