]> git.dujemihanovic.xyz Git - linux.git/commitdiff
ipvs: run_estimation should control the kthread tasks
authorJulian Anastasov <ja@ssi.bg>
Tue, 22 Nov 2022 16:46:04 +0000 (18:46 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sat, 10 Dec 2022 21:44:43 +0000 (22:44 +0100)
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>
Documentation/networking/ipvs-sysctl.rst
include/net/ip_vs.h
net/netfilter/ipvs/ip_vs_ctl.c
net/netfilter/ipvs/ip_vs_est.c

index 1b778705d70656cb69f2d4293adb4cf99295df09..3fb5fa142eef1d0346906927ded31bcc5ccf1da1 100644 (file)
@@ -324,8 +324,8 @@ run_estimation - BOOLEAN
        0 - disabled
        not 0 - enabled (default)
 
-       If disabled, the estimation will be stop, and you can't see
-       any update on speed estimation data.
+       If disabled, the estimation will be suspended and kthread tasks
+       stopped.
 
        You can always re-enable estimation by setting this value to 1.
        But be careful, the first estimation after re-enable is not
index dc51b5497cf730fd6b8be47949e49350ef213640..c6c61100d24457fd06a840af9121d33aee13ae08 100644 (file)
@@ -1605,8 +1605,10 @@ void ip_vs_est_kthread_stop(struct ip_vs_est_kt_data *kd);
 static inline void ip_vs_est_stopped_recalc(struct netns_ipvs *ipvs)
 {
 #ifdef CONFIG_SYSCTL
-       ipvs->est_stopped = ipvs->est_cpulist_valid &&
-                           cpumask_empty(sysctl_est_cpulist(ipvs));
+       /* Stop tasks while cpulist is empty or if disabled with flag */
+       ipvs->est_stopped = !sysctl_run_estimation(ipvs) ||
+                           (ipvs->est_cpulist_valid &&
+                            cpumask_empty(sysctl_est_cpulist(ipvs)));
 #endif
 }
 
index 38df3ee655ede26eb9498030ea2e178067e9c36d..c9f598505642a4ecb9edf4cb777c3607764d2fc4 100644 (file)
@@ -2056,6 +2056,32 @@ static int ipvs_proc_est_nice(struct ctl_table *table, int write,
        return ret;
 }
 
+static int ipvs_proc_run_estimation(struct ctl_table *table, int write,
+                                   void *buffer, size_t *lenp, loff_t *ppos)
+{
+       struct netns_ipvs *ipvs = table->extra2;
+       int *valp = table->data;
+       int val = *valp;
+       int ret;
+
+       struct ctl_table tmp_table = {
+               .data = &val,
+               .maxlen = sizeof(int),
+               .mode = table->mode,
+       };
+
+       ret = proc_dointvec(&tmp_table, write, buffer, lenp, ppos);
+       if (write && ret >= 0) {
+               mutex_lock(&ipvs->est_mutex);
+               if (*valp != val) {
+                       *valp = val;
+                       ip_vs_est_reload_start(ipvs);
+               }
+               mutex_unlock(&ipvs->est_mutex);
+       }
+       return ret;
+}
+
 /*
  *     IPVS sysctl table (under the /proc/sys/net/ipv4/vs/)
  *     Do not change order or insert new entries without
@@ -2230,7 +2256,7 @@ static struct ctl_table vs_vars[] = {
                .procname       = "run_estimation",
                .maxlen         = sizeof(int),
                .mode           = 0644,
-               .proc_handler   = proc_dointvec,
+               .proc_handler   = ipvs_proc_run_estimation,
        },
        {
                .procname       = "est_cpulist",
@@ -4323,6 +4349,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct netns_ipvs *ipvs)
        tbl[idx++].data = &ipvs->sysctl_schedule_icmp;
        tbl[idx++].data = &ipvs->sysctl_ignore_tunneled;
        ipvs->sysctl_run_estimation = 1;
+       tbl[idx].extra2 = ipvs;
        tbl[idx++].data = &ipvs->sysctl_run_estimation;
 
        ipvs->est_cpulist_valid = 0;
index e0f5f5da5b6da07370eed70134d62feb77c78cde..df56073bb2828cdd1cca60857de292e0533dad9b 100644 (file)
@@ -212,7 +212,7 @@ static int ip_vs_estimation_kthread(void *data)
                                kd->est_timer = now;
                }
 
-               if (sysctl_run_estimation(ipvs) && kd->tick_len[row])
+               if (kd->tick_len[row])
                        ip_vs_tick_estimation(kd, row);
 
                row++;