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 X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A6A0C4338F for ; Tue, 27 Jul 2021 10:17:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C4D5615A6 for ; Tue, 27 Jul 2021 10:17:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236208AbhG0KRZ (ORCPT ); Tue, 27 Jul 2021 06:17:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236098AbhG0KRY (ORCPT ); Tue, 27 Jul 2021 06:17:24 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E419C061764 for ; Tue, 27 Jul 2021 03:17:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=5k45kly44+pqVmHGMKU4wiLe+0Gu+CpxUPHHT5h5o3M=; b=SZ6HokUSzCTdUzd1KHtgS2a7ws CecTZP0FjqFkvhvkO1PHmpZR2kwl4i2ejy89amU3nF72ZeWCpKhCC+QHx5vsmYrnJVkV9s2VZMZ1Z Z4ZYVqfTp1uTUOat/FrY3aV2sOgbbm6dv2X3/HI7EI9+3gNYD1crhvGrBnA1EE9UTtbfla3KwEoKF rmt4VW8PS+5p60M4phTfME7/2XD+MliMdsu1sWkOv0N/ePDuQbiB4XJT8wXF8a68mBx0a3J6s01en RfqNOJFGIBnoFaH1I1mGta1SbP5InkwXYjKdYbWmh4qOq8fC8TYqpqkGNc95e6IFkSIbjhXTJAY4a XTwiOoow==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8K4u-00Eu4m-TU; Tue, 27 Jul 2021 10:13:11 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 4F5F2300279; Tue, 27 Jul 2021 12:12:47 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 23918213986E8; Tue, 27 Jul 2021 12:12:47 +0200 (CEST) Date: Tue, 27 Jul 2021 12:12:47 +0200 From: Peter Zijlstra To: Boqun Feng Cc: Guo Ren , Huacai Chen , Geert Uytterhoeven , Huacai Chen , Ingo Molnar , Will Deacon , Arnd Bergmann , Waiman Long , Linux-Arch , Rui Wang , Xuefeng Li , Jiaxun Yang Subject: Re: [PATCH RFC 1/2] arch: Introduce ARCH_HAS_HW_XCHG_SMALL Message-ID: References: <20210724123617.3525377-1-chenhuacai@loongson.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-arch@vger.kernel.org On Tue, Jul 27, 2021 at 01:03:32AM +0800, Boqun Feng wrote: > I'm missing you point here, a) ll/sc can provide forward progress and b) > ll/sc instructions are used to implement xchg/cmpxchg (see ARM64 and > PPC). Correct on both counts, but b) is tricky, even if a), then it doesn't hold that the primitive resulting from b) also provides fwd progress. I feel this point is often overlooked. I should go add something to atomic_t.txt about that I suppose. > > How to make CPU guarantee "load + cmpxchg" forward-progress? Fusion > > these instructions and lock the snoop channel? > > Maybe hardware guys would think that it's easier to implement cas + > > dcas + amo(short & byte). > > > > Please note that if _Q_PENDING_BITS == 1, then the xchg_tail() is > implemented as a "load + cmpxchg", so if "load + cmpxchg" implementation > of xchg16() doesn't provide forward-progress in an architecture, neither > does xchg_tail(). Right, so generally we rely on cmpxchg() to provide fairness. Some architectures (notably Sparc64) go to great lengths to ensure this. I have memories of adding backoff to an LL/SC based arch at some point, but I cannot find it in a hurry, so it could be one of the since deleted archs.