[PATCH OLK-5.10] net/oenetcls: Add mode 2 for rps numa affinity
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/ICBFCS -------------------------------- Add numa affinity RPS to balance softirq for vm. Signed-off-by: Yue Haibing <yuehaibing@huawei.com> --- net/oenetcls/oenetcls.h | 2 ++ net/oenetcls/oenetcls_flow.c | 30 +++++++++++++++++++ net/oenetcls/oenetcls_main.c | 56 +++++++++++++++++++++++++++++++----- 3 files changed, 81 insertions(+), 7 deletions(-) diff --git a/net/oenetcls/oenetcls.h b/net/oenetcls/oenetcls.h index f2726582db91..81f752590f9f 100644 --- a/net/oenetcls/oenetcls.h +++ b/net/oenetcls/oenetcls.h @@ -131,6 +131,8 @@ struct cfg_param { extern int match_ip_flag; extern int debug; +extern int mode; +extern int rcpu_probability; extern int oecls_netdev_num; extern int oecls_numa_num; diff --git a/net/oenetcls/oenetcls_flow.c b/net/oenetcls/oenetcls_flow.c index 62bad2408966..9b2d08d99418 100644 --- a/net/oenetcls/oenetcls_flow.c +++ b/net/oenetcls/oenetcls_flow.c @@ -171,6 +171,17 @@ static void set_oecls_cpu(struct net_device *dev, struct sk_buff *skb, rflow->cpu = next_cpu; } +static bool oecls_do_hash(void) +{ + if (rcpu_probability <= 0) + return false; + + if (rcpu_probability >= 100) + return true; + + return prandom_u32() % 100 < rcpu_probability; +} + static int get_cpu_in_mask(int tcpu, u32 hash) { const struct cpumask *mask; @@ -219,6 +230,25 @@ static void __oecls_set_cpu(struct sk_buff *skb, struct net_device *ndev, if ((val ^ hash) & ~oecls_cpu_mask) return; + if (mode == 2) { + if (!oecls_do_hash()) { + *rcpu = last_recv_cpu; + return; + } + if (last_recv_cpu != cpu) + return; + newcpu = get_cpu_in_mask(last_recv_cpu, hash); + if (newcpu < 0) + newcpu = cpu; + if (newcpu == cpu) { + newcpu = cpumask_first(cpumask_of_node(cpu_to_node(cpu))); + newcpu = newcpu + (cpu + 1) % (nr_cpu_ids / oecls_numa_num); + } + oecls_debug("last_recv_cpu:%d irq_cpu:%d newcpu:%d\n", last_recv_cpu, cpu, newcpu); + *rcpu = newcpu; + return; + } + newcpu = get_cpu_in_mask(last_recv_cpu, hash); if (newcpu >= 0) *rcpu = newcpu; diff --git a/net/oenetcls/oenetcls_main.c b/net/oenetcls/oenetcls_main.c index ec37e38d7f48..04922368bb73 100644 --- a/net/oenetcls/oenetcls_main.c +++ b/net/oenetcls/oenetcls_main.c @@ -19,7 +19,7 @@ int debug; module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "debug switch"); -static int mode; +int mode; module_param(mode, int, 0444); MODULE_PARM_DESC(mode, "mode, default 0"); @@ -43,13 +43,17 @@ static int check_cap = 1; module_param(check_cap, int, 0444); MODULE_PARM_DESC(check_cap, "check_cap, default 1"); +int rcpu_probability = -1; +module_param(rcpu_probability, int, 0444); +MODULE_PARM_DESC(rcpu_probability, "rcpu select policy probability, default -1"); + static char irqname[64] = "comp"; module_param_string(irqname, irqname, sizeof(irqname), 0644); MODULE_PARM_DESC(irqname, "nic irq name string, default comp"); static bool check_params(void) { - if (mode != 0 && mode != 1) + if (mode != 0 && mode != 1 && mode != 2) return false; if (strlen(ifname) == 0) @@ -376,7 +380,7 @@ static struct oecls_netdev_info *alloc_oecls_netdev_info(void) static bool check_irq_name(const char *irq_name, struct oecls_netdev_info *oecls_dev) { if (!strstr(irq_name, "TxRx") && !strstr(irq_name, "comp") && !strstr(irq_name, "rx") && - strlen(irqname) > 0 && !strstr(irq_name, irqname)) + !strstr(irq_name, "virtio0-input") && strlen(irqname) > 0 && !strstr(irq_name, irqname)) return false; if (strstr(irq_name, oecls_dev->dev_name)) @@ -519,10 +523,12 @@ static int init_single_oecls_dev(char *if_name, unsigned int length) goto out; } - ret = oecls_filter_enable(dev_name, &old_state); - if (ret) { - oecls_error("dev [%s] not support ntuple! ret=%d\n", dev_name, ret); - goto out; + if (mode != 2) { + ret = oecls_filter_enable(dev_name, &old_state); + if (ret) { + oecls_error("dev [%s] not support ntuple! ret=%d\n", dev_name, ret); + goto out; + } } oecls_dev = alloc_oecls_netdev_info(); @@ -1017,6 +1023,39 @@ static void set_netdev_xps_queue(bool enable) } } +static void fixup_rcpu_load(void) +{ + char *start = appname, *end; + char *task_name = "redis-proxy"; + + if (!strlen(appname)) + return; + + // support appname: app1#app2#appN + while (*start != '\0') { + end = strchr(start, '#'); + if (end == start) { + start++; + continue; + } + + if (!end) { + if (!strncmp(task_name, start, strlen(start))) { + rcpu_probability = 100; + return; + } + break; + } + + if (!strncmp(task_name, start, end - start)) { + rcpu_probability = 100; + return; + } + start = end + 1; + } + rcpu_probability = 65; +} + static __init int oecls_init(void) { struct oecls_numa_info *numa_info; @@ -1048,6 +1087,9 @@ static __init int oecls_init(void) set_netdev_xps_queue(true); #endif + if (mode == 2 && rcpu_probability < 0) + fixup_rcpu_load(); + if (mode == 0) err = oecls_ntuple_res_init(); else -- 2.34.1
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/18808 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/YR4... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/18808 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/YR4...
participants (2)
-
patchwork bot -
Yue Haibing