From patchwork Mon Jan 29 10:40:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihai Carabas X-Patchwork-Id: 193418 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp512292dyb; Mon, 29 Jan 2024 03:57:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IG3XrzCfzOgWXgmNVIeSSnc7PMjPCA1MdqtrceLLPgs30wb6fX8DJH3tyJkqi7bxT/PYida X-Received: by 2002:a05:6a00:22d4:b0:6db:ad3c:693f with SMTP id f20-20020a056a0022d400b006dbad3c693fmr7167645pfj.11.1706529471714; Mon, 29 Jan 2024 03:57:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706529471; cv=pass; d=google.com; s=arc-20160816; b=v/ew5gDJJZF0BGx7dQSTfVCk00jDbaVylpX6vn63b8kxYFSOJ2nOonRgXfs9Pt3H4w IqLYzkKiVGDLvmxV4YOWKhotK18jodyTJmqfKGHk83t3c9M4csBV3DpYGPxsfwR0A8m1 w67IQSTdEwm/XOfH9gjzHDsEWzX/0M2kMmngdyo2OVjXjAggEGEWZfwQMT4M1i9LRoUV n9yUY/LfIbP9kXxzOwKctOJLhqo1iz4WHPVqORmeRYJ9WjItuCGdc1MDU+qtaU2nPjfI 8otK/hzLrCt6VVOkIOgwzVBFVb0r6X9CsD32IEMYiLH5dWqN6/P9EKn368UzoKiP99td wzeQ== 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=uAhbu4AUajdcQROPp7AvbiHI/LFlFhMVo6VGoxnZCWM=; fh=cS+D6/15hJDwIQ5zbz5Bx0CwkimikQX+QlxAa68UNgo=; b=nDsXdGM+gXT6AaGgY0heule5PKaQAlkCoHXE8sH4Arg/oFuHWq1Upo/Tcvz55nrYeC 1+ndXnaqgCIsn9IwEDWaU8q+aFC33KC7XBKolHAvsqIPmkhEScumBAG2YMuIRYxM3Hj5 SO+de9F8t3v9DfXIkUQG7QaQ7sjSPgO62pvpRw87XcJAn83v6Q+mnzLZvd0bs5wrIXB7 47Qcuuoljr7PewmqJyweIdutvJfhFxrjsAucLDcAPJ9u9hNrjOy/Pgns5GlYRpuLJymp jF0az2HBfiQREIdH+MGX9R0Mgr65euxQzB5lid5eZUkC89Q0KJpA2txY0GEIe2hG2+N2 v3PQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=d2vB39I4; 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-42651-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42651-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 17-20020a056a00073100b006dbaf6c303bsi5490401pfm.6.2024.01.29.03.57.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 03:57:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42651-ouuuleilei=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=d2vB39I4; 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-42651-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42651-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 E9C02284C69 for ; Mon, 29 Jan 2024 11:57:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 31A6F605D8; Mon, 29 Jan 2024 11:56:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="d2vB39I4" Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.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 B9E2A60869; Mon, 29 Jan 2024 11:56:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.165.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706529400; cv=none; b=qxwp8rhUmNffY9EEfn+smy7zneFljF23RKbrWyUZalY/F1csYZ080ImMX6BzPzypCVgslktyXgk2EEdAX7fLtZiUnqA3n0oQy2Ta+beKwPCT1wxajs7CsDjDjEXNCtz8Kd2cJaFLxoCmEy3JTyDo1qg752P0KFWCg7ZnePHL6KY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706529400; c=relaxed/simple; bh=WsC1jzqJt8v0tVnaYxv4ggMXksNSjkzD9+2lyOkYaLE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=dLqOC2g1NkprWtOArZKKZf17nyuIkFOQoDrffG50PWC5cweaVP9I/my5Q+wwolwvyYgj1CzmopgGXIEnvy7njfewclGIcWsoAL+tDtZ5mQ7U87FyP7xHJrU6pFEVVJ9k9dB2DAWfbTNrmYf5b1RYrsPW/i76/ZAPSEXaFq/1Wtg= 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=d2vB39I4; arc=none smtp.client-ip=205.220.165.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 (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40T9i5rb003224; Mon, 29 Jan 2024 11:56:01 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=uAhbu4AUajdcQROPp7AvbiHI/LFlFhMVo6VGoxnZCWM=; b=d2vB39I4Og0wxCVnADXW1/7MnjlGyD2CUhMp3SC3IT8uGtcqSgDb6v/sZdoKLENxoEfe 4n6c2zqynNAZtBYQ7ZzFWa7f4OKN1yIAmJXXuoZMx1DD3IKKTDV2NW3nJ93hJJM1sgFZ ImdnnCApsS+0VQidCglEggQp9Tp5Q1lryPNnIMWvUI1wUM/vqqyrWHoGVu1lEboRaYgf Myd65CzEyBjg/UNp6qSPMZHnSEOejfkdLzRUMzStmig3OhXqSCBJenSD5NaUf0uL9Lty bkc0S3AFI1qFrtQCK6C+yOWl1HkGDgfV9hruFaNq8gAocyQusznCblARVfdaZzH0Uj2D Xg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vvre2bpy9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Jan 2024 11:56:00 +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 40TB1FB6035346; Mon, 29 Jan 2024 11:55:59 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3vvr9bhd06-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Jan 2024 11:55:59 +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 40TBtniI038181; Mon, 29 Jan 2024 11:55:58 GMT Received: from mihai.localdomain (ban25x6uut25.us.oracle.com [10.153.73.25]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3vvr9bhcty-8; Mon, 29 Jan 2024 11:55:58 +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 7/7] cpuidle/poll_state: replace cpu_relax with smp_cond_load_relaxed Date: Mon, 29 Jan 2024 12:40:34 +0200 Message-Id: <1706524834-11275-8-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=999 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401290086 X-Proofpoint-GUID: dQYM6tQD_1vhmUDfI0qPFICGEXTzpN_a X-Proofpoint-ORIG-GUID: dQYM6tQD_1vhmUDfI0qPFICGEXTzpN_a 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: 1789425847292960198 X-GMAIL-MSGID: 1789425847292960198 cpu_relax on ARM64 does a simple "yield". Thus we replace it with smp_cond_load_relaxed which basically does a "wfe". Suggested-by: Peter Zijlstra Signed-off-by: Mihai Carabas --- drivers/cpuidle/poll_state.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/cpuidle/poll_state.c b/drivers/cpuidle/poll_state.c index 9b6d90a72601..440cd713e39a 100644 --- a/drivers/cpuidle/poll_state.c +++ b/drivers/cpuidle/poll_state.c @@ -26,12 +26,16 @@ static int __cpuidle poll_idle(struct cpuidle_device *dev, limit = cpuidle_poll_time(drv, dev); - while (!need_resched()) { - cpu_relax(); - if (loop_count++ < POLL_IDLE_RELAX_COUNT) - continue; - + for (;;) { loop_count = 0; + + smp_cond_load_relaxed(¤t_thread_info()->flags, + (VAL & _TIF_NEED_RESCHED) || + (loop_count++ >= POLL_IDLE_RELAX_COUNT)); + + if (loop_count < POLL_IDLE_RELAX_COUNT) + break; + if (local_clock_noinstr() - time_start > limit) { dev->poll_time_limit = true; break;