From patchwork Mon Nov 20 14:01:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihai Carabas X-Patchwork-Id: 745548 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E223C197A0 for ; Mon, 20 Nov 2023 15:16:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233789AbjKTPQc (ORCPT ); Mon, 20 Nov 2023 10:16:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234089AbjKTPQ3 (ORCPT ); Mon, 20 Nov 2023 10:16:29 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4367FD8; Mon, 20 Nov 2023 07:16:26 -0800 (PST) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AKF2YME031903; Mon, 20 Nov 2023 15:15:20 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-03-30; bh=WF/RvvGLD0DY5qsZ8VlYaxR5Y2ufu/6MrfyvnyHeYNg=; b=WOkdKrg8THkEHHRK1Vr49VLu1XU37NvEKZmK/t4XRdB4NU+eH9djHU6qDtQmzYpZ7385 V9mTyo4fZ+qn0a7c7Tkpgw9x6eRqIoNDss0EcJaU/Y+WX4BVrOFupfTUzszRgvk8uNHJ UcIzh5OF0lML2sgz0kSF5jdYvbc06tWs0wQBSF4II/XQkLEX/u6X0CDncTlkA7LZaGvc NQhEhoGfPvaIvZD15g6s9EyErYgY7r2JwaaFZUcaIt2PZ5TT5Ckb3g2C+SRkYmL/WvTH Z9Gb+8uDFRar4GfshLqbphsQ9x09qZh+x/CS+SNJrKq0cE5NTwqz36yukoEWRGfUWgaF gA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3uenadjw5s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Nov 2023 15:15:19 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3AKDq0up023517; Mon, 20 Nov 2023 15:15:19 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3uekq5gr0h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Nov 2023 15:15:19 +0000 Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AKFFF8T037000; Mon, 20 Nov 2023 15:15:18 GMT Received: from mihai.localdomain (ban25x6uut25.us.oracle.com [10.153.73.25]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3uekq5gqwc-3; Mon, 20 Nov 2023 15:15:18 +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 2/7] x86/kvm: Move haltpoll_want() to be arch defined Date: Mon, 20 Nov 2023 16:01:33 +0200 Message-Id: <1700488898-12431-3-git-send-email-mihai.carabas@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1700488898-12431-1-git-send-email-mihai.carabas@oracle.com> References: <1700488898-12431-1-git-send-email-mihai.carabas@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-20_15,2023-11-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311200106 X-Proofpoint-GUID: rt-YbBsIs9NWtChDWPYah5SFcMWtTrIW X-Proofpoint-ORIG-GUID: rt-YbBsIs9NWtChDWPYah5SFcMWtTrIW Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 --- 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 1cceac5984da..75a24f107b2a 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -1151,4 +1151,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 e66df22f9695..72f9c84990c5 100644 --- a/drivers/cpuidle/cpuidle-haltpoll.c +++ b/drivers/cpuidle/cpuidle-haltpoll.c @@ -96,7 +96,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) @@ -104,11 +104,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