Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4225410pxf; Tue, 6 Apr 2021 10:49:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1qJUlhvVyihar4Zqi1+ndIql62tXWSssj4CoxSgIYs6hyCo9uNPkz9IYorKqKT1QVcOF3 X-Received: by 2002:a17:906:76da:: with SMTP id q26mr8715980ejn.420.1617731383353; Tue, 06 Apr 2021 10:49:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617731383; cv=none; d=google.com; s=arc-20160816; b=vMLYo3gSrgHsjEBHaRK+dZ8HUjJOSBfF0K3SYAn08Goxb3KKST4nYW4PVwGn63A9R2 uQGQb2hJJTLHIxNpDc+81DKFjtJKmRUCj+08+f/i4RTANfrovQQHBuydD1bYfJAwc8BY DY0/YwJABtC+MLYCkFDuh3ZH+duzr046575KN9jrKeDE2CZcvB2ByXdVhKfsRJS466Jg Xlb1ThqEZY4oEmAza/hZTa1chzhkEJI8fAaWknPocGLUxXFcvRZ8KLEZ7aWLRzWj20vs 1fiB43fr05QbDgGtdV/Dci/tdXxCRetrJsRfMhauhNHevgfeah3T/RooL+OosjzxCCw7 Nk5w== 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=9xdIx72BUryR8S57j/82YwQXQXS2KpU1UgBOV30ECIY=; b=t+VIjG6/y2WGlEDDnhXbbfKFvh71MowlOpeAIIPv9VOydJpFMmv5BYHstKCJT4xV7b xgfbBSC05hbvjjIpEIUoJFgex61XWX2qCnJokEr75uftvLbxLjWCNCbSFYsEJdFBcxhA WCoganktl1fWWxjJz1n6manPJKTrZvFAaNamPHr7jd4ikAeDKF5l8jV5D2BpVZ3/P2C7 VrLQG0iATxVjFu572NIK73aPA59Dg9zuaYM7k9B5LlEmKs7MPSzqP8trO0Ni9QrNptg/ XZNMCfAz8Z/jMxbEVLDjK0Sn8WDqeOQK8eUHENyV/TB3Gop/FKGf7w6jOix7dpRC8dG0 ssuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TgIHqrGy; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c15si696163eds.9.2021.04.06.10.49.20; Tue, 06 Apr 2021 10:49:43 -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=@gmail.com header.s=20161025 header.b=TgIHqrGy; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240694AbhDFI4j (ORCPT + 99 others); Tue, 6 Apr 2021 04:56:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233699AbhDFI4i (ORCPT ); Tue, 6 Apr 2021 04:56:38 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98558C06174A; Tue, 6 Apr 2021 01:56:30 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id d8so7099954plh.11; Tue, 06 Apr 2021 01:56:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=9xdIx72BUryR8S57j/82YwQXQXS2KpU1UgBOV30ECIY=; b=TgIHqrGywgKnXMNklZnPmsxbnxfQhVs1/eip8i8YiMxdQR4RjRlUfUxvxL630b2ohO rj2MijmqaoRwFrfwquFATd9n3hub69GPxaoNcqnBz2I7sZK6VJYlluvXsDtx5mHIhdhs ZNb8vVejIeFztXXuQziXLhO2PBkkuOPLaeAZQ1hJVhNn/vgj04P4CaddpoOm6SftW7YY mCSjyGZWcprkJpY1wYgKpI/0r6PjQN0c36Ji2kzFWI7fulQOkeaQxbkYvtYeOHDTT01N oSjFXgnoLMaxPKM3mKNKMvqL16eyPYfI2+5st9Fnd4OUC03rXpzroRXoDUX8jVZr9GwA DHYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=9xdIx72BUryR8S57j/82YwQXQXS2KpU1UgBOV30ECIY=; b=lII6vAxennsFxOCVPzre1p0/Dp+vtziFsq+ahJoAtHgP5TL+ChpG6ms2Rlim6elxnF Y8peYr4dJ7bc3pTEg7e7+5wCOmbkqv5IKy2v7TzFKpi9YaIgOjsGWtCwQOZHWXl+s8Vm Giy7mJOdrSDIPqsred7S1g3a0UOtoHQ4qy8PUrf6XalVmgLPMYhJGbNQaHlAA262y4pa g3ZoafCKx+ZiCJILzQ/Znh0TgGPuLmaJGtIXzkevf6k+AtJLxkyHj0Lp1o0G5lxSNBK3 0vRIi4ur3NH0ZauOQKwKAHSnnX6vAIyF3qex5ww7mysy1W1lBNIIKyJjV5dGVObHEQhl Kyuw== X-Gm-Message-State: AOAM532ePoRQ1MOi33WH1ANZE4Tlt4yDtfVTVpRRMCw19J35Qp6ijklN FMYoSJtvWL0gBAhD5nyzWGY= X-Received: by 2002:a17:902:d30b:b029:e8:dc10:86fb with SMTP id b11-20020a170902d30bb02900e8dc1086fbmr13105385plc.46.1617699390137; Tue, 06 Apr 2021 01:56:30 -0700 (PDT) Received: from localhost (g139.124-45-193.ppp.wakwak.ne.jp. [124.45.193.139]) by smtp.gmail.com with ESMTPSA id s2sm2010583pjs.49.2021.04.06.01.56.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 01:56:29 -0700 (PDT) Date: Tue, 6 Apr 2021 17:56:26 +0900 From: Stafford Horne To: Guo Ren Cc: Arnd Bergmann , Peter Zijlstra , linux-riscv , Linux Kernel Mailing List , linux-csky@vger.kernel.org, linux-arch , Guo Ren , Will Deacon , Ingo Molnar , Waiman Long , Anup Patel Subject: Re: [PATCH v4 3/4] locking/qspinlock: Add ARCH_USE_QUEUED_SPINLOCKS_XCHG32 Message-ID: <20210406085626.GE3288043@lianli.shorne-pla.net> References: <20210330223514.GE1171117@lianli.shorne-pla.net> 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 Tue, Apr 06, 2021 at 11:50:38AM +0800, Guo Ren wrote: > On Wed, Mar 31, 2021 at 3:23 PM Arnd Bergmann wrote: > > > > On Wed, Mar 31, 2021 at 12:35 AM Stafford Horne wrote: > > > > > > I just want to chime in here, there may be a better spot in the thread to > > > mention this but, for OpenRISC I did implement some generic 8/16-bit xchg code > > > which I have on my todo list somwhere to replace the other generic > > > implementations like that in mips. > > > > > > arch/openrisc/include/asm/cmpxchg.h > > > > > > The idea would be that architectures just implement these methods: > > > > > > long cmpxchg_u32(*ptr,old,new) > > > long xchg_u32(*ptr,val) > > > > > > Then the rest of the generic header would implement cmpxchg. > > > > I like the idea of generalizing it a little further. I'd suggest staying a > > little closer to the existing naming here though, as we already have > > cmpxchg() for the type-agnostic version, and cmpxchg64() for the > > fixed-length 64-bit version. > > > > I think a nice interface between architecture-specific and architecture > > independent code would be to have architectures provide > > arch_cmpxchg32()/arch_xchg32() as the most basic version, as well > > as arch_cmpxchg8()/arch_cmpxchg16()/arch_xchg8()/arch_xchg16() > > if they have instructions for those. > > > > The common code can then build cmpxchg16()/xchg16() on top of > > either the 16-bit or the 32-bit primitives, and build the cmpxchg()/xchg() > > wrapper around those (or alternatively we can decide to have them > > only deal with fixed-32-bit and long/pointer sized atomics). > I think these emulation codes are suitable for some architectures but not riscv. > > We shouldn't export xchg16/cmpxchg16(emulated by lr.w/sc.w) in riscv, > We should forbid these sub-word atomic primitive and lets the > programmers consider their atomic design. Fair enough, having the generic sub-word emulation would be something that an architecture can select to use/export. -Stafford