Re: [PATCH v3 2/7] documentation for stats_fs

2020-06-04 Thread Emanuele Giuseppe Esposito
Hi, + +The STATS_FS_HIDDEN attribute won't affect the aggregation, it will only +block the creation of the files. Why does HIDDEN block the creation of files? instead of their visibility? The file itself is used to allow the user to view the content of a value. In order to make it hidden,

Re: [PATCH v3 3/7] kunit: tests for stats_fs API

2020-05-27 Thread Emanuele Giuseppe Esposito
In order to run them, the kernel .config must set CONFIG_KUNIT=y and a new .kunitconfig file must be created with CONFIG_STATS_FS=y and CONFIG_STATS_FS_TEST=y It looks like CONFIG_STATS_FS is built-in, but it exports much of the functionality you are testing. However could the tests also be

Re: [PATCH v3 0/7] Statsfs: a new ram-based file system for Linux kernel statistics

2020-05-27 Thread Emanuele Giuseppe Esposito
The file system is mounted on /sys/kernel/stats and would be already used by kvm. Statsfs was initially introduced by Paolo Bonzini [1]. What's the direct motivation for this work? Moving KVM stats out of debugfs? There's many reasons: one of these is not using debugfs for statistics, but

Re: [PATCH v3 7/7] [not for merge] netstats: example use of stats_fs API

