Message ID | 20221101072506.7307-1-liubo03@inspur.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2794389wru; Tue, 1 Nov 2022 00:28:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5TEr+evwC7T6SeNtxl7pKE7sLW6oRDpiKhRpKkTvq125l7lJ9442B3saZ5y7ZuUMfUsRUp X-Received: by 2002:a17:90b:378f:b0:213:acf2:13ba with SMTP id mz15-20020a17090b378f00b00213acf213bamr17216538pjb.25.1667287708854; Tue, 01 Nov 2022 00:28:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667287708; cv=none; d=google.com; s=arc-20160816; b=uqXwkrfSvPouQ87PrL2NhZ//1/LHa3Ded4LFoomkf+hGBzmsDnfLRQ0yThk9FfqDn4 tszJRS4m1IEfuymy7viSrr6HzSS21WDlRMT9xWeDZqcV3Wg+BIOJF2eztc3pu80fVGKp eyi15rNXRrVa9fBQRrSM5N17KYskXWzL31Qboqyci5XC4PF3RhcVjI6pSTCEcHW4W65R YMJod69D4GqJe8he0UrPq3rYvwPllYqjEIEAuXU6IJhczpyJ0ExY6Imd4S//gjiELLHC sutyc5g8mBXuYkoY7bJtL9c7fGy099M6o1xIvGqZRF/Ib3zX7YeQJAAeqBGUOvM0Rm80 gMRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:abuse-reports-to:tuid:mime-version:message-id :date:subject:cc:to:from; bh=bo5593ksBwLCv2zf9X4AbIjBYbAiE+Ag71JyJPzt/7k=; b=mdKRUn4gbv7+AQE7CxfDXTmULTTzWu015u5mXjmH3nes5Hw8Fw7hZvijcTpG5I66kx RMNCBddqbYtp3N9bbqtO0gufzDP9BHI87n/MZG9jF1d07oXT+HjvgA/CaWOeimUac4XB eIhIeZQWsBiEi4gKc9tJxe6WekwZ/4ogSn/4Do17TAZ/Tl/UXQCgpM3ip/SS8BQ66Oay 4K4wkoo0YX8GiZj97bMhRH9Y2wMbUUin0fdAA2AVYS6tEUvmVw1GduCBevYQ7EG9lDcv ELOzAj9pNpThXF8YVb0hxp2dZGJDJmSCWgn5J2tybjH+mCISMqqNqPvpQYJFEgXB0F6g 5nPw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x185-20020a6386c2000000b0046fe1646542si3049825pgd.574.2022.11.01.00.28.15; Tue, 01 Nov 2022 00:28:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229779AbiKAHZR (ORCPT <rfc822;kartikey406@gmail.com> + 99 others); Tue, 1 Nov 2022 03:25:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbiKAHZP (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 1 Nov 2022 03:25:15 -0400 Received: from ssh248.corpemail.net (ssh248.corpemail.net [210.51.61.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB35213F9D; Tue, 1 Nov 2022 00:25:12 -0700 (PDT) Received: from ([60.208.111.195]) by ssh248.corpemail.net ((D)) with ASMTP (SSL) id VIA00106; Tue, 01 Nov 2022 15:25:06 +0800 Received: from localhost.localdomain (10.200.104.97) by jtjnmail201603.home.langchao.com (10.100.2.3) with Microsoft SMTP Server id 15.1.2507.12; Tue, 1 Nov 2022 15:25:07 +0800 From: Bo Liu <liubo03@inspur.com> To: <pbonzini@redhat.com> CC: <kvm@vger.kernel.org>, <linux-kernel@vger.kernel.org>, Bo Liu <liubo03@inspur.com> Subject: [PATCH] KVM: replace DEFINE_SIMPLE_ATTRIBUTE with DEFINE_DEBUGFS_ATTRIBUTE Date: Tue, 1 Nov 2022 03:25:06 -0400 Message-ID: <20221101072506.7307-1-liubo03@inspur.com> X-Mailer: git-send-email 2.18.2 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.200.104.97] tUid: 20221101152506542b37a066d351f49ca7da895e039e5a X-Abuse-Reports-To: service@corp-email.com Abuse-Reports-To: service@corp-email.com X-Complaints-To: service@corp-email.com X-Report-Abuse-To: service@corp-email.com X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748277876465658387?= X-GMAIL-MSGID: =?utf-8?q?1748277876465658387?= |
Series |
KVM: replace DEFINE_SIMPLE_ATTRIBUTE with DEFINE_DEBUGFS_ATTRIBUTE
|
|
Commit Message
Bo Liu
Nov. 1, 2022, 7:25 a.m. UTC
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(-)
Comments
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
On Wed, Nov 02, 2022, Paolo Bonzini wrote: > 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. Heh, some serious deja vu here[1]. This is the second case of identical, flawed patches being sent in response to misguided coccinelle warnings in a rather short amount of time, the "return min(r, 0)" horror being the other case[2][3]. The min() thing is supposed to be fixed by commit aeb300c1dbfc ("coccinelle: misc: minmax: suppress patch generation for err returns"). Is that patch broken, or are folks just running old scripts? As for the DEFINE_DEBUGFS_ATTRIBUTE check, can that warning be downgraded (is that even a thing?) or even deleted? As much as I enjoyed the opportunity to learn more about debugfs, the unnecessary confusion and wasted time was/is annoying. [1] https://lore.kernel.org/all/Yxoo1A2fmlAWruyV@google.com [2] https://lore.kernel.org/all/8881d7b4-0c31-cafd-1158-0d42c1c7f43a@redhat.com [3] https://lore.kernel.org/all/d8a518c4a4014307b30020b38022d633@AcuMS.aculab.com
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) {