Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4361835pxu; Mon, 12 Oct 2020 17:35:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsxhOWdgrwoTuNAVTcYqYV1XDRNlWECwEArzIOlL1dKxOClqGRAY3b5h7cKo8YT7kuodER X-Received: by 2002:aa7:c9c3:: with SMTP id i3mr17415265edt.236.1602549347950; Mon, 12 Oct 2020 17:35:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602549347; cv=none; d=google.com; s=arc-20160816; b=l8oe5/jrm9FBfXgQOlMkHVR1T9VbYO1pvtxOGT8uXjJkwGR5cULWsKa+smCABaxsMA H1onMZcqxGWMu3hN0tGWhleL4FsAmmTcdLeULNoIN6hkOZnejoWoMLpP2vp1E0heiEs1 ZX+JTb9kV79cgNj5Uj4w61vT8c/c6QF8YFjDu615MGwdc/GkaJ3uDXT9A8cGWbRcQvZD gxzd0lXemEuZT0CNAve/FuL2pu+Vb7fhHIEvwi+//dX1SBVEihrEPuxSOOreenmjiwMU VSkVauFHk+dI/vqchheOCKz5zGESLKipXNdWhrxa2vfCDPxaUOClQtA1pFugDDgTHqJw ocDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UXjzzMzbg43G3Rgxua31XPFisw4k4ApzYWcuEG92jdc=; b=oIbXJ+AXp2MUbQzmaqbb6l7fVbgFRm71Q1kNxcPifrLy59EOdj2vt045HPK2QGNbc3 la6nTS8wvGAdp7pfnC17I3s3cPMDFkC1SHRqH0TgSERrhFT1lBU7OtSfQPBIXxpy5pju PewbxFe0d+Z4pOSDngToy1pF61XhbhtwnQAmqI3qAnsksKKC2mEFq7s1C41JH51pMsS6 yEM/OOugqTFaXzViCop3mvNIU7ysbxv80cA7bb3xFiCL9ghcE+XvTf2hEF74Lny++gTu 82N7azpGRb05DAldeji3wwFGZcXbgftAFUmo/m5l0wppvmzlUmEWkW1c3BQP7+w5slW1 50Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LiGMmWdL; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b12si13087598edy.394.2020.10.12.17.35.25; Mon, 12 Oct 2020 17:35:47 -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; dkim=pass header.i=@kernel.org header.s=default header.b=LiGMmWdL; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730535AbgJLOAB (ORCPT + 99 others); Mon, 12 Oct 2020 10:00:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:43860 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731461AbgJLNjz (ORCPT ); Mon, 12 Oct 2020 09:39:55 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ADFEA2087E; Mon, 12 Oct 2020 13:39:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602509994; bh=s6ADBcTjHZ3iiqt/bK4CzylMNoHP4CtDNcj9pTtmnJI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LiGMmWdLyw6CwsQRpcZho9lMN0ZtMcFPooYDM+E0Men/55r9C4Cpw8amLrYMZPSpm BYJ5bG8SeJhhjPEjmSiPsMmoJqDxWi53vjwjVNnH2VjX7X8DEB96SBQGkhq/gsHLMY iGUCZy6vumvh9f/g015QBPQnXDkMzYXM1TAlOGbQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Srikar Dronamraju , Kajol Jain , "Peter Zijlstra (Intel)" , Ingo Molnar , Barret Rhoden , Sasha Levin Subject: [PATCH 4.19 46/49] perf: Fix task_function_call() error handling Date: Mon, 12 Oct 2020 15:27:32 +0200 Message-Id: <20201012132631.529843742@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012132629.469542486@linuxfoundation.org> References: <20201012132629.469542486@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kajol Jain [ Upstream commit 6d6b8b9f4fceab7266ca03d194f60ec72bd4b654 ] The error handling introduced by commit: 2ed6edd33a21 ("perf: Add cond_resched() to task_function_call()") looses any return value from smp_call_function_single() that is not {0, -EINVAL}. This is a problem because it will return -EXNIO when the target CPU is offline. Worse, in that case it'll turn into an infinite loop. Fixes: 2ed6edd33a21 ("perf: Add cond_resched() to task_function_call()") Reported-by: Srikar Dronamraju Signed-off-by: Kajol Jain Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Reviewed-by: Barret Rhoden Tested-by: Srikar Dronamraju Link: https://lkml.kernel.org/r/20200827064732.20860-1-kjain@linux.ibm.com Signed-off-by: Sasha Levin --- kernel/events/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index a17e6302ded53..a35d742b0ba82 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -98,7 +98,7 @@ static void remote_function(void *data) * 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 + * returns @func return value or -ESRCH or -ENXIO when the process isn't running */ static int task_function_call(struct task_struct *p, remote_function_f func, void *info) @@ -114,7 +114,8 @@ task_function_call(struct task_struct *p, remote_function_f func, void *info) for (;;) { ret = smp_call_function_single(task_cpu(p), remote_function, &data, 1); - ret = !ret ? data.ret : -EAGAIN; + if (!ret) + ret = data.ret; if (ret != -EAGAIN) break; -- 2.25.1