From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941154AbcIVSSV (ORCPT ); Thu, 22 Sep 2016 14:18:21 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35751 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S941118AbcIVSSR (ORCPT ); Thu, 22 Sep 2016 14:18:17 -0400 From: Nicolai Stange To: Peter Zijlstra Cc: Juergen Gross , Ingo Molnar , Thomas Gleixner , Davidlohr Bueso , Richard Weinberger , linux-kernel@vger.kernel.org, Nicolai Stange Subject: [PATCH] smp: smp_call_on_cpu(): use INIT_WORK_ONSTACK() for automatic work_struct Date: Thu, 22 Sep 2016 20:17:58 +0200 Message-Id: <20160922181758.3449-1-nicstange@gmail.com> X-Mailer: git-send-email 2.10.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This new warning INFO: trying to register non-static key. the code is fine but needs lockdep annotation. turning off the locking correctness validator. CPU: 0 PID: 82 Comm: kworker/0:1 Not tainted 4.8.0-rc6+ #360 Hardware name: Dell Inc. Latitude E6540/0725FP, BIOS A10 06/26/2014 Workqueue: events smp_call_on_cpu_callback [...] Call Trace: [] dump_stack+0x68/0x93 [] register_lock_class+0x54a/0x550 [] __lock_acquire+0x88/0x12a0 [] ? debug_lockdep_rcu_enabled+0x1d/0x20 [] lock_acquire+0xe9/0x1d0 [] ? process_one_work+0x197/0x6c0 [] process_one_work+0x1f0/0x6c0 [] ? process_one_work+0x197/0x6c0 [] worker_thread+0x4e/0x4a0 [] ? process_one_work+0x6c0/0x6c0 [] ? process_one_work+0x6c0/0x6c0 [] kthread+0xff/0x120 [] ? kthread_park+0x60/0x60 [] ret_from_fork+0x27/0x40 dcdbas dcdbas: Dell Systems Management Base Driver (version 5.6.0-3.2) can be bisected to commit e23f22b5cb9e ("dcdbas: Make use of smp_call_on_cpu()"). The reason is that smp_call_on_cpu(), introduced with commit df8ce9d78a4e ("smp: Add function to execute a function synchronously on a CPU"), initializes a work_struct with automatic storage duration by means of __WORK_INITIALIZER(). Use INIT_WORK_ONSTACK() there instead, just like the very similar work_on_cpu() does. Fixes: df8ce9d78a4e ("smp: Add function to execute a function synchronously on a CPU") Signed-off-by: Nicolai Stange --- kernel/smp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/smp.c b/kernel/smp.c index f4f6137..a129ac3 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -759,7 +759,6 @@ static void smp_call_on_cpu_callback(struct work_struct *work) int smp_call_on_cpu(unsigned int cpu, int (*func)(void *), void *par, bool phys) { struct smp_call_on_cpu_struct sscs = { - .work = __WORK_INITIALIZER(sscs.work, smp_call_on_cpu_callback), .done = COMPLETION_INITIALIZER_ONSTACK(sscs.done), .func = func, .data = par, @@ -769,9 +768,13 @@ int smp_call_on_cpu(unsigned int cpu, int (*func)(void *), void *par, bool phys) if (cpu >= nr_cpu_ids || !cpu_online(cpu)) return -ENXIO; + INIT_WORK_ONSTACK(&sscs.work, smp_call_on_cpu_callback); + queue_work_on(cpu, system_wq, &sscs.work); wait_for_completion(&sscs.done); + destroy_work_on_stack(&sscs.work); + return sscs.ret; } EXPORT_SYMBOL_GPL(smp_call_on_cpu); -- 2.10.0