From: George Spelvin <lkml@sdf.org>
To: Andrew Morton <akpm@linux-foundation.org>,
Stephen Rothwell <sfr@canb.auug.org.au>,
kbuild test robot <lkp@intel.com>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
George Spelvin <lkml@sdf.org>, Andrey Abramov <st5pub@yandex.ru>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Daniel Wagner <daniel.wagner@siemens.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Don Mullis <don.mullis@gmail.com>,
Dave Chinner <dchinner@redhat.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH 6/5] lib/list_sort: Fix GCC warning
Date: Fri, 29 Mar 2019 04:31:52 GMT [thread overview]
Message-ID: <201903290431.x2T4Vq5A024120@sdf.org> (raw)
In-Reply-To: <f63c410e0ff76009c9b58e01027e751ff7fdb749.1552704200.git.lkml@sdf.org>
It turns out that GCC 4.9, 7.3, and 8.1 ignore the __pure
attribute on function pointers and (with the standard kernel
compile flags) emit a warning about it.
Even though it accurately describes a comparison function
(the compiler need not reload cached pointers across the call),
it doesn't actually help GCC 8.3's code generation, so just
omit it.
Signed-off-by: George Spelvin <lkml@sdf.org>
Fixes: 820c81be5237 ("lib/list_sort: simplify and remove MAX_LIST_LENGTH_BITS")
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
---
lib/list_sort.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/lib/list_sort.c b/lib/list_sort.c
index 623a9158ac8a..b1b492e20f1d 100644
--- a/lib/list_sort.c
+++ b/lib/list_sort.c
@@ -8,12 +8,16 @@
#include <linux/list.h>
/*
- * By declaring the compare function with the __pure attribute, we give
- * the compiler more opportunity to optimize. Ideally, we'd use this in
- * the prototype of list_sort(), but that would involve a lot of churn
- * at all call sites, so just cast the function pointer passed in.
+ * A more accurate type for comparison functions. Ideally, we'd use
+ * this in the prototype of list_sort(), but that would involve a lot of
+ * churn at all call sites, so just cast the function pointer passed in.
+ *
+ * This could also include __pure to give the compiler more opportunity
+ * to optimize, but that elicits an "attribute ignored" warning on
+ * GCC <= 8.1, and doesn't change GCC 8.3's code generation at all,
+ * so it's omitted.
*/
-typedef int __pure __attribute__((nonnull(2,3))) (*cmp_func)(void *,
+typedef int __attribute__((nonnull(2,3))) (*cmp_func)(void *,
struct list_head const *, struct list_head const *);
/*
--
2.20.1
next prev parent reply other threads:[~2019-03-29 4:34 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-16 2:43 [PATCH v2 0/5] lib/sort & lib/list_sort: faster and smaller George Spelvin
2019-02-21 6:30 ` [PATCH v2 1/5] lib/sort: Make swap functions more generic George Spelvin
2019-02-21 8:21 ` [PATCH v2 3/5] lib/sort: Avoid indirect calls to built-in swap George Spelvin
2019-02-21 8:21 ` [PATCH v2 2/5] lib/sort: Use more efficient bottom-up heapsort variant George Spelvin
2019-03-05 3:06 ` [PATCH v2 4/5] lib/list_sort: Simplify and remove MAX_LIST_LENGTH_BITS George Spelvin
2019-03-05 5:58 ` [PATCH v2 5/5] lib/list_sort: Optimize number of calls to comparison function George Spelvin
2019-03-19 8:15 ` [RESEND PATCH v2 0/5] lib/sort & lib/list_sort: faster and smaller George Spelvin
2019-03-19 8:15 ` [RESEND PATCH v2 1/5] lib/sort: Make swap functions more generic George Spelvin
2019-03-19 8:15 ` [RESEND PATCH v2 2/5] lib/sort: Use more efficient bottom-up heapsort variant George Spelvin
2019-03-19 8:15 ` [RESEND PATCH v2 3/5] lib/sort: Avoid indirect calls to built-in swap George Spelvin
2019-03-19 8:16 ` [RESEND PATCH v2 4/5] lib/list_sort: Simplify and remove MAX_LIST_LENGTH_BITS George Spelvin
2019-03-28 22:08 ` Andrew Morton
2019-03-29 4:10 ` George Spelvin
2019-03-29 4:31 ` George Spelvin [this message]
2019-03-19 8:16 ` [RESEND PATCH v2 5/5] lib/list_sort: Optimize number of calls to comparison function George Spelvin
2019-03-19 10:56 ` [RESEND PATCH v2 0/5] lib/sort & lib/list_sort: faster and smaller Rasmus Villemoes
2019-03-19 14:01 ` Andy Shevchenko
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=201903290431.x2T4Vq5A024120@sdf.org \
--to=lkml@sdf.org \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=daniel.wagner@siemens.com \
--cc=dchinner@redhat.com \
--cc=don.mullis@gmail.com \
--cc=geert@linux-m68k.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=lkp@intel.com \
--cc=sfr@canb.auug.org.au \
--cc=st5pub@yandex.ru \
/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;
as well as URLs for NNTP newsgroup(s).