From: Al Viro <viro@zeniv.linux.org.uk>
To: Daniel Xu <dxu@dxuuu.xyz>
Cc: bpf@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
kernel-team@fb.com, jolsa@kernel.org, hannes@cmpxchg.org,
yhs@fb.com
Subject: Re: [RFC bpf-next 1/1] bpf: Introduce iter_pagecache
Date: Thu, 8 Apr 2021 16:45:37 +0000 [thread overview]
Message-ID: <YG8zMV59hSzpCHSn@zeniv-ca.linux.org.uk> (raw)
In-Reply-To: <22bededbd502e0df45326a54b3056941de65a101.1617831474.git.dxu@dxuuu.xyz>
On Wed, Apr 07, 2021 at 02:46:11PM -0700, Daniel Xu wrote:
> +static void fini_seq_pagecache(void *priv_data)
> +{
> + struct bpf_iter_seq_pagecache_info *info = priv_data;
> + struct radix_tree_iter iter;
> + struct super_block *sb;
> + void **slot;
> +
> + radix_tree_for_each_slot(slot, &info->superblocks, &iter, 0) {
> + sb = (struct super_block *)iter.index;
> + atomic_dec(&sb->s_active);
> + radix_tree_delete(&info->superblocks, iter.index);
> + }
... and if in the meanwhile all other contributors to ->s_active have
gone away, that will result in...?
IOW, NAK. The objects you are playing with have non-trivial lifecycle
and poking into the guts of data structures without bothering to
understand it is not a good idea.
Rule of the thumb: if your code ends up using fields that are otherwise
handled by a small part of codebase, the odds are that you need to be
bloody careful. In particular, ->ns_lock has 3 users - all in
fs/namespace.c. ->list/->mnt_list: all users in fs/namespace.c and
fs/pnode.c. ->s_active: majority in fs/super.c, with several outliers
in filesystems and safety of those is not trivial.
Any time you see that kind of pattern, you are risking to reprise
a scene from The Modern Times - the one with Charlie taking a trip
through the guts of machinery.
next prev parent reply other threads:[~2021-04-08 16:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-07 21:46 [RFC bpf-next 0/1] bpf: Add page cache iterator Daniel Xu
[not found] ` <22bededbd502e0df45326a54b3056941de65a101.1617831474.git.dxu@dxuuu.xyz>
2021-04-08 6:14 ` [RFC bpf-next 1/1] bpf: Introduce iter_pagecache Matthew Wilcox
2021-04-08 19:48 ` Daniel Xu
2021-04-08 21:29 ` Matthew Wilcox
2021-04-08 8:19 ` Christian Brauner
2021-04-08 16:45 ` Al Viro [this message]
2021-04-08 20:49 ` Daniel Xu
2021-04-08 21:04 ` Al Viro
2021-04-08 22:11 ` Dave Chinner
2021-04-08 7:51 ` [RFC bpf-next 0/1] bpf: Add page cache iterator Christian Brauner
2021-04-08 16:08 ` Daniel Xu
2021-04-08 21:33 ` Shakeel Butt
2021-04-08 23:13 ` Darrick J. Wong
2021-04-09 0:24 ` Daniel Xu
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=YG8zMV59hSzpCHSn@zeniv-ca.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=bpf@vger.kernel.org \
--cc=dxu@dxuuu.xyz \
--cc=hannes@cmpxchg.org \
--cc=jolsa@kernel.org \
--cc=kernel-team@fb.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=yhs@fb.com \
/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