Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/cc/cc_cdg.c
Show First 20 Lines • Show All 479 Lines • ▼ Show 20 Lines | |||||
* probability of backoff over time. | * probability of backoff over time. | ||||
* | * | ||||
* Prob_backoff = 1 - exp(-qtrend / V_cdg_exp_backoff_scale), where | * Prob_backoff = 1 - exp(-qtrend / V_cdg_exp_backoff_scale), where | ||||
* V_cdg_exp_backoff_scale is the average qtrend for the exponential backoff. | * V_cdg_exp_backoff_scale is the average qtrend for the exponential backoff. | ||||
*/ | */ | ||||
static inline int | static inline int | ||||
prob_backoff(long qtrend) | prob_backoff(long qtrend) | ||||
{ | { | ||||
int backoff, idx, p; | u_int backoff, idx, p; | ||||
cem: I am hesitant to make type changes like this. They’re unrelated to using arc4random. | |||||
backoff = (qtrend > ((MAXGRAD * V_cdg_exp_backoff_scale) << D_P_E)); | backoff = (qtrend > ((MAXGRAD * V_cdg_exp_backoff_scale) << D_P_E)); | ||||
if (!backoff) { | if (!backoff) { | ||||
if (V_cdg_exp_backoff_scale > 1) | if (V_cdg_exp_backoff_scale > 1) | ||||
idx = (qtrend + V_cdg_exp_backoff_scale / 2) / | idx = (qtrend + V_cdg_exp_backoff_scale / 2) / | ||||
V_cdg_exp_backoff_scale; | V_cdg_exp_backoff_scale; | ||||
else | else | ||||
idx = qtrend; | idx = qtrend; | ||||
/* Backoff probability proportional to rate of queue growth. */ | /* Backoff probability proportional to rate of queue growth. */ | ||||
p = (INT_MAX / (1 << EXP_PREC)) * probexp[idx]; | p = (UINT_MAX / (1 << EXP_PREC)) * probexp[idx]; | ||||
backoff = (random() < p); | backoff = (arc4random() < p); | ||||
Not Done Inline ActionsThis is now a completely different expression in a way that has nothing to do with s/random/arc4random/. Ditto earlier concerns about not being an expert in this code; I don’t know how significant unpredictability is in this context. cem: This is now a completely different expression in a way that has nothing to do with… | |||||
Done Inline ActionsThe real change happens in the comparison in the next line. pfg: The real change happens in the comparison in the next line.
Yes, the change is tricky and has… | |||||
} | } | ||||
return (backoff); | return (backoff); | ||||
} | } | ||||
static inline void | static inline void | ||||
calc_moving_average(struct cdg *cdg_data, long qdiff_max, long qdiff_min) | calc_moving_average(struct cdg *cdg_data, long qdiff_max, long qdiff_min) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 190 Lines • Show Last 20 Lines |
I am hesitant to make type changes like this. They’re unrelated to using arc4random.