2020-05-26 Thread Emanuele Giuseppe Esposito
Hi Andrew How do you atomically get and display a group of statistics? If you look at how the netlink socket works, you will see code like: do { start = u64_stats_fetch_begin_irq(&cpu_stats->syncp); rx_packets = cpu_stats->rx

[PATCH v3 7/7] [not for merge] netstats: example use of stats_fs API

2020-05-26 Thread Emanuele Giuseppe Esposito
Apply stats_fs on the networking statistics subsystem. Currently it only works with disabled network namespace (CONFIG_NET_NS=n), because multiple namespaces will have the same device name under the same root source that will cause a conflict in stats_fs. Signed-off-by: Emanuele Giuseppe

[PATCH v3 6/7] [not for merge] kvm: example of stats_fs_value show function

2020-05-26 Thread Emanuele Giuseppe Esposito
the kvm//vcpu/mp_state file Signed-off-by: Emanuele Giuseppe Esposito --- arch/x86/kvm/stats_fs.c | 54 + 1 file changed, 54 insertions(+) diff --git a/arch/x86/kvm/stats_fs.c b/arch/x86/kvm/stats_fs.c index f6edebb9c559..902be18562da 100644 --- a/arch

[PATCH v3 5/7] kvm_main: replace debugfs with stats_fs

2020-05-26 Thread Emanuele Giuseppe Esposito
/debugfs/kvm is left for backward compatibility. Signed-off-by: Emanuele Giuseppe Esposito --- arch/arm64/kvm/Kconfig | 1 + arch/arm64/kvm/guest.c | 2 +- arch/mips/kvm/Kconfig | 1 + arch/mips/kvm/mips.c| 2 +- arch/powerpc/kvm/Kconfig| 1

[PATCH v3 4/7] stats_fs fs: virtual fs to show stats to the end-user

2020-05-26 Thread Emanuele Giuseppe Esposito
: Emanuele Giuseppe Esposito --- fs/stats_fs/Makefile | 2 +- fs/stats_fs/inode.c| 461 + fs/stats_fs/internal.h | 15 ++ fs/stats_fs/stats_fs.c | 92 +++- include/linux/stats_fs.h | 18 ++ include/uapi/linux/magic.h | 1 + tools

[PATCH v3 3/7] kunit: tests for stats_fs API

2020-05-26 Thread Emanuele Giuseppe Esposito
root directory of the linux kernel source tree: ./tools/testing/kunit/kunit.py run --timeout=30 --jobs=`nproc --all` Signed-off-by: Emanuele Giuseppe Esposito --- fs/Kconfig |6 + fs/stats_fs/Makefile |2 + fs/stats_fs/stats_fs-tests.c | 1097

[PATCH v3 2/7] documentation for stats_fs

2020-05-26 Thread Emanuele Giuseppe Esposito
Html docs for a complete documentation of the stats_fs API, filesystem and usage. Signed-off-by: Emanuele Giuseppe Esposito --- Documentation/filesystems/index.rst| 1 + Documentation/filesystems/stats_fs.rst | 222 + 2 files changed, 223 insertions(+) create mode

[PATCH v3 1/7] stats_fs API: create, add and remove stats_fs sources and values

2020-05-26 Thread Emanuele Giuseppe Esposito
former calling it when it needs to display and clear statistics, the latter to add values and sources. Signed-off-by: Emanuele Giuseppe Esposito --- MAINTAINERS | 7 + fs/Kconfig | 14 + fs/Makefile | 1 + fs/stats_fs/Makefile | 5 + fs/stats_fs

[PATCH v3 0/7] Statsfs: a new ram-based file system for Linux kernel statistics

2020-05-26 Thread Emanuele Giuseppe Esposito
ttps://lore.kernel.org/kvm/5d6cdcb1-d8ad-7ae6-7351-3544e2fa3...@redhat.com/?fbclid=IwAR18LHJ0PBcXcDaLzILFhHsl3qpT3z2vlG60RnqgbpGYhDv7L43n0ZXJY8M Signed-off-by: Emanuele Giuseppe Esposito v2 -> v3 move kconfig entry in the pseudo filesystem menu, add documentation, get/clear function for value ty

Re: [PATCH v2 0/5] Statsfs: a new ram-based file sytem for Linux kernel statistics

2020-05-11 Thread Emanuele Giuseppe Esposito
On 5/8/20 11:44 AM, Paolo Bonzini wrote: > So in general I'd say the sources/values model holds up. We certainly > want to: > > - switch immediately to callbacks instead of the type constants (so that > core statsfs code only does signed/unsigned) > > - add a field to distinguish cumulative an

Re: [PATCH v2 0/5] Statsfs: a new ram-based file sytem for Linux kernel statistics

2020-05-05 Thread Emanuele Giuseppe Esposito
On 5/4/20 11:37 PM, David Rientjes wrote: On Mon, 4 May 2020, Emanuele Giuseppe Esposito wrote: In this patch series I introduce statsfs, a synthetic ram-based virtual filesystem that takes care of gathering and displaying statistics for the Linux kernel subsystems. This is exciting, we

[PATCH v2 5/5] kvm_main: replace debugfs with stats_fs

2020-05-04 Thread Emanuele Giuseppe Esposito
/debugfs/kvm is left for backward compatibility. Signed-off-by: Emanuele Giuseppe Esposito --- arch/arm64/kvm/Kconfig | 1 + arch/arm64/kvm/guest.c | 2 +- arch/mips/kvm/Kconfig | 1 + arch/mips/kvm/mips.c| 2 +- arch/powerpc/kvm/Kconfig| 1

[PATCH v2 4/5] stats_fs fs: virtual fs to show stats to the end-user

2020-05-04 Thread Emanuele Giuseppe Esposito
, with the exception that the API is only composed by stats_fs_create_file, stats_fs_create_dir and stats_fs_remove. Signed-off-by: Emanuele Giuseppe Esposito --- fs/stats_fs/Makefile | 2 +- fs/stats_fs/inode.c| 337 + fs/stats_fs/internal.h

[PATCH v2 3/5] kunit: tests for stats_fs API

2020-05-04 Thread Emanuele Giuseppe Esposito
root directory of the linux kernel source tree: ./tools/testing/kunit/kunit.py run --timeout=30 --jobs=`nproc --all` Signed-off-by: Emanuele Giuseppe Esposito --- fs/Kconfig |6 + fs/stats_fs/Makefile |2 + fs/stats_fs/stats_fs-tests.c | 1088

[PATCH v2 0/5] Statsfs: a new ram-based file sytem for Linux kernel statistics

2020-05-04 Thread Emanuele Giuseppe Esposito
FhHsl3qpT3z2vlG60RnqgbpGYhDv7L43n0ZXJY8M Signed-off-by: Emanuele Giuseppe Esposito v1->v2 remove unnecessary list_foreach_safe loops, fix wrong indentation, change statsfs in stats_fs Emanuele Giuseppe Esposito (5): refcount, kref: add dec-and-test wrappers for rw_semaphores stats_fs API:

[PATCH v2 2/5] stats_fs API: create, add and remove stats_fs sources and values

2020-05-04 Thread Emanuele Giuseppe Esposito
by a virtual file system in patch 4. Its usage will be shared between the stats_fs file system and the end-users like kvm, the former calling it when it needs to display and clear statistics, the latter to add values and sources. Signed-off-by: Emanuele Giuseppe Esposito --- MAINTAINERS

[PATCH v2 1/5] refcount, kref: add dec-and-test wrappers for rw_semaphores

2020-05-04 Thread Emanuele Giuseppe Esposito
stats_fs_source data structures, which are protected by an rw_semaphore to allow concurrent sysfs reads. Signed-off-by: Emanuele Giuseppe Esposito --- include/linux/kref.h | 11 +++ include/linux/refcount.h | 2 ++ lib/refcount.c | 32 3 files

[PATCH v2 7/7] tracefs: switch to simplefs inode creation API

2020-04-21 Thread Emanuele Giuseppe Esposito
There is no semantic change intended; the code in the libfs.c functions in fact was derived from debugfs and tracefs code. Signed-off-by: Emanuele Giuseppe Esposito --- fs/tracefs/inode.c | 86 -- 1 file changed, 7 insertions(+), 79 deletions(-) diff

[PATCH v2 6/7] debugfs: switch to simplefs inode creation API

2020-04-21 Thread Emanuele Giuseppe Esposito
The only difference, compared to the pre-existing code, is that symlink creation now triggers fsnotify_create. This was a bug in the debugfs code, since for example vfs_symlink does call fsnotify_create. Signed-off-by: Emanuele Giuseppe Esposito --- fs/debugfs/inode.c | 144

[PATCH v2 5/7] libfs: add file creation functions

2020-04-21 Thread Emanuele Giuseppe Esposito
parameter to the creation functions, but pushes all error recovery into fs/libfs.c. Signed-off-by: Emanuele Giuseppe Esposito --- fs/libfs.c | 226 + include/linux/fs.h | 18 2 files changed, 244 insertions(+) diff --git a/fs/libfs.c b/fs

[PATCH v2 4/7] libfs: add alloc_anon_inode wrapper

2020-04-21 Thread Emanuele Giuseppe Esposito
libfs.c has many functions that are useful to implement dentry and inode operations, but not many at the filesystem level. Start adding file creation wrappers, the simplest returns an anonymous inode. There is no functional change intended. Signed-off-by: Emanuele Giuseppe Esposito --- drivers

[PATCH v2 3/7] libfs: introduce new_inode_current_time

2020-04-21 Thread Emanuele Giuseppe Esposito
It is a common special case for new_inode to initialize the time to the current time and the inode to get_next_ino(). Introduce a core function that does it. Signed-off-by: Emanuele Giuseppe Esposito --- fs/libfs.c | 20 include/linux/fs.h | 1 + 2 files changed

[PATCH v2 2/7] libfs: wrap simple_pin_fs/simple_release_fs arguments in a struct

2020-04-21 Thread Emanuele Giuseppe Esposito
Simplify passing the count and mount to simple_pin_fs and simple_release_fs by wrapping them in the simple_fs struct, in preparation for adding more high level operations to fs/libfs.c There is no functional change intended. Signed-off-by: Emanuele Giuseppe Esposito --- drivers/gpu/drm

[PATCH v2 1/7] apparmor: just use vfs_kern_mount to make .null

2020-04-21 Thread Emanuele Giuseppe Esposito
0 on entry and on exit). There is no functional change intended. Signed-off-by: Emanuele Giuseppe Esposito --- security/apparmor/apparmorfs.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c index

