From patchwork Thu Feb 15 07:41:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihai Carabas X-Patchwork-Id: 201288 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp262709dyb; Thu, 15 Feb 2024 01:03:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVq+rgjoIh9VnPQPleWSSYcLX8vfOxQ4cEUJo3n3HWjWCcFE/b0dJ2Fakr1iC4S4vu9PM1K1d/mEPSnHfzl4tdLppY80Q== X-Google-Smtp-Source: AGHT+IEISD2FOtH3SAr9sSN6msrwkBWkkMRcNQeiQoPZ4rYSUMJAnJgOX9rlPg/pp0epZdt677qI X-Received: by 2002:a17:90b:394:b0:296:ea8c:cfc6 with SMTP id ga20-20020a17090b039400b00296ea8ccfc6mr1042692pjb.24.1707987817864; Thu, 15 Feb 2024 01:03:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707987817; cv=pass; d=google.com; s=arc-20160816; b=mByxM8r3bZY3ChLSyfz+BGIeSZ5ljRZgM0+8SsRYZKOs9fRF/bCC3APqBKGw0q/s8s qGoAjrz8CZRv28nVYZa1uv8yj5gtNZbfFgSGIaYZkr7BskujFMlpWCGrz7WxIn/xB/gg QnO1H59bG6x8acASoC5MksmrWqSPmCg5ojji0903zZJinLsX6hRIDU2HpSKwVl/wPxvH 5cHlf3mWa1Nt9Vpo7krYczxLJ+2b9F2TzUvGkvqrRBWB/OQhJZD9XHhWgko3pwXFzUZO 3wXHnKPyEoN2JMqE6MppT6YZs8alxIWv4guO0qINw1TB5zw99sIgiAvA2ie+OEm9mnfx If4A== 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66471-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id sh7-20020a17090b524700b0028cfa4f3873si915422pjb.45.2024.02.15.01.03.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 01:03:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66471-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66471-ouuuleilei=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 93E1E28E04E for ; Thu, 15 Feb 2024 09:01:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C5F151CABC; Thu, 15 Feb 2024 08:58:17 +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: X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790955034061413407 X-GMAIL-MSGID: 1790955034061413407 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