Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3592363rwb; Tue, 16 Aug 2022 05:55:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR6kEqHG83VRuOqjaZbGkN9WTxkoBDGjy9neBTmf5++cZm8JF2RfxNc3UUtz9X03tKbJYTdS X-Received: by 2002:a05:6402:4148:b0:440:cb9f:d10f with SMTP id x8-20020a056402414800b00440cb9fd10fmr652574eda.77.1660654512380; Tue, 16 Aug 2022 05:55:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660654512; cv=none; d=google.com; s=arc-20160816; b=DGapftdwX2rZjnTEJgamY9atbYuDnl7iTefez45ZFOkORsJbJU4SCInv3XnfCBb4IJ n9XsfX+vX5QINWYSsIIGF6Sxjpphb5IiXukJY2jAzHpHG4NyNY5hbW22h1HtdyCR1uD4 KyPWmtSNXSC1Stvz38SatENjukeRqqA+7gVjTlS7caFxGyDecaYlHdyNCHq21kVjHJHz PEF6xkDhxcdS1QmNGwzF3wBvdzVPlnx51WKg2H+ZcJfjZWu07oFPAwX53iliR9GVYFuY poYqMboaGiRdi2pd/VoYptx05bOIaH2d1GMF3meL8rHJiSLg1wRq0p05fPyQz8s4SS+g FfRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=hfTOgFZQULH3HGjZfVeACZajEiyrHVTnjNgOWYibpaE=; b=gyoafGwe6fUyaw+GCrwqx8tUDyinC3qQDTDAZQG49GzwoBU18Y/x98xNlaip5Qy0jj 8lybrcXviKozw5KyD7Wn5jXS6vnRgPZxdL3TWcPSxRjwNcmwN9dhzi7Odw6nZZk0wlFK 5KrRkr59iq5MjBAZnTpDJKlTUZHPvE9TyjVud8v/ecOsDP7XY/PbWP5XYuvGwjp3JcVi onpqqoHWj0OtJBZS9ryqhnRT2rr34Q2VqvpCJWiEfpaJxXrXrDwCd4FVitoGoCAvLUKQ 4zhvFRXu1QSyehyu5KlqFFG6opK+GLtrSzKmQgb1mV/zf+XnepfpgpIymCbUUx62GaeS nhLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@solid-run-com.20210112.gappssmtp.com header.s=20210112 header.b=uO+dRTgA; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id vp22-20020a17090712d600b0072aeded8896si8127730ejb.396.2022.08.16.05.54.46; Tue, 16 Aug 2022 05:55:12 -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=pass header.i=@solid-run-com.20210112.gappssmtp.com header.s=20210112 header.b=uO+dRTgA; 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 S231528AbiHPMaf (ORCPT + 99 others); Tue, 16 Aug 2022 08:30:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235433AbiHPMa2 (ORCPT ); Tue, 16 Aug 2022 08:30:28 -0400 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C82876B674 for ; Tue, 16 Aug 2022 05:30:26 -0700 (PDT) Received: by mail-il1-x12d.google.com with SMTP id i18so4105321ila.12 for ; Tue, 16 Aug 2022 05:30:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=solid-run-com.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=hfTOgFZQULH3HGjZfVeACZajEiyrHVTnjNgOWYibpaE=; b=uO+dRTgAMmNd3fHUIcqiRK5OLbpDzwLIIw1WOm6XSzHseadwJQvRDZx9EQVgkOmhIT jU6tQJTaqseJy6jOZ8wLd9+i/S1yFw7g1xDOZox4YLQoO0t05HU6azKLDikZTeOdiRtY 52OeEIxLIGWo9urVKqH6zTKXEPCftK713RYvvNSD0nZDDuHJNnwUm8W62b1tRJw5OxAx Dfhysyugrt4yKaKlt0zX97iKip9YxK7FKebF9Obu5Nrqj0wCGVgF7bHnxLlcbW86qwqL P7NjzTkgnEyzkpdBgleanNe1JjZEQRj30waCSclse2wcpfdR68xYll/8GRa8gDuoaCUy FIAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=hfTOgFZQULH3HGjZfVeACZajEiyrHVTnjNgOWYibpaE=; b=j9Ib07GNsCXeLeXnuzZJEodtjamYZ2mnwAkv9c18CldZET3xfvJK8HAvJlXU52C0k4 CaKh+TDHeP1p4WL5BYubp5PhWT/O1ebXlk9nXOuyR+r2Gcs/Xg/57sNZTjA8eg/d4l5x chmzz8V/kIm4MpQoEsuSfB+QyvQ5xCaJpDAYx6lRjr2apLhk7SBjpZuMclE+8xj4Y33I x/RoKAP+AWFb7Cx+Wjdf7YmNg/T1iwPd9qyFphf1cMeSqqFHTVMF1WOuQSQFJBYLU6ql 6VDVly1Yry37ZJnpgY9yzkdaOG4Q+dUPE3uie5mepC41/nLaYKWsWi4kvv+jQ66vo9Jr suKQ== X-Gm-Message-State: ACgBeo0P8iBYsoGQFqL0JWS/IsTkz3QjRQwWx65XSWe1kypo7I7FLVe4 s8PtfQTgekpCYE4hI98hInQchkJQ017qPeafXlWasw== X-Received: by 2002:a05:6e02:2145:b0:2e4:b2f3:d6fb with SMTP id d5-20020a056e02214500b002e4b2f3d6fbmr7584606ilv.163.1660653026211; Tue, 16 Aug 2022 05:30:26 -0700 (PDT) MIME-Version: 1.0 References: <20220816070311.89186-1-marcan@marcan.st> In-Reply-To: From: Jon Nettleton Date: Tue, 16 Aug 2022 14:29:49 +0200 Message-ID: Subject: Re: [PATCH] locking/atomic: Make test_and_*_bit() ordered on failure To: Arnd Bergmann Cc: Hector Martin , Will Deacon , Peter Zijlstra , Ingo Molnar , Alan Stern , Andrea Parri , Boqun Feng , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , "Paul E. McKenney" , Akira Yokosawa , Daniel Lustig , Joel Fernandes , Mark Rutland , Jonathan Corbet , Tejun Heo , jirislaby@kernel.org, Marc Zyngier , Catalin Marinas , Oliver Neukum , Linus Torvalds , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Asahi Linux , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, 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 On Tue, Aug 16, 2022 at 10:17 AM Arnd Bergmann wrote: > > On Tue, Aug 16, 2022 at 9:03 AM Hector Martin wrote: > > > > These operations are documented as always ordered in > > include/asm-generic/bitops/instrumented-atomic.h, and producer-consumer > > type use cases where one side needs to ensure a flag is left pending > > after some shared data was updated rely on this ordering, even in the > > failure case. > > > > This is the case with the workqueue code, which currently suffers from a > > reproducible ordering violation on Apple M1 platforms (which are > > notoriously out-of-order) that ends up causing the TTY layer to fail to > > deliver data to userspace properly under the right conditions. This > > change fixes that bug. > > > > Change the documentation to restrict the "no order on failure" story to > > the _lock() variant (for which it makes sense), and remove the > > early-exit from the generic implementation, which is what causes the > > missing barrier semantics in that case. Without this, the remaining > > atomic op is fully ordered (including on ARM64 LSE, as of recent > > versions of the architecture spec). > > > > Suggested-by: Linus Torvalds > > Cc: stable@vger.kernel.org > > Fixes: e986a0d6cb36 ("locking/atomics, asm-generic/bitops/atomic.h: Rewrite using atomic_*() APIs") > > Fixes: 61e02392d3c7 ("locking/atomic/bitops: Document and clarify ordering semantics for failed test_and_{}_bit()") > > Signed-off-by: Hector Martin > > --- > > Documentation/atomic_bitops.txt | 2 +- > > include/asm-generic/bitops/atomic.h | 6 ------ > > I double-checked all the architecture specific implementations to ensure > that the asm-generic one is the only one that needs the fix. > > I assume this gets merged through the locking tree or that Linus picks it up > directly, not through my asm-generic tree. > > Reviewed-by: Arnd Bergmann > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel Testing this patch on pre Armv8.1 specifically Cortex-A72 and Cortex-A53 cores I am seeing a huge performance drop with this patch applied. Perf is showing lock_is_held_type() as the worst offender but that could just be the function getting blamed. The most obvious indicator of the performance loss is ssh throughput. With the patch I am only able to achieve around 20MB/s and without the patch I am able to transfer around 112MB/s, no other changes. When I have more time I can do some more in depth testing, but for now I just wanted to bring this issue up so perhaps others can chime in regarding how it performs on their hardware. -Jon