Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2291491rdb; Mon, 20 Nov 2023 07:16:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IED8muyrf+0l3t6lMItlYmEyUtzDBdm+iULDyucfN9AQpQJwo/L13ptrdj2o/cwC6+yCkGk X-Received: by 2002:a05:6a20:4a23:b0:187:dadd:7e9d with SMTP id fr35-20020a056a204a2300b00187dadd7e9dmr5150597pzb.10.1700493419177; Mon, 20 Nov 2023 07:16:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700493419; cv=none; d=google.com; s=arc-20160816; b=mIEeAZO4s3DUk1WtjOMx0jC1q+Tp3/7qBxMbOUkSfcoSsGhQugKNN7KMrg5NyGhYpy SYUCFTLBNtW34uEpVCjdPZBC4c55xE8l6XwYAdHc51GVIazsj+AcxU0hm1Mpy0aafPXl 6AvNwuli2B69vvNhitbI0U27iuNE+PTMk0lNaw1UQStBx4+hp7Atzypt/+h7iyoKJcXZ kTrYfp+Loexlnv6UKS5Affh6TD8PteRKby0YlbYTQJWBcZQD/vcsv5VgUh/o4NGGD4XQ Uvckr0Fxej9yULVZxg1nTZMi50RvSpqwazJXKh2ZBKfUAV6Z6/ibw2dSyQR/Evl905he GDbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=WF/RvvGLD0DY5qsZ8VlYaxR5Y2ufu/6MrfyvnyHeYNg=; fh=cS+D6/15hJDwIQ5zbz5Bx0CwkimikQX+QlxAa68UNgo=; b=zIEG1kIquxnlSIvj0nKfjfo4GJaBL9iCDcVHTxaKf1ltja1ps2w25zqKJxfvTumro2 xTbDuyS9mMz7XWalcXlLgDoRQuw6CiHePj+4BimKUq2UPGxu6U5Q03MwlHNuT36Rkpys WHM1QpozX2/2SgO9eNyPvSTQBf35OsRLL9r1Aa9Crc+08HJKQKm4eB+K0EliLhoNyUqW BKL/T85y1dPvlo/9ZV1LucC7oc1n5N/HBZZ0FahqAnfqDgwRLwz73ZTtbZmWRI0SqoPN TBrEwD6U6FqQ8mQT1tvzh7jwx96XQLvJvn7lCxTRwiy5HVaMBWki2jH6/yROkLi9Ru8Q UVpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=WOkdKrg8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id e14-20020a63ee0e000000b005bd0432d9b0si5507469pgi.100.2023.11.20.07.16.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 07:16:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=WOkdKrg8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 4761B8047545; Mon, 20 Nov 2023 07:16:54 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234265AbjKTPQd (ORCPT + 99 others); Mon, 20 Nov 2023 10:16:33 -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 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 20 Nov 2023 07:16:54 -0800 (PST) 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 -- 1.8.3.1