* [PATCH RESEND v3 0/2] Introduce tracepoint for hugetlbfs
@ 2024-08-29 6:41 Hongbo Li
2024-08-29 6:41 ` [PATCH RESEND v3 1/2] hugetlbfs: support tracepoint Hongbo Li
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Hongbo Li @ 2024-08-29 6:41 UTC (permalink / raw)
To: muchun.song, rostedt, mhiramat, mathieu.desnoyers, linux-mm,
david
Cc: linux-trace-kernel, linux-fsdevel, lihongbo22
Here we add some basic tracepoints for debugging hugetlbfs: {alloc, free,
evict}_inode, setattr and fallocate.
v2 can be found at:
https://lore.kernel.org/all/ZoYY-sfj5jvs8UpQ@casper.infradead.org/T/
Changes since v2:
- Simplify the tracepoint output for setattr.
- Make every token be space separated.
v1 can be found at:
https://lore.kernel.org/linux-mm/20240701194906.3a9b6765@gandalf.local.home/T/
Changes since v1:
- Decrease the parameters for setattr tracer suggested by Steve and Mathieu.
- Replace current_user_ns() with init_user_ns when translate uid/gid.
Hongbo Li (2):
hugetlbfs: support tracepoint
hugetlbfs: use tracepoints in hugetlbfs functions.
MAINTAINERS | 1 +
fs/hugetlbfs/inode.c | 17 +++-
include/trace/events/hugetlbfs.h | 156 +++++++++++++++++++++++++++++++
3 files changed, 172 insertions(+), 2 deletions(-)
create mode 100644 include/trace/events/hugetlbfs.h
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH RESEND v3 1/2] hugetlbfs: support tracepoint
2024-08-29 6:41 [PATCH RESEND v3 0/2] Introduce tracepoint for hugetlbfs Hongbo Li
@ 2024-08-29 6:41 ` Hongbo Li
2024-09-03 19:56 ` Steven Rostedt
2024-08-29 6:41 ` [PATCH RESEND v3 2/2] hugetlbfs: use tracepoints in hugetlbfs functions Hongbo Li
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Hongbo Li @ 2024-08-29 6:41 UTC (permalink / raw)
To: muchun.song, rostedt, mhiramat, mathieu.desnoyers, linux-mm,
david
Cc: linux-trace-kernel, linux-fsdevel, lihongbo22
Add basic tracepoints for {alloc, evict, free}_inode, setattr and
fallocate. These can help users to debug hugetlbfs more conveniently.
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
MAINTAINERS | 1 +
include/trace/events/hugetlbfs.h | 156 +++++++++++++++++++++++++++++++
2 files changed, 157 insertions(+)
create mode 100644 include/trace/events/hugetlbfs.h
diff --git a/MAINTAINERS b/MAINTAINERS
index a70b7c9c3533..f7d90c090961 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10367,6 +10367,7 @@ F: Documentation/mm/hugetlbfs_reserv.rst
F: Documentation/mm/vmemmap_dedup.rst
F: fs/hugetlbfs/
F: include/linux/hugetlb.h
+F: include/trace/events/hugetlbfs.h
F: mm/hugetlb.c
F: mm/hugetlb_vmemmap.c
F: mm/hugetlb_vmemmap.h
diff --git a/include/trace/events/hugetlbfs.h b/include/trace/events/hugetlbfs.h
new file mode 100644
index 000000000000..8331c904a9ba
--- /dev/null
+++ b/include/trace/events/hugetlbfs.h
@@ -0,0 +1,156 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM hugetlbfs
+
+#if !defined(_TRACE_HUGETLBFS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_HUGETLBFS_H
+
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(hugetlbfs_alloc_inode,
+
+ TP_PROTO(struct inode *inode, struct inode *dir, int mode),
+
+ TP_ARGS(inode, dir, mode),
+
+ TP_STRUCT__entry(
+ __field(dev_t, dev)
+ __field(ino_t, ino)
+ __field(ino_t, dir)
+ __field(__u16, mode)
+ ),
+
+ TP_fast_assign(
+ __entry->dev = inode->i_sb->s_dev;
+ __entry->ino = inode->i_ino;
+ __entry->dir = dir->i_ino;
+ __entry->mode = mode;
+ ),
+
+ TP_printk("dev %d,%d ino %lu dir %lu mode 0%o",
+ MAJOR(__entry->dev), MINOR(__entry->dev),
+ (unsigned long) __entry->ino,
+ (unsigned long) __entry->dir, __entry->mode)
+);
+
+DECLARE_EVENT_CLASS(hugetlbfs__inode,
+
+ TP_PROTO(struct inode *inode),
+
+ TP_ARGS(inode),
+
+ TP_STRUCT__entry(
+ __field(dev_t, dev)
+ __field(ino_t, ino)
+ __field(__u16, mode)
+ __field(loff_t, size)
+ __field(unsigned int, nlink)
+ __field(unsigned int, seals)
+ __field(blkcnt_t, blocks)
+ ),
+
+ TP_fast_assign(
+ __entry->dev = inode->i_sb->s_dev;
+ __entry->ino = inode->i_ino;
+ __entry->mode = inode->i_mode;
+ __entry->size = inode->i_size;
+ __entry->nlink = inode->i_nlink;
+ __entry->seals = HUGETLBFS_I(inode)->seals;
+ __entry->blocks = inode->i_blocks;
+ ),
+
+ TP_printk("dev %d,%d ino %lu mode 0%o size %lld nlink %u seals %u blocks %llu",
+ MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long) __entry->ino,
+ __entry->mode, __entry->size, __entry->nlink, __entry->seals,
+ (unsigned long long)__entry->blocks)
+);
+
+DEFINE_EVENT(hugetlbfs__inode, hugetlbfs_evict_inode,
+
+ TP_PROTO(struct inode *inode),
+
+ TP_ARGS(inode)
+);
+
+DEFINE_EVENT(hugetlbfs__inode, hugetlbfs_free_inode,
+
+ TP_PROTO(struct inode *inode),
+
+ TP_ARGS(inode)
+);
+
+TRACE_EVENT(hugetlbfs_setattr,
+
+ TP_PROTO(struct inode *inode, struct dentry *dentry,
+ struct iattr *attr),
+
+ TP_ARGS(inode, dentry, attr),
+
+ TP_STRUCT__entry(
+ __field(dev_t, dev)
+ __field(ino_t, ino)
+ __field(unsigned int, d_len)
+ __string(d_name, dentry->d_name.name)
+ __field(unsigned int, ia_valid)
+ __field(unsigned int, ia_mode)
+ __field(loff_t, old_size)
+ __field(loff_t, ia_size)
+ ),
+
+ TP_fast_assign(
+ __entry->dev = inode->i_sb->s_dev;
+ __entry->ino = inode->i_ino;
+ __entry->d_len = dentry->d_name.len;
+ __assign_str(d_name);
+ __entry->ia_valid = attr->ia_valid;
+ __entry->ia_mode = attr->ia_mode;
+ __entry->old_size = inode->i_size;
+ __entry->ia_size = attr->ia_size;
+ ),
+
+ TP_printk("dev %d,%d ino %lu name %.*s valid %#x mode 0%o old_size %lld size %lld",
+ MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long)__entry->ino,
+ __entry->d_len, __get_str(d_name), __entry->ia_valid, __entry->ia_mode,
+ __entry->old_size, __entry->ia_size)
+);
+
+TRACE_EVENT(hugetlbfs_fallocate,
+
+ TP_PROTO(struct inode *inode, int mode,
+ loff_t offset, loff_t len, int ret),
+
+ TP_ARGS(inode, mode, offset, len, ret),
+
+ TP_STRUCT__entry(
+ __field(dev_t, dev)
+ __field(ino_t, ino)
+ __field(int, mode)
+ __field(loff_t, offset)
+ __field(loff_t, len)
+ __field(loff_t, size)
+ __field(int, ret)
+ ),
+
+ TP_fast_assign(
+ __entry->dev = inode->i_sb->s_dev;
+ __entry->ino = inode->i_ino;
+ __entry->mode = mode;
+ __entry->offset = offset;
+ __entry->len = len;
+ __entry->size = inode->i_size;
+ __entry->ret = ret;
+ ),
+
+ TP_printk("dev %d,%d ino %lu mode 0%o offset %lld len %lld size %lld ret %d",
+ MAJOR(__entry->dev), MINOR(__entry->dev),
+ (unsigned long)__entry->ino, __entry->mode,
+ (unsigned long long)__entry->offset,
+ (unsigned long long)__entry->len,
+ (unsigned long long)__entry->size,
+ __entry->ret)
+);
+
+#endif /* _TRACE_HUGETLBFS_H */
+
+ /* This part must be outside protection */
+#include <trace/define_trace.h>
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH RESEND v3 2/2] hugetlbfs: use tracepoints in hugetlbfs functions.
2024-08-29 6:41 [PATCH RESEND v3 0/2] Introduce tracepoint for hugetlbfs Hongbo Li
2024-08-29 6:41 ` [PATCH RESEND v3 1/2] hugetlbfs: support tracepoint Hongbo Li
@ 2024-08-29 6:41 ` Hongbo Li
2024-09-14 8:09 ` [PATCH RESEND v3 0/2] Introduce tracepoint for hugetlbfs Hongbo Li
2024-09-17 9:08 ` Christian Brauner
3 siblings, 0 replies; 7+ messages in thread
From: Hongbo Li @ 2024-08-29 6:41 UTC (permalink / raw)
To: muchun.song, rostedt, mhiramat, mathieu.desnoyers, linux-mm,
david
Cc: linux-trace-kernel, linux-fsdevel, lihongbo22
Here we use the hugetlbfs tracepoint to track the call stack. And
the output in trace is as follows:
```
touch-5265 [005] ..... 43.246550: hugetlbfs_alloc_inode: dev 0,51 ino 24621 dir 21959 mode 0100644
touch-5265 [005] ..... 43.246638: hugetlbfs_setattr: dev 0,51 ino 24621 name testfile valid 0x20070 mode 0177777 old_size 0 size -51622648042749952
truncate-5266 [005] ..... 45.590890: hugetlbfs_setattr: dev 0,51 ino 24621 name testfile valid 0x2068 mode 00 old_size 0 size 2097152
rm-5273 [007] ..... 110.052783: hugetlbfs_evict_inode: dev 0,51 ino 24621 mode 0100644 size 2097152 nlink 0 seals 1 blocks 0
<idle>-0 [007] ..s1. 110.059441: hugetlbfs_free_inode: dev 0,51 ino 24621 mode 0100644 size 2097152 nlink 0 seals 1 blocks 0
```
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
fs/hugetlbfs/inode.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 9f6cff356796..1689c01a11a0 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -39,6 +39,9 @@
#include <linux/uaccess.h>
#include <linux/sched/mm.h>
+#define CREATE_TRACE_POINTS
+#include <trace/events/hugetlbfs.h>
+
static const struct address_space_operations hugetlbfs_aops;
static const struct file_operations hugetlbfs_file_operations;
static const struct inode_operations hugetlbfs_dir_inode_operations;
@@ -687,6 +690,7 @@ static void hugetlbfs_evict_inode(struct inode *inode)
{
struct resv_map *resv_map;
+ trace_hugetlbfs_evict_inode(inode);
remove_inode_hugepages(inode, 0, LLONG_MAX);
/*
@@ -814,8 +818,10 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
return -EOPNOTSUPP;
- if (mode & FALLOC_FL_PUNCH_HOLE)
- return hugetlbfs_punch_hole(inode, offset, len);
+ if (mode & FALLOC_FL_PUNCH_HOLE) {
+ error = hugetlbfs_punch_hole(inode, offset, len);
+ goto out_nolock;
+ }
/*
* Default preallocate case.
@@ -919,6 +925,9 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
inode_set_ctime_current(inode);
out:
inode_unlock(inode);
+
+out_nolock:
+ trace_hugetlbfs_fallocate(inode, mode, offset, len, error);
return error;
}
@@ -935,6 +944,8 @@ static int hugetlbfs_setattr(struct mnt_idmap *idmap,
if (error)
return error;
+ trace_hugetlbfs_setattr(inode, dentry, attr);
+
if (ia_valid & ATTR_SIZE) {
loff_t oldsize = inode->i_size;
loff_t newsize = attr->ia_size;
@@ -1033,6 +1044,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb,
break;
}
lockdep_annotate_inode_mutex_key(inode);
+ trace_hugetlbfs_alloc_inode(inode, dir, mode);
} else {
if (resv_map)
kref_put(&resv_map->refs, resv_map_release);
@@ -1272,6 +1284,7 @@ static struct inode *hugetlbfs_alloc_inode(struct super_block *sb)
static void hugetlbfs_free_inode(struct inode *inode)
{
+ trace_hugetlbfs_free_inode(inode);
kmem_cache_free(hugetlbfs_inode_cachep, HUGETLBFS_I(inode));
}
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH RESEND v3 1/2] hugetlbfs: support tracepoint
2024-08-29 6:41 ` [PATCH RESEND v3 1/2] hugetlbfs: support tracepoint Hongbo Li
@ 2024-09-03 19:56 ` Steven Rostedt
2024-09-07 7:57 ` Hongbo Li
0 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2024-09-03 19:56 UTC (permalink / raw)
To: Hongbo Li
Cc: muchun.song, mhiramat, mathieu.desnoyers, linux-mm, david,
linux-trace-kernel, linux-fsdevel
On Thu, 29 Aug 2024 14:41:09 +0800
Hongbo Li <lihongbo22@huawei.com> wrote:
> Add basic tracepoints for {alloc, evict, free}_inode, setattr and
> fallocate. These can help users to debug hugetlbfs more conveniently.
>
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
Pretty basic trace events.
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-- Steve
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RESEND v3 1/2] hugetlbfs: support tracepoint
2024-09-03 19:56 ` Steven Rostedt
@ 2024-09-07 7:57 ` Hongbo Li
0 siblings, 0 replies; 7+ messages in thread
From: Hongbo Li @ 2024-09-07 7:57 UTC (permalink / raw)
To: Steven Rostedt
Cc: muchun.song, mhiramat, mathieu.desnoyers, linux-mm, david,
linux-trace-kernel, linux-fsdevel, songmuchun
On 2024/9/4 3:56, Steven Rostedt wrote:
> On Thu, 29 Aug 2024 14:41:09 +0800
> Hongbo Li <lihongbo22@huawei.com> wrote:
>
>> Add basic tracepoints for {alloc, evict, free}_inode, setattr and
>> fallocate. These can help users to debug hugetlbfs more conveniently.
>>
>> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
>
> Pretty basic trace events.
yeah, very basic. Thanks for reviewing!😄
Thanks,
Hongbo
>
> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
>
> -- Steve
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RESEND v3 0/2] Introduce tracepoint for hugetlbfs
2024-08-29 6:41 [PATCH RESEND v3 0/2] Introduce tracepoint for hugetlbfs Hongbo Li
2024-08-29 6:41 ` [PATCH RESEND v3 1/2] hugetlbfs: support tracepoint Hongbo Li
2024-08-29 6:41 ` [PATCH RESEND v3 2/2] hugetlbfs: use tracepoints in hugetlbfs functions Hongbo Li
@ 2024-09-14 8:09 ` Hongbo Li
2024-09-17 9:08 ` Christian Brauner
3 siblings, 0 replies; 7+ messages in thread
From: Hongbo Li @ 2024-09-14 8:09 UTC (permalink / raw)
To: muchun.song, rostedt, mhiramat, mathieu.desnoyers, linux-mm,
david, songmuchun
Cc: linux-trace-kernel, linux-fsdevel
Hi,
Just a gently ping for this. Does this patch have a change of making it
into this cycle?
Thanks,
Hongbo
On 2024/8/29 14:41, Hongbo Li wrote:
> Here we add some basic tracepoints for debugging hugetlbfs: {alloc, free,
> evict}_inode, setattr and fallocate.
>
> v2 can be found at:
> https://lore.kernel.org/all/ZoYY-sfj5jvs8UpQ@casper.infradead.org/T/
>
> Changes since v2:
> - Simplify the tracepoint output for setattr.
> - Make every token be space separated.
>
>
> v1 can be found at:
> https://lore.kernel.org/linux-mm/20240701194906.3a9b6765@gandalf.local.home/T/
>
> Changes since v1:
> - Decrease the parameters for setattr tracer suggested by Steve and Mathieu.
> - Replace current_user_ns() with init_user_ns when translate uid/gid.
>
> Hongbo Li (2):
> hugetlbfs: support tracepoint
> hugetlbfs: use tracepoints in hugetlbfs functions.
>
> MAINTAINERS | 1 +
> fs/hugetlbfs/inode.c | 17 +++-
> include/trace/events/hugetlbfs.h | 156 +++++++++++++++++++++++++++++++
> 3 files changed, 172 insertions(+), 2 deletions(-)
> create mode 100644 include/trace/events/hugetlbfs.h
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RESEND v3 0/2] Introduce tracepoint for hugetlbfs
2024-08-29 6:41 [PATCH RESEND v3 0/2] Introduce tracepoint for hugetlbfs Hongbo Li
` (2 preceding siblings ...)
2024-09-14 8:09 ` [PATCH RESEND v3 0/2] Introduce tracepoint for hugetlbfs Hongbo Li
@ 2024-09-17 9:08 ` Christian Brauner
3 siblings, 0 replies; 7+ messages in thread
From: Christian Brauner @ 2024-09-17 9:08 UTC (permalink / raw)
To: muchun.song, rostedt, mhiramat, mathieu.desnoyers, linux-mm,
david, Hongbo Li
Cc: Christian Brauner, linux-trace-kernel, linux-fsdevel
On Thu, 29 Aug 2024 14:41:08 +0800, Hongbo Li wrote:
> Here we add some basic tracepoints for debugging hugetlbfs: {alloc, free,
> evict}_inode, setattr and fallocate.
>
> v2 can be found at:
> https://lore.kernel.org/all/ZoYY-sfj5jvs8UpQ@casper.infradead.org/T/
>
> Changes since v2:
> - Simplify the tracepoint output for setattr.
> - Make every token be space separated.
>
> [...]
Applied to the vfs.misc.v6.13 branch of the vfs/vfs.git tree.
Patches in the vfs.misc.v6.13 branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.misc.v6.13
[1/2] hugetlbfs: support tracepoint
https://git.kernel.org/vfs/vfs/c/318580ad7f28
[2/2] hugetlbfs: use tracepoints in hugetlbfs functions.
https://git.kernel.org/vfs/vfs/c/014ad7c42a69
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-09-17 9:08 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-29 6:41 [PATCH RESEND v3 0/2] Introduce tracepoint for hugetlbfs Hongbo Li
2024-08-29 6:41 ` [PATCH RESEND v3 1/2] hugetlbfs: support tracepoint Hongbo Li
2024-09-03 19:56 ` Steven Rostedt
2024-09-07 7:57 ` Hongbo Li
2024-08-29 6:41 ` [PATCH RESEND v3 2/2] hugetlbfs: use tracepoints in hugetlbfs functions Hongbo Li
2024-09-14 8:09 ` [PATCH RESEND v3 0/2] Introduce tracepoint for hugetlbfs Hongbo Li
2024-09-17 9:08 ` Christian Brauner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).