[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <02D2F126-C40B-4EC1-92E5-243238B348A7@fb.com>
Date: Thu, 7 Nov 2024 19:39:58 +0000
From: Song Liu <songliubraving@...a.com>
To: Jan Kara <jack@...e.cz>
CC: Amir Goldstein <amir73il@...il.com>, Song Liu <songliubraving@...a.com>,
Jeff Layton <jlayton@...nel.org>, Song Liu <song@...nel.org>,
bpf
<bpf@...r.kernel.org>,
Linux-Fsdevel <linux-fsdevel@...r.kernel.org>,
LKML
<linux-kernel@...r.kernel.org>,
Kernel Team <kernel-team@...a.com>,
Andrii
Nakryiko <andrii@...nel.org>,
Eduard Zingerman <eddyz87@...il.com>,
Alexei
Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Martin
KaFai Lau <martin.lau@...ux.dev>,
Al Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>, KP Singh <kpsingh@...nel.org>,
Matt
Bobrowski <mattbobrowski@...gle.com>,
"repnop@...gle.com"
<repnop@...gle.com>,
Josef Bacik <josef@...icpanda.com>
Subject: Re: [RFC bpf-next fanotify 2/5] samples/fanotify: Add a sample
fanotify fastpath handler
> On Nov 7, 2024, at 2:41 AM, Jan Kara <jack@...e.cz> wrote:
>
> On Wed 06-11-24 20:40:50, Amir Goldstein wrote:
>> On Thu, Oct 31, 2024 at 2:52 AM Song Liu <songliubraving@...a.com> wrote:
>>>> Alternately, maybe there is some way to designate that an entire
>>>> vfsmount is a child of a watched (or ignored) directory?
>>>>
>>>>> @Christian, I would like to know your thoughts on this (walking up the
>>>>> directory tree in fanotify fastpath handler). It can be expensive for
>>>>> very very deep subtree.
>>>>>
>>>>
>>>> I'm not Christian, but I'll make the case for it. It's basically a
>>>> bunch of pointer chasing. That's probably not "cheap", but if you can
>>>> do it under RCU it might not be too awful. It might still suck with
>>>> really deep paths, but this is a sample module. It's not expected that
>>>> everyone will want to use it anyway.
>>>
>>> Thanks for the suggestion! I will try to do it under RCU.
>>>
>>
>> That's the cost of doing a subtree filter.
>> Not sure how it could be avoided?
>
> Yes. For a real solution (not this example), we'd probably have to limit
> the parent walk to say 16 steps and if we can reach neither root nor our
> dir in that number of steps, we'll just chicken out and pass the event to
> userspace to deal with it. This way the kernel filter will deal with most
> cases anyway and we won't risk livelocking or too big performance overhead
> of the filter.
>
> For this example, I think using fs/dcache.c:is_subdir() will be OK for
> demonstration purposes.
Thanks for the pointer! It does look like a good solution for this example.
Song
Powered by blists - more mailing lists