public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux-next] KVM:define vcpu_get_pid_fops with DEFINE_DEBUGFS_ATTRIBUTE
@ 2022-08-15  3:12 cgel.zte
  2022-09-08 17:39 ` Sean Christopherson
  0 siblings, 1 reply; 2+ messages in thread
From: cgel.zte @ 2022-08-15  3:12 UTC (permalink / raw)
  To: pbonzini; +Cc: kvm, linux-kernel, ye xingchen, Zeal Robot

From: ye xingchen <ye.xingchen@zte.com.cn>

From the coccinelle check:
./virt/kvm/kvm_main.c line 3847
WARNING  vcpu_get_pid_fops should be defined with DEFINE_DEBUGFS_ATTRIBUTE

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
---
 virt/kvm/kvm_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 515dfe9d3bcf..a0817179f8e4 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -3844,7 +3844,7 @@ static int vcpu_get_pid(void *data, u64 *val)
 	return 0;
 }
 
-DEFINE_SIMPLE_ATTRIBUTE(vcpu_get_pid_fops, vcpu_get_pid, NULL, "%llu\n");
+DEFINE_DEBUGFS_ATTRIBUTE(vcpu_get_pid_fops, vcpu_get_pid, NULL, "%llu\n");
 
 static void kvm_create_vcpu_debugfs(struct kvm_vcpu *vcpu)
 {
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH linux-next] KVM:define vcpu_get_pid_fops with DEFINE_DEBUGFS_ATTRIBUTE
  2022-08-15  3:12 [PATCH linux-next] KVM:define vcpu_get_pid_fops with DEFINE_DEBUGFS_ATTRIBUTE cgel.zte
@ 2022-09-08 17:39 ` Sean Christopherson
  0 siblings, 0 replies; 2+ messages in thread
From: Sean Christopherson @ 2022-09-08 17:39 UTC (permalink / raw)
  To: cgel.zte; +Cc: pbonzini, kvm, linux-kernel, ye xingchen, Zeal Robot

On Mon, Aug 15, 2022, cgel.zte@gmail.com wrote:
> From: ye xingchen <ye.xingchen@zte.com.cn>
> 
> From the coccinelle check:
> ./virt/kvm/kvm_main.c line 3847
> WARNING  vcpu_get_pid_fops should be defined with DEFINE_DEBUGFS_ATTRIBUTE
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
> ---
>  virt/kvm/kvm_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 515dfe9d3bcf..a0817179f8e4 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -3844,7 +3844,7 @@ static int vcpu_get_pid(void *data, u64 *val)
>  	return 0;
>  }
>  
> -DEFINE_SIMPLE_ATTRIBUTE(vcpu_get_pid_fops, vcpu_get_pid, NULL, "%llu\n");
> +DEFINE_DEBUGFS_ATTRIBUTE(vcpu_get_pid_fops, vcpu_get_pid, NULL, "%llu\n");

Based on the comments in scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci,
it seems that using DEFINE_DEBUGFS_ATTRIBUTE is only beneficial if the file is
created with debugfs_create_file_unsafe().  IIUC, using DEFINE_DEBUGFS_ATTRIBUTE
without switching to debugfs_create_file_unsafe() will actually _add_ overhead.

	//# Rationale: DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file()
	//# imposes some significant overhead as compared to
	//# DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe().

Using DEFINE_DEBUGFS_ATTRIBUTE also effectively drops ->llseek() support.  I assume
that's not a problem?  But someone that knows how this is actually used should
chime in.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-08 17:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-15  3:12 [PATCH linux-next] KVM:define vcpu_get_pid_fops with DEFINE_DEBUGFS_ATTRIBUTE cgel.zte
2022-09-08 17:39 ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox