Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3563885pxf; Mon, 29 Mar 2021 05:51:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5B0+RI9c8TW4Jr+3+DKcxlltPMagHvSR0tVqLHQ6y2plxlHiJVAeR9n7tjFpc/zWrQUDW X-Received: by 2002:a17:906:38da:: with SMTP id r26mr29229067ejd.251.1617022306747; Mon, 29 Mar 2021 05:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617022306; cv=none; d=google.com; s=arc-20160816; b=V/c9dvyF8qZC/OI1Y/AsJN4qf/DFr78+KZ9up/8x51FES1bpS/+HDG2YSK8ZbH6RQ/ seZkeHy0kKARrIouZsD546vDntSGGxvreAsnInjgUxf/vyyKIB5ZZ6iWQllyOorZWSqv UIWacHp34YIMjkjTWivUzgEkrh9aQxmJWBfLa1DZfxIJjs0SsnYLaJSBidw3LlF2Svaq fi00BTaAVoL5/b4v4gISOzvFs7nsnVzlGYiqiwvq5veNQ76tzrFIgXBQEI5HhUWPKZC1 ZVzBUng4jUb0hstdMoTH9iUnn2gSYTIErSh8zLzpBLP3n5WjFz2y4wiRigo9N1WmHuU8 P4aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1918iT4uzotqNOl2NIVcMWIyYjsHFO6ajOdXvBHTmz0=; b=k9rnN7HcYF2AASXCD7lAwC9Skuwq9jK++Nn/Eoa8QBuZiL7xt6G1JdIgGzfhCIhgfk I82gUPXTOtFmWzGNPPBYTH4QhFH9dDlDliCAAT7RYrrrnpadH8qzSMydAlR9LQKlVO5Z fWkMhVWoVE3TkHu33T8HmmUpTV8GL6GbZcCO8Sce5EL9bPZOrKWNoT2ySB8MjHrXCL7Q gHh0HRqpEka1KQ795qhVowvCyLDa5YPDSxbnGicZueqDIvQ9k8AU7BuU/GWnpuYzGSZz GPN0WfSVYiOrZiDs+NThSY+4van7gLBwZlz5QeAt0GvfRAsEWiX4z5YRlf9sqsBsK1Uf yl7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=OsUkcjaE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rh9si13808434ejb.341.2021.03.29.05.51.24; Mon, 29 Mar 2021 05:51:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=OsUkcjaE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231528AbhC2Mu3 (ORCPT + 99 others); Mon, 29 Mar 2021 08:50:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231460AbhC2MuK (ORCPT ); Mon, 29 Mar 2021 08:50:10 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63782C061574; Mon, 29 Mar 2021 05:50:10 -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=1918iT4uzotqNOl2NIVcMWIyYjsHFO6ajOdXvBHTmz0=; b=OsUkcjaEC5QtmphwWlRuqGUNXm sguIJD8uR8Q6kUa/CzuVxzzaza4CR5bOBGKP4wnkUapwhIyaIa816SR+QuolvtGEeRoMiWR2U9eOr Y1eGuQ39WXYD2PlMMJRwOtlSCLtcRu4QL+9EJgRmP4v9eAwl7tq2lUyzErBosRYBRiXGA6p4r3piE l3JMoIDOkzIUC+gtjIaBZ6l+MT9NDe1uo3vldrRNQoHOB8kZQIUDYfehHZXB4CZYq4g4KuqP6ffRZ BR6rRc+bXfkJyW0+ypDZRJmZNSqGj/yhXMvIYXGocXid1OhDKbYDx235eu3aXlyeJx62QZv3dzYgb mTqTXNMg==; 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 (Red Hat Linux)) id 1lQrKo-001aXI-L9; Mon, 29 Mar 2021 12:49:37 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id CFD843011FE; Mon, 29 Mar 2021 14:49:31 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id BA3C42BB1A697; Mon, 29 Mar 2021 14:49:31 +0200 (CEST) Date: Mon, 29 Mar 2021 14:49:31 +0200 From: Peter Zijlstra To: Guo Ren Cc: linux-riscv , Linux Kernel Mailing List , linux-csky@vger.kernel.org, linux-arch , Guo Ren , Will Deacon , Ingo Molnar , Waiman Long , Arnd Bergmann , Anup Patel Subject: Re: [PATCH v4 3/4] locking/qspinlock: Add ARCH_USE_QUEUED_SPINLOCKS_XCHG32 Message-ID: References: <1616868399-82848-1-git-send-email-guoren@kernel.org> <1616868399-82848-4-git-send-email-guoren@kernel.org> 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-kernel@vger.kernel.org On Mon, Mar 29, 2021 at 08:01:41PM +0800, Guo Ren wrote: > u32 a = 0x55aa66bb; > u16 *ptr = &a; > > CPU0 CPU1 > ========= ========= > xchg16(ptr, new) while(1) > WRITE_ONCE(*(ptr + 1), x); > > When we use lr.w/sc.w implement xchg16, it'll cause CPU0 deadlock. Then I think your LL/SC is broken. That also means you really don't want to build super complex locking primitives on top, because that live-lock will percolate through. Step 1 would be to get your architecute fixed such that it can provide fwd progress guarantees for LL/SC. Otherwise there's absolutely no point in building complex systems with it.