Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3624051rwb; Tue, 16 Aug 2022 06:21:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR5bYCrXBBjbrrRErYK45AU0lUR8dbgZlSIsJx+7iYf5onATIX9yO3fOIadPwwO3/+zAgyCt X-Received: by 2002:a05:6a00:1d9e:b0:52d:aa13:67fc with SMTP id z30-20020a056a001d9e00b0052daa1367fcmr20864422pfw.73.1660656081084; Tue, 16 Aug 2022 06:21:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660656081; cv=none; d=google.com; s=arc-20160816; b=aqjg9dJCiIDKsfOeFzMdcYD2xNPh5fegOEYEbeTbg/FCnLJqrwP1VknresejhMIe8Q Ee5S/BHY3Jp93J9aeee7/PAJyGnPPvfyA6E7PpwyG4Hv6KMtEwqjbeGiLocwF5Avyr8i 7h8nsuxeeRH1OE9S1XCorQCAiX0O1xzZJlqlukItvCzhC91a89UCXoTMtr6IPscpV0DL x85Fd67twWA+JtpJOrfIXdwgRKuGguvK9X68CHX/HPay+nQF0ojMzCg9ct2eoFSmPfMm rMX7seB6Kpaz73EjAos+so6xNzXhFcTr3k6USKk6eL7NELlUb1LnXYtyC56fN2rfOQLJ +owQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=KGhEpoH+byZHvTuOL1RDgklnjdZj5kPryUCGDvuZD00=; b=XIqQdMGLkPd2c1M1jILjOVRU5W+/FivGNYEbz2HygQNX8IzXug/EcwaLsrrjCgFC61 3pYgl2/YsxVlBjU7Z0wvmooLBREmtj6z2mTHrZLS2ZRZxgATJrZsSHpmW3TY2FivARtn qOCXNwvnW3uGsxpODLvg6ZV79v+WCH/LjBM+5XfS+TiV2M694Uw+F+gJSdN5pcPa7b6z R5R3Ag6dM/6kaVhWTe1rTXVA74VLSUoytnbeWMkhFljStrNBAbbPmMQ6cBhjvCvDYCBS Uz6RTw4rroABkptEGE645sYB0UyFmHrh1wJHPnFQ2K+H7G9fIj5WGzUTc+yZygv47aZK HCFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hBKbJz4b; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e11-20020a17090a630b00b001e8927db60bsi17846613pjj.73.2022.08.16.06.21.09; Tue, 16 Aug 2022 06:21:21 -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=@kernel.org header.s=k20201202 header.b=hBKbJz4b; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233695AbiHPNCx (ORCPT + 99 others); Tue, 16 Aug 2022 09:02:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231383AbiHPNBB (ORCPT ); Tue, 16 Aug 2022 09:01:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4980C49B51; Tue, 16 Aug 2022 06:01:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DA15B61361; Tue, 16 Aug 2022 13:00:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8E15C433D7; Tue, 16 Aug 2022 13:00:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660654859; bh=acdDLBpXut9yLHqRuyu2ALBHD3iFgQWicla89BdHDe4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hBKbJz4b1yLZKBf8gXwHc/dL5iqGIHsW7JBt+mdjOAtHh3fICXkv4kaMtG9UHrEGi FfFgTrzG4/3/z4kNg9G1sMXkirHFDUaiXQXMXL5WawsERh5PHYPlWC5C+eD74ynDT4 F8D5oWXtbW1nifB6EKC5McdPBTz09xtxsq8TqyzVieNtYtE7FrTbmGwsjgqKeYrAmF Dkb/aE9ajcITuzF577LgWnXrdn+kYNQ1uHeB5K4NtlRde2iJmWTJKa0jcfTlugEO8V QQer5lR7aYkNzUmwWuL1dZD9AsHAx6EOapIekW4PXGEwqSj62HFpBx/4rQBjBAJx0P lIUEU6K+IAuGA== Date: Tue, 16 Aug 2022 14:00:50 +0100 From: Will Deacon To: Jon Nettleton Cc: Arnd Bergmann , Hector Martin , 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 Subject: Re: [PATCH] locking/atomic: Make test_and_*_bit() ordered on failure Message-ID: <20220816130048.GA11202@willie-the-truck> References: <20220816070311.89186-1-marcan@marcan.st> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 02:29:49PM +0200, Jon Nettleton wrote: > 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 Hmm, that should only exist if LOCKDEP is enabled and performance tends to go out of the window if you have that on. Can you reproduce the same regression with lockdep disabled? Will