[RHEL7,COMMIT] ve/proc/net/nr_cpus: cut lines in /proc/net/softnet_stat to number of vcpus in CT

Submitted by Konstantin Khorenko on Dec. 6, 2017, 4:24 p.m.


Message ID 201712061624.vB6GOw8b029338@finist_ce7.work
State New
Series "nr_cpus: cut lines in /proc/net/softnet_stat to number of vcpus in CT"
Headers show

Commit Message

Konstantin Khorenko Dec. 6, 2017, 4:24 p.m.
The commit is pushed to "branch-rh7-3.10.0-693.11.1.vz7.39.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.11.1.vz7.39.1
commit f1ed22d6992b0a1b04e887f89eea342f130b588d
Author: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Date:   Wed Dec 6 19:24:58 2017 +0300

    ve/proc/net/nr_cpus: cut lines in /proc/net/softnet_stat to number of vcpus in CT
    Counters are not virtualized, we just remove the leak of host's number
    of cpus. Done similar to /proc/cpuinfo, in case of cpu hotplug race with
    reading proc, can actually show arbitrary number of lines as we do no
    locking like get_online_cpus or cpuhp_lock_acquire_read, it seem we do
    so for the sake of simplicity.
    Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
 net/core/net-procfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
index 0ea5ce99aec1..263edc6794b5 100644
--- a/net/core/net-procfs.c
+++ b/net/core/net-procfs.c
@@ -121,7 +121,8 @@  static struct softnet_data *softnet_get_online(loff_t *pos)
 	while (*pos < nr_cpu_ids)
 		if (cpu_online(*pos)) {
-			sd = &per_cpu(softnet_data, *pos);
+			if (__cpus_weight(cpu_online_mask, *pos) < num_online_vcpus())
+				sd = &per_cpu(softnet_data, *pos);
 		} else