[Devel] [PATCH RHEL7 COMMIT] ms/drop_monitor: Split tracing enable / disable to different functions

Konstantin Khorenko khorenko at virtuozzo.com
Thu Jul 28 22:28:44 MSK 2022


The commit is pushed to "branch-rh7-3.10.0-1160.66.1.vz7.188.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.66.1.vz7.188.6
------>
commit 9acb568073729fac3aae322087f1d823b16059cd
Author: Ido Schimmel <idosch at mellanox.com>
Date:   Mon Jul 4 21:51:57 2022 +0300

    ms/drop_monitor: Split tracing enable / disable to different functions
    
    Subsequent patches will need to enable / disable tracing based on the
    configured alerting mode.
    
    Reduce the nesting level and prepare for the introduction of this
    functionality by splitting the tracing enable / disable operations into
    two different functions.
    
    Signed-off-by: Ido Schimmel <idosch at mellanox.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>
    (cherry picked from commit 7c747838a55818fd0cdbe48afd98fba726aa898d)
    
    Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn at virtuozzo.com>
    
    =================
    Patchset description:
    drop_monitor: Add packet alert mode
    
    Just port and adapt packet alert mode feature for RHEL7 kernel.
    
    https://jira.sw.ru/browse/PSBM-140937
    
    Ported-by: Alexander Mikhalitsyn <alexander.mikhalitsyn at virtuozzo.com>
---
 net/core/drop_monitor.c | 72 ++++++++++++++++++++++++++++++-------------------
 1 file changed, 45 insertions(+), 27 deletions(-)

diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
index 0e2be8e3e8845..17ebc6f573917 100644
--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -239,44 +239,62 @@ static void trace_napi_poll_hit(void *ignore, struct napi_struct *napi)
 	rcu_read_unlock();
 }
 
+static int net_dm_trace_on_set(void)
+{
+	int rc;
+
+	if (!try_module_get(THIS_MODULE))
+		return -ENODEV;
+
+	rc = register_trace_kfree_skb(trace_kfree_skb_hit, NULL);
+	if (rc)
+		goto err_module_put;
+
+	rc = register_trace_napi_poll(trace_napi_poll_hit, NULL);
+	if (rc)
+		goto err_unregister_trace;
+
+	return 0;
+
+err_unregister_trace:
+	unregister_trace_kfree_skb(trace_kfree_skb_hit, NULL);
+err_module_put:
+	module_put(THIS_MODULE);
+	return rc;
+}
+
+static void net_dm_trace_off_set(void)
+{
+	struct dm_hw_stat_delta *new_stat, *temp;
+
+	unregister_trace_napi_poll(trace_napi_poll_hit, NULL);
+	unregister_trace_kfree_skb(trace_kfree_skb_hit, NULL);
+
+	tracepoint_synchronize_unregister();
+
+	list_for_each_entry_safe(new_stat, temp, &hw_stats_list, list) {
+		if (new_stat->dev == NULL) {
+			list_del_rcu(&new_stat->list);
+			kfree_rcu(new_stat, rcu);
+		}
+	}
+
+	module_put(THIS_MODULE);
+}
+
 static int set_all_monitor_traces(int state)
 {
 	int rc = 0;
-	struct dm_hw_stat_delta *new_stat = NULL;
-	struct dm_hw_stat_delta *temp;
 
 	if (state == trace_state)
 		return -EAGAIN;
 
 	switch (state) {
 	case TRACE_ON:
-		if (!try_module_get(THIS_MODULE)) {
-			rc = -ENODEV;
-			break;
-		}
-
-		rc |= register_trace_kfree_skb(trace_kfree_skb_hit, NULL);
-		rc |= register_trace_napi_poll(trace_napi_poll_hit, NULL);
+		rc = net_dm_trace_on_set();
 		break;
-
 	case TRACE_OFF:
-		rc |= unregister_trace_kfree_skb(trace_kfree_skb_hit, NULL);
-		rc |= unregister_trace_napi_poll(trace_napi_poll_hit, NULL);
-
-		tracepoint_synchronize_unregister();
-
-		/*
-		 * Clean the device list
-		 */
-		list_for_each_entry_safe(new_stat, temp, &hw_stats_list, list) {
-			if (new_stat->dev == NULL) {
-				list_del_rcu(&new_stat->list);
-				kfree_rcu(new_stat, rcu);
-			}
-		}
-
-		module_put(THIS_MODULE);
-
+		net_dm_trace_off_set();
 		break;
 	default:
 		rc = 1;


More information about the Devel mailing list