Add PREEMPT_RT 4.4.9-rt17 patch series
Add the PREEMPT_RT 4.4.9-rt17 patch series as a set of .patch files in
the rt-patches subdir of the kernel. The intention is to apply these
at build time to RT kernels.
IGNORE_GVS
Change-Id: I7e0d9282c0e17540aa98c18a15e88634c57a3a23
Signed-off-by: Allen Martin <amartin@nvidia.com>
Reviewed-on: http://git-master/r/1193842
Reviewed-by: Samuel Payne <spayne@nvidia.com>
diff --git a/rt-patches/0286-net-Add-a-mutex-around-devnet_rename_seq.patch b/rt-patches/0286-net-Add-a-mutex-around-devnet_rename_seq.patch
new file mode 100644
index 0000000..23da301
--- /dev/null
+++ b/rt-patches/0286-net-Add-a-mutex-around-devnet_rename_seq.patch
@@ -0,0 +1,114 @@
+From 076cddd3a60a39327238bbd9ee8859aabd91cbec Mon Sep 17 00:00:00 2001
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Wed, 20 Mar 2013 18:06:20 +0100
+Subject: [PATCH 286/317] net: Add a mutex around devnet_rename_seq
+X-NVConfidentiality: public
+
+On RT write_seqcount_begin() disables preemption and device_rename()
+allocates memory with GFP_KERNEL and grabs later the sysfs_mutex
+mutex. Serialize with a mutex and add use the non preemption disabling
+__write_seqcount_begin().
+
+To avoid writer starvation, let the reader grab the mutex and release
+it when it detects a writer in progress. This keeps the normal case
+(no reader on the fly) fast.
+
+[ tglx: Instead of replacing the seqcount by a mutex, add the mutex ]
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Signed-off-by: Allen Martin <amartin@nvidia.com>
+---
+ net/core/dev.c | 34 ++++++++++++++++++++--------------
+ 1 file changed, 20 insertions(+), 14 deletions(-)
+
+diff --git a/net/core/dev.c b/net/core/dev.c
+index 1071719e5449..0e17592adbff 100644
+--- a/net/core/dev.c
++++ b/net/core/dev.c
+@@ -186,6 +186,7 @@ static unsigned int napi_gen_id;
+ static DEFINE_HASHTABLE(napi_hash, 8);
+
+ static seqcount_t devnet_rename_seq;
++static DEFINE_MUTEX(devnet_rename_mutex);
+
+ static inline void dev_base_seq_inc(struct net *net)
+ {
+@@ -884,7 +885,8 @@ retry:
+ strcpy(name, dev->name);
+ rcu_read_unlock();
+ if (read_seqcount_retry(&devnet_rename_seq, seq)) {
+- cond_resched();
++ mutex_lock(&devnet_rename_mutex);
++ mutex_unlock(&devnet_rename_mutex);
+ goto retry;
+ }
+
+@@ -1153,20 +1155,17 @@ int dev_change_name(struct net_device *dev, const char *newname)
+ if (dev->flags & IFF_UP)
+ return -EBUSY;
+
+- write_seqcount_begin(&devnet_rename_seq);
++ mutex_lock(&devnet_rename_mutex);
++ __raw_write_seqcount_begin(&devnet_rename_seq);
+
+- if (strncmp(newname, dev->name, IFNAMSIZ) == 0) {
+- write_seqcount_end(&devnet_rename_seq);
+- return 0;
+- }
++ if (strncmp(newname, dev->name, IFNAMSIZ) == 0)
++ goto outunlock;
+
+ memcpy(oldname, dev->name, IFNAMSIZ);
+
+ err = dev_get_valid_name(net, dev, newname);
+- if (err < 0) {
+- write_seqcount_end(&devnet_rename_seq);
+- return err;
+- }
++ if (err < 0)
++ goto outunlock;
+
+ if (oldname[0] && !strchr(oldname, '%'))
+ netdev_info(dev, "renamed from %s\n", oldname);
+@@ -1179,11 +1178,12 @@ rollback:
+ if (ret) {
+ memcpy(dev->name, oldname, IFNAMSIZ);
+ dev->name_assign_type = old_assign_type;
+- write_seqcount_end(&devnet_rename_seq);
+- return ret;
++ err = ret;
++ goto outunlock;
+ }
+
+- write_seqcount_end(&devnet_rename_seq);
++ __raw_write_seqcount_end(&devnet_rename_seq);
++ mutex_unlock(&devnet_rename_mutex);
+
+ netdev_adjacent_rename_links(dev, oldname);
+
+@@ -1204,7 +1204,8 @@ rollback:
+ /* err >= 0 after dev_alloc_name() or stores the first errno */
+ if (err >= 0) {
+ err = ret;
+- write_seqcount_begin(&devnet_rename_seq);
++ mutex_lock(&devnet_rename_mutex);
++ __raw_write_seqcount_begin(&devnet_rename_seq);
+ memcpy(dev->name, oldname, IFNAMSIZ);
+ memcpy(oldname, newname, IFNAMSIZ);
+ dev->name_assign_type = old_assign_type;
+@@ -1217,6 +1218,11 @@ rollback:
+ }
+
+ return err;
++
++outunlock:
++ __raw_write_seqcount_end(&devnet_rename_seq);
++ mutex_unlock(&devnet_rename_mutex);
++ return err;
+ }
+
+ /**
+--
+2.9.3
+