All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: [PATCH] KVM: nVMX: nSVM: fix debugfs_simple_attr.cocci warnings
Date: Fri, 13 Aug 2021 00:21:29 +0800	[thread overview]
Message-ID: <20210812162129.GA4690@eae47cd7be8b> (raw)
In-Reply-To: <202108130055.ZyE6Wm0v-lkp@intel.com>

[-- Attachment #1: Type: text/plain, Size: 5272 bytes --]

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Krish Sadhukhan <krish.sadhukhan@oracle.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Sean Christopherson <seanjc@google.com>
CC: Vitaly Kuznetsov <vkuznets@redhat.com>
CC: Wanpeng Li <wanpengli@tencent.com>
CC: Jim Mattson <jmattson@google.com>
CC: Joerg Roedel <joro@8bytes.org>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Ingo Molnar <mingo@redhat.com>
CC: Borislav Petkov <bp@alien8.de>

From: kernel test robot <lkp@intel.com>

arch/x86/kvm/debugfs.c:27:0-23: WARNING: vcpu_guest_mode_fops should be defined with DEFINE_DEBUGFS_ATTRIBUTE
arch/x86/kvm/debugfs.c:18:0-23: WARNING: vcpu_timer_advance_ns_fops should be defined with DEFINE_DEBUGFS_ATTRIBUTE
arch/x86/kvm/debugfs.c:36:0-23: WARNING: vcpu_tsc_offset_fops should be defined with DEFINE_DEBUGFS_ATTRIBUTE
arch/x86/kvm/debugfs.c:45:0-23: WARNING: vcpu_tsc_scaling_fops should be defined with DEFINE_DEBUGFS_ATTRIBUTE
arch/x86/kvm/debugfs.c:53:0-23: WARNING: vcpu_tsc_scaling_frac_fops should be defined with DEFINE_DEBUGFS_ATTRIBUTE

 Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE
 for debugfs files.

Semantic patch information:
 Rationale: DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file()
 imposes some significant overhead as compared to
 DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe().

Generated by: scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci

Fixes: d5a0483f9f32 ("KVM: nVMX: nSVM: Add a new VCPU statistic to show if VCPU is in guest mode")
CC: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: kernel test robot <lkp@intel.com>
---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   1746f4db513563bb22e0ba0c419d0c90912dfae1
commit: d5a0483f9f3250fe359224327ca1b4a29d106981 KVM: nVMX: nSVM: Add a new VCPU statistic to show if VCPU is in guest mode
:::::: branch date: 10 hours ago
:::::: commit date: 8 weeks ago

Please take the patch only if it's a positive warning. Thanks!

 debugfs.c |   41 +++++++++++++++++++++++------------------
 1 file changed, 23 insertions(+), 18 deletions(-)

--- a/arch/x86/kvm/debugfs.c
+++ b/arch/x86/kvm/debugfs.c
@@ -15,7 +15,8 @@ static int vcpu_get_timer_advance_ns(voi
 	return 0;
 }
 
-DEFINE_SIMPLE_ATTRIBUTE(vcpu_timer_advance_ns_fops, vcpu_get_timer_advance_ns, NULL, "%llu\n");
+DEFINE_DEBUGFS_ATTRIBUTE(vcpu_timer_advance_ns_fops,
+			 vcpu_get_timer_advance_ns, NULL, "%llu\n");
 
 static int vcpu_get_guest_mode(void *data, u64 *val)
 {
@@ -24,7 +25,8 @@ static int vcpu_get_guest_mode(void *dat
 	return 0;
 }
 
-DEFINE_SIMPLE_ATTRIBUTE(vcpu_guest_mode_fops, vcpu_get_guest_mode, NULL, "%lld\n");
+DEFINE_DEBUGFS_ATTRIBUTE(vcpu_guest_mode_fops, vcpu_get_guest_mode, NULL,
+			 "%lld\n");
 
 static int vcpu_get_tsc_offset(void *data, u64 *val)
 {
@@ -33,7 +35,8 @@ static int vcpu_get_tsc_offset(void *dat
 	return 0;
 }
 
-DEFINE_SIMPLE_ATTRIBUTE(vcpu_tsc_offset_fops, vcpu_get_tsc_offset, NULL, "%lld\n");
+DEFINE_DEBUGFS_ATTRIBUTE(vcpu_tsc_offset_fops, vcpu_get_tsc_offset, NULL,
+			 "%lld\n");
 
 static int vcpu_get_tsc_scaling_ratio(void *data, u64 *val)
 {
@@ -42,7 +45,8 @@ static int vcpu_get_tsc_scaling_ratio(vo
 	return 0;
 }
 
-DEFINE_SIMPLE_ATTRIBUTE(vcpu_tsc_scaling_fops, vcpu_get_tsc_scaling_ratio, NULL, "%llu\n");
+DEFINE_DEBUGFS_ATTRIBUTE(vcpu_tsc_scaling_fops, vcpu_get_tsc_scaling_ratio,
+			 NULL, "%llu\n");
 
 static int vcpu_get_tsc_scaling_frac_bits(void *data, u64 *val)
 {
@@ -50,26 +54,27 @@ static int vcpu_get_tsc_scaling_frac_bit
 	return 0;
 }
 
-DEFINE_SIMPLE_ATTRIBUTE(vcpu_tsc_scaling_frac_fops, vcpu_get_tsc_scaling_frac_bits, NULL, "%llu\n");
+DEFINE_DEBUGFS_ATTRIBUTE(vcpu_tsc_scaling_frac_fops,
+			 vcpu_get_tsc_scaling_frac_bits, NULL, "%llu\n");
 
 void kvm_arch_create_vcpu_debugfs(struct kvm_vcpu *vcpu, struct dentry *debugfs_dentry)
 {
-	debugfs_create_file("guest_mode", 0444, debugfs_dentry, vcpu,
-			    &vcpu_guest_mode_fops);
-	debugfs_create_file("tsc-offset", 0444, debugfs_dentry, vcpu,
-			    &vcpu_tsc_offset_fops);
+	debugfs_create_file_unsafe("guest_mode", 0444, debugfs_dentry, vcpu,
+				   &vcpu_guest_mode_fops);
+	debugfs_create_file_unsafe("tsc-offset", 0444, debugfs_dentry, vcpu,
+				   &vcpu_tsc_offset_fops);
 
 	if (lapic_in_kernel(vcpu))
-		debugfs_create_file("lapic_timer_advance_ns", 0444,
-				    debugfs_dentry, vcpu,
-				    &vcpu_timer_advance_ns_fops);
+		debugfs_create_file_unsafe("lapic_timer_advance_ns", 0444,
+					   debugfs_dentry, vcpu,
+					   &vcpu_timer_advance_ns_fops);
 
 	if (kvm_has_tsc_control) {
-		debugfs_create_file("tsc-scaling-ratio", 0444,
-				    debugfs_dentry, vcpu,
-				    &vcpu_tsc_scaling_fops);
-		debugfs_create_file("tsc-scaling-ratio-frac-bits", 0444,
-				    debugfs_dentry, vcpu,
-				    &vcpu_tsc_scaling_frac_fops);
+		debugfs_create_file_unsafe("tsc-scaling-ratio", 0444,
+					   debugfs_dentry, vcpu,
+					   &vcpu_tsc_scaling_fops);
+		debugfs_create_file_unsafe("tsc-scaling-ratio-frac-bits",
+					   0444, debugfs_dentry, vcpu,
+					   &vcpu_tsc_scaling_frac_fops);
 	}
 }

      reply	other threads:[~2021-08-12 16:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-12 16:21 arch/x86/kvm/debugfs.c:27:0-23: WARNING: vcpu_guest_mode_fops should be defined with DEFINE_DEBUGFS_ATTRIBUTE kernel test robot
2021-08-12 16:21 ` kernel test robot [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=20210812162129.GA4690@eae47cd7be8b \
    --to=lkp@intel.com \
    --cc=kbuild@lists.01.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.