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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F00DFC43334 for ; Wed, 29 Jun 2022 07:09:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232442AbiF2HJZ (ORCPT ); Wed, 29 Jun 2022 03:09:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230516AbiF2HJS (ORCPT ); Wed, 29 Jun 2022 03:09:18 -0400 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6469ACE38; Wed, 29 Jun 2022 00:09:15 -0700 (PDT) Received: from mail-yb1-f179.google.com ([209.85.219.179]) by mrelayeu.kundenserver.de (mreue012 [213.165.67.97]) with ESMTPSA (Nemesis) id 1MG90u-1ns5os1Tie-00GXtg; Wed, 29 Jun 2022 09:09:14 +0200 Received: by mail-yb1-f179.google.com with SMTP id i7so26262714ybe.11; Wed, 29 Jun 2022 00:09:14 -0700 (PDT) X-Gm-Message-State: AJIora+Xehkji/981Hp0OYc1DdC+n9DioimAnhofWjtP9n/5HDPYzWIe 67ebnbMPeLWBuSIRciAYSDzWDGZ6vaArXKrTCx4= X-Google-Smtp-Source: AGRyM1vwFx+KUXwvbgg/ASvRBxEdL/JjOQ3Jx1tv8VOFIFQwJBGUiZKdd3oyAVRe8CZHrAKOLM6aLE6JRIBVMMOSe+E= X-Received: by 2002:a25:760e:0:b0:66c:95eb:6c69 with SMTP id r14-20020a25760e000000b0066c95eb6c69mr1899906ybc.106.1656486552981; Wed, 29 Jun 2022 00:09:12 -0700 (PDT) MIME-Version: 1.0 References: <20220628081707.1997728-1-guoren@kernel.org> <20220628081707.1997728-5-guoren@kernel.org> <09abc75e-2ffb-1ab5-d0fc-1c15c943948d@redhat.com> <5166750c-3dc6-9b09-4a1e-cd53141cdde8@redhat.com> In-Reply-To: <5166750c-3dc6-9b09-4a1e-cd53141cdde8@redhat.com> From: Arnd Bergmann Date: Wed, 29 Jun 2022 09:08:56 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH V7 4/5] asm-generic: spinlock: Add combo spinlock (ticket & queued) To: Waiman Long Cc: Guo Ren , Palmer Dabbelt , Arnd Bergmann , Ingo Molnar , Will Deacon , Boqun Feng , linux-riscv , linux-arch , Linux Kernel Mailing List , Guo Ren , Peter Zijlstra Content-Type: text/plain; charset="UTF-8" X-Provags-ID: V03:K1:yLYGSlgFf4Tbp+OluMxIlmPCxct5Gr/dLB71q2PeGr8RkvuIWk7 sZ+jqj0IK/TtnXWK5NxcWFXFuBEsk2vQUYbx+yP+dGLRADpZhpDLy4/0owaD/5cRYlnZ7IP /ueZf/D3WToQe8yvsKIlSmijN5d5FHwpCJq6574qSy8sy2rSJ//IxTkLoRshchtXQbjpzHY ggM0JSY4IGwXI7WND8BYg== X-UI-Out-Filterresults: notjunk:1;V03:K0:/uRhtt7xI/c=:oLmicir/z9PxngyFEgNPN8 25gBrsOvi1iVu4P5KRVkFxnR1d5AGh6ANFhXt0I48z8UNJ/lj2r5m4bWg5C4qGrm8IA7oyBt3 Vc2sJ6lCj21h1j+wkheSl3ypy/mN3a5nouWz4vT4bOFTqPANW70+0/lJZfTY9kt+5KzR32qDk wPR13xOcfriU/OSthc9F7ui6wTVvWSBcfcxREpDkm1g4B7qNtSRFue0OBkQmscxBcsbnyTGct LP3s8Bw6Gvw25MbEDkRN7t5NkuBU2mHEU1AT+sh3riNQ3by1K2+10kg6UTF/QBuoxcjiOLJh1 Ygu+2vvEi2tXyROw+WdOTUAypxkJKFz5FWg1ckWmzAOzzu6NNAKYxQJ7XpM5OBgFZjWZ5s4+x rgdz5NOhf5Roh1S9NOC2QkCua2fvdLSLUgaId5VPAppng+ha7KRu4SLkdOeA4GyyYgL3Hhv8v PjI/kv77Wkrb3yPsGsGMRCjXb3Nt20FL4JEZNZ0vJfgpI1NtpLbDsYgbkPPBdGcy3l4WqL6Gr rFX9HtbbVlw2L4xAa+Ng7TZ/6Mx8hwY1FkFJSVLcuoZq1st3t3pGzFRSvn/GQ0tugQ3XGncGD H5Juhk+lcBDX3uW5dSJ4VE+ekmZK7BqjNY0mqJvxaKYcNESw+J3JQtU89Lyad0Xe6toDLRSe/ XSJ1yE6WECugNL/SPykyjI83IEGO3CLVZPiZIz2LD9hXt4/pdTCr1A1yh9J8smk1mH1UOEVqR QtU5HnVNviE2bvPMNQXYcBEmxJN+FfZ7KFUwvg== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 29, 2022 at 3:34 AM Waiman Long wrote: > On 6/28/22 21:17, Guo Ren wrote: > > On Wed, Jun 29, 2022 at 2:13 AM Waiman Long wrote: > >> On 6/28/22 04:17, guoren@kernel.org wrote: > >> > >> So the current config setting determines if qspinlock will be used, not > >> some boot time parameter that user needs to specify. This patch will > >> just add useless code to lock/unlock sites. I don't see any benefit of > >> doing that. > > This is a startup patch for riscv. next, we could let vendors make choices. > > I'm not sure they like cmdline or vendor-specific errata style. > > > > Eventually, we would let one riscv Image support all machines, some > > use ticket-lock, and some use qspinlock. > > OK. Maybe you can postpone this combo spinlock until there is a good use > case for it. Upstream usually don't accept patches that have no good use > case yet. I think the usecase on risc-v is this: there are cases where the qspinlock is preferred for performance reasons, but there are also CPU cores on which it is not safe to use. risc-v like most modern architectures has a strict rule about being able to build kernels that work on all machines, so without something like this, it would not be able to use qspinlock at all. On the other hand, I don't really like the idea of putting the static-key wrapper into the asm-generic header. Especially the ticket spinlock implementation should be simple and not depend on jump labels. >From looking at the header file dependencies on arm64, I know that putting jump labels into core infrastructure like the arch_spin_lock() makes a big mess of indirect includes and measurably slows down the kernel build. I think this can still be done in the riscv asm/spinlock.h header with minimal impact on the asm-generic file if the riscv maintainers see a significant enough advantage, but I don't want it in the common code. Arnd 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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 434F8C43334 for ; Wed, 29 Jun 2022 07:09:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6bfIrc99Sw+Wo+EuFeV3s5JFkTWIMUPgpejUiBVAJ8U=; b=dIW9OG25PX+52Q lZ7Zf14Q2clFKt1ejXZFU+dcCqwCic7MhNwViC5XuFliw3UmjqbXQJILlURxwZHtAhMCushYzo2ZO XtELSLwg51MPO9aoYln82Gnds1N+DQ9Wqad3ZQrBJWFMFNenng8DEMw8Qq1TXYMZNWvpZQXngljb9 NEWWMf6AnlZscuHDwgAMCxksoA8s/txA5RZ8aLlekQp/ugGuvrfeLIFmoiuOXmqrytmne3+Pe5jVo PYCDP5umK1K3yShJZKoqu4e8J9eZOhIcCbo16hsRBTblAwwXRlut1/1NrUCnlShMAPDhOSv7Yflyc NSm0Ka6m3vNI9xIptnTQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6RpA-00A0YK-D7; Wed, 29 Jun 2022 07:09:20 +0000 Received: from mout.kundenserver.de ([212.227.126.130]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6Rp7-00A0Wb-II for linux-riscv@lists.infradead.org; Wed, 29 Jun 2022 07:09:19 +0000 Received: from mail-yb1-f172.google.com ([209.85.219.172]) by mrelayeu.kundenserver.de (mreue012 [213.165.67.97]) with ESMTPSA (Nemesis) id 1M7ehh-1o0eWd1tsr-007zgB for ; Wed, 29 Jun 2022 09:09:14 +0200 Received: by mail-yb1-f172.google.com with SMTP id h187so24108163ybg.0 for ; Wed, 29 Jun 2022 00:09:14 -0700 (PDT) X-Gm-Message-State: AJIora+UVc4sYbcA/3mzaRWhzkIbdfp7UhI/S6fTqbj4wM6poEKsl/5G AV+JY4cIjiJ6lsESfwz2brY51tmKRoIPsTFySgc= X-Google-Smtp-Source: AGRyM1vwFx+KUXwvbgg/ASvRBxEdL/JjOQ3Jx1tv8VOFIFQwJBGUiZKdd3oyAVRe8CZHrAKOLM6aLE6JRIBVMMOSe+E= X-Received: by 2002:a25:760e:0:b0:66c:95eb:6c69 with SMTP id r14-20020a25760e000000b0066c95eb6c69mr1899906ybc.106.1656486552981; Wed, 29 Jun 2022 00:09:12 -0700 (PDT) MIME-Version: 1.0 References: <20220628081707.1997728-1-guoren@kernel.org> <20220628081707.1997728-5-guoren@kernel.org> <09abc75e-2ffb-1ab5-d0fc-1c15c943948d@redhat.com> <5166750c-3dc6-9b09-4a1e-cd53141cdde8@redhat.com> In-Reply-To: <5166750c-3dc6-9b09-4a1e-cd53141cdde8@redhat.com> From: Arnd Bergmann Date: Wed, 29 Jun 2022 09:08:56 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH V7 4/5] asm-generic: spinlock: Add combo spinlock (ticket & queued) To: Waiman Long Cc: Guo Ren , Palmer Dabbelt , Arnd Bergmann , Ingo Molnar , Will Deacon , Boqun Feng , linux-riscv , linux-arch , Linux Kernel Mailing List , Guo Ren , Peter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NlcFrWhvIi4H1myiNpHOtgfumMktE TZaPFYhrAeD4/2DaCu+28pbR85P8+VQY2klihwmaxulM6Ofo7wYVEjh+TFg/jF4IxmxUWp6GH +14SgpWAC4THCBo4oyUw== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220629_000917_947674_ED0E6344 X-CRM114-Status: GOOD ( 27.41 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Wed, Jun 29, 2022 at 3:34 AM Waiman Long wrote: > On 6/28/22 21:17, Guo Ren wrote: > > On Wed, Jun 29, 2022 at 2:13 AM Waiman Long wrote: > >> On 6/28/22 04:17, guoren@kernel.org wrote: > >> > >> So the current config setting determines if qspinlock will be used, not > >> some boot time parameter that user needs to specify. This patch will > >> just add useless code to lock/unlock sites. I don't see any benefit of > >> doing that. > > This is a startup patch for riscv. next, we could let vendors make choices. > > I'm not sure they like cmdline or vendor-specific errata style. > > > > Eventually, we would let one riscv Image support all machines, some > > use ticket-lock, and some use qspinlock. > > OK. Maybe you can postpone this combo spinlock until there is a good use > case for it. Upstream usually don't accept patches that have no good use > case yet. I think the usecase on risc-v is this: there are cases where the qspinlock is preferred for performance reasons, but there are also CPU cores on which it is not safe to use. risc-v like most modern architectures has a strict rule about being able to build kernels that work on all machines, so without something like this, it would not be able to use qspinlock at all. On the other hand, I don't really like the idea of putting the static-key wrapper into the asm-generic header. Especially the ticket spinlock implementation should be simple and not depend on jump labels. >From looking at the header file dependencies on arm64, I know that putting jump labels into core infrastructure like the arch_spin_lock() makes a big mess of indirect includes and measurably slows down the kernel build. I think this can still be done in the riscv asm/spinlock.h header with minimal impact on the asm-generic file if the riscv maintainers see a significant enough advantage, but I don't want it in the common code. Arnd _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv