From: Peter Zijlstra <peterz@infradead.org>
To: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
linux-kernel@vger.kernel.org, Xuefeng Li <lixuefeng@loongson.cn>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH] locking/lock_events: no need to check return value of debugfs_create functions
Date: Mon, 9 Nov 2020 09:32:51 +0100 [thread overview]
Message-ID: <20201109083251.GA2594@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <1604740753-17662-1-git-send-email-yangtiezhu@loongson.cn>
On Sat, Nov 07, 2020 at 05:19:13PM +0800, Tiezhu Yang wrote:
> When calling debugfs functions, there is no need to ever check the
> return value. The function can work or not, but the code logic should
> never do something different based on this.
I strongly disagree and have told this to Greg before. Having half a
debug interface is weird at best, so upon failure we remove the whole
thing, which is consistent.
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
> kernel/locking/lock_events.c | 19 ++++---------------
> 1 file changed, 4 insertions(+), 15 deletions(-)
>
> diff --git a/kernel/locking/lock_events.c b/kernel/locking/lock_events.c
> index fa2c2f9..bac77a1 100644
> --- a/kernel/locking/lock_events.c
> +++ b/kernel/locking/lock_events.c
> @@ -146,9 +146,6 @@ static int __init init_lockevent_counts(void)
> struct dentry *d_counts = debugfs_create_dir(LOCK_EVENTS_DIR, NULL);
> int i;
>
> - if (!d_counts)
> - goto out;
> -
> /*
> * Create the debugfs files
> *
> @@ -159,21 +156,13 @@ static int __init init_lockevent_counts(void)
> for (i = 0; i < lockevent_num; i++) {
> if (skip_lockevent(lockevent_names[i]))
> continue;
> - if (!debugfs_create_file(lockevent_names[i], 0400, d_counts,
> - (void *)(long)i, &fops_lockevent))
> - goto fail_undo;
> + debugfs_create_file(lockevent_names[i], 0400, d_counts,
> + (void *)(long)i, &fops_lockevent);
> }
>
> - if (!debugfs_create_file(lockevent_names[LOCKEVENT_reset_cnts], 0200,
> - d_counts, (void *)(long)LOCKEVENT_reset_cnts,
> - &fops_lockevent))
> - goto fail_undo;
> + debugfs_create_file(lockevent_names[LOCKEVENT_reset_cnts], 0200, d_counts,
> + (void *)(long)LOCKEVENT_reset_cnts, &fops_lockevent);
>
> return 0;
> -fail_undo:
> - debugfs_remove_recursive(d_counts);
> -out:
> - pr_warn("Could not create '%s' debugfs entries\n", LOCK_EVENTS_DIR);
> - return -ENOMEM;
> }
> fs_initcall(init_lockevent_counts);
> --
> 2.1.0
>
next prev parent reply other threads:[~2020-11-09 8:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-07 9:19 [PATCH] locking/lock_events: no need to check return value of debugfs_create functions Tiezhu Yang
2020-11-09 8:32 ` Peter Zijlstra [this message]
2020-11-09 9:51 ` Tiezhu Yang
2020-11-09 10:04 ` Greg Kroah-Hartman
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=20201109083251.GA2594@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lixuefeng@loongson.cn \
--cc=mingo@redhat.com \
--cc=will@kernel.org \
--cc=yangtiezhu@loongson.cn \
/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