99#include "homa_pacer.h"
1010#include "homa_rpc.h"
1111
12- #ifndef __STRIP__ /* See strip.py */
1312/* Used to enable sysctl access to pacer-specific configuration parameters. The
1413 * @data fields are actually offsets within a struct homa_pacer; these are
1514 * converted to pointers into a net-specific struct homa later.
@@ -38,7 +37,6 @@ static struct ctl_table pacer_ctl_table[] = {
3837 .proc_handler = homa_pacer_dointvec
3938 },
4039};
41- #endif /* See strip.py */
4240
4341/**
4442 * homa_pacer_alloc() - Allocate and initialize a new pacer object, which
@@ -71,15 +69,13 @@ struct homa_pacer *homa_pacer_alloc(struct homa *homa)
7169 }
7270 atomic64_set (& pacer -> link_idle_time , homa_clock ());
7371
74- #ifndef __STRIP__ /* See strip.py */
7572 pacer -> sysctl_header = register_net_sysctl (& init_net , "net/homa" ,
7673 pacer_ctl_table );
7774 if (!pacer -> sysctl_header ) {
7875 err = - ENOMEM ;
7976 pr_err ("couldn't register sysctl parameters for Homa pacer\n" );
8077 goto error ;
8178 }
82- #endif /* See strip.py */
8379 homa_pacer_update_sysctl_deps (pacer );
8480 return pacer ;
8581
@@ -96,12 +92,10 @@ struct homa_pacer *homa_pacer_alloc(struct homa *homa)
9692 */
9793void homa_pacer_free (struct homa_pacer * pacer )
9894{
99- #ifndef __STRIP__ /* See strip.py */
10095 if (pacer -> sysctl_header ) {
10196 unregister_net_sysctl_table (pacer -> sysctl_header );
10297 pacer -> sysctl_header = NULL ;
10398 }
104- #endif /* See strip.py */
10599 if (pacer -> kthread ) {
106100 kthread_stop (pacer -> kthread );
107101 pacer -> kthread = NULL ;
@@ -141,27 +135,12 @@ int homa_pacer_check_nic_q(struct homa_pacer *pacer, struct sk_buff *skb,
141135 if ((clock + pacer -> max_nic_queue_cycles ) < idle && !force &&
142136 !(pacer -> homa -> flags & HOMA_FLAG_DONT_THROTTLE ))
143137 return 0 ;
144- #ifndef __STRIP__ /* See strip.py */
145138 if (!list_empty (& pacer -> throttled_rpcs ))
146139 INC_METRIC (pacer_bytes , bytes );
147- if (idle < clock ) {
148- if (pacer -> wake_time ) {
149- u64 lost = (pacer -> wake_time > idle )
150- ? clock - pacer -> wake_time
151- : clock - idle ;
152- INC_METRIC (pacer_lost_cycles , lost );
153- tt_record1 ("pacer lost %d cycles" , lost );
154- }
155- new_idle = clock + cycles_for_packet ;
156- } else {
157- new_idle = idle + cycles_for_packet ;
158- }
159- #else /* See strip.py */
160140 if (idle < clock )
161141 new_idle = clock + cycles_for_packet ;
162142 else
163143 new_idle = idle + cycles_for_packet ;
164- #endif /* See strip.py */
165144
166145 /* This method must be thread-safe. */
167146 if (atomic64_cmpxchg_relaxed (& pacer -> link_idle_time , idle ,
@@ -180,15 +159,15 @@ int homa_pacer_check_nic_q(struct homa_pacer *pacer, struct sk_buff *skb,
180159int homa_pacer_main (void * arg )
181160{
182161 struct homa_pacer * pacer = arg ;
162+ u64 wake_time ;
183163 int status ;
184164
185165 while (1 ) {
186166 if (kthread_should_stop ())
187167 break ;
188- pacer -> wake_time = homa_clock ();
168+ wake_time = homa_clock ();
189169 homa_pacer_xmit (pacer );
190- INC_METRIC (pacer_cycles , homa_clock () - pacer -> wake_time );
191- pacer -> wake_time = 0 ;
170+ INC_METRIC (pacer_cycles , homa_clock () - wake_time );
192171 if (!list_empty (& pacer -> throttled_rpcs )) {
193172 /* NIC queue is full; before calling pacer again,
194173 * give other threads a chance to run (otherwise
@@ -285,12 +264,8 @@ void homa_pacer_xmit(struct homa_pacer *pacer)
285264 /* Note: rpc->state could be RPC_DEAD here, but the code
286265 * below should work anyway.
287266 */
288- #ifndef __STRIP__ /* See strip.py */
289267 if (!* rpc -> msgout .next_xmit || rpc -> msgout .next_xmit_offset >=
290268 rpc -> msgout .granted ) {
291- #else /* See strip.py */
292- if (!* rpc -> msgout .next_xmit ) {
293- #endif /* See strip.py */
294269 /* No more data can be transmitted from this message
295270 * (right now), so remove it from the throttled list.
296271 */
@@ -317,25 +292,22 @@ void homa_pacer_manage_rpc(struct homa_rpc *rpc)
317292 struct homa_pacer * pacer = rpc -> hsk -> homa -> pacer ;
318293 struct homa_rpc * candidate ;
319294 int bytes_left ;
320-
321- IF_NO_STRIP (int checks = 0 );
322- IF_NO_STRIP (u64 now );
295+ int checks = 0 ;
296+ u64 now ;
323297
324298 if (!list_empty (& rpc -> throttled_links ))
325299 return ;
326- IF_NO_STRIP (now = homa_clock ());
327- #ifndef __STRIP__ /* See strip.py */
300+ now = homa_clock ();
328301 if (!list_empty (& pacer -> throttled_rpcs ))
329- INC_METRIC (throttled_cycles , now - pacer -> throttle_add );
302+ INC_METRIC (nic_backlog_cycles , now - pacer -> throttle_add );
330303 pacer -> throttle_add = now ;
331- #endif /* See strip.py */
332304 bytes_left = rpc -> msgout .length - rpc -> msgout .next_xmit_offset ;
333305 homa_pacer_throttle_lock (pacer );
334306 list_for_each_entry (candidate , & pacer -> throttled_rpcs ,
335307 throttled_links ) {
336308 int bytes_left_cand ;
337309
338- IF_NO_STRIP ( checks ++ ) ;
310+ checks ++ ;
339311
340312 /* Watch out: the pacer might have just transmitted the last
341313 * packet from candidate.
@@ -371,11 +343,9 @@ void homa_pacer_unmanage_rpc(struct homa_rpc *rpc)
371343 UNIT_LOG ("; " , "removing id %llu from throttled list" , rpc -> id );
372344 homa_pacer_throttle_lock (pacer );
373345 list_del_init (& rpc -> throttled_links );
374- #ifndef __STRIP__ /* See strip.py */
375346 if (list_empty (& pacer -> throttled_rpcs ))
376- INC_METRIC (throttled_cycles , homa_clock ()
347+ INC_METRIC (nic_backlog_cycles , homa_clock ()
377348 - pacer -> throttle_add );
378- #endif /* See strip.py */
379349 homa_pacer_throttle_unlock (pacer );
380350 }
381351}
@@ -399,7 +369,6 @@ void homa_pacer_update_sysctl_deps(struct homa_pacer *pacer)
399369 pacer -> cycles_per_mbyte = tmp ;
400370}
401371
402- #ifndef __STRIP__ /* See strip.py */
403372/**
404373 * homa_pacer_dointvec() - This function is a wrapper around proc_dointvec. It
405374 * is invoked to read and write pacer-related sysctl values.
@@ -481,4 +450,3 @@ void homa_pacer_throttle_lock_slow(struct homa_pacer *pacer)
481450 INC_METRIC (throttle_lock_misses , 1 );
482451 INC_METRIC (throttle_lock_miss_cycles , homa_clock () - start );
483452}
484- #endif /* See strip.py */
0 commit comments