]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: activity: report context switch counts instead of rates
authorWilly Tarreau <w@1wt.eu>
Tue, 30 Apr 2019 12:55:18 +0000 (14:55 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 30 Apr 2019 12:55:18 +0000 (14:55 +0200)
It's not logical to report context switch rates per thread in show activity
because everything else is a counter and it's not even possible to compare
values. Let's only report counts. Further, this simplifies the scheduler's
code.

include/types/activity.h
src/cli.c
src/task.c

index 0c23f76f6344b0ec1acb148a91f9e43dd9d42970..605fe7a74749a949906166c89a42435b491a7f2d 100644 (file)
@@ -50,12 +50,12 @@ struct activity {
        /* one cache line */
        struct freq_ctr cpust_1s;  // avg amount of half-ms stolen over last second
        struct freq_ctr_period cpust_15s; // avg amount of half-ms stolen over last 15s
-       struct freq_ctr ctxsw_rate;// context switching rate over last second
-       struct freq_ctr tasks_rate;// task wakeup rate over last second
        unsigned int avg_loop_us;  // average run time per loop over last 1024 runs
        unsigned int accepted;     // accepted incoming connections
        unsigned int accq_pushed;  // accept queue connections pushed
        unsigned int accq_full;    // accept queue connection not pushed because full
+       unsigned int ctxsw;        // total number of context switches
+       unsigned int tasksw;       // total number of task switches
        char __pad[0]; // unused except to check remaining room
        char __end[0] __attribute__((aligned(64))); // align size to 64.
 };
index 9581369c234fd4e9fbf8bbec3eee4d046f899033..88fbae33a71839e4baceb234aa6c3d0bc1068747 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -1087,8 +1087,8 @@ static int cli_io_handler_show_activity(struct appctx *appctx)
        chunk_appendf(&trash, "\nstream:");       for (thr = 0; thr < global.nbthread; thr++) chunk_appendf(&trash, " %u", activity[thr].stream);
        chunk_appendf(&trash, "\nempty_rq:");     for (thr = 0; thr < global.nbthread; thr++) chunk_appendf(&trash, " %u", activity[thr].empty_rq);
        chunk_appendf(&trash, "\nlong_rq:");      for (thr = 0; thr < global.nbthread; thr++) chunk_appendf(&trash, " %u", activity[thr].long_rq);
-       chunk_appendf(&trash, "\nctxsw_rate:");   for (thr = 0; thr < global.nbthread; thr++) chunk_appendf(&trash, " %u", read_freq_ctr(&activity[thr].ctxsw_rate));
-       chunk_appendf(&trash, "\ntasks_rate:");   for (thr = 0; thr < global.nbthread; thr++) chunk_appendf(&trash, " %u", read_freq_ctr(&activity[thr].tasks_rate));
+       chunk_appendf(&trash, "\nctxsw:");        for (thr = 0; thr < global.nbthread; thr++) chunk_appendf(&trash, " %u", activity[thr].ctxsw);
+       chunk_appendf(&trash, "\ntasksw:");       for (thr = 0; thr < global.nbthread; thr++) chunk_appendf(&trash, " %u", activity[thr].tasksw);
        chunk_appendf(&trash, "\ncpust_ms_tot:"); for (thr = 0; thr < global.nbthread; thr++) chunk_appendf(&trash, " %u", activity[thr].cpust_total/2);
        chunk_appendf(&trash, "\ncpust_ms_1s:");  for (thr = 0; thr < global.nbthread; thr++) chunk_appendf(&trash, " %u", read_freq_ctr(&activity[thr].cpust_1s)/2);
        chunk_appendf(&trash, "\ncpust_ms_15s:"); for (thr = 0; thr < global.nbthread; thr++) chunk_appendf(&trash, " %u", read_freq_ctr_period(&activity[thr].cpust_15s, 15000)/2);
index 27757436d7d7f2e599a4813e0242df01e5dcf3f6..0e5419da7ec96bf6d1f2953f7798c76a7d5cb2b0 100644 (file)
@@ -279,8 +279,6 @@ void process_runnable_tasks()
        struct eb32sc_node *lrq = NULL; // next local run queue entry
        struct eb32sc_node *grq = NULL; // next global run queue entry
        struct task *t;
-       int to_process;
-       int wakeups;
        int max_processed;
 
        if (!(active_tasks_mask & tid_bit)) {
@@ -295,9 +293,6 @@ void process_runnable_tasks()
        if (likely(niced_tasks))
                max_processed = (max_processed + 3) / 4;
 
-       to_process = max_processed;
-       wakeups = 0;
-
        /* Note: the grq lock is always held when grq is not null */
 
        while (task_per_thread[tid].task_list_size < max_processed) {
@@ -350,7 +345,7 @@ void process_runnable_tasks()
 
                /* And add it to the local task list */
                task_insert_into_tasklet_list(t);
-               wakeups++;
+               activity[tid].tasksw++;
        }
 
        /* release the rqueue lock */
@@ -377,6 +372,7 @@ void process_runnable_tasks()
                __ha_barrier_atomic_store();
                __task_remove_from_tasklet_list(t);
 
+               activity[tid].ctxsw++;
                ctx = t->context;
                process = t->process;
                t->calls++;
@@ -426,11 +422,6 @@ void process_runnable_tasks()
                _HA_ATOMIC_OR(&active_tasks_mask, tid_bit);
                activity[tid].long_rq++;
        }
-
-       if (wakeups)
-               update_freq_ctr(&activity[tid].tasks_rate, wakeups);
-       if (to_process - max_processed)
-               update_freq_ctr(&activity[tid].ctxsw_rate, to_process - max_processed);
 }
 
 /*