From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D20E7CD1296 for ; Fri, 5 Apr 2024 21:53:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-ID:In-Reply-To: References:Message-ID:Date:Subject:CC:To:From:Reply-To:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ERbw8lKXk0D77pWNOqjcttpRQJT2sKL1gVq/8ZfNs+0=; b=gvfZxayLmfMwH9 57dAw/W5/K0g5ThIPrMIf8mc16cYfSb/TXuKRzNpQ0EylH5lIDHgljREBRcFrUdeE6/WRnuS8XNko 8d0Gt7GpmGZwLsM8GSPOd8w9KBGk5fNXTiDBbL4ew7edCnEFQfa3E0Huvk2UOkOoy1Y87AYylQ+/k fXWAI0tpmmXWHoyl4+IXavFoXQlUAfzUZcaOIapH3MOs5Fcn3EI/+h3eFjMhFq2kCjkV6bzAQV3XY RfZd0bzx4Q7tVa7QAZ6fow7YtOQeJEg87Xp5/5LNvAY+EBTnGzFE9/1/7hMJeZQrJ6+ijRS8fQQoV p1GC5y3fAhdMae774bNg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rsrUf-00000008ytO-3pTA; Fri, 05 Apr 2024 21:53:05 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rsrTX-00000008yMW-3L28 for linux-arm-kernel@bombadil.infradead.org; Fri, 05 Apr 2024 21:51:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=MIME-Version:Content-Transfer-Encoding :Content-ID:Content-Type:In-Reply-To:References:Message-ID:Date:Subject:CC:To :From:Sender:Reply-To:Content-Description; bh=vNtahWUHoY/YLu4GXx/gtf+bHqqMSaubbSHgvz3384I=; b=QTt13ixJzCVjg37PlXlh8btyoz XvfJX9GS32Qt32ZLvbKKziROZB92EGMyekorJ330MyKzqJjySGDQLApZLOP0hYGeZNHFsvpnWD6Ly ul4zxFxyIsrKTx5eoGEytD/jdEsMzahg83t4uOYF30izmKBqGFamgCusvhJNE8+5xZgeFyE8PzB+p aQniwLE/I1Erv0zune+NgUH4VgxXU6s4LsUH3J3zLMnqXoakZX4P3su6d4xLx5dZtC/dAN9boxewq dhiupC4Og8J9uCvMaEt9ozKSl30b9bsrXalgY4fNMQxs/f8C+lkhotDrDbS272VJ1ZhCtBr8KvpfI DxnvzuBQ==; Received: from smtp-fw-80009.amazon.com ([99.78.197.220]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rsrTR-00000005sIx-2jyq for linux-arm-kernel@lists.infradead.org; Fri, 05 Apr 2024 21:51:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1712353909; x=1743889909; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=vNtahWUHoY/YLu4GXx/gtf+bHqqMSaubbSHgvz3384I=; b=Ufdpni4YZ37CcAQKMDpIGkYtmQgdeywBoHNVZXiVqf8zZfASPERcZWwW PewW53lpZUdDEhJgvUPp0TQxiQ/+KOiGevJw4/pqv8S2aX+wxu+U8aFOb Ns9qgJ9eRXpL2W/pj/8hGjH/kHavk9GOOYeXly1XCMXPvo7QIWzIf792h g=; X-IronPort-AV: E=Sophos;i="6.07,182,1708387200"; d="scan'208";a="79148505" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev) ([10.25.36.210]) by smtp-border-fw-80009.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2024 21:51:44 +0000 Received: from EX19MTAUWB002.ant.amazon.com [10.0.38.20:38255] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.50.222:2525] with esmtp (Farcaster) id 7e2f3bf9-2208-42a0-b475-dbe52d0ca4da; Fri, 5 Apr 2024 21:51:44 +0000 (UTC) X-Farcaster-Flow-ID: 7e2f3bf9-2208-42a0-b475-dbe52d0ca4da Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWB002.ant.amazon.com (10.250.64.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Fri, 5 Apr 2024 21:51:44 +0000 Received: from EX19D001UWA003.ant.amazon.com (10.13.138.211) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.28; Fri, 5 Apr 2024 21:51:43 +0000 Received: from EX19D001UWA003.ant.amazon.com ([fe80::256a:26de:3ee6:48a2]) by EX19D001UWA003.ant.amazon.com ([fe80::256a:26de:3ee6:48a2%7]) with mapi id 15.02.1258.028; Fri, 5 Apr 2024 21:51:43 +0000 From: "Okanovic, Haris" To: "mihai.carabas@oracle.com" CC: "kvm@vger.kernel.org" , "joao.m.martins@oracle.com" , "dianders@chromium.org" , "ankur.a.arora@oracle.com" , "mic@digikod.net" , "pmladek@suse.com" , "wanpengli@tencent.com" , "akpm@linux-foundation.org" , "linux-kernel@vger.kernel.org" , "catalin.marinas@arm.com" , "mingo@redhat.com" , "pbonzini@redhat.com" , "tglx@linutronix.de" , "daniel.lezcano@linaro.org" , "arnd@arndb.de" , "will@kernel.org" , "hpa@zytor.com" , "peterz@infradead.org" , "npiggin@gmail.com" , "vkuznets@redhat.com" , "bp@alien8.de" , "linux-pm@vger.kernel.org" , "rafael@kernel.org" , "rick.p.edgecombe@intel.com" , "juerg.haefliger@canonical.com" , "x86@kernel.org" , "linux-arm-kernel@lists.infradead.org" Subject: Re: [PATCH v4 7/8] cpuidle/poll_state: replace cpu_relax with smp_cond_load_relaxed Thread-Topic: [PATCH v4 7/8] cpuidle/poll_state: replace cpu_relax with smp_cond_load_relaxed Thread-Index: AQHahgAj0rMfU3rQtUK6VuthoD2QJ7FaOuMA Date: Fri, 5 Apr 2024 21:51:43 +0000 Message-ID: <7f3e540ad30f40ae51f1abda24b1bea2c8b648ea.camel@amazon.com> References: <1707982910-27680-1-git-send-email-mihai.carabas@oracle.com> <1707982910-27680-8-git-send-email-mihai.carabas@oracle.com> In-Reply-To: <1707982910-27680-8-git-send-email-mihai.carabas@oracle.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.106.179.30] Content-ID: <5085DAE90D860D488EC7F7953547FE48@amazon.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240405_225151_228077_849E2C5F X-CRM114-Status: GOOD ( 19.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 2024-02-15 at 09:41 +0200, Mihai Carabas wrote: > 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 | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > > diff --git a/drivers/cpuidle/poll_state.c b/drivers/cpuidle/poll_state.c > index 9b6d90a72601..1e45be906e72 100644 > --- a/drivers/cpuidle/poll_state.c > +++ b/drivers/cpuidle/poll_state.c > @@ -13,6 +13,7 @@ > static int __cpuidle poll_idle(struct cpuidle_device *dev, > struct cpuidle_driver *drv, int index) > { > + unsigned long ret; > u64 time_start; > > time_start = local_clock_noinstr(); > @@ -26,12 +27,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; > + > + ret = smp_cond_load_relaxed(¤t_thread_info()->flags, > + VAL & _TIF_NEED_RESCHED || > + loop_count++ >= POLL_IDLE_RELAX_COUNT); Is it necessary to repeat this 200 times with a wfe poll? Does kvm not implement a timeout period? Could you make it configurable? This patch improves certain workloads on AWS Graviton instances as well, but blocks up to 6ms in 200 * 30us increments before going to wfi, which is a bit excessive. > + > + if (!(ret & _TIF_NEED_RESCHED)) > + break; > + > if (local_clock_noinstr() - time_start > limit) { > dev->poll_time_limit = true; > break; _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel