From mboxrd@z Thu Jan 1 00:00:00 1970 From: Greg Kroah-Hartman Date: Fri, 25 Jan 2019 07:11:59 +0000 Subject: Re: [PATCH -next] MIPS: fix debugfs_simple_attr.cocci warnings Message-Id: <20190125071159.GA11891@kroah.com> List-Id: References: <1548384137-171488-1-git-send-email-yuehaibing@huawei.com> In-Reply-To: <1548384137-171488-1-git-send-email-yuehaibing@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: YueHaibing Cc: Ralf Baechle , Paul Burton , James Hogan , linux-mips@vger.kernel.org, kernel-janitors@vger.kernel.org On Fri, Jan 25, 2019 at 02:42:17AM +0000, YueHaibing wrote: > 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(). What kind of overhead is this adding, and how are you measuring it? > > Generated by: scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci > > Signed-off-by: YueHaibing > --- > arch/mips/kernel/spinlock_test.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/arch/mips/kernel/spinlock_test.c b/arch/mips/kernel/spinlock_test.c > index ab4e3e1..509de1e 100644 > --- a/arch/mips/kernel/spinlock_test.c > +++ b/arch/mips/kernel/spinlock_test.c > @@ -35,7 +35,7 @@ static int ss_get(void *data, u64 *val) > return 0; > } > > -DEFINE_SIMPLE_ATTRIBUTE(fops_ss, ss_get, NULL, "%llu\n"); > +DEFINE_DEBUGFS_ATTRIBUTE(fops_ss, ss_get, NULL, "%llu\n"); > > > > @@ -114,14 +114,14 @@ static int multi_get(void *data, u64 *val) > return 0; > } > > -DEFINE_SIMPLE_ATTRIBUTE(fops_multi, multi_get, NULL, "%llu\n"); > +DEFINE_DEBUGFS_ATTRIBUTE(fops_multi, multi_get, NULL, "%llu\n"); > > static int __init spinlock_test(void) > { > - debugfs_create_file("spin_single", S_IRUGO, mips_debugfs_dir, NULL, > - &fops_ss); > - debugfs_create_file("spin_multi", S_IRUGO, mips_debugfs_dir, NULL, > - &fops_multi); > + debugfs_create_file_unsafe("spin_single", 0444, mips_debugfs_dir, > + NULL, &fops_ss); > + debugfs_create_file_unsafe("spin_multi", 0444, mips_debugfs_dir, > + NULL, &fops_multi); > return 0; > } > device_initcall(spinlock_test); This is just testing code, right? Why is using the unsafe methods needed? thanks, greg k-h From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E208CC282C0 for ; Fri, 25 Jan 2019 07:12:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B4E34218D9 for ; Fri, 25 Jan 2019 07:12:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548400322; bh=tk8Wbwzmicy9aaW0Sla82CIhoxFQGlS7b0dCQ3w/gIU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=H4hpMT7QFYG+91e/tyq+8Y9jqGIl2B/SCkgTn3b80WkYW7apXlTsmBoSiNSwDyRWh A2GtfNifP/quKs/YkilTkXUzH2k24a0m8Ddo064uFTZZM6TKrpraR1J/aLQtsWC9oI XvWbZkNcCgr2z/3ikw7GyAQk5ixRDsEDs3Oq0xkY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728053AbfAYHMC (ORCPT ); Fri, 25 Jan 2019 02:12:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:45090 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728030AbfAYHMC (ORCPT ); Fri, 25 Jan 2019 02:12:02 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 54A0D218A2; Fri, 25 Jan 2019 07:12:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548400321; bh=tk8Wbwzmicy9aaW0Sla82CIhoxFQGlS7b0dCQ3w/gIU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=diqg/GX+i1dKXY3BlcWbPI7sRvnW0WAdFQf69ARxJr7Ob+pWU4NBvBmgrj/2uS3PK Q4NXECAlGg4m+0P2sjgekGpHpNfP1msmjleeT9PHQ3alWMRvdPxO4K7FKK6y3HthOV p+A50bmqAZF5oaakd/zpORQZ7pRMFR8FyeZeYZlY= Date: Fri, 25 Jan 2019 08:11:59 +0100 From: Greg Kroah-Hartman To: YueHaibing Cc: Ralf Baechle , Paul Burton , James Hogan , linux-mips@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH -next] MIPS: fix debugfs_simple_attr.cocci warnings Message-ID: <20190125071159.GA11891@kroah.com> References: <1548384137-171488-1-git-send-email-yuehaibing@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1548384137-171488-1-git-send-email-yuehaibing@huawei.com> User-Agent: Mutt/1.11.2 (2019-01-07) Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org On Fri, Jan 25, 2019 at 02:42:17AM +0000, YueHaibing wrote: > 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(). What kind of overhead is this adding, and how are you measuring it? > > Generated by: scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci > > Signed-off-by: YueHaibing > --- > arch/mips/kernel/spinlock_test.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/arch/mips/kernel/spinlock_test.c b/arch/mips/kernel/spinlock_test.c > index ab4e3e1..509de1e 100644 > --- a/arch/mips/kernel/spinlock_test.c > +++ b/arch/mips/kernel/spinlock_test.c > @@ -35,7 +35,7 @@ static int ss_get(void *data, u64 *val) > return 0; > } > > -DEFINE_SIMPLE_ATTRIBUTE(fops_ss, ss_get, NULL, "%llu\n"); > +DEFINE_DEBUGFS_ATTRIBUTE(fops_ss, ss_get, NULL, "%llu\n"); > > > > @@ -114,14 +114,14 @@ static int multi_get(void *data, u64 *val) > return 0; > } > > -DEFINE_SIMPLE_ATTRIBUTE(fops_multi, multi_get, NULL, "%llu\n"); > +DEFINE_DEBUGFS_ATTRIBUTE(fops_multi, multi_get, NULL, "%llu\n"); > > static int __init spinlock_test(void) > { > - debugfs_create_file("spin_single", S_IRUGO, mips_debugfs_dir, NULL, > - &fops_ss); > - debugfs_create_file("spin_multi", S_IRUGO, mips_debugfs_dir, NULL, > - &fops_multi); > + debugfs_create_file_unsafe("spin_single", 0444, mips_debugfs_dir, > + NULL, &fops_ss); > + debugfs_create_file_unsafe("spin_multi", 0444, mips_debugfs_dir, > + NULL, &fops_multi); > return 0; > } > device_initcall(spinlock_test); This is just testing code, right? Why is using the unsafe methods needed? thanks, greg k-h