-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathhoma_metrics.h
More file actions
865 lines (724 loc) · 22.7 KB
/
homa_metrics.h
File metadata and controls
865 lines (724 loc) · 22.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
/* SPDX-License-Identifier: BSD-2-Clause or GPL-2.0+ */
/* This file contains declarations related to Homa's performance metrics. */
#ifndef _HOMA_METRICS_H
#define _HOMA_METRICS_H
#include <linux/percpu-defs.h>
#include <linux/types.h>
#include "homa_wire.h"
/**
* struct homa_metrics - various performance counters kept by Homa.
*
* There is one of these structures for each core, so counters can
* be updated without worrying about synchronization or extra cache
* misses.
*
* All counters are free-running: they never reset.
*/
struct homa_metrics {
/**
* @small_msg_bytes: entry i holds the total number of bytes
* received in messages whose length is between 64*i and 64*i + 63,
* inclusive.
*/
#define HOMA_NUM_SMALL_COUNTS 64
u64 small_msg_bytes[HOMA_NUM_SMALL_COUNTS];
/**
* @medium_msg_bytes: entry i holds the total number of bytes
* received in messages whose length is between 1024*i and
* 1024*i + 1023, inclusive. The first four entries are always 0
* (small_msg_counts covers this range).
*/
#define HOMA_NUM_MEDIUM_COUNTS 128
u64 medium_msg_bytes[HOMA_NUM_MEDIUM_COUNTS];
/**
* @large_msg_count: the total number of messages received whose
* length is too large to appear in medium_msg_bytes.
*/
u64 large_msg_count;
/**
* @large_msg_bytes: the total number of bytes received in
* messages too large to be counted by medium_msg_bytes.
*/
u64 large_msg_bytes;
/**
* @client_requests_started: cumulative count of all client RPCs
* that have been initiated on this node.
*/
u64 client_requests_started;
/**
* @client_request_bytes_started: total number of bytes in the
* request messages for all client RPCs that have been initiated on
* this node.
*/
u64 client_request_bytes_started;
/**
* @client_request_bytes_done: total number of bytes in request
* messages that no longer need to be transmitted (for the first time)
* either because they were transmitted or because the RPC was aborted.
* Always <= client_request_bytes_started.
*/
u64 client_request_bytes_done;
/**
* @client_requests_done: cumulative count of all client RPCs
* whose request messages have been completely transmitted (or the RPC
* was aborted).
*/
u64 client_requests_done;
/**
* @client_responses_started: cumulative count of all client RPCs
* for which at least one packet of the response has been received.
*/
u64 client_responses_started;
/**
* @client_response_bytes_started: total number of bytes in
* response messages for client RPCs for which at least one byte
* of response has been received.
*/
u64 client_response_bytes_started;
/**
* @client_response_bytes_done: cumulative count of bytes in
* @client_response_bytes_started that no longer need to be received
* (either they were received or the RPC was aborted).
*/
u64 client_response_bytes_done;
/**
* @client_responses_done: cumulative count of all client RPCs
* that have been completed on this node (either successfully or
* with errors).
*/
u64 client_responses_done;
/**
* @server_requests_started: cumulative count of all server RPCs
* for which at least one packet of the request has been received.
*/
u64 server_requests_started;
/**
* @server_request_bytes_started: total number of bytes in the
* request messages for server RPCs counted by @server_reuqests_started.
*/
u64 server_request_bytes_started;
/**
* @server_request_bytes_done: total number of bytes in
* @server_request_bytes_started that no longer need to be received
* (either they were received or the RPC was aborted).
*/
u64 server_request_bytes_done;
/**
* @server_requests_done: cumulative count of all server RPCs
* whose request messages have been completely received (or the RPC
* was aborted).
*/
u64 server_requests_done;
/**
* @server_responses_started: cumulative count of all server RPCs
* for which transmission of the response has begun.
*/
u64 server_responses_started;
/**
* @server_response_bytes_started: total number of bytes in
* the messages counted by @server_responses_started.
*/
u64 server_response_bytes_started;
/**
* @server_response_bytes_done: total number of bytes in
* @server_response_bytes_started that no longer need to be transmitted
* (either they were transmitted at least once or the RPC was aborted).
*/
u64 server_response_bytes_done;
/**
* @server_responses_done: total number of server RPCS in
* @server_requests_started that are no longer active (either the
* response was completely sent or the RPC was aborted).
*/
u64 server_responses_done;
/**
* @sent_msg_bytes: The total number of bytes in outbound
* messages.
*/
u64 sent_msg_bytes;
/**
* @packets_sent: total number of packets sent for each packet type
* (entry 0 corresponds to DATA, and so on).
*/
u64 packets_sent[MAX_OP + 1 - DATA];
/**
* @packets_received: total number of packets received for each
* packet type (entry 0 corresponds to DATA, and so on).
*/
u64 packets_received[MAX_OP + 1 - DATA];
/** @priority_bytes: total bytes sent at each priority level. */
u64 priority_bytes[HOMA_MAX_PRIORITIES];
/** @priority_packets: total packets sent at each priority level. */
u64 priority_packets[HOMA_MAX_PRIORITIES];
/**
* @skb_allocs: total number of calls to homa_skb_alloc_tx.
*/
u64 skb_allocs;
/** @skb_alloc_cycles: total time spent in homa_skb_alloc_tx. */
u64 skb_alloc_cycles;
/**
* @skb_frees: total number of sk_buffs for data packets that have
* been freed (counts normal paths only).
*/
u64 skb_frees;
/** @skb_free_cycles: total time spent freeing sk_buffs. */
u64 skb_free_cycles;
/**
* @skb_page_allocs: total number of calls to homa_skb_page_alloc.
*/
u64 skb_page_allocs;
/** @skb_page_alloc_cycles: total time spent in homa_skb_page_alloc. */
u64 skb_page_alloc_cycles;
/**
* @requests_received: total number of request messages received.
*/
u64 requests_received;
/**
* @responses_received: total number of response messages received.
*/
u64 responses_received;
/**
* @wait_none: total number of times that an incoming message was
* already waiting when recvmsg was invoked.
*/
u64 wait_none;
/**
* @wait_fast: total number of times that a thread received an
* incoming message while polling (i.e. the message wasn't
* immediately available, but the thread never blocked).
*/
u64 wait_fast;
/**
* @wait_block: total number of times that a thread received an
* incoming message after blocking at least once.
*/
u64 wait_block;
/**
* @handoffs_thread_waiting: total number of times that an RPC
* was handed off to a waiting thread (vs. being queued).
*/
u64 handoffs_thread_waiting;
/**
* @handoffs_alt_thread: total number of times that a thread other
* than the first on the list was chosen for a handoff (because the
* first thread was on a busy core).
*/
u64 handoffs_alt_thread;
/**
* @poll_cycles: total time spent in the polling loop in
* homa_wait_for_message.
*/
u64 poll_cycles;
/**
* @softirq_calls: total number of calls to homa_softirq (i.e.,
* total number of GRO packets processed, each of which could contain
* multiple Homa packets.
*/
u64 softirq_calls;
/**
* @softirq_cycles: total time spent executing homa_softirq when
* invoked under Linux's SoftIRQ handler.
*/
u64 softirq_cycles;
/**
* @bypass_softirq_cycles: total time spent executing homa_softirq when
* invoked during GRO, bypassing the SoftIRQ mechanism.
*/
u64 bypass_softirq_cycles;
/**
* @linux_softirq_cycles: total time spent executing all softirq
* activities, as measured by the linux softirq module. Only
* available with modified Linux kernels.
*/
u64 linux_softirq_cycles;
/**
* @napi_cycles: total time spent executing all NAPI activities, as
* measured by the linux softirq module. Only available with modified
* Linux kernels.
*/
u64 napi_cycles;
/**
* @linux_softirqd_actions: total number of times that a SoftIRQ
* action was taken in the softirqd daemon thread (slow path) rather
* than in the bottom-half SoftIRQ handler.
*/
u64 linux_softirqd_actions;
/**
* @send_cycles: total time spent executing the homa_sendmsg kernel
* call handler to send requests.
*/
u64 send_cycles;
/**
* @send_calls: total number of invocations of homa_semdmsg
* for requests.
*/
u64 send_calls;
/**
* @recv_cycles: total time spent executing homa_recvmsg (including
* time when the thread is blocked).
*/
u64 recv_cycles;
/** @recv_calls: total number of invocations of homa_recvmsg. */
u64 recv_calls;
/**
* @blocked_cycles: total time spent by threads in blocked state
* while executing the homa_recvmsg kernel call handler.
*/
u64 blocked_cycles;
/**
* @reply_cycles: total time spent executing the homa_sendmsg kernel
* call handler to send responses.
*/
u64 reply_cycles;
/**
* @reply_calls: total number of invocations of homa_semdmsg
* for responses.
*/
u64 reply_calls;
/**
* @abort_cycles: total time spent executing the homa_ioc_abort
* kernel call handler.
*/
u64 abort_cycles;
/**
* @abort_calls: total number of invocations of the homa_ioc_abort
* kernel call.
*/
u64 abort_calls;
/**
* @so_set_buf_cycles: total time spent executing the homa_ioc_set_buf
* kernel call handler.
*/
u64 so_set_buf_cycles;
/**
* @so_set_buf_calls: total number of invocations of the homa_ioc_set_buf
* kernel call.
*/
u64 so_set_buf_calls;
/** @grant_lock_cycles: total time spent with the grant lock locked. */
u64 grant_lock_cycles;
/** @timer_cycles: total time spent in homa_timer. */
u64 timer_cycles;
/**
* @timer_reap_cycles: total time spent by homa_timer to reap dead
* RPCs. This time is included in @timer_cycles.
*/
u64 timer_reap_cycles;
/**
* @data_pkt_reap_cycles: total time spent by homa_data_pkt to reap
* dead RPCs.
*/
u64 data_pkt_reap_cycles;
/**
* @idle_time_conflicts: total number of times that an update to
* link_idle_time in homa_qdisc_update_link_idle failed because
* of a conflicting access.
*/
__u64 idle_time_conflicts;
/**
* @nic_backlog_cycles: total amount of time when there were packets
* waiting to be transmitted in homa_qdisc because the NIC queue was
* too long.
*/
u64 nic_backlog_cycles;
/**
* @pacer_cycles: total execution time in the pacer thread (excluding
* blocked time).
*/
u64 pacer_cycles;
/**
* @pacer_xmit_cycles: total time spent by the pacer actually
* transmitting packets (as opposed to polling waiting for the
* NIC queue to subside).
*/
u64 pacer_xmit_cycles;
/**
* @pacer_homa_packets: total number of Homa packets that were
* transmitted by homa_qdisc_pacer (they were deferred because of
* NIC queue overload).
*/
u64 pacer_homa_packets;
/**
* @pacer_homa_bytes: total number of bytes in Homa packets that were
* transmitted by homa_qdisc_pacer (they were deferred because of
* NIC queue overload).
*/
u64 pacer_homa_bytes;
/**
* @pacer_fifo_bytes: total number of bytes in Homa packets that
* were transmitted using FIFO priority rather than SRPC.
*/
u64 pacer_fifo_bytes;
/**
* @pacer_tcp_packets: total number of TCP packets that were
* transmitted by homa_qdisc_pacer (they were deferred because of
* NIC queue overload).
*/
u64 pacer_tcp_packets;
/**
* @pacer_tcp_bytes: total number of bytes in TCP packets that were
* transmitted by homa_qdisc_pacer (they were deferred because of
* NIC queue overload).
*/
u64 pacer_tcp_bytes;
/**
* @pacer_help_bytes: bytes that the pacer transmitted via calls to
* homa_qdisc_pacer_check (presumably because the pacer thread
* wasn't keeping up). Includes both TCP and Homa packets as well as
* header bytes.
*/
u64 pacer_help_bytes;
/**
* @qdisc_tcp_packets: total number of TCP packets that passed through
* homa_qdisc; includes packets that were transmitted immediately as
* well as those that were deferred.
*/
u64 qdisc_tcp_packets;
/**
* @resent_packets: total number of data packets issued in response to
* RESEND packets.
*/
u64 resent_packets;
/**
* @peer_allocs: total # of new entries created in Homa's
* peer table (this value doesn't increment if the desired peer is
* found in the entry in its hash chain).
*/
u64 peer_allocs;
/**
* @peer_kmalloc_errors: total number of times homa_peer_get
* returned an error because it couldn't allocate memory for a new
* peer.
*/
u64 peer_kmalloc_errors;
/**
* @peer_route_errors: total number of times homa_peer_get
* returned an error because it couldn't create a route to the peer.
*/
u64 peer_route_errors;
/**
* @peer_dst_refreshes: total number of times that the dst for a
* peer had to be regenerated because the existing one had become
* obsolete.
*/
u64 peer_dst_refreshes;
/**
* @control_xmit_errors: total number of times ip_queue_xmit
* failed when transmitting a control packet.
*/
u64 control_xmit_errors;
/**
* @data_xmit_errors: total number of times ip_queue_xmit
* failed when transmitting a data packet.
*/
u64 data_xmit_errors;
/**
* @unknown_rpcs: total number of times an incoming packet was
* discarded because it referred to a nonexistent RPC. Doesn't
* count grant packets received by servers (since these are
* fairly common).
*/
u64 unknown_rpcs;
/**
* @server_cant_create_rpcs: total number of times a server discarded
* an incoming packet because it couldn't create a homa_rpc object.
*/
u64 server_cant_create_rpcs;
/**
* @unknown_packet_types: total number of times a packet was discarded
* because its type wasn't one of the supported values.
*/
u64 unknown_packet_types;
/**
* @short_packets: total number of times a packet was discarded
* because it was too short to hold all the required information.
*/
u64 short_packets;
/**
* @packet_discards: total number of times a normal (non-retransmitted)
* packet was discarded because all its data had already been received.
*/
u64 packet_discards;
/**
* @resent_discards: total number of times a retransmitted packet
* was discarded because its data had already been received.
*/
u64 resent_discards;
/**
* @resent_packets_used: total number of times a resent packet was
* actually incorporated into the message at the target (i.e. it
* wasn't redundant).
*/
u64 resent_packets_used;
/**
* @rpc_timeouts: total number of times an RPC (either client or
* server) was aborted because the peer was nonresponsive.
*/
u64 rpc_timeouts;
/**
* @server_rpc_discards: total number of times an RPC was aborted on
* the server side because of a timeout.
*/
u64 server_rpc_discards;
/**
* @server_rpcs_unknown: total number of times an RPC was aborted on
* the server side because it is no longer known to the client.
*/
u64 server_rpcs_unknown;
/**
* @client_lock_misses: total number of times that Homa had to wait
* to acquire a client bucket lock.
*/
u64 client_lock_misses;
/**
* @client_lock_miss_cycles: total time spent waiting for client
* bucket lock misses.
*/
u64 client_lock_miss_cycles;
/**
* @server_lock_misses: total number of times that Homa had to wait
* to acquire a server bucket lock.
*/
u64 server_lock_misses;
/**
* @server_lock_miss_cycles: total time spent waiting for server
* bucket lock misses.
*/
u64 server_lock_miss_cycles;
/**
* @socket_lock_miss_cycles: total time spent waiting for socket
* lock misses.
*/
u64 socket_lock_miss_cycles;
/**
* @socket_lock_misses: total number of times that Homa had to wait
* to acquire a socket lock.
*/
u64 socket_lock_misses;
/**
* @throttle_lock_miss_cycles: total time spent waiting for throttle
* lock misses.
*/
u64 throttle_lock_miss_cycles;
/**
* @throttle_lock_misses: total number of times that Homa had to wait
* to acquire the throttle lock.
*/
u64 throttle_lock_misses;
/**
* @peer_ack_lock_miss_cycles: total time spent waiting for peer lock misses.
*/
u64 peer_ack_lock_miss_cycles;
/**
* @peer_ack_lock_misses: total number of times that Homa had to wait
* to acquire the lock used for managing acks for a peer.
*/
u64 peer_ack_lock_misses;
/**
* @grant_lock_miss_cycles: total time spent waiting for grant lock
* misses.
*/
u64 grant_lock_miss_cycles;
/**
* @grant_lock_misses: total number of times that Homa had to wait
* to acquire the grant lock.
*/
u64 grant_lock_misses;
/**
* @grantable_rpcs_integral: cumulative sum of time_delta*grantable,
* where time_delta is in nanoseconds and grantable is the value of
* homa->num_grantable_rpcs over that time period.
*/
u64 grantable_rpcs_integral;
/**
* @grant_check_calls: cumulative number of times homa_grant_check_rpc
* has been invoked.
*/
u64 grant_check_calls;
/**
* @grant_check_locked: cumulative number of times an invocation of
* homa_grant_check_rpc acquired the grant lock at least once.
*/
u64 grant_check_locked;
/**
* @grant_check_recalcs: cumulative number of times that
* homa_grant_check_rpc verified and/or adjusted the priority of
* active RPCs.
*/
u64 grant_check_recalcs;
/**
* @grant_check_others: cumulative number of times homa_grant_check_rpc
* checked other RPCs besides the invoking one for potential grants.
*/
u64 grant_check_others;
/**
* @grant_priority_bumps: cumulative number of times the grant priority
* of an RPC has increased above its next-higher-priority neighbor.
*/
u64 grant_priority_bumps;
/**
* @fifo_grant_bytes: total number of bytes of grants issued via
* the FIFO granting mechanism
*/
u64 fifo_grant_bytes;
/**
* @disabled_reaps: total number of times that the reaper couldn't
* run at all because it was disabled.
*/
u64 disabled_reaps;
/**
* @deferred_rpc_reaps: total number of times that the reaper skipped
* an RPC because it was still in use elsewhere.
*/
u64 deferred_rpc_reaps;
/**
* @reaper_calls: total number of times that the reaper was invoked
* and was not disabled.
*/
u64 reaper_calls;
/**
* @reaper_dead_skbs: incremented by hsk->dead_skbs each time that
* reaper_calls is incremented.
*/
u64 reaper_dead_skbs;
/**
* @reaper_active_skbs: total number of times homa_rpc_reap had to skip
* an RPC because one of its tx skb's was still in the transmit
* pipeline.
*/
u64 reaper_active_skbs;
/**
* @throttle_list_adds: total number of calls to homa_add_to_throttled.
*/
u64 throttle_list_adds;
/**
* @throttle_list_checks: number of list elements examined in
* calls to homa_add_to_throttled.
*/
u64 throttle_list_checks;
/**
* @ack_overflows: total number of times that homa_peer_add_ack
* found insufficient space for the new id and hence had to send an
* ACK message.
*/
u64 ack_overflows;
/**
* @ignored_need_acks: total number of times that a NEED_ACK packet
* was ignored because the RPC's result hadn't been fully received.
*/
u64 ignored_need_acks;
/**
* @bpage_reuses: total number of times that, when an owned page
* reached the end, it could be reused because all existing
* allocations had been released.
*/
u64 bpage_reuses;
/**
* @buffer_alloc_failures: total number of times that
* homa_pool_alloc_msg was unable to allocate buffer space for
* an incoming message.
*/
u64 buffer_alloc_failures;
/**
* @linux_pkt_alloc_bytes: total bytes allocated in new packet buffers
* by the NIC driver because of packet cache underflows.
*/
u64 linux_pkt_alloc_bytes;
/**
* @dropped_data_no_bufs: total bytes of incoming data dropped because
* there was no application buffer space available.
*/
u64 dropped_data_no_bufs;
/**
* @gen3_handoffs: total number of handoffs from GRO to SoftIRQ made
* by Gen3 load balancer.
*/
u64 gen3_handoffs;
/**
* @gen3_alt_handoffs: total number of GRO->SoftIRQ handoffs that
* didn't choose the primary SoftIRQ core because it was busy with
* app threads.
*/
u64 gen3_alt_handoffs;
/**
* @gro_grant_bypasses: total number of GRANT packets passed directly
* to homa_softirq by homa_gro_receive, bypassing the normal SoftIRQ
* mechanism (triggered by HOMA_GRO_FAST_GRANTS).
*/
u64 gro_grant_bypasses;
/**
* @gro_data_bypasses: total number of DATA packets passed directly
* to homa_softirq by homa_gro_receive, bypassing the normal SoftIRQ
* mechanism (triggered by HOMA_GRO_SHORT_BYPASS).
*/
u64 gro_data_bypasses;
/** @temp: For temporary use during testing. */
#define NUM_TEMP_METRICS 10
u64 temp[NUM_TEMP_METRICS];
};
DECLARE_PER_CPU(struct homa_metrics, homa_metrics);
/**
* struct homa_metrics_output - Holds global information used to export metrics
* information through a file in /proc.
*/
struct homa_metrics_output {
/**
* @mutex: Used to synchronize accesses to @active_opens
* and updates to @output.
*/
struct mutex mutex;
/**
* @output: a human-readable string containing recent values
* for all the Homa performance metrics, as generated by
* homa_append_metric. This string is kmalloc-ed; NULL means
* homa_append_metric has never been called.
*/
char *output;
/** @capacity: number of bytes available at @output. */
size_t capacity;
/**
* @length: current length of the string in @output, not including
* terminating NULL character.
*/
size_t length;
/**
* @active_opens: number of open struct files that currently exist
* for the metrics file in /proc.
*/
int active_opens;
/**
* @dir_entry: Used to remove /proc/net/homa_metrics when the
* module is unloaded.
*/
struct proc_dir_entry *dir_entry;
};
/**
* homa_metrics_per_cpu() - Return the metrics structure for the current core.
* This is unsynchronized and doesn't guarantee non-preemption.
* Return: see above
*/
static inline struct homa_metrics *homa_metrics_per_cpu(void)
{
return &per_cpu(homa_metrics, raw_smp_processor_id());
}
/* It isn't necessary to disable preemption here, because we don't need
* perfect synchronization: if the invoking thread is moved to a
* different core and races with an INC_METRIC there, the worst that
* happens is that one of the INC_METRICs is lost, which isn't a big deal.
*/
#define INC_METRIC(metric, count) (per_cpu(homa_metrics, \
raw_smp_processor_id()).metric += (count))
extern struct homa_metrics_output homa_mout;
void homa_metric_append(const char *name, u64 value, const char *format, ...);
void homa_metrics_end(void);
int homa_metrics_init(void);
loff_t homa_metrics_lseek(struct file *file, loff_t offset,
int whence);
int homa_metrics_open(struct inode *inode, struct file *file);
char *homa_metrics_print(void);
ssize_t homa_metrics_read(struct file *file, char __user *buffer,
size_t length, loff_t *offset);
int homa_metrics_release(struct inode *inode, struct file *file);
int homa_proc_read_metrics(char *buffer, char **start, off_t offset,
int count, int *eof, void *data);
#endif /* _HOMA_METRICS_H */