From patchwork Wed May 10 13:23:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 9147 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3627934vqo; Wed, 10 May 2023 06:34:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Acb++tUQexJp0Nwtw3zmefKZ9ynOBemumVnxnPoTZuWtnqpWqSdA2k9DxL6CXSl+RuzPl X-Received: by 2002:a05:6a00:2ea0:b0:648:ebb2:3d6 with SMTP id fd32-20020a056a002ea000b00648ebb203d6mr334466pfb.26.1683725673910; Wed, 10 May 2023 06:34:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683725673; cv=none; d=google.com; s=arc-20160816; b=uvCDppW2hed+kPH8uPB7TgL/rvotky07YnyC3obq9raRjGitUL5VQnT42JPaJWx2BF qvLcZPiKQnKgr7tt5ZEo73jHpecP1z93mmo+L4l95pVVXEvocX/QPPVmuh0xymDM1Yr4 FAWIpGK4X5fC2xl7yz/+XCnfZ9PtpH76gMcAM9bmIURLyP16Lm0iU+jZ/rew/0b/fF26 ecIjIOMDDof6t/zxnga/ThH6oIvylmxqyQTnqfnO0kvwS3oKVD3G/VbByPbj6iyzRF32 9tvTke3EUl/cvo1gJftxWxBEjXa0ddB5D/5i9F0zLR58lHY8YnNbk5SQw2+c/SekbcKK 49Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=cjC4hA9agwUu2lae+YOuNmLHyS5lot8qx1tQCCjNDUs=; b=0XqFo8fgoWlNkKXYmj3UpxKq80iWK8M515Yk8cHlfyyHzmrlYkdoae8xhYSIHUrDJu r+U7ukS9oVyX8kOBHgMTs1HUSDMG2324Yl7RcAvJu0KDPVnO3xVR6Vk6CSgZHtmArHa3 sSpwe2Tqd7wQpsLH/OgprLdJIlih412C/RTERS85yGFnZ1LZ+HLAgIdNoNMA4FrVeTQf fThuxutQhPvH+oZcLW1N7U5eJwiiXHhOM2Iufuba4OlabMOMQlMfAw7GVodrxiJUmQkg foDMxbp+LB0yPzppH2XVHrF9UDz2nzkMtGI85cU4EZms95Qq2DH0JPGE852cTSp5V5Wx lkxA== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y75-20020a62644e000000b00648628d3103si1212256pfb.377.2023.05.10.06.34.16; Wed, 10 May 2023 06:34:33 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237012AbjEJNXp (ORCPT + 99 others); Wed, 10 May 2023 09:23:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236753AbjEJNXk (ORCPT ); Wed, 10 May 2023 09:23:40 -0400 Received: from michel.telenet-ops.be (michel.telenet-ops.be [IPv6:2a02:1800:110:4::f00:18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A01E95BAE for ; Wed, 10 May 2023 06:23:35 -0700 (PDT) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed30:cc75:d8ef:4074:8af9]) by michel.telenet-ops.be with bizsmtp id v1PG290093l7qvk061PGka; Wed, 10 May 2023 15:23:33 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1pwjme-001nDj-DC; Wed, 10 May 2023 15:23:16 +0200 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1pwjmm-00F6qH-2e; Wed, 10 May 2023 15:23:16 +0200 From: Geert Uytterhoeven To: Stephen Boyd , Tomasz Figa , Sylwester Nawrocki , Will Deacon , Arnd Bergmann , Wolfram Sang , Dejin Zheng , Kai-Heng Feng , Nicholas Piggin , Heiko Carstens , Peter Zijlstra , Russell King , John Stultz , Thomas Gleixner , Tony Lindgren , Krzysztof Kozlowski , Tero Kristo , Ulf Hansson , "Rafael J . Wysocki" , Vincent Guittot Cc: linux-arm-kernel@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2 0/2] iopoll: Busy loop and timeout improvements Date: Wed, 10 May 2023 15:23:12 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765514331885587189?= X-GMAIL-MSGID: =?utf-8?q?1765514331885587189?= Hi all, When implementing a polling loop, a common review comment is to use one of the read*_poll_timeout*() helpers. Unfortunately this is not always possible, or might introduce subtle bugs. This patch series aims to improve these helpers, so they can gain wider use. 1. The first patch improves busy-looping behavior of both the atomic and non-atomic read*_poll_timeout*() helpers. The issue addressed by this patch was discussed before[1-2], but I am not aware of any patches moving forward. 2. The second patch fixes timeout handling of the atomic variants. Some of the issues addressed by this patch were mitigated in various places[3-5], and some of these findings may of interest to the authors of [6-8]. The first patch was sent before, and already received some acks, but I hadn't queued it yet as a depedency for more read*_poll_timeout*() use, because I ran into the issue fixed by the second patch. Changes compared to v1[9]: - Add Acked-by, - Add compiler barrier and inlining explanation (thanks, Peter!), - Add patch [2/2]. Thanks for your comments! [1] "Re: [PATCH 6/7] clk: renesas: rcar-gen3: Add custom clock for PLLs" https://lore.kernel.org/all/CAMuHMdWUEhs=nwP+a0vO2jOzkq-7FEOqcJ+SsxAGNXX1PQ2KMA@mail.gmail.com [2] "Re: [PATCH v2] clk: samsung: Prevent potential endless loop in the PLL set_rate ops" https://lore.kernel.org/all/20200811164628.GA7958@kozik-lap [3] b3e9431854e8f305 ("bus: ti-sysc: Fix timekeeping_suspended warning on resume") [4] 44a9e78f9242872c ("clk: samsung: Prevent potential endless loop in the PLL ops") [5] 3d8598fb9c5a7783 ("clk: ti: clkctrl: use fallback udelay approach if timekeeping is suspended") [6] bd40cbb0e3b37a4d ("PM: domains: Move genpd's time-accounting to ktime_get_mono_fast_ns()") [7] c155f6499f9797f2 ("PM-runtime: Switch accounting over to ktime_get_mono_fast_ns()") [8] 15efb47dc560849d ("PM-runtime: Fix deadlock with ktime_get()") [9] https://lore.kernel.org/r/8d492ee4a391bd089a01c218b0b4e05cf8ea593c.1674729407.git.geert+renesas@glider.be/ Geert Uytterhoeven (2): iopoll: Call cpu_relax() in busy loops iopoll: Do not use timekeeping in read_poll_timeout_atomic() include/linux/iopoll.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)