Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3533123pxf; Mon, 29 Mar 2021 05:03:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAmP/my947CoXafCYJLBlGKDxw4UIHB4YPpiYo545F2ldcJTDxr9iAcJmOuL/3LPUwVJSH X-Received: by 2002:a17:906:f296:: with SMTP id gu22mr27636666ejb.20.1617019421200; Mon, 29 Mar 2021 05:03:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617019421; cv=none; d=google.com; s=arc-20160816; b=jdoQCg90lM6ITDTtc/HZ5TRpp4KsFgkpDYKYGHy5iViLi6UTtNd0m2u689o7LcUWIx afgmp9wYsJ7miW9CS0UiezkALzlDRALDdv/Vw2cXFPBMR2dZNL6HmW55wsOrZ9cFpzyw wemz4zg3x+KXfDHmSC6Co5FJHNJRaDDyxfpP05aHnIV7ytDKHpIiJg9BZynF2KiKlcC1 vszzbvd7PEhPnwLlQ/ERrpZyD49cIsKkM437pr8u5OoOtuePkstErU5CO5KXUWiTeyqa inUaI9xBBRf2g99o3tNsjQEcF8k1lsn7nL/63/yG/JBqaYRq5EsWHTaEfVjJgOXgHD2G 2K/w== 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=KpQCDSx/VzddMEowwQBunufKRHpUJhTbBR5TH8USTyo=; b=vhPuLvbwpuFptNvIfXv7xSHVYZAbDmIWTmjkfc2C5WPzq6XXWI/wfMC5Pf6Ah+8o+z oaywIvZ/dHBz+unn5u4O/j6Zhu+i19a/FcWEQH2nzQNopToSQHMWy0HrMpR3wOJdivF4 2xgQ9MAqcQYiw2Y/HSu0Q8eYhicuqx8V7DXtrOdjJiP1YGUKDGmQ135P0TtkUxWgKip6 6fcttoi54KKyCIq2WmQCPeqKjKkWEb4D03Cx01pCZK+UJ1ZeUAwFC1k1Yi6wTYCSlR4A kZpR3edu2mRXRhiYOVxTpdHSF2sHwuWUNODsfF/KKhr+dvwTJ1fkLAlNnUowQeZDImDi rLVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MfOCEZUN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e24si12582306edv.373.2021.03.29.05.03.18; Mon, 29 Mar 2021 05:03:41 -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=@kernel.org header.s=k20201202 header.b=MfOCEZUN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231466AbhC2MCZ (ORCPT + 99 others); Mon, 29 Mar 2021 08:02:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:42920 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230434AbhC2MBy (ORCPT ); Mon, 29 Mar 2021 08:01:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2110361930; Mon, 29 Mar 2021 12:01:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617019314; bh=UT+UrRIVgNhbmAkKeg6HsueNZaK8AB1/0MS5NZZ5NQU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=MfOCEZUNUnR4dKPxmau5OQU9kxgxhGvwo8N3JR/s148VGWrMMAXEH9mfymMgQHnNI YhluAI+zInviPvrAzt7wGZUmUh24tq3e4VUhcVfmrQG16kSpgI34Eop4Epu9GViqs/ IVmw0BZ5JkW63+MoqQ6G98fb6T2mfyqZ3IP+ltAjR0AILOFUyaO7MNL3hyVm/5bPws gCi9d/jWTSzGzH6MVMCsFqvbEQnKc5jTCLn7HLSVlr+Xmmw1KvMQXyicd6Uc2kzljR 404UjwjSmNXVdzJce57PFhk1eGmE8j82NwIiXy6V+pb94GZGHpnIFXPED1fvDHqRUM VFkV5eigHQKew== Received: by mail-lj1-f175.google.com with SMTP id 15so15680568ljj.0; Mon, 29 Mar 2021 05:01:54 -0700 (PDT) X-Gm-Message-State: AOAM531QGLHi1fZ3Kz0L044sDVLidaUegeRgFF5MU8mi9G/8mFRc0JN2 R6zrajyHs0YtSKgJncIyrNcsaS8Bnv0AAcOdSY0= X-Received: by 2002:a2e:9084:: with SMTP id l4mr17142105ljg.498.1617019312425; Mon, 29 Mar 2021 05:01:52 -0700 (PDT) MIME-Version: 1.0 References: <1616868399-82848-1-git-send-email-guoren@kernel.org> <1616868399-82848-4-git-send-email-guoren@kernel.org> In-Reply-To: From: Guo Ren Date: Mon, 29 Mar 2021 20:01:41 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 3/4] locking/qspinlock: Add ARCH_USE_QUEUED_SPINLOCKS_XCHG32 To: Peter Zijlstra 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 29, 2021 at 7:26 PM Peter Zijlstra wrote: > > On Mon, Mar 29, 2021 at 07:19:29PM +0800, Guo Ren wrote: > > On Mon, Mar 29, 2021 at 3:50 PM Peter Zijlstra wrote: > > > > > > On Sat, Mar 27, 2021 at 06:06:38PM +0000, guoren@kernel.org wrote: > > > > From: Guo Ren > > > > > > > > Some architectures don't have sub-word swap atomic instruction, > > > > they only have the full word's one. > > > > > > > > The sub-word swap only improve the performance when: > > > > NR_CPUS < 16K > > > > * 0- 7: locked byte > > > > * 8: pending > > > > * 9-15: not used > > > > * 16-17: tail index > > > > * 18-31: tail cpu (+1) > > > > > > > > The 9-15 bits are wasted to use xchg16 in xchg_tail. > > > > > > > > Please let architecture select xchg16/xchg32 to implement > > > > xchg_tail. > > > > > > So I really don't like this, this pushes complexity into the generic > > > code for something that's really not needed. > > > > > > Lots of RISC already implement sub-word atomics using word ll/sc. > > > Obviously they're not sharing code like they should be :/ See for > > > example arch/mips/kernel/cmpxchg.c. > > I see, we've done two versions of this: > > - Using cmpxchg codes from MIPS by Michael > > - Re-write with assembly codes by Guo > > > > But using the full-word atomic xchg instructions implement xchg16 has > > the semantic risk for atomic operations. > > What? -ENOPARSE 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. > > > > Also, I really do think doing ticket locks first is a far more sensible > > > step. > > NACK by Anup > > Who's he when he's not sending NAKs ? We've talked before: https://lore.kernel.org/linux-riscv/CAAhSdy1JHLUFwu7RuCaQ+RUWRBks2KsDva7EpRt8--4ZfofSUQ@mail.gmail.com/T/#t -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/