Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1160269lqa; Sun, 28 Apr 2024 22:55:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX/ljLy0YF6NE94h9YjRNPdaQQrJtwA/V3aIykpqpidcuKFgBqpPbCs82/OO4jWTtSQ+8iWThvlky/Jq68v7QcFHT/1khH/k2T6vaInlw== X-Google-Smtp-Source: AGHT+IErsUluCS8edHsljA7rT2qtvwfxm+kTO2OBU3EAH2LswyngW/pCUxDRO2kcsvtaxYoYOh3w X-Received: by 2002:ac8:5791:0:b0:439:83a4:a908 with SMTP id v17-20020ac85791000000b0043983a4a908mr11818159qta.61.1714370144729; Sun, 28 Apr 2024 22:55:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714370144; cv=pass; d=google.com; s=arc-20160816; b=a02cEZYTfmCsmJKnV5p9HAAYrfVf0LZoouawvum5mz8wNWmSsJqCFJVYXjHjSDz3aX 3j4Ls/Gi0S7mVd8T66exv4xHu6sMHomYTNtE5AY5D+hNOIUyYLkH17OMV8ymRWP4nzl6 bdDpXqdXkRsxXUJwtZUPWmYIxfSXA1A2eFurEkPiGIKQGjxXQeb2O5fe0fLUjlml+GyL 6/qo0vv0zm8mOoRybJDL/4prxBRTcoHalRMiQe0/vXf+9aZKorvD8jtt9bANTL3X3cgB A2MrhVIikUNTOOfOyXVQ60/VNpGCHSLx3UWKrp1cVQAyyl9fN3t4/06kYLAlwwNDDLUS bDPw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=cNxs2TQAt/Gjy+68TESEKnKwZfqi+c0s1TOQ+rGD0Gc=; fh=1027+2x/wvpq1orAYM10UVwXNVPtXY9Rqlr6TT6o4MQ=; b=EMVKGkOCBpBvDlLxqF1bHdv2gJ1E8J35hV2/OVGvLdwrzg9Ymoy795G9TFq6rf3zXk JgMXiRi0Ikaxfe6HYfUbBQ1rWvletuGqUa5wGQBxsxvgIleQxaz8XOsRjACl4pMMKK+K ZqUNuWnICucAQJG7GdX6dq4eBrKmSNRWqNT7jc7OlsDaaYghu1hX5DaUlQAwEXX3hZrF 6PnumwH7ZcuMMOwqI501rfBRjYXzNxv4/GgBGWgFH8XTtzfBLBEGNJoQo4At5UcXRepb v4UQqdjpws2q5ShW97bb9kSj/raCCcV8vDo50SgoQ6WXejasO7q2qKV4QWtgslqGVenZ tZmw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Adpq5CPz; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-161761-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161761-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v11-20020a05622a188b00b0043ad386a177si2591003qtc.95.2024.04.28.22.55.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 22:55:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-161761-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Adpq5CPz; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-161761-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161761-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7629F1C214BF for ; Mon, 29 Apr 2024 05:55:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 80330F9DF; Mon, 29 Apr 2024 05:55:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Adpq5CPz" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8FD61119F; Mon, 29 Apr 2024 05:55:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714370116; cv=none; b=dUeIsbg9bQ1NiqsIZOU+3Z0OQ1gDNGlBnaeAv9BlCkTrKU0tijTWiWQB0BR7Qk3BRgvsXX15s9j3n3/4L7mh9jTePo2+1Ek2Lf3L88J/IziUxlSANcUca8pOxxa6cDOHwjtDvL/DalKv3e2r1WXgXQC4KborQKKCzHIVhjAcF7s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714370116; c=relaxed/simple; bh=RpSffKBYdZJHtJT6BEJldCAqUGT6J1+z9IACpC9e4bw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=OEz5UmKDmzljTDXlMG5guRZf1dBFGMPZeT0wQZspLHtMMAIY2cgJhBq7mtUyTF/RU3sUtIHvRLaodEg2QWhZBPx7QFK+zOe/wPZTlrTWsPeyxYuUnglBdu6bkKquNdACG1kRX+K8fDzf3ruaot7KD6i2cGlTbnyukUXkkp9NEtw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=Adpq5CPz; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43T4oJnU021349; Mon, 29 Apr 2024 05:54:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=cNxs2TQAt/Gjy+68TESEKnKwZfqi+c0s1TOQ+rGD0Gc=; b=Adpq5CPzUBrV/q5gLBQPQQyEirSZeqT+8f+l91DONSXqux+zPmw+gPVtMakAEErAbSXD kqXdcpCKCVNvN5cLfAVjpXKTSrAbqliXrlkJN2fRD+T3cBNSJW0+SWQWao1jWxahk/dr agdgHaUmrZ2TUxB46Zj419pTwEMEgc2zJSBnt1RjfBjyOREcvMqM2HmyFno+Md3p2FN6 axNFtzHDCJQyioRjHoogAWbesBTJxn7XtBjJSFPGiiGwkyUXizhnehpngM8+nOHhDx5s Ob3egMdqnRbL5LU4KSRMUD1aYR8eFcp5U79UJ3H/fzNij8nbeVzzpzo0z+L95J90EiFm gA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xt1yn8ahu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 29 Apr 2024 05:54:31 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 43T5sVDL018481; Mon, 29 Apr 2024 05:54:31 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xt1yn8ahp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 29 Apr 2024 05:54:31 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 43T1qmHC015545; Mon, 29 Apr 2024 05:54:30 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3xsed2n5we-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 29 Apr 2024 05:54:30 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43T5sQhC43385190 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 05:54:28 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 575FD2004E; Mon, 29 Apr 2024 05:54:26 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 444CD2004D; Mon, 29 Apr 2024 05:54:26 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTPS; Mon, 29 Apr 2024 05:54:26 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 55390) id D00CEE082E; Mon, 29 Apr 2024 07:54:25 +0200 (CEST) From: Sven Schnelle To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider Cc: Heiko Carstens , linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] sched/core: Test online status in available_idle_cpu() Date: Mon, 29 Apr 2024 07:54:15 +0200 Message-Id: <20240429055415.3278672-1-svens@linux.ibm.com> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: It9T9tFBeBRTt7wpgRGL86vUJr4uVOoq X-Proofpoint-ORIG-GUID: -qZoA8vCQ80tkAysgnCFlRyAJAlThVxg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_03,2024-04-26_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 lowpriorityscore=0 phishscore=0 malwarescore=0 bulkscore=0 impostorscore=0 mlxscore=0 priorityscore=1501 mlxlogscore=999 spamscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290038 The current implementation of available_idle_cpu() doesn't test whether a possible cpu is offline. On s390 this dereferences a NULL pointer in arch_vcpu_is_preempted() because lowcore is not allocated for offline cpus. On x86, tracing also shows calls to available_idle_cpu() after a cpu is disabled, but it looks like this isn't causing any (obvious) issue. Nevertheless, add a check and return early if the cpu isn't online. Signed-off-by: Sven Schnelle --- kernel/sched/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 7019a40457a6..1d9b80411594 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7434,6 +7434,9 @@ int idle_cpu(int cpu) */ int available_idle_cpu(int cpu) { + if (!cpu_online(cpu)) + return 0; + if (!idle_cpu(cpu)) return 0; -- 2.40.1