[PATCH v2 0/7] libfs: group and simplify linux fs code

2020-04-21 Thread Emanuele Giuseppe Esposito
duces the dentry and inode creation functions. Patch 6-7 can then adopt them in debugfs and tracefs. Signed-off-by: Emanuele Giuseppe Esposito v1->v2: rename simple_new_inode in new_inode_current_time, more detailed explanations, put all common code in fs/libfs.c Emanuele Giuseppe Esposito (7

Re: [PATCH 2/8] fs: extract simple_pin/release_fs to separate files

2020-04-21 Thread Emanuele Giuseppe Esposito
On 4/21/20 1:19 PM, Frederic Barrat wrote: diff --git a/drivers/misc/cxl/Kconfig b/drivers/misc/cxl/Kconfig index 39eec9031487..a62795079d9c 100644 --- a/drivers/misc/cxl/Kconfig +++ b/drivers/misc/cxl/Kconfig @@ -19,6 +19,7 @@ config CXL   select CXL_BASE   select CXL_AFU_DRIVER_OP

Re: [PATCH 0/8] Simplefs: group and simplify linux fs code

2020-04-20 Thread Emanuele Giuseppe Esposito
On 4/16/20 8:59 AM, Luis Chamberlain wrote: On Tue, Apr 14, 2020 at 02:42:54PM +0200, Emanuele Giuseppe Esposito wrote: This series of patches introduce wrappers for functions, arguments simplification in functions calls and most importantly groups duplicated code in a single header

Re: [PATCH 1/8] apparmor: just use vfs_kern_mount to make .null

2020-04-20 Thread Emanuele Giuseppe Esposito
On 4/16/20 8:44 AM, Luis Chamberlain wrote: On Tue, Apr 14, 2020 at 02:42:55PM +0200, Emanuele Giuseppe Esposito wrote: aa_mk_null_file is using simple_pin_fs/simple_release_fs with local variables as arguments, for what would amount to a simple vfs_kern_mount/mntput pair if everything was

Re: [PATCH 4/8] fs: introduce simple_new_inode

2020-04-20 Thread Emanuele Giuseppe Esposito
On 4/14/20 3:01 PM, Greg Kroah-Hartman wrote: On Tue, Apr 14, 2020 at 02:42:58PM +0200, Emanuele Giuseppe Esposito wrote: It is a common special case for new_inode to initialize the time to the current time and the inode to get_next_ino(). Introduce a core function that does it and use it

Re: [PATCH 6/8] simplefs: add file creation functions

2020-04-20 Thread Emanuele Giuseppe Esposito
On 4/14/20 2:56 PM, Greg Kroah-Hartman wrote: On Tue, Apr 14, 2020 at 02:43:00PM +0200, Emanuele Giuseppe Esposito wrote: A bunch of code is duplicated between debugfs and tracefs, unify it to the simplefs library. The code is very similar, except that dentry and inode creation are unified

Re: [PATCH] kvm_host: unify VM_STAT and VCPU_STAT definitions in a single place

2020-04-14 Thread Emanuele Giuseppe Esposito
On 4/14/20 10:18 AM, Paolo Bonzini wrote: On 13/04/20 23:34, Philippe Mathieu-Daudé wrote: +#define VM_STAT(x, ...) offsetof(struct kvm, stat.x), KVM_STAT_VM, ## __VA_ARGS__ +#define VCPU_STAT(x, ...) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU, ## __VA_ARGS__ I find this macro expand

[PATCH 8/8] tracefs: switch to simplefs inode creation API

2020-04-14 Thread Emanuele Giuseppe Esposito
There is no semantic change intended; the code in the simplefs.c functions in fact was derived from debugfs and tracefs code. Signed-off-by: Emanuele Giuseppe Esposito --- fs/tracefs/inode.c | 86 -- 1 file changed, 7 insertions(+), 79 deletions

[PATCH 7/8] debugfs: switch to simplefs inode creation API

2020-04-14 Thread Emanuele Giuseppe Esposito
The only difference, compared to the pre-existing code, is that symlink creation now triggers fsnotify_create. This was a bug in the debugfs code, since for example vfs_symlink does call fsnotify_create. Signed-off-by: Emanuele Giuseppe Esposito --- fs/debugfs/inode.c | 144

[PATCH 6/8] simplefs: add file creation functions

2020-04-14 Thread Emanuele Giuseppe Esposito
parameter to the creation functions, but pushes all error recovery into fs/simplefs.c. Signed-off-by: Emanuele Giuseppe Esposito --- fs/simplefs.c| 150 +++ include/linux/simplefs.h | 19 + 2 files changed, 169 insertions(+) diff --git a/fs

[PATCH 5/8] simplefs: add alloc_anon_inode wrapper

2020-04-14 Thread Emanuele Giuseppe Esposito
Start adding file creation wrappers, the simplest returns an anonymous inode. Signed-off-by: Emanuele Giuseppe Esposito --- drivers/gpu/drm/drm_drv.c | 2 +- drivers/misc/cxl/api.c | 2 +- drivers/scsi/cxlflash/ocxl_hw.c | 2 +- fs/simplefs.c | 6 ++ include

[PATCH 4/8] fs: introduce simple_new_inode

2020-04-14 Thread Emanuele Giuseppe Esposito
It is a common special case for new_inode to initialize the time to the current time and the inode to get_next_ino(). Introduce a core function that does it and use it throughout Linux. Signed-off-by: Emanuele Giuseppe Esposito --- arch/powerpc/platforms/cell/spufs/inode.c | 4 +--- arch/s390

[PATCH 3/8] fs: wrap simple_pin_fs/simple_release_fs arguments in a struct

2020-04-14 Thread Emanuele Giuseppe Esposito
Simplify passing the count and mount to simple_pin_fs and simple_release_fs, in preparation for adding more high level operations to the simplefs API. Signed-off-by: Emanuele Giuseppe Esposito --- drivers/gpu/drm/drm_drv.c | 11 +-- drivers/misc/cxl/api.c | 13

[PATCH 2/8] fs: extract simple_pin/release_fs to separate files

2020-04-14 Thread Emanuele Giuseppe Esposito
We will augment this family of functions with inode management. To avoid littering include/linux/fs.h and fs/libfs.c, move them to a separate header, with a Kconfig symbol to enable them. Signed-off-by: Emanuele Giuseppe Esposito --- drivers/gpu/drm/Kconfig | 1 + drivers/gpu/drm

[PATCH 1/8] apparmor: just use vfs_kern_mount to make .null

2020-04-14 Thread Emanuele Giuseppe Esposito
aa_mk_null_file is using simple_pin_fs/simple_release_fs with local variables as arguments, for what would amount to a simple vfs_kern_mount/mntput pair if everything was inlined. Just use the normal filesystem API since the reference counting is not needed here. Signed-off-by: Emanuele Giuseppe

[PATCH 0/8] Simplefs: group and simplify linux fs code

2020-04-14 Thread Emanuele Giuseppe Esposito
This series of patches introduce wrappers for functions, arguments simplification in functions calls and most importantly groups duplicated code in a single header, simplefs, to avoid redundancy in the linux fs, especially debugfs and tracefs. Signed-off-by: Emanuele Giuseppe Esposito Emanuele

[PATCH] kvm_host: unify VM_STAT and VCPU_STAT definitions in a single place

2020-04-13 Thread Emanuele Giuseppe Esposito
: Emanuele Giuseppe Esposito --- arch/arm64/kvm/guest.c| 23 +++ arch/mips/kvm/mips.c | 61 +++ arch/powerpc/kvm/book3s.c | 3 -- arch/powerpc/kvm/booke.c | 3 -- arch/s390/kvm/kvm-s390.c | 3 -- arch/x86/kvm/x86.c| 3