[RFC V3 PATCH 06/26] net/netpolicy: set and remove IRQ affinity
From: kan . liang
Date: Mon Sep 12 2016 - 10:59:00 EST
From: Kan Liang <kan.liang@xxxxxxxxx>
This patches introduces functions to set and remove IRQ affinity
according to cpu and queue mapping.
The functions will not record the previous affinity status. After a
set/remove cycles, it will set the affinity on all online CPU with IRQ
balance enabling.
Signed-off-by: Kan Liang <kan.liang@xxxxxxxxx>
---
net/core/netpolicy.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/net/core/netpolicy.c b/net/core/netpolicy.c
index 0972341..adcb5e3 100644
--- a/net/core/netpolicy.c
+++ b/net/core/netpolicy.c
@@ -29,6 +29,7 @@
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/init.h>
+#include <linux/irq.h>
#include <linux/seq_file.h>
#include <linux/proc_fs.h>
#include <linux/uaccess.h>
@@ -129,6 +130,38 @@ err:
return -ENOMEM;
}
+static void netpolicy_clear_affinity(struct net_device *dev)
+{
+ struct netpolicy_sys_info *s_info = &dev->netpolicy->sys_info;
+ u32 i;
+
+ for (i = 0; i < s_info->avail_rx_num; i++) {
+ irq_clear_status_flags(s_info->rx[i].irq, IRQ_NO_BALANCING);
+ irq_set_affinity_hint(s_info->rx[i].irq, cpu_online_mask);
+ }
+
+ for (i = 0; i < s_info->avail_tx_num; i++) {
+ irq_clear_status_flags(s_info->tx[i].irq, IRQ_NO_BALANCING);
+ irq_set_affinity_hint(s_info->tx[i].irq, cpu_online_mask);
+ }
+}
+
+static void netpolicy_set_affinity(struct net_device *dev)
+{
+ struct netpolicy_sys_info *s_info = &dev->netpolicy->sys_info;
+ u32 i;
+
+ for (i = 0; i < s_info->avail_rx_num; i++) {
+ irq_set_status_flags(s_info->rx[i].irq, IRQ_NO_BALANCING);
+ irq_set_affinity_hint(s_info->rx[i].irq, cpumask_of(s_info->rx[i].cpu));
+ }
+
+ for (i = 0; i < s_info->avail_tx_num; i++) {
+ irq_set_status_flags(s_info->tx[i].irq, IRQ_NO_BALANCING);
+ irq_set_affinity_hint(s_info->tx[i].irq, cpumask_of(s_info->tx[i].cpu));
+ }
+}
+
const char *policy_name[NET_POLICY_MAX] = {
"NONE"
};
--
2.5.5