From: Luca Coelho <luca@coelho.fi>
To: backports@vger.kernel.org
Cc: Luca Coelho <luciano.coelho@intel.com>
Subject: [PATCH 03/10] backport: include lib/bucket_locks.c
Date: Sun, 18 Feb 2018 15:24:52 +0200 [thread overview]
Message-ID: <20180218132459.11011-4-luca@coelho.fi> (raw)
In-Reply-To: <20180218132459.11011-1-luca@coelho.fi>
From: Luca Coelho <luciano.coelho@intel.com>
The alloc/free_bucket_spinlocks() functions were moved to a new lib
file, namely bucket_locks.c. Add an auto-backport for the
bucket_locks.c file and move the patching of the code that moved from
rhashtable to bucket_locks.c.
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
backport/backport-include/linux/spinlock.h | 13 +++++++++++++
backport/compat/Kconfig | 7 +++++++
patches/lib-bucket_locks.patch | 29 +++++++++++++++++++++++++++++
patches/lib-rhashtable.patch | 27 ---------------------------
4 files changed, 49 insertions(+), 27 deletions(-)
create mode 100644 backport/backport-include/linux/spinlock.h
create mode 100644 patches/lib-bucket_locks.patch
diff --git a/backport/backport-include/linux/spinlock.h b/backport/backport-include/linux/spinlock.h
new file mode 100644
index 000000000000..07daa358e25d
--- /dev/null
+++ b/backport/backport-include/linux/spinlock.h
@@ -0,0 +1,13 @@
+#ifndef __BACKPORT_SPINLOCK_H
+#define __BACKPORT_SPINLOCK_H
+#include_next <linux/spinlock.h>
+
+#if LINUX_VERSION_IS_LESS(4,16,0)
+int alloc_bucket_spinlocks(spinlock_t **locks, unsigned int *lock_mask,
+ size_t max_size, unsigned int cpu_mult,
+ gfp_t gfp);
+
+void free_bucket_spinlocks(spinlock_t *locks);
+#endif /* LINUX_VERSION_IS_LESS(4,16,0) */
+
+#endif /* __BACKPORT_SPINLOCK_H */
diff --git a/backport/compat/Kconfig b/backport/compat/Kconfig
index 492efbfc7d9f..d73e9a9e17b7 100644
--- a/backport/compat/Kconfig
+++ b/backport/compat/Kconfig
@@ -132,6 +132,13 @@ config BPAUTO_RHASHTABLE
#h-file linux/rhashtable.h
#c-file lib/rhashtable.c
+config BPAUTO_BUCKET_LOCKS
+ bool
+ # the API of bucket_locks that we need was introduced in version 4.16
+ depends on KERNEL_4_16
+ default y if BPAUTO_RHASHTABLE
+ #c-file lib/bucket_locks.c
+
config BPAUTO_BUILD_HDMI
bool
# the hdmi driver got some new apis like hdmi_infoframe_unpack() in
diff --git a/patches/lib-bucket_locks.patch b/patches/lib-bucket_locks.patch
new file mode 100644
index 000000000000..df7420de06fc
--- /dev/null
+++ b/patches/lib-bucket_locks.patch
@@ -0,0 +1,29 @@
+diff --git a/compat/lib-bucket_locks.c b/compat/lib-bucket_locks.c
+index 266a97c5708b..405b52ca5708 100644
+--- a/compat/lib-bucket_locks.c
++++ b/compat/lib-bucket_locks.c
+@@ -30,10 +30,24 @@ int alloc_bucket_spinlocks(spinlock_t **locks, unsigned int *locks_mask,
+ }
+
+ if (sizeof(spinlock_t) != 0) {
++#if LINUX_VERSION_IS_LESS(4,12,0)
++#ifdef CONFIG_NUMA
++ if (size * sizeof(spinlock_t) > PAGE_SIZE &&
++ gfp == GFP_KERNEL)
++ tlocks = vmalloc(size * sizeof(spinlock_t));
++#endif
++ if (gfp != GFP_KERNEL)
++ gfp |= __GFP_NOWARN | __GFP_NORETRY;
++
++ if (!tlocks)
++ tlocks = kmalloc_array(size, sizeof(spinlock_t),
++ gfp);
++#else
+ if (gfpflags_allow_blocking(gfp))
+ tlocks = kvmalloc(size * sizeof(spinlock_t), gfp);
+ else
+ tlocks = kmalloc_array(size, sizeof(spinlock_t), gfp);
++#endif
+ if (!tlocks)
+ return -ENOMEM;
+ for (i = 0; i < size; i++)
diff --git a/patches/lib-rhashtable.patch b/patches/lib-rhashtable.patch
index 59d870c0ef42..d29169f4570b 100644
--- a/patches/lib-rhashtable.patch
+++ b/patches/lib-rhashtable.patch
@@ -1,33 +1,6 @@
--- a/compat/lib-rhashtable.c
+++ b/compat/lib-rhashtable.c
-@@ -86,11 +86,26 @@ static int alloc_bucket_locks(struct rha
- size = min(size, 1U << tbl->nest);
-
- if (sizeof(spinlock_t) != 0) {
-+#if LINUX_VERSION_IS_LESS(4,12,0)
-+ tbl->locks = NULL;
-+#ifdef CONFIG_NUMA
-+ if (size * sizeof(spinlock_t) > PAGE_SIZE &&
-+ gfp == GFP_KERNEL)
-+ tbl->locks = vmalloc(size * sizeof(spinlock_t));
-+#endif
-+ if (gfp != GFP_KERNEL)
-+ gfp |= __GFP_NOWARN | __GFP_NORETRY;
-+
-+ if (!tbl->locks)
-+ tbl->locks = kmalloc_array(size, sizeof(spinlock_t),
-+ gfp);
-+#else
- if (gfpflags_allow_blocking(gfp))
- tbl->locks = kvmalloc(size * sizeof(spinlock_t), gfp);
- else
- tbl->locks = kmalloc_array(size, sizeof(spinlock_t),
- gfp);
-+#endif
- if (!tbl->locks)
- return -ENOMEM;
- for (i = 0; i < size; i++)
@@ -211,10 +226,11 @@ static struct bucket_table *bucket_table
int i;
--
2.15.1
--
To unsubscribe from this list: send the line "unsubscribe backports" in
next prev parent reply other threads:[~2018-02-18 13:55 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-18 13:24 [PATCH 00/10] backport: updates for v4.16 Luca Coelho
2018-02-18 13:24 ` [PATCH 01/10] compat: only define thermal backports if CONFIG_THERMAL is enabled Luca Coelho
2018-02-18 13:24 ` [PATCH 02/10] backport: add pcie_find_root_port() Luca Coelho
2018-02-18 13:24 ` Luca Coelho [this message]
2018-02-18 13:24 ` [PATCH 04/10] backport: update genl_dump_check_consistent() backport Luca Coelho
2018-02-18 13:24 ` [PATCH 05/10] backport: remove pkcs7_verify.c patch hunk Luca Coelho
2018-02-18 13:24 ` [PATCH 06/10] backport: add new build_bug.h file Luca Coelho
2018-02-18 13:24 ` [PATCH 07/10] backports: fix typo "TIMKEEPING" and fix gfp.h Luca Coelho
2018-02-18 13:24 ` [PATCH 08/10] backport: remove stddef.h inclusions Luca Coelho
2018-02-18 13:24 ` [PATCH 09/10] backport: increase max stack frame size compiler check to 1280 Luca Coelho
2018-02-18 13:24 ` [PATCH 10/10] backport: implement alloc_percpu_gfp() for < 3.18 Luca Coelho
2018-02-18 16:10 ` Hauke Mehrtens
2018-02-18 17:58 ` Luciano Coelho
2018-02-28 18:32 ` Hauke Mehrtens
2018-02-28 18:48 ` Luca Coelho
2018-02-18 16:11 ` [PATCH 00/10] backport: updates for v4.16 Hauke Mehrtens
2018-02-19 8:08 ` Luciano Coelho
2018-02-23 11:35 ` Johannes Berg
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=20180218132459.11011-4-luca@coelho.fi \
--to=luca@coelho.fi \
--cc=backports@vger.kernel.org \
--cc=luciano.coelho@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;
as well as URLs for NNTP newsgroup(s).