Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4364643pxu; Mon, 12 Oct 2020 17:41:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0OTqFuusKHrZbEfrF5DKlFe5JnR8tgMKr/ncRqfabSX4cpbsNkwTLBqoLVjn8WNTKi8cs X-Received: by 2002:aa7:dc50:: with SMTP id g16mr17002051edu.95.1602549713158; Mon, 12 Oct 2020 17:41:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602549713; cv=none; d=google.com; s=arc-20160816; b=UlKkrA4Y55fHJduw1IyIWJV1/qtXnwgwFsRyzUCoWDeOczCtnjsZDCaJ2ZSpGpSsov TAlN4+Q/kO/S8AaxKJF1h8YuzAb06i815QUDe9get5cjVPjiJmm0WrN91IiOVKLCnJ5U eTVspDeGnwWgh9nA96PoGwlLWNo4G01Um3xYgIla66IZ13xfTvvZsq/yx92GdKZFW63l cveS6VgW+XzT+cVkIngSOzLQqf94RbLNqkX/DKadNWwoahI6H7orTIXMzAWj4zAL1Ufa gJzTr1YdNrTHQntyF3r3I16Da4mTcs9KzsGB9IViTmSyHm2JHG2jTWuj64kWUsEsxkK1 hvnQ== 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=T3PeYUc1in5pppQwdT/kicNunxNl5vyRXdphpRFg1W0=; b=IEPJWU2ILvNNVJ22kZzA9GrePicMppiV+KKTCYXNbpX3ICBSaSStSYGKT0gnFogaqS xnhl93cPAef/Fqh5dXtN/YvJhuFMZ2hTpEiWzrgBTsj56Qz107pK8ShO5nfF3RPP2D9N HnG/GCKNr32hwcySDd7/NQ3grPxzVoWLCCFG5wtGl4GbDF3o+BLsPHO+14aPWLLf971e SQppCUJaIillhc2qzrvpDWo1nE+QlBKP9DpT+Sur9Lgq1RSd/J3Gi7BdEpSeTt8nGRyz NAVIiWWX+/VYmwjrkoA5T+K9cYVKCM+sEf8TbOsMmMf7dTzSdTJQC/a9M6wO4GQZN9M+ RN1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="OHg9D/E2"; 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 w22si12009233edi.294.2020.10.12.17.41.31; Mon, 12 Oct 2020 17:41:53 -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="OHg9D/E2"; 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 S1731223AbgJLOFE (ORCPT + 99 others); Mon, 12 Oct 2020 10:05:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:37228 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730262AbgJLNfh (ORCPT ); Mon, 12 Oct 2020 09:35:37 -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 14731208B8; Mon, 12 Oct 2020 13:35:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602509728; bh=cRZwsTwV1n6Wp1uz0djYGfR4/C8Jq4a8bdMtfvv7hLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OHg9D/E2KWti101XC9NyT3b+JHOnWIBoa6nYbZjty3XPTEpOfe1FepBDcmun15QQR WWFGIVWSyvC/Woqbz8hw3BWZP28WhaU936cfhTvvNPsgPIrrSoEA+gG+lJrfj3WTTj 69rWFRz6ANvwUxbzl5kHJA89FJ9V1YGDr7wA7YTo= 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.9 52/54] perf: Fix task_function_call() error handling Date: Mon, 12 Oct 2020 15:27:14 +0200 Message-Id: <20201012132631.977230363@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012132629.585664421@linuxfoundation.org> References: <20201012132629.585664421@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 b562467d2d498..7aad4d22b4223 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -94,7 +94,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) @@ -110,7 +110,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