public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: cgel.zte@gmail.com
Cc: pbonzini@redhat.com, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	ye xingchen <ye.xingchen@zte.com.cn>,
	Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH linux-next] KVM:define vcpu_get_pid_fops with DEFINE_DEBUGFS_ATTRIBUTE
Date: Thu, 8 Sep 2022 17:39:32 +0000	[thread overview]
Message-ID: <Yxoo1A2fmlAWruyV@google.com> (raw)
In-Reply-To: <20220815031228.64126-1-ye.xingchen@zte.com.cn>

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.

      reply	other threads:[~2022-09-08 17:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yxoo1A2fmlAWruyV@google.com \
    --to=seanjc@google.com \
    --cc=cgel.zte@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=ye.xingchen@zte.com.cn \
    --cc=zealci@zte.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox