From: Matthew Wilcox <willy@infradead.org>
To: Waiman Long <llong@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
Boqun Feng <boqun.feng@gmail.com>,
linux-kernel@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
Christoph Hellwig <hch@infradead.org>,
linux-fsdevel@vger.kernel.org
Subject: Re: [RFC 1/1] rwsem: Shrink rwsem by one pointer
Date: Wed, 18 Feb 2026 23:06:05 +0000 [thread overview]
Message-ID: <aZZF3SYiC7pCU4r0@casper.infradead.org> (raw)
In-Reply-To: <1aab1afa-d23b-40c6-8e56-a6314fa728dc@redhat.com>
On Wed, Feb 18, 2026 at 05:47:52PM -0500, Waiman Long wrote:
> On 2/17/26 2:08 PM, Matthew Wilcox (Oracle) wrote:
> > Instead of embedding a list_head in struct rw_semaphore, store a pointer
> > to the first waiter. The list of waiters remains a doubly linked list
> > so we can efficiently add to the tail of the list, remove from the front
> > (or middle) of the list.
> >
> > Some of the list manipulation becomes more complicated, but it's a
> > reasonable tradeoff on the slow paths to shrink some core data structures
> > like struct inode.
>
> If the goal is to use only one pointer for the rwsem structure, would it
> make sense to change list_head to hlist_head for instance? At least we have
> existing helpers that can be used instead of making our own coding
> convention here.
There's no hlist_add_tail(), and obviously there can't be.
hlist_head.first = node1
node1.pprev = hlist_head.first
node1.next = node2
node2.pprev = node1
node2.next = NULL
now we want to add node3 to the tail. there's no pointer to it, we have
to walk the entire chain to find out where to put it.
Whereas with this scheme, we can put it at ->first_waiter.prev. If you
want to generalise this way to use list_head, be my guest, but I don't
want to do that work (and I don't want this patch to get held up behind
a "boil the ocean" approach).
prev parent reply other threads:[~2026-02-18 23:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-17 19:08 [RFC 0/1] Shrinking rwsem Matthew Wilcox (Oracle)
2026-02-17 19:08 ` [RFC 1/1] rwsem: Shrink rwsem by one pointer Matthew Wilcox (Oracle)
2026-02-17 20:27 ` Linus Torvalds
2026-02-18 21:00 ` Matthew Wilcox
2026-02-18 21:37 ` Linus Torvalds
2026-02-18 22:26 ` Peter Zijlstra
2026-02-18 22:45 ` Linus Torvalds
2026-02-18 22:52 ` Linus Torvalds
2026-03-04 19:51 ` Matthew Wilcox
2026-02-18 22:47 ` Waiman Long
2026-02-18 23:06 ` Matthew Wilcox [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aZZF3SYiC7pCU4r0@casper.infradead.org \
--to=willy@infradead.org \
--cc=boqun.feng@gmail.com \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llong@redhat.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=torvalds@linux-foundation.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox