[Devel] [PATCH RHEL8 COMMIT] ve/proc/net/nr_cpus: Cut lines in /proc/net/softnet_stat to number of vcpus in CT

Konstantin Khorenko khorenko at virtuozzo.com
Fri Apr 30 13:15:16 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.23
------>
commit 99815677ae77304719cc2724f03b2d20ccfd2c7d
Author: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Date:   Fri Apr 30 13:15:16 2021 +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.
    
    https://jira.sw.ru/browse/PSBM-73238
    Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
    
    eshatokhin@: updated the conditional to match what is now used for
    /proc/cpuinfo (see __c_start() and cpuinfo_op in arch/x86/kernel/cpu/proc.c).
    No changes in semantics.
    
    Done in the scope of https://jira.sw.ru/browse/PSBM-127794.
    Cherry-picked from vz7 commit 7705706ecb71 ("ve/proc/net/nr_cpus: cut lines in
    /proc/net/softnet_stat to number of vcpus in CT")
    
    Signed-off-by: Evgenii Shatokhin <eshatokhin at virtuozzo.com>
---
 net/core/net-procfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
index 7083d708db3b..ff0da3fe7597 100644
--- a/net/core/net-procfs.c
+++ b/net/core/net-procfs.c
@@ -122,7 +122,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 (bitmap_weight(cpumask_bits(cpu_online_mask), *pos) < num_online_vcpus())
+				sd = &per_cpu(softnet_data, *pos);
 			break;
 		} else
 			++*pos;


More information about the Devel mailing list