From patchwork Wed Aug 9 11:39:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihai Carabas X-Patchwork-Id: 133253 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2802286vqr; Wed, 9 Aug 2023 06:31:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHD83/Dp6+zkbmDfiK3lk0y71cuaAIifDIqOzA7Xf6+MMt7G/NgAKyJ5KkhBc/TaUhHfid1 X-Received: by 2002:a2e:9103:0:b0:2b6:cf0f:1fbf with SMTP id m3-20020a2e9103000000b002b6cf0f1fbfmr1884203ljg.42.1691587861720; Wed, 09 Aug 2023 06:31:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691587861; cv=none; d=google.com; s=arc-20160816; b=EiFlDmZ5Ec+WTsB5Sgt3b1yDbc8/r/ldvVV4yOOEIRMeJLvKtQd7vRjK7AnQZ1wAAM cQonCsrLso6VeqquuUkIZQRPsnKIT5yqJzYgTgcKaAToHnJUyF3zGOR/KciiVdBTEXFP nCBhnql473oF/lVQ09r7OLu+aspNgTwqlrHbM/8U/vBuu3LYSvMMN+qH29NlbGJz1w6M FFnmW5Ilu93sgwRgDZ+piWnTS9dN2gFD7dHFFHSUOk6Lh+T5p2xcxThmVn7yVHyu74pe OES1/Rqzpj70pJUSGYcbIHCVssJ4fmDLKSXdVs0jVWbtC2khm62XjZX+HgsPDaI26qEu 8ArQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:in-reply-to:message-id:date :subject:cc:from:dkim-signature; bh=4x+zE4hQtUzx7DvsxU62TsC9MtAa7FotAn6Rbv4QSws=; fh=0jFi7Lu4NMUyo4e/+x3IX0TBqq/3sSWuUfDA7G5slOU=; b=wfRO3UEx6AE8/665UpHn5SxjXIpXhE7ixI3NawDZcIVxnULwBRc1XXjYVDdb80lptk fpRFuNir0T9TtpqkWeC8ju1HvVYuA3bt6PqjKaPdx8LxOGUx6hdVPjSI+ntcHZjhkw2Y idSdDOQD7qa4rMIiWru7T7TbQXiP/mRde9bS2yek9gdKOfpHbxLUhMr69yp/SXOJnfSZ 5YZsrY1r2lIxSzgTZGQLtvA2kkl+Az52sy+gCa3J7X/g2hilKTLcRJWzFBhs0bMpqvGc SeuMwmca7gjvft5GRJO6SkqG/xaoHRKq7UaIlwnlskXtdy5TbFo6CrF+AWnLj+gRFqW/ Z6XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@oracle.com header.s=corp-2023-03-30 header.b=s8vkesQl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g2-20020a17090670c200b0099325564b77si8720113ejk.548.2023.08.09.06.30.37; Wed, 09 Aug 2023 06:31:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@oracle.com header.s=corp-2023-03-30 header.b=s8vkesQl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232716AbjHIMyG (ORCPT + 99 others); Wed, 9 Aug 2023 08:54:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231287AbjHIMyC (ORCPT ); Wed, 9 Aug 2023 08:54:02 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D642F2122; Wed, 9 Aug 2023 05:53:58 -0700 (PDT) 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 379CqBJ3005733; Wed, 9 Aug 2023 12:52:59 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=4x+zE4hQtUzx7DvsxU62TsC9MtAa7FotAn6Rbv4QSws=; b=s8vkesQltMGztBt8U/Sn8oCyOJoaMWgkXjG0sdvIljOLPU+A90hZgOGa0RGeQ0gsWG/u henwl5geffvsUq3Gz1gOpYYXuS+l+qPn/q/T8CwJ93S5ALoTV1boT8Mcc/Yvi5hvdk5/ ERNgVPpCfFOpQJeXI9q1v7xo/9MHaZxFStAatnpa2344tObkh9CsezfwhB8DpuJcRnvs J7X23Z4OUeEJ3Mvaf63dqgc+yLYw3CAX10nKY9YsBD5pCudZmyZLvIJ2xaKjc0ccGu/N 7NKY+ZK8zzMU5fI79j5uYZ/RJiKjVDhXEtRdENi32/xqMFNYZDDgb7LI4DJLs8wSY4QV Og== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s9cuerfvm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Aug 2023 12:52:59 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 379BXdcP021556; Wed, 9 Aug 2023 12:52:58 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s9cvdyfvn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Aug 2023 12:52:58 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 379CqCGJ027258; Wed, 9 Aug 2023 12:52:57 GMT Received: from mihai.localdomain (ban25x6uut25.us.oracle.com [10.153.73.25]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3s9cvdyf90-4; Wed, 09 Aug 2023 12:52:57 +0000 From: Mihai Carabas Cc: Joao Martins , Ankur Arora , Mihai Carabas , Catalin Marinas , Will Deacon , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Paolo Bonzini , Wanpeng Li , Vitaly Kuznetsov , "Rafael J. Wysocki" , Daniel Lezcano , Andrew Morton , Kees Cook , Peter Zijlstra , Petr Mladek , Ard Biesheuvel , Sami Tolvanen , Nicholas Piggin , Juerg Haefliger , =?utf-8?q?Micka=C3=ABl_Sal?= =?utf-8?q?a=C3=BCn?= , Arnd Bergmann , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH 3/7] x86/kvm: Move haltpoll_want() to be arch defined Date: Wed, 9 Aug 2023 14:39:37 +0300 Message-Id: <1691581193-8416-4-git-send-email-mihai.carabas@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1691581193-8416-1-git-send-email-mihai.carabas@oracle.com> References: <1691581193-8416-1-git-send-email-mihai.carabas@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-09_10,2023-08-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=950 bulkscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308090113 X-Proofpoint-ORIG-GUID: Iz4AGH0IRJb3G1PZ_b520EPEYVR2M_ZH X-Proofpoint-GUID: Iz4AGH0IRJb3G1PZ_b520EPEYVR2M_ZH X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773758433809045046 X-GMAIL-MSGID: 1773758433809045046 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. 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 | 6 ++++++ drivers/cpuidle/cpuidle-haltpoll.c | 4 ++-- include/linux/cpuidle_haltpoll.h | 5 +++++ 4 files changed, 14 insertions(+), 2 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..817594cbda11 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -1151,4 +1151,10 @@ 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) +{ + 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 0ca3c8422eb6..e2d4d78744ae 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) @@ -110,7 +110,7 @@ static int __init haltpoll_init(void) return -ENODEV; #endif - 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