From: Christian Brauner <brauner@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-fsdevel@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
Jann Horn <jannh@google.com>,
Christian Brauner <brauner@kernel.org>
Subject: [PATCH RFC 0/4] fs: port files to rcuref_long_t
Date: Sat, 05 Oct 2024 21:16:43 +0200 [thread overview]
Message-ID: <20241005-brauner-file-rcuref-v1-0-725d5e713c86@kernel.org> (raw)
As atomic_inc_not_zero() is implemented with a try_cmpxchg() loop it has
O(N^2) behaviour under contention with N concurrent operations. The
rcuref infrastructure uses atomic_add_negative_relaxed() for the fast
path, which scales better under contention and we get overflow
protection for free.
I've been testing this with will-it-scale using a multi-threaded fstat()
on the same file descriptor on a machine that Jens gave me access (thank
you very much!):
processor : 511
vendor_id : AuthenticAMD
cpu family : 25
model : 160
model name : AMD EPYC 9754 128-Core Processor
and I consistently get a 3-5% improvement on workloads with 256+ and
more threads comparing v6.12-rc1 as base against with these patches
applied.
Note that atomic_inc_not_zero() contained a full memory barrier that we
relied upon. But we only need an acquire barrier and so I replaced the
second load from the file table with a smp_load_acquire(). I'm not
completely sure this is correct or if we could get away with something
else. Linus, maybe you have input here?
Maybe this is all a bad idea but I've wasted enough time on performance
testing this that I at least wanted to have it on list.
Signed-off-by: Christian Brauner <brauner@kernel.org>
---
Christian Brauner (4):
fs: protect backing files with rcu
types: add rcuref_long_t
rcuref: add rcuref_long_*() helpers
fs: port files to rcuref_long_t
drivers/gpu/drm/i915/gt/shmem_utils.c | 2 +-
drivers/gpu/drm/vmwgfx/ttm_object.c | 2 +-
fs/eventpoll.c | 2 +-
fs/file.c | 17 ++--
fs/file_table.c | 18 ++--
include/linux/fs.h | 9 +-
include/linux/rcuref_long.h | 166 ++++++++++++++++++++++++++++++++++
include/linux/types.h | 10 ++
lib/rcuref.c | 104 +++++++++++++++++++++
9 files changed, 308 insertions(+), 22 deletions(-)
---
base-commit: 9852d85ec9d492ebef56dc5f229416c925758edc
change-id: 20240927-brauner-file-rcuref-bfa4a4ba915b
next reply other threads:[~2024-10-05 19:17 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-05 19:16 Christian Brauner [this message]
2024-10-05 19:16 ` [PATCH RFC 1/4] fs: protect backing files with rcu Christian Brauner
2024-10-05 19:16 ` [PATCH RFC 2/4] types: add rcuref_long_t Christian Brauner
2024-10-05 19:16 ` [PATCH RFC 3/4] rcuref: add rcuref_long_*() helpers Christian Brauner
2024-10-05 19:16 ` [PATCH RFC 4/4] fs: port files to rcuref_long_t Christian Brauner
2024-10-05 21:42 ` [PATCH RFC 0/4] " Linus Torvalds
2024-10-05 22:01 ` Al Viro
2024-10-05 22:14 ` Linus Torvalds
2024-10-05 22:28 ` Al Viro
2024-10-05 22:43 ` Linus Torvalds
2024-10-05 22:51 ` Al Viro
2024-10-06 9:55 ` Christian Brauner
2024-10-05 22:01 ` Linus Torvalds
2024-10-06 10:21 ` Christian Brauner
2024-10-06 18:09 ` Linus Torvalds
2024-10-07 7:37 ` Christian Brauner
2024-10-06 9:48 ` Christian Brauner
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=20241005-brauner-file-rcuref-v1-0-725d5e713c86@kernel.org \
--to=brauner@kernel.org \
--cc=jannh@google.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).