Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp328924rdb; Thu, 15 Feb 2024 01:03:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU3UhFB6Dkhjzhp+en9jT49It2M0H4CRcGt6LcKjkzeU99bMpgp15yZM9nQjoUEXh3qWpWqcIuifKIzEpxmqxsoZVgoMKiP3+fNLA288Q== X-Google-Smtp-Source: AGHT+IES3s4/7Vmbi9lPtEAG4aND04V/nk5msTlu/DZ1/CjmBQcVp00Y36EMz0JxGv3h4C0IfD5B X-Received: by 2002:a17:902:6e0f:b0:1d9:167b:8e6c with SMTP id u15-20020a1709026e0f00b001d9167b8e6cmr1034578plk.46.1707987796034; Thu, 15 Feb 2024 01:03:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707987796; cv=pass; d=google.com; s=arc-20160816; b=QkIvxO2g3trz8iZEVFWg5+wcoywNWYFn+66oI+TkbI2SrLt35AS0vW4ptqHpQYJ8F4 Hr2jNg74M9p6N3e4BHuPz74dP6Zl7V0tO83R6U1i4QYHRTouMK0Y6Hf7YjwM1vOh1kQj txyGSXRTkOjgTvVE8s+m+m9eAnTpLO4KldiEF4Y+ORgYDNJiFigkCG1yPT+6YXs/n6mx +Y3vtzQNtqx4mkCA/yjcZhYA4M9h7XLqQpGr0ZGrsCEVarOUoJqgoSdp+FAYVHvIdoHy T2c+gfjy/G0raq4/GJfcd+WAuAGi0D+qeisyHtxfK0aO7+VY/guEe8yw86jH04iwKFfr MINQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=TAwS+2D72yyBJ0cEfl5gl5b2nb9+6zOA/B/kxENfM7w=; fh=cS+D6/15hJDwIQ5zbz5Bx0CwkimikQX+QlxAa68UNgo=; b=l76y1hENQ5uXXFKWRK0xb3F8eAfxKf9RlthfHtzJH1mXIL8V3bdp7LpNZmIKAVc47m Na0Ldgkl9eLxsmggIYvMTRH3wVs6KYeUDNT7wjjSCsPzgC73/k4RvjZkQ/2bWyF+VgIW nIQFLXFfcianFCDTNBUYVtVrGTmd+yIeTCUvGYcgV8u2fUBzezlA2+W1bKKaIu72/JAb XBTwwwsuH2N8vjsj/zEkowJj/wkGms1S+NjBakeBXt81vZxbGr82LQirzxApIKnLXx1z EhuJZxto0czODm4+QDbHN1h9HmYYTwzS9nRt5ZdaC/nLo1L7vaAVkxNmgdAX6QtPhKXb wquA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=nTmX+yOF; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel+bounces-66471-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66471-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id a21-20020a170902b59500b001db71b1752bsi770389pls.424.2024.02.15.01.03.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 01:03:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66471-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=nTmX+yOF; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel+bounces-66471-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66471-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 43A3428AD15 for ; Thu, 15 Feb 2024 09:00:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94BFD1BC2D; Thu, 15 Feb 2024 08:58:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="nTmX+yOF" Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 DF3661B963; Thu, 15 Feb 2024 08:58:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.177.32 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707987494; cv=none; b=JjZYH3mVSkCWYLYGHI6AAqRL7a0iSRHgvkSS2hnmiOkZ4myOp8eS6gNB9FPAtvS1Y+CKq8B725lmEpY14kV3y2w+EnHkOvWw9otOXOAkjpl0aIXRsqinhufi1MU9G8yMWdkP7SSaopCDktijFHKekS6a3a8a2w53fsPGJp0xW90= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707987494; c=relaxed/simple; bh=1Fmk6TMn5KQ39g/kifUWbxTNBjmLAzVdlMpxRDqcWaY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=fKCywgGdQLp+a8BQRqEi/8BHksr6ITxJqrYAsxicmXjKp6Xr43ua8nP182R9N8SH9IrsQwyeaI91W+Zr385JQOnr89t/mTJwQxoMe4xTeRtbBqOQsA9mC3wZtmulokki1dx4yXbJFwKeWxRlOjOEY/QA5225i5mJwNQHHVTBGJA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=nTmX+yOF; arc=none smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41F6i03S027040; Thu, 15 Feb 2024 08:57:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=TAwS+2D72yyBJ0cEfl5gl5b2nb9+6zOA/B/kxENfM7w=; b=nTmX+yOF17M8oC2BpW+rfuX7BuScJEgPZ7aeHhxbSxfBpf0WtTeJ1vAHqABkUJ1aFUmk jAB1IUlg57+eAFU/qSiv1VEa1DI0uVwS4qB6z+k6s/4+1ARL/+HEgYL5VWWdQUF4U93d U3hALemyPfk1irHd6hv8XWxqBFbqFwz7VA3aMocDCySnif4507e0xxh5K3tk46lFydlG JzF2DjGGo7RXJc8mL2/SuqixVQ7CkEchue73ZghNaFk6PghgNduMDOeBQ5Ad6Gt94TPh xl5sfP/4rLH6LLE2kPzI4xtvj2vJcuSWjsampjQ1XGOHwAzNwk4oMhDWNHoSZzc8l9em OQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3w92j0hfjc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Feb 2024 08:57:22 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 41F8TYih015073; Thu, 15 Feb 2024 08:57:21 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3w5yka73h8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Feb 2024 08:57:21 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 41F8vDcr033748; Thu, 15 Feb 2024 08:57:20 GMT Received: from mihai.localdomain (ban25x6uut25.us.oracle.com [10.153.73.25]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3w5yka73cg-3; Thu, 15 Feb 2024 08:57:20 +0000 From: Mihai Carabas To: linux-arm-kernel@lists.infradead.org Cc: kvm@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, will@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, pbonzini@redhat.com, wanpengli@tencent.com, vkuznets@redhat.com, rafael@kernel.org, daniel.lezcano@linaro.org, akpm@linux-foundation.org, pmladek@suse.com, peterz@infradead.org, dianders@chromium.org, npiggin@gmail.com, rick.p.edgecombe@intel.com, joao.m.martins@oracle.com, juerg.haefliger@canonical.com, mic@digikod.net, mihai.carabas@oracle.com, arnd@arndb.de, ankur.a.arora@oracle.com Subject: [PATCH v4 2/8] x86/kvm: Move haltpoll_want() to be arch defined Date: Thu, 15 Feb 2024 09:41:44 +0200 Message-Id: <1707982910-27680-3-git-send-email-mihai.carabas@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707982910-27680-1-git-send-email-mihai.carabas@oracle.com> References: <1707982910-27680-1-git-send-email-mihai.carabas@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-15_08,2024-02-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 suspectscore=0 phishscore=0 adultscore=0 spamscore=0 mlxlogscore=995 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402150069 X-Proofpoint-GUID: pHUncGFQIZ7WEILBNb1GEfXndDxI0-cV X-Proofpoint-ORIG-GUID: pHUncGFQIZ7WEILBNb1GEfXndDxI0-cV Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: Joao Martins Right now, kvm_para_has_hint(KVM_HINTS_REALTIME) is x86 only, and so in the pursuit of making cpuidle-haltpoll arch independent, move the check for haltpoll enablement to be defined per architecture. Same thing for boot_option_idle_override. To that end, add a arch_haltpoll_want() and move the check there. Signed-off-by: Joao Martins Signed-off-by: Ankur Arora Signed-off-by: Mihai Carabas Acked-by: Rafael J. Wysocki --- arch/x86/include/asm/cpuidle_haltpoll.h | 1 + arch/x86/kernel/kvm.c | 10 ++++++++++ drivers/cpuidle/cpuidle-haltpoll.c | 8 ++------ include/linux/cpuidle_haltpoll.h | 5 +++++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/cpuidle_haltpoll.h b/arch/x86/include/asm/cpuidle_haltpoll.h index c8b39c6716ff..2c5a53ce266f 100644 --- a/arch/x86/include/asm/cpuidle_haltpoll.h +++ b/arch/x86/include/asm/cpuidle_haltpoll.h @@ -4,5 +4,6 @@ void arch_haltpoll_enable(unsigned int cpu); void arch_haltpoll_disable(unsigned int cpu); +bool arch_haltpoll_want(void); #endif diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 428ee74002e1..259212eb478d 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -1150,4 +1150,14 @@ void arch_haltpoll_disable(unsigned int cpu) smp_call_function_single(cpu, kvm_enable_host_haltpoll, NULL, 1); } EXPORT_SYMBOL_GPL(arch_haltpoll_disable); + +bool arch_haltpoll_want(void) +{ + /* Do not load haltpoll if idle= is passed */ + if (boot_option_idle_override != IDLE_NO_OVERRIDE) + return false; + + return kvm_para_has_hint(KVM_HINTS_REALTIME); +} +EXPORT_SYMBOL_GPL(arch_haltpoll_want); #endif diff --git a/drivers/cpuidle/cpuidle-haltpoll.c b/drivers/cpuidle/cpuidle-haltpoll.c index d8515d5c0853..d68550270802 100644 --- a/drivers/cpuidle/cpuidle-haltpoll.c +++ b/drivers/cpuidle/cpuidle-haltpoll.c @@ -95,7 +95,7 @@ static void haltpoll_uninit(void) static bool haltpoll_want(void) { - return kvm_para_has_hint(KVM_HINTS_REALTIME) || force; + return (kvm_para_available() && arch_haltpoll_want()) || force; } static int __init haltpoll_init(void) @@ -103,11 +103,7 @@ static int __init haltpoll_init(void) int ret; struct cpuidle_driver *drv = &haltpoll_driver; - /* Do not load haltpoll if idle= is passed */ - if (boot_option_idle_override != IDLE_NO_OVERRIDE) - return -ENODEV; - - if (!kvm_para_available() || !haltpoll_want()) + if (!haltpoll_want()) return -ENODEV; cpuidle_poll_state_init(drv); diff --git a/include/linux/cpuidle_haltpoll.h b/include/linux/cpuidle_haltpoll.h index d50c1e0411a2..bae68a6603e3 100644 --- a/include/linux/cpuidle_haltpoll.h +++ b/include/linux/cpuidle_haltpoll.h @@ -12,5 +12,10 @@ static inline void arch_haltpoll_enable(unsigned int cpu) static inline void arch_haltpoll_disable(unsigned int cpu) { } + +static inline bool arch_haltpoll_want(void) +{ + return false; +} #endif #endif -- 1.8.3.1