On Thu, Aug 03, 2023 at 08:45:54AM -0700, Linus Torvalds wrote: > On Thu, 3 Aug 2023 at 02:53, Mateusz Guzik <mjguzik@xxxxxxxxx> wrote: > > > > So yes, atomics remain expensive on x86-64 even on a very moden uarch > > and their impact is measurable in a syscall like read. > > Well, a patch like this should fix it. > > I intentionally didn't bother with the alpha osf version of readdir, > because nobody cares, but I guess we could do this in the header too. > > Or we could have split the FMODE_ATOMIC_POS bit into two, and had a > "ALWAYS" version and a regular version, but just having a > "fdget_dir()" made it simpler. > > So this - together with just reverting commit 20ea1e7d13c1 ("file: > always lock position for FMODE_ATOMIC_POS") - *should* fix any > performance regression. > > But I have not tested it at all. So.... Yeah, this is my suggestion - and your earlier suggestion - in the thread. Only thing that's missing is exclusion with seek on directories as that's the heinous part.