Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752479AbbEAUAX (ORCPT ); Fri, 1 May 2015 16:00:23 -0400 Received: from mail-db3on0097.outbound.protection.outlook.com ([157.55.234.97]:57344 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750984AbbEAUAD (ORCPT ); Fri, 1 May 2015 16:00:03 -0400 Authentication-Results: infradead.org; dkim=none (message not signed) header.d=none; Message-ID: <5543DABF.4060303@ezchip.com> Date: Fri, 1 May 2015 15:57:51 -0400 From: Chris Metcalf User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Frederic Weisbecker , Andrew Morton CC: Don Zickus , Ingo Molnar , Andrew Jones , Ulrich Obergfell , Fabian Frederick , Aaron Tomlin , Ben Zhang , Christoph Lameter , Gilad Ben-Yossef , Steven Rostedt , , Jonathan Corbet , , Thomas Gleixner , Peter Zijlstra Subject: Re: [PATCH v10 1/3] smpboot: allow excluding cpus from the smpboot threads References: <1430422766-19703-1-git-send-email-cmetcalf@ezchip.com> <1430422766-19703-2-git-send-email-cmetcalf@ezchip.com> <20150501085356.GA14149@lerouge> In-Reply-To: <20150501085356.GA14149@lerouge> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [12.216.194.146] X-ClientProxiedBy: BLUPR07CA0108.namprd07.prod.outlook.com (10.255.223.179) To AM2PR02MB0770.eurprd02.prod.outlook.com (25.163.146.155) X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AM2PR02MB0770; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:AM2PR02MB0770;BCL:0;PCL:0;RULEID:;SRVR:AM2PR02MB0770; X-Forefront-PRVS: 0563F2E8B7 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6049001)(6009001)(377454003)(24454002)(479174004)(51704005)(46102003)(83506001)(19580395003)(23746002)(36756003)(64126003)(15975445007)(86362001)(50986999)(54356999)(80316001)(19580405001)(40100003)(5001770100001)(42186005)(122386002)(50466002)(65816999)(4001350100001)(87976001)(92566002)(62966003)(77156002)(77096005)(2950100001)(47776003)(65806001)(66066001)(76176999)(65956001)(5001960100002)(33656002)(18886065003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM2PR02MB0770;H:[10.7.0.41];FPR:;SPF:None;MLV:sfv;LANG:en; X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2015 19:59:57.6666 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM2PR02MB0770 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4294 Lines: 94 On 05/01/2015 04:53 AM, Frederic Weisbecker wrote: > On Thu, Apr 30, 2015 at 03:39:24PM -0400, Chris Metcalf wrote: >> This change allows some cores to be excluded from running the >> smp_hotplug_thread tasks. The following commit to update >> kernel/watchdog.c to use this functionality is the motivating >> example, and more information on the motivation is provided there. >> >> A new smp_hotplug_thread field is introduced, "cpumask", which >> is cpumask field managed by the smpboot subsystem that indicates whether >> or not the given smp_hotplug_thread should run on that core; the >> cpumask is checked when deciding whether to unpark the thread. >> >> To limit the cpumask to less than cpu_possible, you must call >> smpboot_update_cpumask_percpu_thread() after registering. >> >> Signed-off-by: Chris Metcalf >> --- >> include/linux/smpboot.h | 5 +++++ >> kernel/smpboot.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++- >> 2 files changed, 59 insertions(+), 1 deletion(-) >> >> diff --git a/include/linux/smpboot.h b/include/linux/smpboot.h >> index d600afb21926..7c42153edfac 100644 >> --- a/include/linux/smpboot.h >> +++ b/include/linux/smpboot.h >> @@ -27,6 +27,8 @@ struct smpboot_thread_data; >> * @pre_unpark: Optional unpark function, called before the thread is >> * unparked (cpu online). This is not guaranteed to be >> * called on the target cpu of the thread. Careful! >> + * @cpumask: Internal state. To update which threads are unparked, >> + * call smpboot_update_cpumask_percpu_thread(). >> * @selfparking: Thread is not parked by the park function. >> * @thread_comm: The base name of the thread >> */ >> @@ -41,11 +43,14 @@ struct smp_hotplug_thread { >> void (*park)(unsigned int cpu); >> void (*unpark)(unsigned int cpu); >> void (*pre_unpark)(unsigned int cpu); >> + struct cpumask cpumask; > I believe it should be allocated dynamically, otherwise it gets the size of NR_CPUS > instead of nr_cpus_bits. It's not _that_ much space spared but think there should be > several struct smp_hotplug_thread registered. I'll submit a follow-up patch to do this. I'm assuming this doesn't need to be rolled as a v11, and can be a stand-alone patch, but I'll do it whichever way Andrew prefers. >> + /* Unpark any threads that were voluntarily parked. */ >> + for_each_cpu_not(cpu, &ht->cpumask) { >> + if (cpu_online(cpu)) { >> + struct task_struct *tsk = *per_cpu_ptr(ht->store, cpu); >> + if (tsk) >> + kthread_unpark(tsk); > I'm still not clear why we are doing that. kthread_stop() should be able > to handle parked kthreads, otherwise it needs to be fixed. Checking without the unpark, it's actually only a problem with nohz_full. In a system without nohz_full, the kthreads are able to stop even when they are parked; it's only in the nohz_full case that things wedge. For example, booting with only cpu 0 as a housekeeping core (and therefore all watchdogs 1-35 on my 36-core tilegx are parked), and immediately doing "echo 0 > /proc/sys/kernel/watchdog", I see (via SysRq ^O-l) the first parked watchdog, on cpu 1, hung with: frame 0: 0xfffffff7000f2928 lock_hrtimer_base+0xb8/0xc0 frame 1: 0xfffffff7000f2a28 hrtimer_try_to_cancel+0x40/0x170 frame 2: 0xfffffff7000f2a28 hrtimer_try_to_cancel+0x40/0x170 frame 3: 0xfffffff7000f2b98 hrtimer_cancel+0x40/0x68 frame 4: 0xfffffff70014cce0 watchdog_disable+0x50/0x70 frame 5: 0xfffffff70008c2d0 smpboot_thread_fn+0x350/0x438 frame 6: 0xfffffff700084b28 kthread+0x160/0x178 The other cores are all idle. I have no idea why lock_hrtimer_base() is hanging; perhaps the hrtimer_cpu_base lock is taken by some other task that is now scheduled out. The config does not have NO_HZ_FULL_ALL or NO_HZ_FULL_SYSIDLE set, and does have RCU_FAST_NO_HZ and RCU_NOCB_CPU_ALL. I don't really know how to start debugging this, but I do know that unparking the threads first avoids the issue :-) -- Chris Metcalf, EZChip Semiconductor http://www.ezchip.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/