Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1827294pxb; Fri, 22 Oct 2021 08:23:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfg61T7mhLaBfDFftCzYR7O2MUnW5SFR5u8/yyeq0GCi9llm+MD2SpdihWrcIohCaBOhwl X-Received: by 2002:a50:d88a:: with SMTP id p10mr825681edj.274.1634916219099; Fri, 22 Oct 2021 08:23:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634916219; cv=none; d=google.com; s=arc-20160816; b=L9bhrGNDhMYLt3EZT9CDOWA1iZyaD+4q/H9o3pNhFdOpbsslvpgh/pyz3s3d4/rVQM RTS43V1jey90vZ4i1eqWRcDyZIs2KnWK5OmXFRFKmqaw68/4ofMPa4ngFv4SmAuvb/S2 dHvCVWbLPrHgHoSg/qtTuZh+WxzBjhL6d8CGuVbnnOsB35bngxOqHAdUrOzcI5vgy5ni MQiyXrWilaHlYfdUdA8U+JgzkuyNLofT4PbsGT2iMLpY7suAx+C2dWpPduQGQ4SrhiX8 elYxk1a+OmmzahdpYcAhVHYo/R50piWOkCZEudzaP3DUkw/qK/FenODWkxcjUF0+cSZB KHPw== 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=edUysRKGfaZOTuM3uYR99rq4ae03o5LqY877IUKK/u4=; b=B7Rcu71jWpeZvUAPx/YBBNkWOMqN0m6S2W8zczrItn0AFmUF5XgrTipUsYgQGT6Di5 JO3rxmB+2BGdPi1Xjfds4AQKIZ+QKGaAFRyZVmaaSYihhArSM/0fNYUJ9jHietoJc57k a3ovWxK9H2+PGQzzxTyKDZtM5z5YG3D+LVlTzIZNNqVUZ9zdwV7/90G9xgogo9AziK5G ju7hsfqptdr83lBu1/A/CkKn39DnqNyqazYMfbCTx7e4/B/GtthmaaswTTEbtEG8ow84 6bK5BNEDorq7C/CPrRmS4iRL0EjqdD7VZ5Y2ZrEYxyqTDm/H/31haZ1smLevOxcoquBX er1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=OV9+U6++; 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 a25si12837379edn.511.2021.10.22.08.23.14; Fri, 22 Oct 2021 08:23:39 -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=20210112 header.b=OV9+U6++; 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 S233257AbhJVPWK (ORCPT + 99 others); Fri, 22 Oct 2021 11:22:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232528AbhJVPWJ (ORCPT ); Fri, 22 Oct 2021 11:22:09 -0400 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1404C061764; Fri, 22 Oct 2021 08:19:51 -0700 (PDT) Received: by mail-io1-xd2e.google.com with SMTP id i189so5884857ioa.1; Fri, 22 Oct 2021 08:19:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=edUysRKGfaZOTuM3uYR99rq4ae03o5LqY877IUKK/u4=; b=OV9+U6++bii1LgELrCjulmFIWampisMJ86zIok+nNJ7XJXUfILrGKlaXTqwBgRyUTz +sxGL4FGIVlFzBSamuiZADhcODjGZ36A8Pwjub6rVMGCeZi0RufSJ2xoa2XpQcJvzEeY JpoKvpjMTyHfmCbel/hNNKU5kbM5rEWpLOr7OGYIX3EZccKxgFzm7YR7erBYUMBP/a+j FQqxIRh28Zf/ixoUZT/Ivj59Qp2DqfSkIsWUSUmYC157rAVTDfLvk0STBFuiesHFpGgY KEKtTn2LZ9o8Cyjvbyuvi7hnIDlVeo1SXRfIp1GbaO9gv81h6dU0Kyu3UVdSZd3u0ja3 npgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=edUysRKGfaZOTuM3uYR99rq4ae03o5LqY877IUKK/u4=; b=7qWvZM8pn62Rtv/58TqKViJjEGTOwjFNMjt2Qo06U1vbKldgfzSzatIRe7lko1vKZO 6oWiObvsvcpib4f3x3iLLAG0Urjk79MH83tM6OAOEN6XF+/EMiOFVMQ9ADzpcMLENfZ4 9IPV/c0/rgYBry8b3YUgXc1tI0X3+ynpMdJut7i7uOLVTjTNetCGht0cBstJk5cUSrwn UEBI1VylbBa+VOH9OR3oduYOrWqQgd255VfBaWPApTnqctmzna0LuX+jOy4hAXbAJ/DW 0fXs0GLlyOidgM+aDC12FsqHWg67eIYdIMcrWFzKPlXHPTyHNglprqlDrhwLz0mc+Ji5 MhoQ== X-Gm-Message-State: AOAM533Ogas4xcDCGozlPUhaWBaBZtYQy+mv8ORGCIpF5pNhG7PLiL8Z zDt0al+HvL0eKAulz9+DIRk= X-Received: by 2002:a6b:ea11:: with SMTP id m17mr131844ioc.139.1634915991219; Fri, 22 Oct 2021 08:19:51 -0700 (PDT) Received: from auth2-smtp.messagingengine.com (auth2-smtp.messagingengine.com. [66.111.4.228]) by smtp.gmail.com with ESMTPSA id x5sm4208612ioh.23.2021.10.22.08.19.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Oct 2021 08:19:50 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id C689827C005A; Fri, 22 Oct 2021 11:19:47 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 22 Oct 2021 11:19:47 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvkedgjeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeeuohhquhhn ucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrfgrth htvghrnhepvdelieegudfggeevjefhjeevueevieetjeeikedvgfejfeduheefhffggedv geejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepsg hoqhhunhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqieelvdeghedtieeg qddujeejkeehheehvddqsghoqhhunhdrfhgvnhhgpeepghhmrghilhdrtghomhesfhhigi hmvgdrnhgrmhgv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 22 Oct 2021 11:19:45 -0400 (EDT) Date: Fri, 22 Oct 2021 23:19:17 +0800 From: Boqun Feng To: Waiman Long Cc: Peter Zijlstra , Will Deacon , Ingo Molnar , Arnd Bergmann , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Guo Ren , Palmer Dabbelt , Anup Patel , linux-riscv , Christoph =?iso-8859-1?Q?M=FCllner?= , Stafford Horne Subject: Re: [PATCH] locking: Generic ticket lock Message-ID: References: <4de96b16-a146-f82a-a7f2-706dba4f901f@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4de96b16-a146-f82a-a7f2-706dba4f901f@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 21, 2021 at 02:04:55PM -0400, Waiman Long wrote: [...] > > +static __always_inline int ticket_is_contended(arch_spinlock_t *lock) > > +{ > > + u32 val = atomic_read(lock); > > + > > + return (__ticket(val) - __owner(val)) > 1; > Nit: The left side is unsigned, but the right is signed. I think you are > relying on the implicit signed to unsigned conversion. It may be a bit > clearer if you use 1U instead. > > +} > > + > > +static __always_inline int ticket_is_locked(arch_spinlock_t *lock) > > +{ > > + return __ticket_is_locked(atomic_read(lock)); > > +} > > + > > +static __always_inline int ticket_value_unlocked(arch_spinlock_t lock) > > +{ > > + return !__ticket_is_locked(lock.counter); > > +} > > + > > +#undef __owner > > +#undef __ticket > > +#undef ONE_TICKET > > + > > +#define arch_spin_lock(l) ticket_lock(l) > > +#define arch_spin_trylock(l) ticket_trylock(l) > > +#define arch_spin_unlock(l) ticket_unlock(l) > > +#define arch_spin_is_locked(l) ticket_is_locked(l) > > +#define arch_spin_is_contended(l) ticket_is_contended(l) > > +#define arch_spin_value_unlocked(l) ticket_value_unlocked(l) > > + > > +#endif /* __ASM_GENERIC_TICKET_LOCK_H */ > > Other than the nit above, the patch looks good to me. > > Reviewed-by: Waiman Long > Same here ;-) Reviewed-by: Boqun Feng Regards, Boqun