mirror of
https://github.com/opnsense/src.git
synced 2026-06-11 01:30:30 -04:00
tcp: improve variable and constant names
Don't use ticks in variable names or constant when they don't have
a relation to ticks. Use slots or usecs.
No functional change intended.
Reviewed by: tuexen
Sponsored by: Netflix, Inc.
(cherry picked from commit f197a24d11)
This commit is contained in:
parent
c89b8ac883
commit
ea12fa13fe
4 changed files with 42 additions and 42 deletions
|
|
@ -365,7 +365,7 @@ sysctl_net_inet_tcp_hpts_max_sleep(SYSCTL_HANDLER_ARGS)
|
|||
new = hpts_sleep_max;
|
||||
error = sysctl_handle_int(oidp, &new, 0, req);
|
||||
if (error == 0 && req->newptr) {
|
||||
if ((new < (dynamic_min_sleep/HPTS_TICKS_PER_SLOT)) ||
|
||||
if ((new < (dynamic_min_sleep/HPTS_USECS_PER_SLOT)) ||
|
||||
(new > HPTS_MAX_SLEEP_ALLOWED))
|
||||
error = EINVAL;
|
||||
else
|
||||
|
|
@ -403,15 +403,15 @@ SYSCTL_PROC(_net_inet_tcp_hpts, OID_AUTO, minsleep,
|
|||
&sysctl_net_inet_tcp_hpts_min_sleep, "IU",
|
||||
"The minimum time the hpts must sleep before processing more slots");
|
||||
|
||||
static int ticks_indicate_more_sleep = TICKS_INDICATE_MORE_SLEEP;
|
||||
static int ticks_indicate_less_sleep = TICKS_INDICATE_LESS_SLEEP;
|
||||
static int slots_indicate_more_sleep = SLOTS_INDICATE_MORE_SLEEP;
|
||||
static int slots_indicate_less_sleep = SLOTS_INDICATE_LESS_SLEEP;
|
||||
static int tcp_hpts_no_wake_over_thresh = 1;
|
||||
|
||||
SYSCTL_INT(_net_inet_tcp_hpts, OID_AUTO, more_sleep, CTLFLAG_RW,
|
||||
&ticks_indicate_more_sleep, 0,
|
||||
&slots_indicate_more_sleep, 0,
|
||||
"If we only process this many or less on a timeout, we need longer sleep on the next callout");
|
||||
SYSCTL_INT(_net_inet_tcp_hpts, OID_AUTO, less_sleep, CTLFLAG_RW,
|
||||
&ticks_indicate_less_sleep, 0,
|
||||
&slots_indicate_less_sleep, 0,
|
||||
"If we process this many or more on a timeout, we need less sleep on the next callout");
|
||||
SYSCTL_INT(_net_inet_tcp_hpts, OID_AUTO, nowake_over_thresh, CTLFLAG_RW,
|
||||
&tcp_hpts_no_wake_over_thresh, 0,
|
||||
|
|
@ -876,7 +876,7 @@ tcp_hpts_insert_diag(struct tcpcb *tp, uint32_t slot, int32_t line, struct hpts_
|
|||
return (slot_on);
|
||||
}
|
||||
/* Get the current time relative to the wheel */
|
||||
wheel_cts = tcp_tv_to_hptstick(&tv);
|
||||
wheel_cts = tcp_tv_to_hpts_slot(&tv);
|
||||
/* Map it onto the wheel */
|
||||
wheel_slot = tick_to_wheel(wheel_cts);
|
||||
/* Now what's the max we can place it at? */
|
||||
|
|
@ -948,7 +948,7 @@ tcp_hpts_insert_diag(struct tcpcb *tp, uint32_t slot, int32_t line, struct hpts_
|
|||
* We need to reschedule the hpts's time-out.
|
||||
*/
|
||||
hpts->p_hpts_sleep_time = slot;
|
||||
need_new_to = slot * HPTS_TICKS_PER_SLOT;
|
||||
need_new_to = slot * HPTS_USECS_PER_SLOT;
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
|
@ -1119,7 +1119,7 @@ again:
|
|||
HPTS_MTX_ASSERT(hpts);
|
||||
slots_to_run = hpts_slots_diff(hpts->p_prev_slot, hpts->p_cur_slot);
|
||||
if (((hpts->p_curtick - hpts->p_lasttick) >
|
||||
((NUM_OF_HPTSI_SLOTS-1) * HPTS_TICKS_PER_SLOT)) &&
|
||||
((NUM_OF_HPTSI_SLOTS-1) * HPTS_USECS_PER_SLOT)) &&
|
||||
(hpts->p_on_queue_cnt != 0)) {
|
||||
/*
|
||||
* Wheel wrap is occuring, basically we
|
||||
|
|
@ -1200,7 +1200,7 @@ again:
|
|||
* was not any (i.e. if slots_to_run == 1, no delay).
|
||||
*/
|
||||
hpts->p_delayed_by = (slots_to_run - (i + 1)) *
|
||||
HPTS_TICKS_PER_SLOT;
|
||||
HPTS_USECS_PER_SLOT;
|
||||
|
||||
runningslot = hpts->p_runningslot;
|
||||
hptsh = &hpts->p_hptss[runningslot];
|
||||
|
|
@ -1571,7 +1571,7 @@ __tcp_run_hpts(void)
|
|||
ticks_ran = tcp_hptsi(hpts, 0);
|
||||
/* We may want to adjust the sleep values here */
|
||||
if (hpts->p_on_queue_cnt >= conn_cnt_thresh) {
|
||||
if (ticks_ran > ticks_indicate_less_sleep) {
|
||||
if (ticks_ran > slots_indicate_less_sleep) {
|
||||
struct timeval tv;
|
||||
sbintime_t sb;
|
||||
|
||||
|
|
@ -1581,7 +1581,7 @@ __tcp_run_hpts(void)
|
|||
/* Reschedule with new to value */
|
||||
tcp_hpts_set_max_sleep(hpts, 0);
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = hpts->p_hpts_sleep_time * HPTS_TICKS_PER_SLOT;
|
||||
tv.tv_usec = hpts->p_hpts_sleep_time * HPTS_USECS_PER_SLOT;
|
||||
/* Validate its in the right ranges */
|
||||
if (tv.tv_usec < hpts->p_mysleep.tv_usec) {
|
||||
hpts->overidden_sleep = tv.tv_usec;
|
||||
|
|
@ -1603,7 +1603,7 @@ __tcp_run_hpts(void)
|
|||
callout_reset_sbt_on(&hpts->co, sb, 0,
|
||||
hpts_timeout_swi, hpts, hpts->p_cpu,
|
||||
(C_DIRECT_EXEC | C_PREL(tcp_hpts_precision)));
|
||||
} else if (ticks_ran < ticks_indicate_more_sleep) {
|
||||
} else if (ticks_ran < slots_indicate_more_sleep) {
|
||||
/* For the further sleep, don't reschedule hpts */
|
||||
hpts->p_mysleep.tv_usec *= 2;
|
||||
if (hpts->p_mysleep.tv_usec > dynamic_max_sleep)
|
||||
|
|
@ -1686,7 +1686,7 @@ tcp_hpts_thread(void *ctx)
|
|||
hpts->p_hpts_active = 1;
|
||||
ticks_ran = tcp_hptsi(hpts, 1);
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = hpts->p_hpts_sleep_time * HPTS_TICKS_PER_SLOT;
|
||||
tv.tv_usec = hpts->p_hpts_sleep_time * HPTS_USECS_PER_SLOT;
|
||||
if ((hpts->p_on_queue_cnt > conn_cnt_thresh) && (hpts->hit_callout_thresh == 0)) {
|
||||
hpts->hit_callout_thresh = 1;
|
||||
atomic_add_int(&hpts_that_need_softclock, 1);
|
||||
|
|
@ -1700,11 +1700,11 @@ tcp_hpts_thread(void *ctx)
|
|||
* Only adjust sleep time if we were
|
||||
* called from the callout i.e. direct_wake == 0.
|
||||
*/
|
||||
if (ticks_ran < ticks_indicate_more_sleep) {
|
||||
if (ticks_ran < slots_indicate_more_sleep) {
|
||||
hpts->p_mysleep.tv_usec *= 2;
|
||||
if (hpts->p_mysleep.tv_usec > dynamic_max_sleep)
|
||||
hpts->p_mysleep.tv_usec = dynamic_max_sleep;
|
||||
} else if (ticks_ran > ticks_indicate_less_sleep) {
|
||||
} else if (ticks_ran > slots_indicate_less_sleep) {
|
||||
hpts->p_mysleep.tv_usec /= 2;
|
||||
if (hpts->p_mysleep.tv_usec < dynamic_min_sleep)
|
||||
hpts->p_mysleep.tv_usec = dynamic_min_sleep;
|
||||
|
|
@ -1998,7 +1998,7 @@ tcp_hpts_mod_load(void)
|
|||
}
|
||||
}
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = hpts->p_hpts_sleep_time * HPTS_TICKS_PER_SLOT;
|
||||
tv.tv_usec = hpts->p_hpts_sleep_time * HPTS_USECS_PER_SLOT;
|
||||
hpts->sleeping = tv.tv_usec;
|
||||
sb = tvtosbt(tv);
|
||||
callout_reset_sbt_on(&hpts->co, sb, 0,
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@
|
|||
#ifndef __tcp_hpts_h__
|
||||
#define __tcp_hpts_h__
|
||||
|
||||
/* Number of useconds in a hpts tick */
|
||||
#define HPTS_TICKS_PER_SLOT 10
|
||||
/* Number of useconds represented by an hpts slot */
|
||||
#define HPTS_USECS_PER_SLOT 10
|
||||
#define HPTS_MS_TO_SLOTS(x) ((x * 100) + 1)
|
||||
#define HPTS_USEC_TO_SLOTS(x) ((x+9) /10)
|
||||
#define HPTS_USEC_IN_SEC 1000000
|
||||
|
|
@ -91,8 +91,8 @@ struct hpts_diag {
|
|||
#define DYNAMIC_MAX_SLEEP 5000 /* 5ms */
|
||||
|
||||
/* Thresholds for raising/lowering sleep */
|
||||
#define TICKS_INDICATE_MORE_SLEEP 100 /* This would be 1ms */
|
||||
#define TICKS_INDICATE_LESS_SLEEP 1000 /* This would indicate 10ms */
|
||||
#define SLOTS_INDICATE_MORE_SLEEP 100 /* This would be 1ms */
|
||||
#define SLOTS_INDICATE_LESS_SLEEP 1000 /* This would indicate 10ms */
|
||||
/**
|
||||
*
|
||||
* Dynamic adjustment of sleeping times is done in "new" mode
|
||||
|
|
@ -102,10 +102,10 @@ struct hpts_diag {
|
|||
* When we are in the "new" mode i.e. conn_cnt > conn_cnt_thresh
|
||||
* then we do a dynamic adjustment on the time we sleep.
|
||||
* Our threshold is if the lateness of the first client served (in ticks) is
|
||||
* greater than or equal too ticks_indicate_more_sleep (10ms
|
||||
* greater than or equal too slots_indicate_more_sleep (10ms
|
||||
* or 10000 ticks). If we were that late, the actual sleep time
|
||||
* is adjusted down by 50%. If the ticks_ran is less than
|
||||
* ticks_indicate_more_sleep (100 ticks or 1000usecs).
|
||||
* slots_indicate_more_sleep (100 ticks or 1000usecs).
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
@ -165,9 +165,9 @@ extern int32_t tcp_min_hptsi_time;
|
|||
* to userspace as well.
|
||||
*/
|
||||
static inline uint32_t
|
||||
tcp_tv_to_hptstick(const struct timeval *sv)
|
||||
tcp_tv_to_hpts_slot(const struct timeval *sv)
|
||||
{
|
||||
return ((sv->tv_sec * 100000) + (sv->tv_usec / HPTS_TICKS_PER_SLOT));
|
||||
return ((sv->tv_sec * 100000) + (sv->tv_usec / HPTS_USECS_PER_SLOT));
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
|
|
@ -195,7 +195,7 @@ extern int32_t tcp_min_hptsi_time;
|
|||
static inline int32_t
|
||||
get_hpts_min_sleep_time(void)
|
||||
{
|
||||
return (tcp_min_hptsi_time + HPTS_TICKS_PER_SLOT);
|
||||
return (tcp_min_hptsi_time + HPTS_USECS_PER_SLOT);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
|
|
@ -206,7 +206,7 @@ tcp_gethptstick(struct timeval *sv)
|
|||
if (sv == NULL)
|
||||
sv = &tv;
|
||||
microuptime(sv);
|
||||
return (tcp_tv_to_hptstick(sv));
|
||||
return (tcp_tv_to_hpts_slot(sv));
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
|
|
|
|||
|
|
@ -14098,17 +14098,17 @@ bbr_switch_failed(struct tcpcb *tp)
|
|||
toval = bbr->rc_pacer_started - cts;
|
||||
} else {
|
||||
/* one slot please */
|
||||
toval = HPTS_TICKS_PER_SLOT;
|
||||
toval = HPTS_USECS_PER_SLOT;
|
||||
}
|
||||
} else if (bbr->r_ctl.rc_hpts_flags & PACE_TMR_MASK) {
|
||||
if (TSTMP_GT(bbr->r_ctl.rc_timer_exp, cts)) {
|
||||
toval = bbr->r_ctl.rc_timer_exp - cts;
|
||||
} else {
|
||||
/* one slot please */
|
||||
toval = HPTS_TICKS_PER_SLOT;
|
||||
toval = HPTS_USECS_PER_SLOT;
|
||||
}
|
||||
} else
|
||||
toval = HPTS_TICKS_PER_SLOT;
|
||||
toval = HPTS_USECS_PER_SLOT;
|
||||
(void)tcp_hpts_insert_diag(tp, HPTS_USEC_TO_SLOTS(toval),
|
||||
__LINE__, &diag);
|
||||
bbr_log_hpts_diag(bbr, cts, &diag);
|
||||
|
|
|
|||
|
|
@ -6790,22 +6790,22 @@ rack_start_hpts_timer(struct tcp_rack *rack, struct tcpcb *tp, uint32_t cts,
|
|||
* on the clock. We always have a min
|
||||
* 10 slots (10 x 10 i.e. 100 usecs).
|
||||
*/
|
||||
if (slot <= HPTS_TICKS_PER_SLOT) {
|
||||
if (slot <= HPTS_USECS_PER_SLOT) {
|
||||
/* We gain delay */
|
||||
rack->r_ctl.rc_agg_delayed += (HPTS_TICKS_PER_SLOT - slot);
|
||||
slot = HPTS_TICKS_PER_SLOT;
|
||||
rack->r_ctl.rc_agg_delayed += (HPTS_USECS_PER_SLOT - slot);
|
||||
slot = HPTS_USECS_PER_SLOT;
|
||||
} else {
|
||||
/* We take off some */
|
||||
rack->r_ctl.rc_agg_delayed -= (slot - HPTS_TICKS_PER_SLOT);
|
||||
slot = HPTS_TICKS_PER_SLOT;
|
||||
rack->r_ctl.rc_agg_delayed -= (slot - HPTS_USECS_PER_SLOT);
|
||||
slot = HPTS_USECS_PER_SLOT;
|
||||
}
|
||||
} else {
|
||||
slot -= rack->r_ctl.rc_agg_delayed;
|
||||
rack->r_ctl.rc_agg_delayed = 0;
|
||||
/* Make sure we have 100 useconds at minimum */
|
||||
if (slot < HPTS_TICKS_PER_SLOT) {
|
||||
rack->r_ctl.rc_agg_delayed = HPTS_TICKS_PER_SLOT - slot;
|
||||
slot = HPTS_TICKS_PER_SLOT;
|
||||
if (slot < HPTS_USECS_PER_SLOT) {
|
||||
rack->r_ctl.rc_agg_delayed = HPTS_USECS_PER_SLOT - slot;
|
||||
slot = HPTS_USECS_PER_SLOT;
|
||||
}
|
||||
if (rack->r_ctl.rc_agg_delayed == 0)
|
||||
rack->r_late = 0;
|
||||
|
|
@ -14765,17 +14765,17 @@ rack_switch_failed(struct tcpcb *tp)
|
|||
toval = rack->r_ctl.rc_last_output_to - cts;
|
||||
} else {
|
||||
/* one slot please */
|
||||
toval = HPTS_TICKS_PER_SLOT;
|
||||
toval = HPTS_USECS_PER_SLOT;
|
||||
}
|
||||
} else if (rack->r_ctl.rc_hpts_flags & PACE_TMR_MASK) {
|
||||
if (TSTMP_GT(rack->r_ctl.rc_timer_exp, cts)) {
|
||||
toval = rack->r_ctl.rc_timer_exp - cts;
|
||||
} else {
|
||||
/* one slot please */
|
||||
toval = HPTS_TICKS_PER_SLOT;
|
||||
toval = HPTS_USECS_PER_SLOT;
|
||||
}
|
||||
} else
|
||||
toval = HPTS_TICKS_PER_SLOT;
|
||||
toval = HPTS_USECS_PER_SLOT;
|
||||
(void)tcp_hpts_insert_diag(tp, HPTS_USEC_TO_SLOTS(toval),
|
||||
__LINE__, &diag);
|
||||
rack_log_hpts_diag(rack, cts, &diag, &tv);
|
||||
|
|
@ -15365,7 +15365,7 @@ rack_init(struct tcpcb *tp, void **ptr)
|
|||
if (TSTMP_GT(qr.timer_pacing_to, us_cts))
|
||||
tov = qr.timer_pacing_to - us_cts;
|
||||
else
|
||||
tov = HPTS_TICKS_PER_SLOT;
|
||||
tov = HPTS_USECS_PER_SLOT;
|
||||
}
|
||||
if (qr.timer_hpts_flags & PACE_TMR_MASK) {
|
||||
rack->r_ctl.rc_timer_exp = qr.timer_timer_exp;
|
||||
|
|
@ -15373,7 +15373,7 @@ rack_init(struct tcpcb *tp, void **ptr)
|
|||
if (TSTMP_GT(qr.timer_timer_exp, us_cts))
|
||||
tov = qr.timer_timer_exp - us_cts;
|
||||
else
|
||||
tov = HPTS_TICKS_PER_SLOT;
|
||||
tov = HPTS_USECS_PER_SLOT;
|
||||
}
|
||||
}
|
||||
rack_log_chg_info(tp, rack, 4,
|
||||
|
|
|
|||
Loading…
Reference in a new issue