mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Bo Liu <liubo03@inspur.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: replace DEFINE_SIMPLE_ATTRIBUTE with DEFINE_DEBUGFS_ATTRIBUTE
Date: Wed, 2 Nov 2022 18:48:19 +0100	[thread overview]
Message-ID: <c0b98151-16b6-6d8f-1765-0f7d46682d60@redhat.com> (raw)
In-Reply-To: <20221101072506.7307-1-liubo03@inspur.com>

On 11/1/22 08:25, Bo Liu wrote:
> Fix the following coccicheck warning:
>    virt/kvm/kvm_main.c:3847:0-23: WARNING
>      vcpu_get_pid_fops should be defined with DEFINE_DEBUGFS_ATTRIBUTE
> 
> Signed-off-by: Bo Liu <liubo03@inspur.com>
> ---
>   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 f1df24c2bc84..3f383f27d3d7 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)
>   {

If you really wanted to do this, you would also have to replace 
debugfs_create_file with debugfs_create_file_unsafe.

However, this is not a good idea.  The rationale in the .cocci file is 
that "DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file() imposes some 
significant overhead", but this should not really be relevant for a 
debugfs file.

Such a patch would only make sense if there was a version of 
debugfs_create_file_unsafe() with a less-terrible name (e.g. 
debugfs_create_simple_attr?), which could _only_ be used with fops 
created by DEFINE_DEBUGFS_ATTRIBUTE.  Without such a type-safe trick, 
the .cocci file is only adding confusion to perfectly fine code.

Paolo


  reply	other threads:[~2022-11-02 17:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-01  7:25 Bo Liu
2022-11-02 17:48 ` Paolo Bonzini [this message]
2022-11-02 19:39   ` Sean Christopherson
  -- strict thread matches above, loose matches on Subject: below --
2021-02-01  8:38 [PATCH] KVM: Replace " Jiapeng Chong
2021-02-01  9:01 ` Paolo Bonzini

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=c0b98151-16b6-6d8f-1765-0f7d46682d60@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liubo03@inspur.com \
    /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

all inboxes | Powered by JetHome®