Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ipvs: run_estimation should control the kthread tasks

Change the run_estimation flag to start/stop the kthread tasks.

Signed-off-by: Julian Anastasov <ja@ssi.bg>
Cc: yunhong-cgl jiang <xintian1976@gmail.com>
Cc: "dust.li" <dust.li@linux.alibaba.com>
Reviewed-by: Jiri Wiesner <jwiesner@suse.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

authored by

Julian Anastasov and committed by
Pablo Neira Ayuso
144361c1 f0be83d5

+35 -6
+2 -2
Documentation/networking/ipvs-sysctl.rst
··· 324 324 0 - disabled 325 325 not 0 - enabled (default) 326 326 327 - If disabled, the estimation will be stop, and you can't see 328 - any update on speed estimation data. 327 + If disabled, the estimation will be suspended and kthread tasks 328 + stopped. 329 329 330 330 You can always re-enable estimation by setting this value to 1. 331 331 But be careful, the first estimation after re-enable is not
+4 -2
include/net/ip_vs.h
··· 1605 1605 static inline void ip_vs_est_stopped_recalc(struct netns_ipvs *ipvs) 1606 1606 { 1607 1607 #ifdef CONFIG_SYSCTL 1608 - ipvs->est_stopped = ipvs->est_cpulist_valid && 1609 - cpumask_empty(sysctl_est_cpulist(ipvs)); 1608 + /* Stop tasks while cpulist is empty or if disabled with flag */ 1609 + ipvs->est_stopped = !sysctl_run_estimation(ipvs) || 1610 + (ipvs->est_cpulist_valid && 1611 + cpumask_empty(sysctl_est_cpulist(ipvs))); 1610 1612 #endif 1611 1613 } 1612 1614
+28 -1
net/netfilter/ipvs/ip_vs_ctl.c
··· 2056 2056 return ret; 2057 2057 } 2058 2058 2059 + static int ipvs_proc_run_estimation(struct ctl_table *table, int write, 2060 + void *buffer, size_t *lenp, loff_t *ppos) 2061 + { 2062 + struct netns_ipvs *ipvs = table->extra2; 2063 + int *valp = table->data; 2064 + int val = *valp; 2065 + int ret; 2066 + 2067 + struct ctl_table tmp_table = { 2068 + .data = &val, 2069 + .maxlen = sizeof(int), 2070 + .mode = table->mode, 2071 + }; 2072 + 2073 + ret = proc_dointvec(&tmp_table, write, buffer, lenp, ppos); 2074 + if (write && ret >= 0) { 2075 + mutex_lock(&ipvs->est_mutex); 2076 + if (*valp != val) { 2077 + *valp = val; 2078 + ip_vs_est_reload_start(ipvs); 2079 + } 2080 + mutex_unlock(&ipvs->est_mutex); 2081 + } 2082 + return ret; 2083 + } 2084 + 2059 2085 /* 2060 2086 * IPVS sysctl table (under the /proc/sys/net/ipv4/vs/) 2061 2087 * Do not change order or insert new entries without ··· 2256 2230 .procname = "run_estimation", 2257 2231 .maxlen = sizeof(int), 2258 2232 .mode = 0644, 2259 - .proc_handler = proc_dointvec, 2233 + .proc_handler = ipvs_proc_run_estimation, 2260 2234 }, 2261 2235 { 2262 2236 .procname = "est_cpulist", ··· 4349 4323 tbl[idx++].data = &ipvs->sysctl_schedule_icmp; 4350 4324 tbl[idx++].data = &ipvs->sysctl_ignore_tunneled; 4351 4325 ipvs->sysctl_run_estimation = 1; 4326 + tbl[idx].extra2 = ipvs; 4352 4327 tbl[idx++].data = &ipvs->sysctl_run_estimation; 4353 4328 4354 4329 ipvs->est_cpulist_valid = 0;
+1 -1
net/netfilter/ipvs/ip_vs_est.c
··· 212 212 kd->est_timer = now; 213 213 } 214 214 215 - if (sysctl_run_estimation(ipvs) && kd->tick_len[row]) 215 + if (kd->tick_len[row]) 216 216 ip_vs_tick_estimation(kd, row); 217 217 218 218 row++;