linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL] workqueue fixes for v4.13-rc3
@ 2017-07-31 15:38 Tejun Heo
  2017-08-07 12:18 ` Geert Uytterhoeven
  0 siblings, 1 reply; 11+ messages in thread
From: Tejun Heo @ 2017-07-31 15:38 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel, Lai Jiangshan

Hello, Linus.

Two notable fixes.

* While adding NUMA affinity support to unbound workqueues, the
  assumption that an unbound workqueue with max_active == 1 is ordered
  was broken.  The plan was to use explicit alloc_ordered_workqueue()
  for those cases.  Unfortunately, I forgot to update the
  documentation properly and we grew a handful of use cases which
  depend on that assumption.

  While we want to convert them to alloc_ordered_workqueue(), we don't
  really lose anything by enforcing ordered execution on unbound
  max_active == 1 workqueues and it doesn't make sense to risk subtle
  bugs.  Restore the assumption.

* Workqueue assumes that CPU <-> NUMA node mapping remains static.
  This is a general assumption - we don't have any synchronization
  mechanism around CPU <-> node mapping.  Unfortunately, powerpc may
  change the mapping dynamically leading to crashes.  Michael added a
  workaround so that we at least don't crash while powerpc hotplug
  code gets updated.

Thanks.

The following changes since commit 74cbd96bc2e00f5daa805e2ebf49e998f7045062:

  Merge tag 'md/4.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/shli/md (2017-07-18 11:51:08 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git for-4.13-fixes

for you to fetch changes up to 1ad0f0a7aa1bf3bd42dcd108a96713d255eacd9f:

  workqueue: Work around edge cases for calc of pool's cpumask (2017-07-28 11:05:52 -0400)

----------------------------------------------------------------
Michael Bringmann (1):
      workqueue: Work around edge cases for calc of pool's cpumask

Tejun Heo (2):
      workqueue: restore WQ_UNBOUND/max_active==1 to be ordered
      workqueue: implicit ordered attribute should be overridable

 include/linux/workqueue.h |  4 +++-
 kernel/workqueue.c        | 30 ++++++++++++++++++++++++++----
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index c102ef6..db6dc9d 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -323,6 +323,7 @@ enum {
 
 	__WQ_DRAINING		= 1 << 16, /* internal: workqueue is draining */
 	__WQ_ORDERED		= 1 << 17, /* internal: workqueue is ordered */
+	__WQ_ORDERED_EXPLICIT	= 1 << 18, /* internal: alloc_ordered_workqueue() */
 	__WQ_LEGACY		= 1 << 18, /* internal: create*_workqueue() */
 
 	WQ_MAX_ACTIVE		= 512,	  /* I like 512, better ideas? */
@@ -422,7 +423,8 @@ __alloc_workqueue_key(const char *fmt, unsigned int flags, int max_active,
  * Pointer to the allocated workqueue on success, %NULL on failure.
  */
 #define alloc_ordered_workqueue(fmt, flags, args...)			\
-	alloc_workqueue(fmt, WQ_UNBOUND | __WQ_ORDERED | (flags), 1, ##args)
+	alloc_workqueue(fmt, WQ_UNBOUND | __WQ_ORDERED |		\
+			__WQ_ORDERED_EXPLICIT | (flags), 1, ##args)
 
 #define create_workqueue(name)						\
 	alloc_workqueue("%s", __WQ_LEGACY | WQ_MEM_RECLAIM, 1, (name))
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index a86688f..ca937b0 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -3577,6 +3577,13 @@ static bool wq_calc_node_cpumask(const struct workqueue_attrs *attrs, int node,
 
 	/* yeap, return possible CPUs in @node that @attrs wants */
 	cpumask_and(cpumask, attrs->cpumask, wq_numa_possible_cpumask[node]);
+
+	if (cpumask_empty(cpumask)) {
+		pr_warn_once("WARNING: workqueue cpumask: online intersect > "
+				"possible intersect\n");
+		return false;
+	}
+
 	return !cpumask_equal(cpumask, attrs->cpumask);
 
 use_dfl:
@@ -3744,8 +3751,12 @@ static int apply_workqueue_attrs_locked(struct workqueue_struct *wq,
 		return -EINVAL;
 
 	/* creating multiple pwqs breaks ordering guarantee */
-	if (WARN_ON((wq->flags & __WQ_ORDERED) && !list_empty(&wq->pwqs)))
-		return -EINVAL;
+	if (!list_empty(&wq->pwqs)) {
+		if (WARN_ON(wq->flags & __WQ_ORDERED_EXPLICIT))
+			return -EINVAL;
+
+		wq->flags &= ~__WQ_ORDERED;
+	}
 
 	ctx = apply_wqattrs_prepare(wq, attrs);
 	if (!ctx)
@@ -3929,6 +3940,16 @@ struct workqueue_struct *__alloc_workqueue_key(const char *fmt,
 	struct workqueue_struct *wq;
 	struct pool_workqueue *pwq;
 
+	/*
+	 * Unbound && max_active == 1 used to imply ordered, which is no
+	 * longer the case on NUMA machines due to per-node pools.  While
+	 * alloc_ordered_workqueue() is the right way to create an ordered
+	 * workqueue, keep the previous behavior to avoid subtle breakages
+	 * on NUMA.
+	 */
+	if ((flags & WQ_UNBOUND) && max_active == 1)
+		flags |= __WQ_ORDERED;
+
 	/* see the comment above the definition of WQ_POWER_EFFICIENT */
 	if ((flags & WQ_POWER_EFFICIENT) && wq_power_efficient)
 		flags |= WQ_UNBOUND;
@@ -4119,13 +4140,14 @@ void workqueue_set_max_active(struct workqueue_struct *wq, int max_active)
 	struct pool_workqueue *pwq;
 
 	/* disallow meddling with max_active for ordered workqueues */
-	if (WARN_ON(wq->flags & __WQ_ORDERED))
+	if (WARN_ON(wq->flags & __WQ_ORDERED_EXPLICIT))
 		return;
 
 	max_active = wq_clamp_max_active(max_active, wq->flags, wq->name);
 
 	mutex_lock(&wq->mutex);
 
+	wq->flags &= ~__WQ_ORDERED;
 	wq->saved_max_active = max_active;
 
 	for_each_pwq(pwq, wq)
@@ -5253,7 +5275,7 @@ int workqueue_sysfs_register(struct workqueue_struct *wq)
 	 * attributes breaks ordering guarantee.  Disallow exposing ordered
 	 * workqueues.
 	 */
-	if (WARN_ON(wq->flags & __WQ_ORDERED))
+	if (WARN_ON(wq->flags & __WQ_ORDERED_EXPLICIT))
 		return -EINVAL;
 
 	wq->wq_dev = wq_dev = kzalloc(sizeof(*wq_dev), GFP_KERNEL);

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [GIT PULL] workqueue fixes for v4.13-rc3
  2017-07-31 15:38 [GIT PULL] workqueue fixes for v4.13-rc3 Tejun Heo
@ 2017-08-07 12:18 ` Geert Uytterhoeven
  2017-08-07 17:06   ` Tejun Heo
  0 siblings, 1 reply; 11+ messages in thread
From: Geert Uytterhoeven @ 2017-08-07 12:18 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Linus Torvalds, linux-kernel, Lai Jiangshan, Michael Bringmann

Hi Tejun,

On Mon, Jul 31, 2017 at 5:38 PM, Tejun Heo <tj@kernel.org> wrote:
> Two notable fixes.

> * Workqueue assumes that CPU <-> NUMA node mapping remains static.
>   This is a general assumption - we don't have any synchronization
>   mechanism around CPU <-> node mapping.  Unfortunately, powerpc may
>   change the mapping dynamically leading to crashes.  Michael added a
>   workaround so that we at least don't crash while powerpc hotplug
>   code gets updated.

> Michael Bringmann (1):
>       workqueue: Work around edge cases for calc of pool's cpumask

> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -3577,6 +3577,13 @@ static bool wq_calc_node_cpumask(const struct workqueue_attrs *attrs, int node,
>
>         /* yeap, return possible CPUs in @node that @attrs wants */
>         cpumask_and(cpumask, attrs->cpumask, wq_numa_possible_cpumask[node]);
> +
> +       if (cpumask_empty(cpumask)) {
> +               pr_warn_once("WARNING: workqueue cpumask: online intersect > "
> +                               "possible intersect\n");
> +               return false;
> +       }
> +

This triggers on m68k, which doesn't have SMP.
Haven't tried it yet on any other system due to holidays.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [GIT PULL] workqueue fixes for v4.13-rc3
  2017-08-07 12:18 ` Geert Uytterhoeven
