Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7064074ybl; Mon, 23 Dec 2019 17:35:27 -0800 (PST) X-Google-Smtp-Source: APXvYqy3ZJcS8g3RTn36j7suoq1IJdVYJiK+t4uhOvIGyYcuiSND4XCIa5iwyjvP7hwZzYS0JMeH X-Received: by 2002:a9d:23b5:: with SMTP id t50mr34544905otb.122.1577151327761; Mon, 23 Dec 2019 17:35:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577151327; cv=none; d=google.com; s=arc-20160816; b=u1PL5lBlgAxTjpZR4Lo0Irt3UBmbmTq/omCNsf8tIH04MmjJ1b8UQJ4Z2WY5Mctlk4 gtWcHNQneURYfV/2nlgIFh9sWNvY2eJyFg9XQNpAcpsot+xRsc0qIsJm0w/bP74WC/WO JhCGo1P3OYr5v/l2iSiKABwhJWNxMY+wotpssxUDFDU3k3iglODZwj6SD+/Ie5RI+V0F GnOhVRTXFTchNGCFB32ikAYYEE1u3W/o87v4+AY+6dWG3q4i5ygzCH8VlUt7DoBiSp0y wKW4MK0P50YD3fJ19XH9oe/7h2b2olSqoiON7lHR2AVEF6abjmfkWhbPGe51oWZ05X8f iXOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=pzll65ihAiXif3BWe5bPft9SnNzSn9FJobESzCX/f7o=; b=b41XgBptHR/S07/JXQgmFCksInA5M2evnE3Mtg5k//1b6f6LCq5V2wKnPM+PDIKIA9 kgfX/BnrgY+DEgzkTX+qVMB92XD2I0SPTdAHAdiqJYl8eC/hIBMie4EVQ7ogLS+/RqlB i1x4wGdvMRDyVlAvAU7weltpPR6wriTH0qvkVHckz4irZx1auA3ivpoU1xA2svWqIJuH 8srqrP1ktLvi+YE6gXTU4nw0Cy4qACMYM78dNi61bq6+8eQeRqV2nhzJWoIvDFhQlkI7 aS/RWxSqsEyooRe77uYA20ykuK807GED2RjmlGZ5xDKG5ya3zlRI1iiv64osA2GoDPRa gYgA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i20si5769580oie.119.2019.12.23.17.35.15; Mon, 23 Dec 2019 17:35:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727134AbfLXBeT (ORCPT + 99 others); Mon, 23 Dec 2019 20:34:19 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:7732 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727005AbfLXBeT (ORCPT ); Mon, 23 Dec 2019 20:34:19 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 89A462307CBA837A735A; Tue, 24 Dec 2019 09:34:16 +0800 (CST) Received: from localhost.localdomain (10.90.53.225) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.439.0; Tue, 24 Dec 2019 09:34:08 +0800 From: Chen Wandun To: , , , , , , , , CC: Subject: [PATCH next] KVM: Fix debugfs_simple_attr.cocci warnings Date: Tue, 24 Dec 2019 09:41:14 +0800 Message-ID: <1577151674-67949-1-git-send-email-chenwandun@huawei.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(). Signed-off-by: Chen Wandun --- arch/x86/kvm/debugfs.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/arch/x86/kvm/debugfs.c b/arch/x86/kvm/debugfs.c index 018aebc..0867d7d 100644 --- a/arch/x86/kvm/debugfs.c +++ b/arch/x86/kvm/debugfs.c @@ -15,7 +15,8 @@ static int vcpu_get_timer_advance_ns(void *data, u64 *val) 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_tsc_offset(void *data, u64 *val) { @@ -24,7 +25,8 @@ static int vcpu_get_tsc_offset(void *data, u64 *val) 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) { @@ -33,7 +35,8 @@ static int vcpu_get_tsc_scaling_ratio(void *data, u64 *val) 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) { @@ -41,24 +44,25 @@ static int vcpu_get_tsc_scaling_frac_bits(void *data, u64 *val) 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) { - debugfs_create_file("tsc-offset", 0444, vcpu->debugfs_dentry, vcpu, - &vcpu_tsc_offset_fops); + debugfs_create_file_unsafe("tsc-offset", 0444, vcpu->debugfs_dentry, + vcpu, &vcpu_tsc_offset_fops); if (lapic_in_kernel(vcpu)) - debugfs_create_file("lapic_timer_advance_ns", 0444, - vcpu->debugfs_dentry, vcpu, - &vcpu_timer_advance_ns_fops); + debugfs_create_file_unsafe("lapic_timer_advance_ns", 0444, + vcpu->debugfs_dentry, vcpu, + &vcpu_timer_advance_ns_fops); if (kvm_has_tsc_control) { - debugfs_create_file("tsc-scaling-ratio", 0444, - vcpu->debugfs_dentry, vcpu, - &vcpu_tsc_scaling_fops); - debugfs_create_file("tsc-scaling-ratio-frac-bits", 0444, - vcpu->debugfs_dentry, vcpu, - &vcpu_tsc_scaling_frac_fops); + debugfs_create_file_unsafe("tsc-scaling-ratio", 0444, + vcpu->debugfs_dentry, vcpu, + &vcpu_tsc_scaling_fops); + debugfs_create_file_unsafe("tsc-scaling-ratio-frac-bits", 0444, + vcpu->debugfs_dentry, vcpu, + &vcpu_tsc_scaling_frac_fops); } } -- 2.7.4