Index: sys/netinet/tcp_hpts.c =================================================================== --- sys/netinet/tcp_hpts.c +++ sys/netinet/tcp_hpts.c @@ -193,7 +193,8 @@ uint8_t p_direct_wake :1, /* boolean */ p_on_min_sleep:1, /* boolean */ p_hpts_wake_scheduled:1, /* boolean */ - p_avail:5; + hit_callout_thresh:1, + p_avail:4; uint8_t p_fill[3]; /* Fill to 32 bits */ /* Cache line 0x40 */ struct hptsh { @@ -269,6 +270,8 @@ int cpu[MAXCPU]; } hpts_domains[MAXMEMDOM]; +static volatile uint32_t hpts_that_need_softclock = 0; + counter_u64_t hpts_hopelessly_behind; SYSCTL_COUNTER_U64(_net_inet_tcp_hpts_stats, OID_AUTO, hopeless, CTLFLAG_RD, @@ -334,7 +337,7 @@ &tcp_hpts_precision, 120, "Value for PRE() precision of callout"); SYSCTL_INT(_net_inet_tcp_hpts, OID_AUTO, cnt_thresh, CTLFLAG_RW, - &conn_cnt_thresh, 0, + &conn_cnt_thresh, DEFAULT_CONNECTION_THESHOLD, "How many connections (below) make us use the callout based mechanism"); SYSCTL_INT(_net_inet_tcp_hpts, OID_AUTO, logging, CTLFLAG_RW, &hpts_does_tp_logging, 0, @@ -1548,6 +1551,9 @@ struct tcp_hpts_entry *hpts; int ticks_ran; + if (hpts_that_need_softclock == 0) + return; + hpts = tcp_choose_hpts_to_run(); if (hpts->p_hpts_active) { @@ -1683,6 +1689,13 @@ ticks_ran = tcp_hptsi(hpts, 1); tv.tv_sec = 0; tv.tv_usec = hpts->p_hpts_sleep_time * HPTS_TICKS_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); + } else if ((hpts->p_on_queue_cnt <= conn_cnt_thresh) && (hpts->hit_callout_thresh == 1)) { + hpts->hit_callout_thresh = 0; + atomic_subtract_int(&hpts_that_need_softclock, 1); + } if (hpts->p_on_queue_cnt >= conn_cnt_thresh) { if(hpts->p_direct_wake == 0) { /*