@ 2017-08-07 17:06   ` Tejun Heo
  2017-08-23  8:10     ` Geert Uytterhoeven
  0 siblings, 1 reply; 11+ messages in thread
From: Tejun Heo @ 2017-08-07 17:06 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linus Torvalds, linux-kernel, Lai Jiangshan, Michael Bringmann

Hello,

On Mon, Aug 07, 2017 at 02:18:51PM +0200, Geert Uytterhoeven wrote:
> This triggers on m68k, which doesn't have SMP.
> Haven't tried it yet on any other system due to holidays.

That's weird.  Can you please apply the following patch and report the
messages?

Thanks.

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index ca937b0..1b9d21b 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -3579,8 +3579,10 @@ static bool wq_calc_node_cpumask(const struct workqueue_attrs *attrs, int node,
 	cpumask_and(cpumask, attrs->cpumask, wq_numa_possible_cpumask[node]);
 
 	if (cpumask_empty(cpumask)) {
-		pr_warn_once("WARNING: workqueue cpumask: online intersect > "
-				"possible intersect\n");
+		pr_warn_once("WARNING: workqueue empty cpumask: node=%d cpu_going_down=%d cpumask=%*pb online=%*pb possible=%*pb\n",
+			     node, cpu_going_down, cpumask_pr_args(attrs->cpumask),
+			     cpumask_pr_args(cpumask_of_node(node)),
+			     cpumask_pr_args(wq_numa_possible_cpumask[node]));
 		return false;
 	}
 
@@ -5526,6 +5528,9 @@ static void __init wq_numa_init(void)
 
 	wq_numa_possible_cpumask = tbl;
 	wq_numa_enabled = true;
+
+	for_each_node(node)
+		printk("XXX wq node[%d] %*pb\n", node, cpumask_pr_args(wq_numa_possible_cpumask[node]));
 }
 
 /**

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [GIT PULL] workqueue fixes for v4.13-rc3
  2017-08-07 17:06   ` Tejun Heo
@ 2017-08-23  8:10     ` Geert Uytterhoeven
  2017-08-23 14:24       ` Tejun Heo
  0 siblings, 1 reply; 11+ messages in thread
From: Geert Uytterhoeven @ 2017-08-23  8:10 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Linus Torvalds, linux-kernel, Lai Jiangshan, Michael Bringmann

Hi Tejun,

On Mon, Aug 7, 2017 at 7:06 PM, Tejun Heo <tj@kernel.org> wrote:
> On Mon, Aug 07, 2017 at 02:18:51PM +0200, Geert Uytterhoeven wrote:
>> This triggers on m68k, which doesn't have SMP.
>> Haven't tried it yet on any other system due to holidays.
>
> That's weird.  Can you please apply the following patch and report the
> messages?
>
> Thanks.
>
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index ca937b0..1b9d21b 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -3579,8 +3579,10 @@ static bool wq_calc_node_cpumask(const struct workqueue_attrs *attrs, int node,
>         cpumask_and(cpumask, attrs->cpumask, wq_numa_possible_cpumask[node]);
>
>         if (cpumask_empty(cpumask)) {
> -               pr_warn_once("WARNING: workqueue cpumask: online intersect > "
> -                               "possible intersect\n");
> +               pr_warn_once("WARNING: workqueue empty cpumask: node=%d cpu_going_down=%d cpumask=%*pb online=%*pb possible=%*pb\n",
> +                            node, cpu_going_down, cpumask_pr_args(attrs->cpumask),
> +                            cpumask_pr_args(cpumask_of_node(node)),
> +                            cpumask_pr_args(wq_numa_possible_cpumask[node]));

WARNING: workqueue empty cpumask: node=1 cpu_going_down=-1 cpumask=1
online=1 possible=0

>                 return false;
>         }
>
> @@ -5526,6 +5528,9 @@ static void __init wq_numa_init(void)
>
>         wq_numa_possible_cpumask = tbl;
>         wq_numa_enabled = true;
> +
> +       for_each_node(node)
> +               printk("XXX wq node[%d] %*pb\n", node, cpumask_pr_args(wq_numa_possible_cpumask[node]));

XXX wq node[0] 1
XXX wq node[1] 0
XXX wq node[2] 0
XXX wq node[3] 0
XXX wq node[4] 0
XXX wq node[5] 0
XXX wq node[6] 0
XXX wq node[7] 0

>  }

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [GIT PULL] workqueue fixes for v4.13-rc3
  2017-08-23  8:10     ` Geert Uytterhoeven
@ 2017-08-23 14:24       ` Tejun Heo
  2017-08-23 14:47         ` Geert Uytterhoeven
  0 siblings, 1 reply; 11+ messages in thread
From: Tejun Heo @ 2017-08-23 14:24 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linus Torvalds, linux-kernel, Lai Jiangshan, Michael Bringmann

Hello, Geert.

Something is really fishy.

On Wed, Aug 23, 2017 at 10:10:54AM +0200, Geert Uytterhoeven wrote:
> > +               pr_warn_once("WARNING: workqueue empty cpumask: node=%d cpu_going_down=%d cpumask=%*pb online=%*pb possible=%*pb\n",
> > +                            node, cpu_going_down, cpumask_pr_args(attrs->cpumask),
> > +                            cpumask_pr_args(cpumask_of_node(node)),
> > +                            cpumask_pr_args(wq_numa_possible_cpumask[node]));
> 
> WARNING: workqueue empty cpumask: node=1 cpu_going_down=-1 cpumask=1
> online=1 possible=0

So, somehow cpu0 seems to be associated with node 1 instead of 0.  It
seems highly unlikely but does the system actually have multiple NUMA
nodes?

> > @@ -5526,6 +5528,9 @@ static void __init wq_numa_init(void)
> >
> >         wq_numa_possible_cpumask = tbl;
> >         wq_numa_enabled = true;
> > +
> > +       for_each_node(node)
> > +               printk("XXX wq node[%d] %*pb\n", node, cpumask_pr_args(wq_numa_possible_cpumask[node]));
> 
> XXX wq node[0] 1
> XXX wq node[1] 0
> XXX wq node[2] 0
> XXX wq node[3] 0
> XXX wq node[4] 0
> XXX wq node[5] 0
> XXX wq node[6] 0
> XXX wq node[7] 0

No idea why num_possible_cpus() is 8 on a non-SMP system but the
problem is that, during boot while wq_numa_init() was running, cpu0
reported that it's associated with node 0, but later it reports that
it's associated node 1.  It looks like NUMA setup is screwed up.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [GIT PULL] workqueue fixes for v4.13-rc3
  2017-08-23 14:24       ` Tejun Heo
@ 2017-08-23 14:47         ` Geert Uytterhoeven
  2017-08-23 17:08           ` Tejun Heo
  0 siblings, 1 reply; 11+ messages in thread
From: Geert Uytterhoeven @ 2017-08-23 14:47 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Linus Torvalds, linux-kernel, Lai Jiangshan, Michael Bringmann

Hi Tejun,

On Wed, Aug 23, 2017 at 4:24 PM, Tejun Heo <tj@kernel.org> wrote:
> On Wed, Aug 23, 2017 at 10:10:54AM +0200, Geert Uytterhoeven wrote:
>> > +               pr_warn_once("WARNING: workqueue empty cpumask: node=%d cpu_going_down=%d cpumask=%*pb online=%*pb possible=%*pb\n",
>> > +                            node, cpu_going_down, cpumask_pr_args(attrs->cpumask),
>> > +                            cpumask_pr_args(cpumask_of_node(node)),
>> > +                            cpumask_pr_args(wq_numa_possible_cpumask[node]));
>>
>> WARNING: workqueue empty cpumask: node=1 cpu_going_down=-1 cpumask=1
>> online=1 possible=0
>
> So, somehow cpu0 seems to be associated with node 1 instead of 0.  It
> seems highly unlikely but does the system actually have multiple NUMA
> nodes?
>
>> > @@ -5526,6 +5528,9 @@ static void __init wq_numa_init(void)
>> >
>> >         wq_numa_possible_cpumask = tbl;
>> >         wq_numa_enabled = true;
>> > +
>> > +       (node)
>> > +               printk("XXX wq node[%d] %*pb\n", node, cpumask_pr_args(wq_numa_possible_cpumask[node]));
>>
>> XXX wq node[0] 1
>> XXX wq node[1] 0
>> XXX wq node[2] 0
>> XXX wq node[3] 0
>> XXX wq node[4] 0
>> XXX wq node[5] 0
>> XXX wq node[6] 0
>> XXX wq node[7] 0
>
> No idea why num_possible_cpus() is 8 on a non-SMP system but the
> problem is that, during boot while wq_numa_init() was running, cpu0
> reported that it's associated with node 0, but later it reports that
> it's associated node 1.  It looks like NUMA setup is screwed up.

Some code is mixing up multiple memory nodes with multiple cpu nodes.
M68k uses DISCONTIGMEM, but  not NUMA (no SMP):

    config NEED_MULTIPLE_NODES
        def_bool y
        depends on DISCONTIGMEM || NUMA

The (virtual) Atari has 2 memory nodes:
  - node0: start 0x00000000 size 0x00e00000
  - node1: start 0x01000000 size 0x10000000
Both are tied to the same (single) CPU node, of course.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [GIT PULL] workqueue fixes for v4.13-rc3
  2017-08-23 14:47         ` Geert Uytterhoeven
@ 2017-08-23 17:08           ` Tejun Heo
  2017-08-24 13:32             ` Geert Uytterhoeven
  0 siblings, 1 reply; 11+ messages in thread
From: Tejun Heo @ 2017-08-23 17:08 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linus Torvalds, linux-kernel, Lai Jiangshan, Michael Bringmann

Hello, Geert.

On Wed, Aug 23, 2017 at 04:47:41PM +0200, Geert Uytterhoeven wrote:
> Some code is mixing up multiple memory nodes with multiple cpu nodes.
> M68k uses DISCONTIGMEM, but  not NUMA (no SMP):
> 
>     config NEED_MULTIPLE_NODES
>         def_bool y
>         depends on DISCONTIGMEM || NUMA
> 
> The (virtual) Atari has 2 memory nodes:
>   - node0: start 0x00000000 size 0x00e00000
>   - node1: start 0x01000000 size 0x10000000
> Both are tied to the same (single) CPU node, of course.

Ah, okay, so it has multiple nodes but not NUMA.  The generic numa
topology code assumes that there's only one node if !NUMA and reports
all online cpus regardless of the node number, which makes the same
CPUs to be reported for all nodes on the system.  I think something
like the following (completely untested) should work.

Thanks.

diff --git a/include/asm-generic/topology.h b/include/asm-generic/topology.h
index fc824e2..b31e84a 100644
--- a/include/asm-generic/topology.h
+++ b/include/asm-generic/topology.h
@@ -48,7 +48,11 @@
 #define parent_node(node)	((void)(node),0)
 #endif
 #ifndef cpumask_of_node
-#define cpumask_of_node(node)	((void)node, cpu_online_mask)
+  #ifdef CONFIG_NEED_MULTIPLE_NODES
+    #define cpumask_of_node(node)	((node) == 0 ? cpu_online_mask : cpu_empty_mask)
+  #else
+    #define cpumask_of_node(node)	((void)node, cpu_online_mask)
+  #endif
 #endif
 #ifndef pcibus_to_node
 #define pcibus_to_node(bus)	((void)(bus), -1)
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 4bf4479..4d41d3b 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -89,10 +89,12 @@ extern struct cpumask __cpu_possible_mask;
 extern struct cpumask __cpu_online_mask;
 extern struct cpumask __cpu_present_mask;
 extern struct cpumask __cpu_active_mask;
+extern struct cpumask __cpu_empty_mask;
 #define cpu_possible_mask ((const struct cpumask *)&__cpu_possible_mask)
 #define cpu_online_mask   ((const struct cpumask *)&__cpu_online_mask)
 #define cpu_present_mask  ((const struct cpumask *)&__cpu_present_mask)
 #define cpu_active_mask   ((const struct cpumask *)&__cpu_active_mask)
+#define cpu_empty_mask    ((const struct cpumask *)&__cpu_empty_mask)
 
 #if NR_CPUS > 1
 #define num_online_cpus()	cpumask_weight(cpu_online_mask)
diff --git a/kernel/cpu.c b/kernel/cpu.c
index ab86045..eeed945 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1741,6 +1741,9 @@ EXPORT_SYMBOL(__cpu_present_mask);
 struct cpumask __cpu_active_mask __read_mostly;
 EXPORT_SYMBOL(__cpu_active_mask);
 
+struct cpumask __cpu_empty_mask __read_mostly;
+EXPORT_SYMBOL(__cpu_empty_mask);
+
 void init_cpu_present(const struct cpumask *src)
 {
 	cpumask_copy(&__cpu_present_mask, src);

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [GIT PULL] workqueue fixes for v4.13-rc3
  2017-08-23 17:08           ` Tejun Heo
@ 2017-08-24 13:32             ` Geert Uytterhoeven
  2017-08-24 14:33               ` Tejun Heo
  0 siblings, 1 reply; 11+ messages in thread
From: Geert Uytterhoeven @ 2017-08-24 13:32 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Linus Torvalds, linux-kernel, Lai Jiangshan, Michael Bringmann

Hi Tejun,

On Wed, Aug 23, 2017 at 7:08 PM, Tejun Heo <tj@kernel.org> wrote:
> On Wed, Aug 23, 2017 at 04:47:41PM +0200, Geert Uytterhoeven wrote:
>> Some code is mixing up multiple memory nodes with multiple cpu nodes.
>> M68k uses DISCONTIGMEM, but  not NUMA (no SMP):
>>
>>     config NEED_MULTIPLE_NODES
>>         def_bool y
>>         depends on DISCONTIGMEM || NUMA
>>
>> The (virtual) Atari has 2 memory nodes:
>>   - node0: start 0x00000000 size 0x00e00000
>>   - node1: start 0x01000000 size 0x10000000
>> Both are tied to the same (single) CPU node, of course.
>
> Ah, okay, so it has multiple nodes but not NUMA.  The generic numa
> topology code assumes that there's only one node if !NUMA and reports
> all online cpus regardless of the node number, which makes the same
> CPUs to be reported for all nodes on the system.  I think something
> like the following (completely untested) should work.

Thank you, that got rid of the warning.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [GIT PULL] workqueue fixes for v4.13-rc3
  2017-08-24 13:32             ` Geert Uytterhoeven
@ 2017-08-24 14:33               ` Tejun Heo
  2017-08-28  9:07                 ` Geert Uytterhoeven
  0 siblings, 1 reply; 11+ messages in thread
From: Tejun Heo @ 2017-08-24 14:33 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linus Torvalds, linux-kernel, Lai Jiangshan, Michael Bringmann

Hello,

On Thu, Aug 24, 2017 at 03:32:04PM +0200, Geert Uytterhoeven wrote:
> > Ah, okay, so it has multiple nodes but not NUMA.  The generic numa
> > topology code assumes that there's only one node if !NUMA and reports
> > all online cpus regardless of the node number, which makes the same
> > CPUs to be reported for all nodes on the system.  I think something
> > like the following (completely untested) should work.
> 
> Thank you, that got rid of the warning.

Great, it turns out we already have cpu_none_mask.  Can you please
test the following works too?

Thanks.

diff --git a/include/asm-generic/topology.h b/include/asm-generic/topology.h
index fc824e2..5d2add1 100644
--- a/include/asm-generic/topology.h
+++ b/include/asm-generic/topology.h
@@ -48,7 +48,11 @@
 #define parent_node(node)	((void)(node),0)
 #endif
 #ifndef cpumask_of_node
-#define cpumask_of_node(node)	((void)node, cpu_online_mask)
+  #ifdef CONFIG_NEED_MULTIPLE_NODES
+    #define cpumask_of_node(node)	((node) == 0 ? cpu_online_mask : cpu_none_mask)
+  #else
+    #define cpumask_of_node(node)	((void)node, cpu_online_mask)
+  #endif
 #endif
 #ifndef pcibus_to_node
 #define pcibus_to_node(bus)	((void)(bus), -1)

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [GIT PULL] workqueue fixes for v4.13-rc3
  2017-08-24 14:33               ` Tejun Heo
@ 2017-08-28  9:07                 ` Geert Uytterhoeven
  2017-08-28 21:52                   ` Tejun Heo
  0 siblings, 1 reply; 11+ messages in thread
From: Geert Uytterhoeven @ 2017-08-28  9:07 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Linus Torvalds, linux-kernel, Lai Jiangshan, Michael Bringmann

Hi Tejun,

On Thu, Aug 24, 2017 at 4:33 PM, Tejun Heo <tj@kernel.org> wrote:
> On Thu, Aug 24, 2017 at 03:32:04PM +0200, Geert Uytterhoeven wrote:
>> > Ah, okay, so it has multiple nodes but not NUMA.  The generic numa
>> > topology code assumes that there's only one node if !NUMA and reports
>> > all online cpus regardless of the node number, which makes the same
>> > CPUs to be reported for all nodes on the system.  I think something
>> > like the following (completely untested) should work.
>>
>> Thank you, that got rid of the warning.
>
> Great, it turns out we already have cpu_none_mask.  Can you please
> test the following works too?

That works, too.

Thanks!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [GIT PULL] workqueue fixes for v4.13-rc3
  2017-08-28  9:07                 ` Geert Uytterhoeven
@ 2017-08-28 21:52                   ` Tejun Heo
  0 siblings, 0 replies; 11+ messages in thread
From: Tejun Heo @ 2017-08-28 21:52 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linus Torvalds, linux-kernel, Lai Jiangshan, Michael Bringmann

On Mon, Aug 28, 2017 at 11:07:28AM +0200, Geert Uytterhoeven wrote:
> Hi Tejun,
> 
> On Thu, Aug 24, 2017 at 4:33 PM, Tejun Heo <tj@kernel.org> wrote:
> > On Thu, Aug 24, 2017 at 03:32:04PM +0200, Geert Uytterhoeven wrote:
> >> > Ah, okay, so it has multiple nodes but not NUMA.  The generic numa
> >> > topology code assumes that there's only one node if !NUMA and reports
> >> > all online cpus regardless of the node number, which makes the same
> >> > CPUs to be reported for all nodes on the system.  I think something
> >> > like the following (completely untested) should work.
> >>
> >> Thank you, that got rid of the warning.
> >
> > Great, it turns out we already have cpu_none_mask.  Can you please
> > test the following works too?
> 
> That works, too.

Just posted patch w/ description and tested-by tag.  Thanks!

-- 
tejun

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-08-28 21:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-31 15:38 [GIT PULL] workqueue fixes for v4.13-rc3 Tejun Heo
2017-08-07 12:18 ` Geert Uytterhoeven
2017-08-07 17:06   ` Tejun Heo
2017-08-23  8:10     ` Geert Uytterhoeven
2017-08-23 14:24       ` Tejun Heo
2017-08-23 14:47         ` Geert Uytterhoeven
2017-08-23 17:08           ` Tejun Heo
2017-08-24 13:32             ` Geert Uytterhoeven
2017-08-24 14:33               ` Tejun Heo
2017-08-28  9:07                 ` Geert Uytterhoeven
2017-08-28 21:52                   ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).