+ lib-optimize-cpumask_local_spread-v3.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: lib-optimize-cpumask_local_spread-v3
has been added to the -mm tree.  Its filename is
     lib-optimize-cpumask_local_spread-v3.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/lib-optimize-cpumask_local_spread-v3.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/lib-optimize-cpumask_local_spread-v3.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: yuqi jin <jinyuqi@xxxxxxxxxx>
Subject: lib-optimize-cpumask_local_spread-v3

change variables to static and use spinlock to protect

Link: http://lkml.kernel.org/r/1573091048-10595-1-git-send-email-zhangshaokun@xxxxxxxxxxxxx
Signed-off-by: yuqi jin <jinyuqi@xxxxxxxxxx>
Signed-off-by: Shaokun Zhang <zhangshaokun@xxxxxxxxxxxxx>
Cc: Mike Rapoport <rppt@xxxxxxxxxxxxx>
Cc: Paul Burton <paul.burton@xxxxxxxx>
Cc: Michal Hocko <mhocko@xxxxxxxx>
Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
Cc: Anshuman Khandual <anshuman.khandual@xxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 lib/cpumask.c |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

--- a/lib/cpumask.c~lib-optimize-cpumask_local_spread-v3
+++ a/lib/cpumask.c
@@ -6,6 +6,7 @@
 #include <linux/export.h>
 #include <linux/memblock.h>
 #include <linux/numa.h>
+#include <linux/spinlock.h>
 
 /**
  * cpumask_next - get the next cpu in a cpumask
@@ -253,6 +254,7 @@ static unsigned int __cpumask_local_spre
 	BUG();
 }
 
+static DEFINE_SPINLOCK(spread_lock);
 /**
  * cpumask_local_spread - select the i'th cpu with local numa cpu's first
  * @i: index number
@@ -266,8 +268,9 @@ static unsigned int __cpumask_local_spre
  */
 unsigned int cpumask_local_spread(unsigned int i, int node)
 {
-	int node_dist[MAX_NUMNODES] = {0};
-	bool used[MAX_NUMNODES] = {0};
+	static int node_dist[MAX_NUMNODES];
+	static bool used[MAX_NUMNODES];
+	unsigned long flags;
 	int cpu, j, id;
 
 	/* Wrap: we always want a cpu. */
@@ -281,6 +284,8 @@ unsigned int cpumask_local_spread(unsign
 		if (nr_node_ids > MAX_NUMNODES)
 			return __cpumask_local_spread(i, node);
 
+		spin_lock_irqsave(&spread_lock, flags);
+		memset(used, 0, nr_node_ids * sizeof(bool));
 		calc_node_distance(node_dist, node);
 		for (j = 0; j < nr_node_ids; j++) {
 			id = find_nearest_node(node_dist, used);
@@ -289,10 +294,14 @@ unsigned int cpumask_local_spread(unsign
 
 			for_each_cpu_and(cpu, cpumask_of_node(id),
 					 cpu_online_mask)
-				if (i-- == 0)
+				if (i-- == 0) {
+					spin_unlock_irqrestore(&spread_lock,
+							       flags);
 					return cpu;
+				}
 			used[id] = 1;
 		}
+		spin_unlock_irqrestore(&spread_lock, flags);
 
 		for_each_cpu(cpu, cpu_online_mask)
 			if (i-- == 0)
_

Patches currently in -mm which might be from jinyuqi@xxxxxxxxxx are

lib-optimize-cpumask_local_spread.patch
lib-optimize-cpumask_local_spread-v3.patch




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux