Skip to contentSkip to conversation

bpf: Define bpf_token_show_fdinfo with CONFIG_PROC_FS

PATCH In review Tao Chen 3 participants 4 messages Mar 18, 2025 BPF

lore
Share & tools
lore

Tao Chen

author
#0 lore raw

PATCH 1/1 bpf: Define bpf_token_show_fdinfo with CONFIG_PROC_FS

Protect bpf_token_show_fdinfo with CONFIG_PROC_FS check, follow the pattern used with other *_show_fdinfo functions.

Fixes 35f96de04127 ("bpf: Introduce BPF token object")
---
 kernel/bpf/token.c | 4 ++++
 1 file changed, 4 insertions(+)
kernel/bpf/token.c +4 -0
index 26057aa13..104ca37e9 100644
@@ -65,6 +65,7 @@ static int bpf_token_release(struct inode *inode, struct file *filp)
 	return 0;
 }
 
+#ifdef CONFIG_PROC_FS
 static void bpf_token_show_fdinfo(struct seq_file *m, struct file *filp)
 {
 	struct bpf_token *token = filp->private_data;
@@ -98,6 +99,7 @@ static void bpf_token_show_fdinfo(struct seq_file *m, struct file *filp)
 	else
 		seq_printf(m, "allowed_attachs:\t0x%llx\n", token->allowed_attachs);
 }
+#endif
 
 #define BPF_TOKEN_INODE_NAME "bpf-token"
 
@@ -105,7 +107,9 @@ static const struct inode_operations bpf_token_iops = { };
 
 static const struct file_operations bpf_token_fops = {
 	.release	= bpf_token_release,
+#ifdef CONFIG_PROC_FS
 	.show_fdinfo	= bpf_token_show_fdinfo,
+#endif
 };
 
 int bpf_token_create(union bpf_attr *attr)
Signature · 1 line
2.43.0
#1 lore raw
Quoted 30 lines · Tao Chen

Protect bpf_token_show_fdinfo with CONFIG_PROC_FS check, follow the pattern used with other *_show_fdinfo functions.

Fixes 35f96de04127 ("bpf: Introduce BPF token object")
---
 kernel/bpf/token.c | 4 ++++
 1 file changed, 4 insertions(+)
kernel/bpf/token.c +2 -0
index 26057aa13..104ca37e9 100644
@@ -65,6 +65,7 @@ static int bpf_token_release(struct inode *inode, struct file *filp)
 	return 0;
 }
 
+#ifdef CONFIG_PROC_FS
 static void bpf_token_show_fdinfo(struct seq_file *m, struct file *filp)
 {
 	struct bpf_token *token = filp->private_data;
@@ -98,6 +99,7 @@ static void bpf_token_show_fdinfo(struct seq_file *m, struct file *filp)
 	else
 		seq_printf(m, "allowed_attachs:\t0x%llx\n", token->allowed_attachs);
 }
+#endif
 
 #define BPF_TOKEN_INODE_NAME "bpf-token"
 

kernel/bpf/token.c static const struct inode_operations bpf_token_iops = { }; · line 112

Quoted 6 lines
kernel/bpf/token.c +2 -0
@@ -105,7 +107,9 @@ static const struct inode_operations bpf_token_iops = { };
 
 static const struct file_operations bpf_token_fops = {
 	.release	= bpf_token_release,
+#ifdef CONFIG_PROC_FS
 	.show_fdinfo	= bpf_token_show_fdinfo,
+#endif

there's many more of such cases.. I'm not sure if it makes sense to fix that, because it does not break the build and only save space for !CONFIG_PROC_FS kernels

jirka

Quoted 6 lines
kernel/bpf/token.c +0 -0
 };
 
 int bpf_token_create(union bpf_attr *attr)
Signature · 1 line
2.43.0
#2 lore raw
Quoted 33 lines · Jiri Olsa
Quoted 31 lines · Tao Chen

Protect bpf_token_show_fdinfo with CONFIG_PROC_FS check, follow the pattern used with other *_show_fdinfo functions.

Fixes 35f96de04127 ("bpf: Introduce BPF token object")
---
 kernel/bpf/token.c | 4 ++++
 1 file changed, 4 insertions(+)
kernel/bpf/token.c +2 -0
index 26057aa13..104ca37e9 100644
@@ -65,6 +65,7 @@ static int bpf_token_release(struct inode *inode, struct file *filp)
      return 0;
 }
 
+#ifdef CONFIG_PROC_FS
 static void bpf_token_show_fdinfo(struct seq_file *m, struct file *filp)
 {
      struct bpf_token *token = filp->private_data;
@@ -98,6 +99,7 @@ static void bpf_token_show_fdinfo(struct seq_file *m, struct file *filp)
      else
              seq_printf(m, "allowed_attachs:\t0x%llx\n", token->allowed_attachs);
 }
+#endif
 
 #define BPF_TOKEN_INODE_NAME "bpf-token"
 
@@ -105,7 +107,9 @@ static const struct inode_operations bpf_token_iops = { };
 
Quoted 9 lines

kernel/bpf/token.c static const struct inode_operations bpf_token_iops = { }; · line 112

Quoted 5 lines
kernel/bpf/token.c +2 -0
 static const struct file_operations bpf_token_fops = {
      .release        = bpf_token_release,
+#ifdef CONFIG_PROC_FS
      .show_fdinfo    = bpf_token_show_fdinfo,
+#endif

there's many more of such cases.. I'm not sure if it makes sense to fix that, because it does not break the build and only save space for !CONFIG_PROC_FS kernels

+1.
let's keep the code as-is.

pw-bot: cr

author
#3 lore raw
Quoted 44 lines · Alexei Starovoitov
Quoted 33 lines · Jiri Olsa
Quoted 31 lines · Tao Chen

Protect bpf_token_show_fdinfo with CONFIG_PROC_FS check, follow the pattern used with other *_show_fdinfo functions.

Fixes 35f96de04127 ("bpf: Introduce BPF token object")
---
  kernel/bpf/token.c | 4 ++++
  1 file changed, 4 insertions(+)
kernel/bpf/token.c +2 -0
index 26057aa13..104ca37e9 100644
@@ -65,6 +65,7 @@ static int bpf_token_release(struct inode *inode, struct file *filp)
       return 0;
  }
 
+#ifdef CONFIG_PROC_FS
  static void bpf_token_show_fdinfo(struct seq_file *m, struct file *filp)
  {
       struct bpf_token *token = filp->private_data;
@@ -98,6 +99,7 @@ static void bpf_token_show_fdinfo(struct seq_file *m, struct file *filp)
       else
               seq_printf(m, "allowed_attachs:\t0x%llx\n", token->allowed_attachs);
  }
+#endif
 
  #define BPF_TOKEN_INODE_NAME "bpf-token"
 
@@ -105,7 +107,9 @@ static const struct inode_operations bpf_token_iops = { };
 
Quoted 9 lines

kernel/bpf/token.c static const struct inode_operations bpf_token_iops = { }; · line 112

Quoted 5 lines
kernel/bpf/token.c +2 -0
  static const struct file_operations bpf_token_fops = {
       .release        = bpf_token_release,
+#ifdef CONFIG_PROC_FS
       .show_fdinfo    = bpf_token_show_fdinfo,
+#endif

there's many more of such cases.. I'm not sure if it makes sense to fix that, because it does not break the build and only save space for !CONFIG_PROC_FS kernels

Quoted 3 lines

+1.
let's keep the code as-is.

Got it, thanks anyway.

Quoted 1 line

pw-bot: cr

Signature · 2 lines
Best Regards
Tao Chen