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 35E40EC8759 for ; Thu, 7 Sep 2023 19:34:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238766AbjIGTeP (ORCPT ); Thu, 7 Sep 2023 15:34:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239518AbjIGTeN (ORCPT ); Thu, 7 Sep 2023 15:34:13 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 468821BD7; Thu, 7 Sep 2023 12:34:05 -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=SpYv2F9GuCNC42djvfZFztSGAgqrLyKSLHEQbRhwUj0=; b=fAsRp5j1Qs1zwKnTCP1RH0ZM7Q nkwjBmIR3S6SNFMP1Ys5jSENKZ0SujYaWY+X2drfKb8LF6Z+M0IBLZgMPQ+w/FPYbFaSmE25MQpSS gWsWZxazrLmIwEFKFdu3SfSSfYCv1xNlqQiDWiXsgUlUosIUDj9cHWxcZ18Z+5q0f7O9nZ9Z/1rNw ofg0W1KJvxcJwDtCxY1HrZFcgpBZxNjq/TKUBRty94ivbF3PJ1UKnd0IqhKWUE2is7Hnc5pc5fT+Y HRfYOQb6J5zTQNSm/31mC47poT0NpAae87W4Z5uokr6Dc4nBhuSBSetj9UyJ5Go1RfKJexmIcEPVk QSlwfL2g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qeKlJ-00D2hf-CV; Thu, 07 Sep 2023 19:33:57 +0000 Date: Thu, 7 Sep 2023 20:33:57 +0100 From: Matthew Wilcox To: Waiman Long Cc: Peter Zijlstra , Ingo Molnar , Will Deacon , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Chandan Babu R , "Darrick J . Wong" , linux-xfs@vger.kernel.org Subject: Re: [PATCH 1/5] locking: Add rwsem_is_write_locked() Message-ID: References: <20230907174705.2976191-1-willy@infradead.org> <20230907174705.2976191-2-willy@infradead.org> <2cd975ec-f868-f180-350f-b1b704118777@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2cd975ec-f868-f180-350f-b1b704118777@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 07, 2023 at 02:05:54PM -0400, Waiman Long wrote: > On 9/7/23 13:47, Matthew Wilcox (Oracle) wrote: > > +static inline int rwsem_is_write_locked(struct rw_semaphore *sem) > > +{ > > + return atomic_long_read(&sem->count) & 1 /* RWSEM_WRITER_LOCKED */; > > +} > > I would prefer you move the various RWSEM_* count bit macros from > kernel/locking/rwsem.c to under the !PREEMPT_RT block and directly use > RWSEM_WRITER_LOCKED instead of hardcoding a value of 1. Just to be clear, you want the ~50 lines from: /* * On 64-bit architectures, the bit definitions of the count are: ... #define RWSEM_READ_FAILED_MASK (RWSEM_WRITER_MASK|RWSEM_FLAG_WAITERS|\ RWSEM_FLAG_HANDOFF|RWSEM_FLAG_READFAIL) moved from rwsem.c to rwsem.h? Or just these four lines: #define RWSEM_WRITER_LOCKED (1UL << 0) #define RWSEM_FLAG_WAITERS (1UL << 1) #define RWSEM_FLAG_HANDOFF (1UL << 2) #define RWSEM_FLAG_READFAIL (1UL << (BITS_PER_LONG - 1))