Re: generic_permission() optimization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



So I realize that Christian already applied my patch, but I'm coming
back to this because I figured out why it doesn't work as well as I
thought it would..

On Thu, 31 Oct 2024 at 12:31, Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> Added some stats, and on my load (reading email in the web browser,
> some xterms and running an allmodconfig kernel build), I get about a
> 45% hit-rate for the fast-case: out of 44M calls to
> generic_permission(), about 20M hit the fast-case path.

So the 45% hit rate really bothered me, because on the load I was
testing I really thought it should be 100%.

And in fact, sometimes it *was* 100% when I did profiles, and I never
saw the slow case at all. So I saw that odd bimodal behavior where
sometimes about half the accesses went through the slow path, and
sometimes none of them did.

It took me way too long to realize why that was the case:  the quick
"do we have ACL's" test works wonderfully well when the ACL
information is cached, but the cached case isn't always filled in.

For some unfathomable reason I just mindlessly thought that "if the
ACL info isn't filled in, and we will go to the slow case, it now
*will* be filled in, so next time around we'll have it in the cache".

But that was just silly of me. We may never call "check_acl()" at all,
because if we do the lookup as the owner, we never even bother to look
up any ACL information:

        /* Are we the owner? If so, ACL's don't matter */

So next time around, the ACL info *still* won't be filled in, and so
we *still* won't take the fastpath.

End result: that patch is not nearly as effective as I would have
liked. Yes, it actually gets reasonable hit-rates, but the
ACL_NOT_CACHED state ends up being a lot stickier than my original
mental model incorrectly throught it would be.

So the "45% hit rate" was actually on all the successful quick cases
for system directory traversal where I was looking at files as a
non-owner, but all my *own* files wouldn't hit the fast case.

So that old optimization where we don't even bother looking up ACL's
if we are the owner is actually hindering the new optimization from
being effective.

Very annoying. The "don't bother with ACL's if we are the owner" is
definitely a good thing, so I don't want to disable one optimization
just to enable another one.

(Side note: the reason I sometimes saw 100% hit rates on my test was
that a "make install" as root on my kernel tree *would* populate the
ACL caches because now that tree was looked at by a non-owner).

I'll think about this some more. And maybe somebody smarter than me
sees a good solution before I do.

                  Linus




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux