Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp333075rdb; Mon, 29 Jan 2024 03:58:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IHn1moODaH8Eu4UWHzmw9vmYzY6xBdChmvbUX4B8OXa0ld3AXycHZloM4LbSocjnG7hxN6T X-Received: by 2002:a17:902:654e:b0:1d8:d583:1811 with SMTP id d14-20020a170902654e00b001d8d5831811mr1472253pln.38.1706529492852; Mon, 29 Jan 2024 03:58:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706529492; cv=pass; d=google.com; s=arc-20160816; b=AhZ05LD4+QJ/9ZaXmFCuR568w8su+MyK+o5EvvKtktwFRnJXK6B9WM4llcthY2wnGY 4n22kgZPu0dhcw9nmg7u/igvpbq18xFyWBnovfBy/oyFiQckG2za1uNTE+2Cq+zUIyQW CVfxD82aNBH1cnKbAVtEBhU2uP1aCtq0qT6Bfme5spzRkcDJ9xtipdDwFnJukyVsUmj2 z/FC+W6vzXyqcpBI7Z/GXpYPincjNnTD0RyKc6n+qCJYuVpTVCk/NXpAetndXYh7R2Jq Td+vZO9SzbFH8Vs7bEhKNXuh8OtlDf68+V1ZUMmojlCxpEaCZ4zg7pu5RXTzQrWSEeLi pAiw== 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=EiyJUqJjlxAaUjUeSMA2TvLUIS1owYlx58/mzyn6NjU=; fh=cS+D6/15hJDwIQ5zbz5Bx0CwkimikQX+QlxAa68UNgo=; b=I4eExn5ABmYyXWpT9ZrbP8BffzAjqDaXW6L7EJW8zntemEk1r3gVaUkzBQkzygRsSJ jYHhhy5hiQitRpRWFFyyCKHOo59fVABo84CUTMiX2IHRai2CIODUQjIVvsTSutL71bPH AjmolU1pLH6Gq5deO9TcchflgZ1ZuxLl6+Ik3FqSqxp4Dag4Ww1pRklBZrna8b6GzTrb uGaYZo3cgkjnUwrKLUVjvjj510eg5boZMc8zUSkjP9UIu6D6lqlVyBl5c70SYMBl0G1c Z9j0E9/EzbD7W7t8rxNwdkmnIADIhAIu8mI7IwUXhpBETQYqiw29lgDAe3nv4FUjwf43 lYTA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b="arNqT//g"; 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-42655-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42655-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 c11-20020a17090abf0b00b0028e8e78f018si7551632pjs.108.2024.01.29.03.58.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 03:58:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42655-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="arNqT//g"; 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-42655-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42655-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 701FF282ED7 for ; Mon, 29 Jan 2024 11:58:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DC53B60864; Mon, 29 Jan 2024 11:56:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="arNqT//g" 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 3E753605DC; Mon, 29 Jan 2024 11:56:42 +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=1706529404; cv=none; b=fVwahkxgGR2sFzgftJtFdpgJckXoPPyemU6c7Z5JRPzHeSFuH3t1AeW8udEA9o5nk73uW6UcvVMQLCJW8JEc4mdVhCEhFjFVzFAsHdKVlhDFd+A4RLpu9qcjZty3PPvFzvntsqoSFEhPZekE/b8TZPl7V4t98D3mDiIEPZtBjRs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706529404; c=relaxed/simple; bh=itAGpoK1GE+qY997zBIODkztrKLK1F0Hodm4YM3X5T0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=cvWPcG8UiDBgHMKjZUoP95X5oqhW7jlUEBLPvuKVFV3Y+0d09J/oiabwfJhE2iGEe6+Wdn+d9F+1+eXWFkTfoU8bueqGCKoMJIZZ3CwERXpusfih5AywbPxpQW4j0BLB4cGQT5xmYsFiX1aTbrKv/o1KxpjYl33A/Fu2WH31ZtU= 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=arNqT//g; 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 (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40T9hsTD018229; Mon, 29 Jan 2024 11:55:54 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=EiyJUqJjlxAaUjUeSMA2TvLUIS1owYlx58/mzyn6NjU=; b=arNqT//ghWxXIuUihHPtvfaNklTxZwqfzPzF9UwxhvXiZ7FwS+keRXH72XCbMkHCI69D XLVwam4xPoPEd5q4foa1Q48soG7hN4la/eVwvFMvQizvjHPpEaCVTF6nzfWn+aRdKqbQ Cc5JWWmeY8YBBRwLcr+NdxVPZspqaZGeev+S4FZDJKJajoSWweOWZOSwoUYD97u+2Sv6 pnajQkOr8W8L+cOd53Ku4MngAEyd1bSGjM7XPj9yNJTvmoajQVOfZgHlLCUg+rw/9/WE o84xCLuB9zmqrobMnksn37hK8rc/1Z+ZMnnw4F8e2/+L3tTLys5r0nKj+yA1INmAXydB Cw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vvr8ebmnx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Jan 2024 11:55:54 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 40TA9Dw1035385; Mon, 29 Jan 2024 11:55:53 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3vvr9bhcwd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Jan 2024 11:55:53 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40TBtni8038181; Mon, 29 Jan 2024 11:55:52 GMT Received: from mihai.localdomain (ban25x6uut25.us.oracle.com [10.153.73.25]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3vvr9bhcty-3; Mon, 29 Jan 2024 11:55:52 +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 v3 2/7] x86/kvm: Move haltpoll_want() to be arch defined Date: Mon, 29 Jan 2024 12:40:29 +0200 Message-Id: <1706524834-11275-3-git-send-email-mihai.carabas@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1706524834-11275-1-git-send-email-mihai.carabas@oracle.com> References: <1706524834-11275-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-01-29_06,2024-01-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 spamscore=0 phishscore=0 adultscore=0 mlxlogscore=990 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401290086 X-Proofpoint-ORIG-GUID: hbq0cf4vkgAmdyc6X0UvdpumIXbsXutW X-Proofpoint-GUID: hbq0cf4vkgAmdyc6X0UvdpumIXbsXutW 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 b8ab9ee5896c..2ba12da13fc1 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -1149,4 +1149,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