From: Joe Perches <joe@perches.com>
To: "Dilger, Andreas" <andreas.dilger@intel.com>,
Dan Carpenter <dan.carpenter@oracle.com>
Cc: James Simmons <jsimmons@infradead.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
"Drokin, Oleg" <oleg.drokin@intel.com>,
"Siyao, Lai" <lai.siyao@intel.com>, NeilBrown <neilb@suse.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Lustre Development List <lustre-devel@lists.lustre.org>
Subject: Re: [PATCH 4/4] staging: lustre: obdclass: change object lookup to no wait mode
Date: Wed, 16 May 2018 08:44:06 -0700 [thread overview]
Message-ID: <e889f1ece72522303916a755d2dfac507de07de9.camel@perches.com> (raw)
In-Reply-To: <EDCE6E68-0B5C-4F82-B356-8D70AE5FF92A@intel.com>
On Wed, 2018-05-16 at 09:12 +0000, Dilger, Andreas wrote:
> On May 16, 2018, at 02:00, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> >
> > On Tue, May 15, 2018 at 04:02:55PM +0100, James Simmons wrote:
> > >
> > > > > /*
> > > > > * Allocate new object. This may result in rather complicated
> > > > > * operations, including fld queries, inode loading, etc.
> > > > > */
> > > > > o = lu_object_alloc(env, dev, f, conf);
> > > > > - if (IS_ERR(o))
> > > > > + if (unlikely(IS_ERR(o)))
> > > > > return o;
> > > > >
> > > >
> > > > This is an unrelated and totally pointless. likely/unlikely annotations
> > > > hurt readability, and they should only be added if it's something which
> > > > is going to show up in benchmarking. lu_object_alloc() is already too
> > > > slow for the unlikely() to make a difference and anyway IS_ERR() has an
> > > > unlikely built in so it's duplicative...
> > >
> > > Sounds like a good checkpatch case to test for :-)
> >
> > The likely/unlikely annotations have their place in fast paths so a
> > checkpatch warning would get annoying...
>
> I think James was suggesting a check for unlikely(IS_ERR()),
Probably so.
$ git grep -P 'likely\s*\(\s*\!?\s*IS_ERR' | wc -l
42
Are there other known likely/unlikely duplications?
> or possibly
> a check for unlikely() on something that is already unlikely() after CPP
> expansion.
checkpatch isn't the tool for that type of test
as it is a collection of trivial regex tests and
it is not a c90 preprocessor.
Anyway, here's a possible checkpatch patch.
---
scripts/checkpatch.pl | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index baddac9379f0..20c0973f1c39 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6299,6 +6299,12 @@ sub process {
"#define of '$1' is wrong - use Kconfig variables or standard guards instead\n" . $herecurr);
}
+# likely/unlikely tests with IS_ERR (already unlikely)"
+ if ($line =~ /\b((?:un)?likely)\s*\(\s*\!?\s*(IS_ERR[A-Z_]*)\s*\(/) {
+ WARN("DUPLICATE_LIKELY",
+ "Unnecessary use of $1 with $2 as it already has an unlikely\n" . $herecurr);
+ }
+
# likely/unlikely comparisons similar to "(likely(foo) > 0)"
if ($^V && $^V ge 5.10.0 &&
$line =~ /\b((?:un)?likely)\s*\(\s*$FuncArg\s*\)\s*$Compare/) {
next prev parent reply other threads:[~2018-05-16 15:44 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-02 18:21 [PATCH 0/4] staging: lustre: obdclass: missing lu_object fixes James Simmons
2018-05-02 18:21 ` [PATCH 1/4] staging: lustre: obdclass: change spinlock of key to rwlock James Simmons
2018-05-03 13:50 ` David Laight
2018-05-03 23:26 ` NeilBrown
2018-05-04 0:11 ` Dilger, Andreas
2018-05-04 0:53 ` NeilBrown
2018-05-02 18:21 ` [PATCH 2/4] staging: lustre: obdclass: hoist locking in lu_context_exit() James Simmons
2018-05-02 18:21 ` [PATCH 3/4] staging: lustre: obdclass: guarantee all keys filled James Simmons
2018-05-02 18:21 ` [PATCH 4/4] staging: lustre: obdclass: change object lookup to no wait mode James Simmons
2018-05-04 1:15 ` NeilBrown
2018-05-15 0:37 ` James Simmons
2018-05-15 1:37 ` NeilBrown
2018-05-15 2:11 ` James Simmons
2018-05-07 1:47 ` Greg Kroah-Hartman
2018-05-08 11:45 ` Dan Carpenter
2018-05-15 15:02 ` James Simmons
2018-05-16 8:00 ` Dan Carpenter
2018-05-16 9:12 ` Dilger, Andreas
2018-05-16 15:44 ` Joe Perches [this message]
2018-05-16 16:57 ` Greg Kroah-Hartman
2018-05-17 5:07 ` James Simmons
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=e889f1ece72522303916a755d2dfac507de07de9.camel@perches.com \
--to=joe@perches.com \
--cc=andreas.dilger@intel.com \
--cc=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=jsimmons@infradead.org \
--cc=lai.siyao@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lustre-devel@lists.lustre.org \
--cc=neilb@suse.com \
--cc=oleg.drokin@intel.com \
/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
all inboxes | Powered by JetHome®