Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5077403ybi; Sat, 20 Jul 2019 12:21:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxXy2Qw+tOS1XbY0NSKuZMOMAit4jYPBabdhpmfvXjuHqCECcter2hUm9D/MIXBemirQFP X-Received: by 2002:a17:902:7043:: with SMTP id h3mr35831421plt.10.1563650461710; Sat, 20 Jul 2019 12:21:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563650461; cv=none; d=google.com; s=arc-20160816; b=sc1ozIUM27lSlXHU4XbSXa/ZMO7uoUEgD+dTPxZgOAlmlR/MPwniZxPbN+IJVGDGQ+ WUbs9mDVqp7dejDGbiSeytHyLkOMXOG0bH5Kxjxl8t7JJpG9BlhR58btPIVAspcJLgj3 3+mTcLchsg2BEZvpQPiKM1CpPlblTRDIhhF+72KuOmhF/sR0jutpJNpohoqPObqHRJ8c 6KrCPgh/J2Gf8VM8sczZmukS1TDtmWqe5BiRlw7NmBCBYYnSwRLBtdifsetUDGLI6GiV J+U/GlcYOAKAtwPjT8pRD6TSrsBFrVTJFc0YeM2ojOPlUHtLHB2lFN0iP9+5fSx1LxGz +z+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=BBhwiJSF4HFd2wW6rUTEeMMDnaC77jv+fheQaqPwEcQ=; b=X7PCyGzK8wwM/F4uJ3frClJnPj2ohD0agtdCsWB8Fj3BxsG+GCkne4tR1IuV5wqqhl AKeMYW1SfukA9klTUly2SOJjhRabkQpa81SZ26/lA2p/VDRrIFWhcmeBdsSNjgpTkrDO kXxLoDtJh1Yt8BwtGo/VUyuZs/8k9AJzI1dgS+VoHEIoLq5yC9AORaJB+bqImRlQJfif /Kk3n2xcyqf2xy6vQHpMkZ+cnx/pQCw7MEFhWpudOSgHcZ2SY145bwU/+Ccvcg5Jd/zj cHsaocNnMxTCnHTBsEx7rtl0s/yNlxe/3AQ00+8xEkzDrWemypfN0b+york+0tR0hFIN 0fpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019061801 header.b=Jm0iZkDF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f92si3051803plb.330.2019.07.20.12.20.29; Sat, 20 Jul 2019 12:21:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@zytor.com header.s=2019061801 header.b=Jm0iZkDF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727364AbfGTJcd (ORCPT + 99 others); Sat, 20 Jul 2019 05:32:33 -0400 Received: from terminus.zytor.com ([198.137.202.136]:46087 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727325AbfGTJcd (ORCPT ); Sat, 20 Jul 2019 05:32:33 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x6K9Vvxu2881070 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sat, 20 Jul 2019 02:31:57 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x6K9Vvxu2881070 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019061801; t=1563615118; bh=BBhwiJSF4HFd2wW6rUTEeMMDnaC77jv+fheQaqPwEcQ=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=Jm0iZkDF+xWRZob0aMKmnYtFvNgiat/Df8UvYIomWwl0DBWD4FzuNP7c3kMleaBgr ziPH+kyHSiCIHXBAggQ8pPc5VSvT6o/9/nTM8WDGnCuPZfu6D40DvigY8+cm6j4cm+ Elfwp9ufpoEmoERuhBPTpq8cWvrQtSw6HFkULG4yrD6hu40f4LPb5O6Pq/dG+yZig+ ue0qzKk+Chd/3tHCGtBzy5SHptSnwThMbjmF4TqlN6hkhE0nbAdIWYTZIZ38n9eS9X X9Ki8pPNJapCZ3R0Ms2A0KO9meAIB5s160oxNm+XBgT3aPaGU8UUKBr9mv9ftoYru7 Db9u0sMGTcI3g== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x6K9VvQV2881067; Sat, 20 Jul 2019 02:31:57 -0700 Date: Sat, 20 Jul 2019 02:31:57 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Peter Zijlstra Message-ID: Cc: peterz@infradead.org, linux-kernel@vger.kernel.org, luferry@163.com, hpa@zytor.com, mingo@kernel.org, tglx@linutronix.de Reply-To: mingo@kernel.org, luferry@163.com, hpa@zytor.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, peterz@infradead.org In-Reply-To: <20190718160601.GP3402@hirez.programming.kicks-ass.net> References: <20190718160601.GP3402@hirez.programming.kicks-ass.net> To: linux-tip-commits@vger.kernel.org Subject: [tip:smp/urgent] smp: Warn on function calls from softirq context Git-Commit-ID: 19dbdcb8039cff16669a05136a29180778d16d0a X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=1.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, FREEMAIL_FORGED_REPLYTO autolearn=no autolearn_force=no version=3.4.2 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 19dbdcb8039cff16669a05136a29180778d16d0a Gitweb: https://git.kernel.org/tip/19dbdcb8039cff16669a05136a29180778d16d0a Author: Peter Zijlstra AuthorDate: Thu, 18 Jul 2019 11:20:09 +0200 Committer: Thomas Gleixner CommitDate: Sat, 20 Jul 2019 11:27:16 +0200 smp: Warn on function calls from softirq context It's clearly documented that smp function calls cannot be invoked from softirq handling context. Unfortunately nothing enforces that or emits a warning. A single function call can be invoked from softirq context only via smp_call_function_single_async(). The only legit context is task context, so add a warning to that effect. Reported-by: luferry Signed-off-by: Peter Zijlstra Signed-off-by: Thomas Gleixner Link: https://lkml.kernel.org/r/20190718160601.GP3402@hirez.programming.kicks-ass.net --- kernel/smp.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kernel/smp.c b/kernel/smp.c index 616d4d114847..7dbcb402c2fc 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -291,6 +291,14 @@ int smp_call_function_single(int cpu, smp_call_func_t func, void *info, WARN_ON_ONCE(cpu_online(this_cpu) && irqs_disabled() && !oops_in_progress); + /* + * When @wait we can deadlock when we interrupt between llist_add() and + * arch_send_call_function_ipi*(); when !@wait we can deadlock due to + * csd_lock() on because the interrupt context uses the same csd + * storage. + */ + WARN_ON_ONCE(!in_task()); + csd = &csd_stack; if (!wait) { csd = this_cpu_ptr(&csd_data); @@ -416,6 +424,14 @@ void smp_call_function_many(const struct cpumask *mask, WARN_ON_ONCE(cpu_online(this_cpu) && irqs_disabled() && !oops_in_progress && !early_boot_irqs_disabled); + /* + * When @wait we can deadlock when we interrupt between llist_add() and + * arch_send_call_function_ipi*(); when !@wait we can deadlock due to + * csd_lock() on because the interrupt context uses the same csd + * storage. + */ + WARN_ON_ONCE(!in_task()); + /* Try to fastpath. So, what's a CPU they want? Ignoring this one. */ cpu = cpumask_first_and(mask, cpu_online_mask); if (cpu == this_cpu)