From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B0ADC7618E for ; Mon, 24 Apr 2023 06:45:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230505AbjDXGpu (ORCPT ); Mon, 24 Apr 2023 02:45:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230340AbjDXGpq (ORCPT ); Mon, 24 Apr 2023 02:45:46 -0400 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E75E13AAE; Sun, 23 Apr 2023 23:45:43 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Q4bHP1fyXz4f3tNf; Mon, 24 Apr 2023 14:45:37 +0800 (CST) Received: from [10.174.176.117] (unknown [10.174.176.117]) by APP2 (Coremail) with SMTP id Syh0CgCnmuiNJUZkr9fFHw--.41710S2; Mon, 24 Apr 2023 14:45:34 +0800 (CST) Subject: Re: [Lsf-pc] [LSF/MM/BPF TOPIC] bpf iterator for file-system To: Amir Goldstein Cc: lsf-pc@lists.linux-foundation.org, Nhat Pham , Miklos Szeredi , Alexei Starovoitov , linux-fsdevel@vger.kernel.org, Yonghong Song , bpf References: <0a6f0513-b4b3-9349-cee5-b0ad38c81d2e@huaweicloud.com> From: Hou Tao Message-ID: Date: Mon, 24 Apr 2023 14:45:33 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 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2KfnxnUUI43ZEXa7IU1zuWJUUUUU== X-CM-SenderInfo: xkrx3t3r6k3tpzhluzxrxghudrp/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Hi, On 4/16/2023 3:55 PM, Amir Goldstein wrote: > On Tue, Feb 28, 2023 at 5:47 AM Hou Tao wrote: >> From time to time, new syscalls have been proposed to gain more observability >> for file-system: >> >> (1) getvalues() [0]. It uses a hierarchical namespace API to gather and return >> multiple values in single syscall. >> (2) cachestat() [1]. It returns the cache status (e.g., number of dirty pages) >> of a given file in a scalable way. >> >> All these proposals requires adding a new syscall. Here I would like to propose >> another solution for file system observability: bpf iterator for file system >> object. The initial idea came when I was trying to implement a filefrag-like >> page cache tool with support for multi-order folio, so that we can know the >> number of multi-order folios and the orders of those folios in page cache. After >> developing a demo for it, I realized that we could use it to provide more >> observability for file system objects. e.g., dumping the per-cpu iostat for a >> super block [2], iterating all inodes in a super-block to dump info for >> specific inodes (e.g., unlinked but pinned inode), or displaying the flags of a >> specific mount. >> >> The BPF iterator was introduced in v5.8 [3] to support flexible content dumping >> for kernel objects. It works by creating bpf iterator file [4], which is a >> seq-like read-only file, and the content of the bpf iterator file is determined >> by a previously loaded bpf program, so userspace can read the bpf iterator file >> to get the information it needs. However there are some unresolved issues: >> (1) The privilege. >> Loading the bpf program requires CAP_ADMIN or CAP_BPF. This means that the >> observability will be available to the privileged process. Maybe we can load the >> bpf program through a privileged process and make the bpf iterator file being >> readable for normal users. >> (2) Prevent pinning the super-block >> In the current naive implementation, the bpf iterator simply pins the >> super-block of the passed fd and prevents the super-block from being destroyed. >> Perhaps fs-pin is a better choice, so the bpf iterator can be deactivated after >> the filesystem is umounted. >> >> I hope to send out an RFC soon before LSF/MM/BPF for further discussion. > Hi Hou, > > IIUC, there is not much value in making this a cross track session. > Seems like an FS track session that has not much to do with BPF > development. > > Am I understanding correctly or are there any cross subsystem > interactions that need to be discussed? Yes. Although the patchset for file-system iterator is still not ready, but I think the BPF mechanisms for file-system iterator is ready, so a cross track session maybe unnecessary. > > Perhaps we can join you as co-speaker for Miklos' traditional > "fsinfo" session? Thanks. I am glad to be a co-speaker for fsinfo session. > > Thanks, > Amir. > >> [0]: >> https://lore.kernel.org/linux-fsdevel/YnEeuw6fd1A8usjj@miu.piliscsaba.redhat.com/ >> [1]: https://lore.kernel.org/linux-mm/20230219073318.366189-1-nphamcs@gmail.com/ >> [2]: >> https://lore.kernel.org/linux-fsdevel/CAJfpegsCKEx41KA1S2QJ9gX9BEBG4_d8igA0DT66GFH2ZanspA@mail.gmail.com/ >> [3]: https://lore.kernel.org/bpf/20200509175859.2474608-1-yhs@fb.com/ >> [4]: https://docs.kernel.org/bpf/bpf_iterators.html >> >> _______________________________________________ >> Lsf-pc mailing list >> Lsf-pc@lists.linux-foundation.org >> https://lists.linuxfoundation.org/mailman/listinfo/lsf-pc