Skip to content

Commit 398c2b0

Browse files
yaminfSaeed Mahameed
authored andcommitted
linux/dim: Add completions count to dim_sample
Added a measurement of completions per/msec to allow for completion based dim algorithms. In order to use dynamic interrupt moderation with RDMA we need to have a different measurment than packets per second. This change is meant to prepare for adding a new DIM method. All drivers that use net_dim and thus do not need a completion count will have the completions set to 0. Signed-off-by: Yamin Friedman <[email protected]> Reviewed-by: Max Gurtovoy <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 4f75da3 commit 398c2b0

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

include/linux/dim.h

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
struct dim_cq_moder {
3838
u16 usec;
3939
u16 pkts;
40+
u16 comps;
4041
u8 cq_period_mode;
4142
};
4243

@@ -54,6 +55,7 @@ struct dim_sample {
5455
u32 pkt_ctr;
5556
u32 byte_ctr;
5657
u16 event_ctr;
58+
u32 comp_ctr;
5759
};
5860

5961
/**
@@ -65,9 +67,11 @@ struct dim_sample {
6567
* @epms: Events per msec
6668
*/
6769
struct dim_stats {
68-
int ppms;
69-
int bpms;
70-
int epms;
70+
int ppms; /* packets per msec */
71+
int bpms; /* bytes per msec */
72+
int epms; /* events per msec */
73+
int cpms; /* completions per msec */
74+
int cpe_ratio; /* ratio of completions to events */
7175
};
7276

7377
/**
@@ -89,6 +93,7 @@ struct dim {
8993
u8 state;
9094
struct dim_stats prev_stats;
9195
struct dim_sample start_sample;
96+
struct dim_sample measuring_sample;
9297
struct work_struct work;
9398
u8 profile_ix;
9499
u8 mode;
@@ -246,6 +251,23 @@ dim_update_sample(u16 event_ctr, u64 packets, u64 bytes, struct dim_sample *s)
246251
s->event_ctr = event_ctr;
247252
}
248253

254+
/**
255+
* dim_update_sample_with_comps - set a sample's fields with given
256+
* values including the completion parameter
257+
* @event_ctr: number of events to set
258+
* @packets: number of packets to set
259+
* @bytes: number of bytes to set
260+
* @comps: number of completions to set
261+
* @s: DIM sample
262+
*/
263+
static inline void
264+
dim_update_sample_with_comps(u16 event_ctr, u64 packets, u64 bytes, u64 comps,
265+
struct dim_sample *s)
266+
{
267+
dim_update_sample(event_ctr, packets, bytes, s);
268+
s->comp_ctr = comps;
269+
}
270+
249271
/* Net DIM */
250272

251273
/*

lib/dim/dim.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ void dim_calc_stats(struct dim_sample *start, struct dim_sample *end,
6262
u32 npkts = BIT_GAP(BITS_PER_TYPE(u32), end->pkt_ctr, start->pkt_ctr);
6363
u32 nbytes = BIT_GAP(BITS_PER_TYPE(u32), end->byte_ctr,
6464
start->byte_ctr);
65+
u32 ncomps = BIT_GAP(BITS_PER_TYPE(u32), end->comp_ctr,
66+
start->comp_ctr);
6567

6668
if (!delta_us)
6769
return;
@@ -70,5 +72,12 @@ void dim_calc_stats(struct dim_sample *start, struct dim_sample *end,
7072
curr_stats->bpms = DIV_ROUND_UP(nbytes * USEC_PER_MSEC, delta_us);
7173
curr_stats->epms = DIV_ROUND_UP(DIM_NEVENTS * USEC_PER_MSEC,
7274
delta_us);
75+
curr_stats->cpms = DIV_ROUND_UP(ncomps * USEC_PER_MSEC, delta_us);
76+
if (curr_stats->epms != 0)
77+
curr_stats->cpe_ratio =
78+
(curr_stats->cpms * 100) / curr_stats->epms;
79+
else
80+
curr_stats->cpe_ratio = 0;
81+
7382
}
7483
EXPORT_SYMBOL(dim_calc_stats);

0 commit comments

Comments
 (0)