Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp947978ybz; Fri, 1 May 2020 11:27:28 -0700 (PDT) X-Google-Smtp-Source: APiQypL5sUSja7aahghdcdTXsGGlZh7ERKVI/5IggTYnkFUNQc6fQR8D8cacgzfXB6YIkF/cPFmi X-Received: by 2002:a17:906:ca49:: with SMTP id jx9mr4356485ejb.246.1588357648272; Fri, 01 May 2020 11:27:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588357648; cv=none; d=google.com; s=arc-20160816; b=ENSGKqJU6Pf2shIikWp5ascK+ZmiRNGihj5Tx+B0pjnjuXT/ox8U2Sb64eY+Dq9g7i r6VBDQUUY77JVKYDzOtS5YjtXesl3yDPjKtD7nrVnJeVw7OafozasEpAAK/2jUlYV+Ch 8m80Tv/OWPtSuL3LuTX7YH34NTQemo8RPDsN/cn9vAPB/XDZaPPqX6NYO/dV2a1bMT7Z 9FBhzqXe/jeaxVpCY9Ds0f1sDqVPKpMPt4nRLOCS/upIaBhYaFhPBfwHpP0QLc4YRpWF lB3qw+8tA+0aRSWEeeG9/jkVK0xUjQTl43GBRjQkRIfOo+7HIhDOqcq68+p6fcj+780u W5sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=r07v3TCf6fyxHEcdv5y0Lna6se+f0E4V3ksrnzrI/Bo=; b=nWueV4/KBGx2pYlH6BH/6pp7Dc0+F8jGXSps6KazfQxS/s7zfc3ZuEwmfGTiij/mID WR8y8QjAc6K264Dpt1K+Nscepi2DJEe0rV8OmIDFdVY6biGHTFVQomKnrX8O574i2acI sa8vtHfAiRSXXFdXCXPW/TdgQuJqrBU0HC4huXk59NEjgwhw1S7j1TztzdHMv/d4259w CIQRhjOvKJO5O2W8l6XvXfgLrSq2OgnbXTimmI6vuJ5RbecDqxgTINVM+GdSzAbt8xuj 6VXUwNtIP5OY3kYkjPwNqNc2JkLC5xTCGSbvU9MASF+mZUIkoPdS6KRaJ6DO3Yh7VjBP ve/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j19si2054274ejx.382.2020.05.01.11.27.05; Fri, 01 May 2020 11:27:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730515AbgEASWO (ORCPT + 99 others); Fri, 1 May 2020 14:22:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730462AbgEASWM (ORCPT ); Fri, 1 May 2020 14:22:12 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79867C08E934; Fri, 1 May 2020 11:22:12 -0700 (PDT) Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jUaIY-0003WT-F2; Fri, 01 May 2020 20:22:06 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id ED4641C0330; Fri, 1 May 2020 20:22:05 +0200 (CEST) Date: Fri, 01 May 2020 18:22:05 -0000 From: "tip-bot2 for Barret Rhoden" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf: Add cond_resched() to task_function_call() Cc: syzbot+bb4935a5c09b5ff79940@syzkaller.appspotmail.com, Barret Rhoden , "Peter Zijlstra (Intel)" , x86 , LKML In-Reply-To: <20200414222920.121401-1-brho@google.com> References: <20200414222920.121401-1-brho@google.com> MIME-Version: 1.0 Message-ID: <158835732594.8414.10249310108330671272.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/core branch of tip: Commit-ID: 2ed6edd33a214bca02bd2b45e3fc3038a059436b Gitweb: https://git.kernel.org/tip/2ed6edd33a214bca02bd2b45e3fc3038a059436b Author: Barret Rhoden AuthorDate: Tue, 14 Apr 2020 18:29:20 -04:00 Committer: Peter Zijlstra CommitterDate: Thu, 30 Apr 2020 20:14:36 +02:00 perf: Add cond_resched() to task_function_call() Under rare circumstances, task_function_call() can repeatedly fail and cause a soft lockup. There is a slight race where the process is no longer running on the cpu we targeted by the time remote_function() runs. The code will simply try again. If we are very unlucky, this will continue to fail, until a watchdog fires. This can happen in a heavily loaded, multi-core virtual machine. Reported-by: syzbot+bb4935a5c09b5ff79940@syzkaller.appspotmail.com Signed-off-by: Barret Rhoden Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20200414222920.121401-1-brho@google.com --- kernel/events/core.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 52951e9..80cf996 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -95,11 +95,11 @@ static void remote_function(void *data) * @info: the function call argument * * Calls the function @func when the task is currently running. This might - * be on the current CPU, which just calls the function directly + * be on the current CPU, which just calls the function directly. This will + * retry due to any failures in smp_call_function_single(), such as if the + * task_cpu() goes offline concurrently. * - * returns: @func return value, or - * -ESRCH - when the process isn't running - * -EAGAIN - when the process moved away + * returns @func return value or -ESRCH when the process isn't running */ static int task_function_call(struct task_struct *p, remote_function_f func, void *info) @@ -112,11 +112,16 @@ task_function_call(struct task_struct *p, remote_function_f func, void *info) }; int ret; - do { - ret = smp_call_function_single(task_cpu(p), remote_function, &data, 1); - if (!ret) - ret = data.ret; - } while (ret == -EAGAIN); + for (;;) { + ret = smp_call_function_single(task_cpu(p), remote_function, + &data, 1); + ret = !ret ? data.ret : -EAGAIN; + + if (ret != -EAGAIN) + break; + + cond_resched(); + } return ret; }