openwrt/target/linux/mediatek/patches-4.14/0048-net-core-add-RPS-balancer.patch
Koen Vandeputte 4eba86820f kernel: bump 4.14 to 4.14.169
Refreshed all patches.

Fixes:
- CVE-2019-14896
- CVE-2019-14897

Remove upstreamed:
- 023-0007-crypto-crypto4xx-Fix-wrong-ppc4xx_trng_probe-ppc4xx_.patch

Altered patches:
- 102-MIPS-BCM63XX-move-code-touching-the-USB-private-regi.patch
- 105-MIPS-BCM63XX-add-support-for-the-on-chip-OHCI-contro.patch
- 106-MIPS-BCM63XX-register-OHCI-controller-if-board-enabl.patch
- 108-MIPS-BCM63XX-add-support-for-the-on-chip-EHCI-contro.patch
- 207-MIPS-BCM63XX-move-device-registration-code-into-its-.patch
- 350-MIPS-BCM63XX-support-settings-num-usbh-ports.patch
- 356-MIPS-BCM63XX-move-fallback-sprom-support-into-its-ow.patch
- 390-MIPS-BCM63XX-do-not-register-SPI-controllers.patch
- 391-MIPS-BCM63XX-do-not-register-uart.patch
- 392-MIPS-BCM63XX-remove-leds-and-buttons.patch
- 416-BCM63XX-add-a-fixup-for-ath9k-devices.patch
- 422-BCM63XX-add-a-fixup-for-rt2x00-devices.patch
-

Compile-tested on: brcm63xx, cns3xxx
Runtime-tested on: cns3xxx

Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
2020-02-04 18:12:19 +01:00

91 lines
2.2 KiB
Diff

From 3e969c9695b45e1a052d43b367096ec99f2f0aac Mon Sep 17 00:00:00 2001
From: John Crispin <john@phrozen.org>
Date: Thu, 10 Aug 2017 15:58:29 +0200
Subject: [PATCH 48/57] net: core: add RPS balancer
Signed-off-by: John Crispin <john@phrozen.org>
---
net/core/dev.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 56 insertions(+), 1 deletion(-)
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3658,6 +3658,58 @@ set_rps_cpu(struct net_device *dev, stru
return rflow;
}
+#define RPS_TBL_SIZE_SHIFT 10
+#define RPS_TBL_SIZE (1 << RPS_TBL_SIZE_SHIFT)
+struct rps_table {
+ int core;
+ struct timer_list expire;
+};
+static struct rps_table rps_table[RPS_TBL_SIZE];
+static int rps_table_last_core;
+
+static void rps_table_expire(unsigned long data)
+{
+ struct rps_table *entry = (struct rps_table *) data;
+
+ entry->core = -1;
+}
+
+static int rps_table_core(struct rps_map *map)
+{
+ int i;
+
+ for (i = 0; i < map->len; i++) {
+ int cpu = map->cpus[(rps_table_last_core + i + 1) % map->len];
+ if (cpu_online(cpu)) {
+ rps_table_last_core = cpu;
+ return cpu;
+ }
+ }
+ return map->cpus[0];
+}
+
+static int rps_table_lookup(struct rps_map *map, u32 hash)
+{
+ int bucket = hash & 0x3ff;
+
+ if (rps_table[bucket].core < 0)
+ rps_table[bucket].core = rps_table_core(map);
+ mod_timer(&rps_table[bucket].expire, jiffies + HZ);
+
+ return rps_table[bucket].core;
+}
+
+static void rps_table_init(void)
+{
+ int i;
+
+ for (i = 0; i < RPS_TBL_SIZE; i++) {
+ rps_table[i].core = -1;
+ setup_timer(&rps_table[i].expire, rps_table_expire,
+ (unsigned long) &rps_table[i]);
+ }
+}
+
/*
* get_rps_cpu is called from netif_receive_skb and returns the target
* CPU from the RPS map of the receiving queue for a given skb.
@@ -3747,7 +3799,7 @@ static int get_rps_cpu(struct net_device
try_rps:
if (map) {
- tcpu = map->cpus[reciprocal_scale(hash, map->len)];
+ tcpu = rps_table_lookup(map, hash);
if (cpu_online(tcpu)) {
cpu = tcpu;
goto done;
@@ -8859,6 +8911,9 @@ static int __init net_dev_init(void)
sd->backlog.weight = weight_p;
}
+ if (IS_ENABLED(CONFIG_RPS))
+ rps_table_init();
+
dev_boot_phase = 0;
/* The loopback device is special if any other network devices