tcp: add NV congestion control
Subsystems (4)
v4 cover tcp: add NV congestion control
This patchset adds support for NV congestion control.
The first patch replaces two arguments with a struct in pkts_acked() The second patch is a refactor of tcp_skb_cb
The third patch adds in_flight to tcp_skb_cb's tx section The fourth patch adds NV congestion control support.
[RFC PATCH v4 net-next 1/4] tcp: replace cnt & rtt with struct in pkts_acked() [RFC PATCH v4 net-next 2/4] tcp: refactor struct tcp_skb_cb
[RFC PATCH v4 net-next 3/4] tcp: add in_flight to tcp_skb_cb
[RFC PATCH v4 net-next 4/4] tcp: add NV congestion control
include/net/tcp.h | 20 ++- net/ipv4/Kconfig | 16 ++ net/ipv4/Makefile | 1 + net/ipv4/tcp_bic.c | 6 +- net/ipv4/tcp_cdg.c | 14 +- net/ipv4/tcp_cubic.c | 6 +- net/ipv4/tcp_htcp.c | 10 +- net/ipv4/tcp_illinois.c | 20 +-- net/ipv4/tcp_input.c | 10 +- net/ipv4/tcp_lp.c | 6 +- net/ipv4/tcp_nv.c | 479 ++++++++++++++++++++++++++++++++++++++++++++++++++++ net/ipv4/tcp_output.c | 4 +- net/ipv4/tcp_vegas.c | 6 +- net/ipv4/tcp_vegas.h | 2 +- net/ipv4/tcp_veno.c | 6 +- net/ipv4/tcp_westwood.c | 6 +- net/ipv4/tcp_yeah.c | 6 +- 17 files changed, 567 insertions(+), 51 deletions(-)
RFC PATCH v4 2/4 tcp: refactor struct tcp_skb_cb
Refactor tcp_skb_cb to create two overlaping areas to store state for incoming or outgoing skbs based on comments by Neal Cardwell to tcp_nv patch:
AFAICT this patch would not require an increase in the size of sk_buff cb[] if it were to take advantage of the fact that the tcp_skb_cb header.h4 and header.h6 fields are only used in the packet reception code path, and this in_flight field is only used on the transmit side.
--- include/net/tcp.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
include/net/tcp.h +8 -3
@@ -755,11 +755,16 @@ struct tcp_skb_cb {/* 1 byte hole */ __u32 ack_seq;/* Sequence number ACK'd */ union { -struct inet_skb_parm h4; +struct { +/* There is space for up to 20 bytes */ + } tx;/* only used for outgoing skbs */ +union { +struct inet_skb_parm h4;#if IS_ENABLED (CONFIG_IPV6 ) -struct inet6_skb_parm h6; +struct inet6_skb_parm h6;#endif - } header;/* For incoming frames */ + } header;/* For incoming skbs */ + }; };#define TCP_SKB_CB (__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
Signature · 1 line
1.8.1
RFC PATCH v4 1/4 tcp: replace cnt & rtt with struct in pkts_acked()
In reply to Lawrence BrakmoReplace 2 arguments (cnt and rtt) in the congestion control modules' pkts_acked() function with a struct. This will allow adding more information without having to modify existing congestion control modules (tcp_nv in particular needs bytes in flight when packet was sent).
As proposed by Neal Cardwell in his comments to the tcp_nv patch.
--- include/net/tcp.h | 7 ++++++- net/ipv4/tcp_bic.c | 6 +++--- net/ipv4/tcp_cdg.c | 14 +++++++------- net/ipv4/tcp_cubic.c | 6 +++--- net/ipv4/tcp_htcp.c | 10 +++++----- net/ipv4/tcp_illinois.c | 20 ++++++++++---------- net/ipv4/tcp_input.c | 7 +++++-- net/ipv4/tcp_lp.c | 6 +++--- net/ipv4/tcp_vegas.c | 6 +++--- net/ipv4/tcp_vegas.h | 2 +- net/ipv4/tcp_veno.c | 6 +++--- net/ipv4/tcp_westwood.c | 6 +++--- net/ipv4/tcp_yeah.c | 6 +++--- 13 files changed, 55 insertions(+), 47 deletions(-)
include/net/tcp.h +6 -1
@@ -834,6 +834,11 @@ enum tcp_ca_ack_event_flags {union tcp_cc_info ; +struct ack_sample { +u32 pkts_acked; +s32 rtt_us; +}; +struct tcp_congestion_ops {struct list_head list;u32 key;
@@ -857,7 +862,7 @@ struct tcp_congestion_ops {/* new value of cwnd after loss (optional) */ u32 (*undo_cwnd)(struct sock *sk);/* hook for packet ack accounting (optional) */ -void (*pkts_acked)(struct sock *sk,u32 num_acked,s32 rtt_us); +void (*pkts_acked)(struct sock *sk,struct ack_sample *sample);/* get info for inet_diag (optional) */ size_t (*get_info)(struct sock *sk,u32 ext,int *attr,union tcp_cc_info *info);
net/ipv4/tcp_bic.c +3 -3
@@ -197,15 +197,15 @@ static void bictcp_state(struct sock *sk, u8 new_state)/* Track delayed acknowledgment ratio using sliding window * ratio = (15*ratio + sample) / 16 */ -static void bictcp_acked (struct sock *sk,u32 cnt,s32 rtt) +static void bictcp_acked (struct sock *sk,struct ack_sample *sample) {const struct inet_connection_sock *icsk =inet_csk (sk);if (icsk->icsk_ca_state == TCP_CA_Open) {struct bictcp *ca =inet_csk_ca (sk); - cnt -= ca->delayed_ack >>ACK_RATIO_SHIFT ; - ca->delayed_ack += cnt; + ca->delayed_ack += sample->pkts_acked - + (ca->delayed_ack >>ACK_RATIO_SHIFT ); } }
net/ipv4/tcp_cdg.c +7 -7
@@ -294,12 +294,12 @@ static void tcp_cdg_cong_avoid(struct sock *sk, u32 ack, u32 acked) ca->shadow_wnd =max (ca->shadow_wnd, ca->shadow_wnd + incr); } -static void tcp_cdg_acked (struct sock *sk,u32 num_acked,s32 rtt_us) +static void tcp_cdg_acked (struct sock *sk,struct ack_sample *sample) {struct cdg *ca =inet_csk_ca (sk);struct tcp_sock *tp =tcp_sk (sk); -if (rtt_us <=0 ) +if (sample->rtt_us <=0 )return ;/* A heuristic for filtering delayed ACKs, adapted from:
@@ -307,20 +307,20 @@ static void tcp_cdg_acked(struct sock *sk, u32 num_acked, s32 rtt_us)* delay and rate based TCP mechanisms." TR 100219A. CAIA, 2010. */ if (tp->sacked_out ==0 ) { -if (num_acked ==1 && ca->delack) { +if (sample->pkts_acked ==1 && ca->delack) {/* A delayed ACK is only used for the minimum if it is * provenly lower than an existing non-zero minimum. */ - ca->rtt.min =min (ca->rtt.min, rtt_us); + ca->rtt.min =min (ca->rtt.min, sample->rtt_us); ca->delack--;return ; - }else if (num_acked >1 && ca->delack <5 ) { + }else if (sample->pkts_acked >1 && ca->delack <5 ) { ca->delack++; } } - ca->rtt.min =min_not_zero (ca->rtt.min, rtt_us); - ca->rtt.max =max (ca->rtt.max, rtt_us); + ca->rtt.min =min_not_zero (ca->rtt.min, sample->rtt_us); + ca->rtt.max =max (ca->rtt.max, sample->rtt_us); }static u32 tcp_cdg_ssthresh (struct sock *sk)
net/ipv4/tcp_cubic.c +3 -3
@@ -416,21 +416,21 @@ static void hystart_update(struct sock *sk, u32 delay)/* Track delayed acknowledgment ratio using sliding window * ratio = (15*ratio + sample) / 16 */ -static void bictcp_acked (struct sock *sk,u32 cnt,s32 rtt_us) +static void bictcp_acked (struct sock *sk,struct ack_sample *sample) {const struct tcp_sock *tp =tcp_sk (sk);struct bictcp *ca =inet_csk_ca (sk);u32 delay;/* Some calls are for duplicates without timetamps */ -if (rtt_us <0 ) +if (sample->rtt_us <0 )return ;/* Discard delay samples right after fast recovery */ if (ca->epoch_start && (s32)(tcp_time_stamp - ca->epoch_start) <HZ )return ; - delay = (rtt_us <<3 ) /USEC_PER_MSEC ; + delay = (sample->rtt_us <<3 ) /USEC_PER_MSEC ;if (delay ==0 ) delay =1 ;
net/ipv4/tcp_htcp.c +5 -5
@@ -99,7 +99,7 @@ static inline void measure_rtt(struct sock *sk, u32 srtt) }static void measure_achieved_throughput (struct sock *sk, -u32 pkts_acked,s32 rtt) +struct ack_sample *sample) {const struct inet_connection_sock *icsk =inet_csk (sk);const struct tcp_sock *tp =tcp_sk (sk);
@@ -107,10 +107,10 @@ static void measure_achieved_throughput(struct sock *sk,u32 now = tcp_time_stamp;if (icsk->icsk_ca_state == TCP_CA_Open) - ca->pkts_acked = pkts_acked; + ca->pkts_acked = sample->pkts_acked; -if (rtt >0 ) -measure_rtt (sk,usecs_to_jiffies (rtt)); +if (sample->rtt_us >0 ) +measure_rtt (sk,usecs_to_jiffies (sample->rtt_us));if (!use_bandwidth_switch)return ;
@@ -122,7 +122,7 @@ static void measure_achieved_throughput(struct sock *sk,return ; } - ca->packetcount += pkts_acked; + ca->packetcount += sample->pkts_acked; if (ca->packetcount >= tp->snd_cwnd - (ca->alpha >> 7 ? : 1) && now - ca->lasttime >= ca->minRTT &&
net/ipv4/tcp_illinois.c +10 -10
@@ -82,30 +82,30 @@ static void tcp_illinois_init(struct sock *sk) }/* Measure RTT for each ack. */ -static void tcp_illinois_acked (struct sock *sk,u32 pkts_acked,s32 rtt) +static void tcp_illinois_acked (struct sock *sk,struct ack_sample *sample) {struct illinois *ca =inet_csk_ca (sk); - ca->acked = pkts_acked; + ca->acked = sample->pkts_acked;/* dup ack, no rtt sample */ -if (rtt <0 ) +if (sample->rtt_us <0 )return ;/* ignore bogus values, this prevents wraparound in alpha math */ -if (rtt >RTT_MAX ) - rtt =RTT_MAX ; +if (sample->rtt_us >RTT_MAX ) + sample->rtt_us =RTT_MAX ;/* keep track of minimum RTT seen so far */ -if (ca->base_rtt > rtt) - ca->base_rtt = rtt; +if (ca->base_rtt > sample->rtt_us) + ca->base_rtt = sample->rtt_us;/* and max */ -if (ca->max_rtt < rtt) - ca->max_rtt = rtt; +if (ca->max_rtt < sample->rtt_us) + ca->max_rtt = sample->rtt_us; ++ca->cnt_rtt; - ca->sum_rtt += rtt; + ca->sum_rtt += sample->rtt_us; }/* Maximum queuing delay */
net/ipv4/tcp_input.c +5 -2
@@ -3195,8 +3195,11 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets,tcp_rearm_rto (sk); } -if (icsk->icsk_ca_ops->pkts_acked) - icsk->icsk_ca_ops->pkts_acked (sk, pkts_acked, ca_rtt_us); +if (icsk->icsk_ca_ops->pkts_acked) { +struct ack_sample sample = {pkts_acked, ca_rtt_us}; + + icsk->icsk_ca_ops->pkts_acked (sk, &sample); + }#if FASTRETRANS_DEBUG >0 WARN_ON ((int )tp->sacked_out <0 );
net/ipv4/tcp_lp.c +3 -3
@@ -260,13 +260,13 @@ static void tcp_lp_rtt_sample(struct sock *sk, u32 rtt)* newReno in increase case. * We work it out by following the idea from TCP-LP's paper directly */ -static void tcp_lp_pkts_acked (struct sock *sk,u32 num_acked,s32 rtt_us) +static void tcp_lp_pkts_acked (struct sock *sk,struct ack_sample *sample) {struct tcp_sock *tp =tcp_sk (sk);struct lp *lp =inet_csk_ca (sk); -if (rtt_us >0 ) -tcp_lp_rtt_sample (sk, rtt_us); +if (sample->rtt_us >0 ) +tcp_lp_rtt_sample (sk, sample->rtt_us);/* calc inference */ if (tcp_time_stamp > tp->rx_opt.rcv_tsecr)
net/ipv4/tcp_vegas.c +3 -3
@@ -107,16 +107,16 @@ EXPORT_SYMBOL_GPL(tcp_vegas_init);* o min-filter RTT samples from a much longer window (forever for now) * to find the propagation delay (baseRTT) */ -void tcp_vegas_pkts_acked (struct sock *sk,u32 cnt,s32 rtt_us) +void tcp_vegas_pkts_acked (struct sock *sk,struct ack_sample *sample) {struct vegas *vegas =inet_csk_ca (sk);u32 vrtt; -if (rtt_us <0 ) +if (sample->rtt_us <0 )return ;/* Never allow zero rtt or baseRTT */ - vrtt = rtt_us +1 ; + vrtt = sample->rtt_us +1 ;/* Filter to find propagation delay: */ if (vrtt < vegas->baseRTT)
net/ipv4/tcp_vegas.h +1 -1
@@ -17,7 +17,7 @@ struct vegas {void tcp_vegas_init (struct sock *sk);void tcp_vegas_state (struct sock *sk,u8 ca_state); -void tcp_vegas_pkts_acked (struct sock *sk,u32 cnt,s32 rtt_us); +void tcp_vegas_pkts_acked (struct sock *sk,struct ack_sample *sample);void tcp_vegas_cwnd_event (struct sock *sk,enum tcp_ca_event event);size_t tcp_vegas_get_info (struct sock *sk,u32 ext,int *attr,union tcp_cc_info *info);
net/ipv4/tcp_veno.c +3 -3
@@ -69,16 +69,16 @@ static void tcp_veno_init(struct sock *sk) }/* Do rtt sampling needed for Veno. */ -static void tcp_veno_pkts_acked (struct sock *sk,u32 cnt,s32 rtt_us) +static void tcp_veno_pkts_acked (struct sock *sk,struct ack_sample *sample) {struct veno *veno =inet_csk_ca (sk);u32 vrtt; -if (rtt_us <0 ) +if (sample->rtt_us <0 )return ;/* Never allow zero rtt or baseRTT */ - vrtt = rtt_us +1 ; + vrtt = sample->rtt_us +1 ;/* Filter to find propagation delay: */ if (vrtt < veno->basertt)
net/ipv4/tcp_westwood.c +3 -3
@@ -99,12 +99,12 @@ static void westwood_filter(struct westwood *w, u32 delta)* Called after processing group of packets. * but all westwood needs is the last sample of srtt. */ -static void tcp_westwood_pkts_acked (struct sock *sk,u32 cnt,s32 rtt) +static void tcp_westwood_pkts_acked (struct sock *sk,struct ack_sample *sample) {struct westwood *w =inet_csk_ca (sk); -if (rtt >0 ) - w->rtt =usecs_to_jiffies (rtt); +if (sample->rtt_us >0 ) + w->rtt =usecs_to_jiffies (sample->rtt_us); }/*
net/ipv4/tcp_yeah.c +3 -3
@@ -56,15 +56,15 @@ static void tcp_yeah_init(struct sock *sk) tp->snd_cwnd_clamp =min_t (u32, tp->snd_cwnd_clamp,0xffffffff /128 ); } -static void tcp_yeah_pkts_acked (struct sock *sk,u32 pkts_acked,s32 rtt_us) +static void tcp_yeah_pkts_acked (struct sock *sk,struct ack_sample *sample) {const struct inet_connection_sock *icsk =inet_csk (sk);struct yeah *yeah =inet_csk_ca (sk);if (icsk->icsk_ca_state == TCP_CA_Open) - yeah->pkts_acked = pkts_acked; + yeah->pkts_acked = sample->pkts_acked; -tcp_vegas_pkts_acked (sk, pkts_acked, rtt_us); +tcp_vegas_pkts_acked (sk, sample); }static void tcp_yeah_cong_avoid (struct sock *sk,u32 ack,u32 acked)
Signature · 1 line
1.8.1
RFC PATCH v4 3/4 tcp: add in_flight to tcp_skb_cb
In reply to Lawrence BrakmoAdd in_flight (bytes in flight when packet was sent) field to tx component of tcp_skb_cb and make it available to congestion modules' pkts_acked() function through the ack_sample function argument.
--- include/net/tcp.h | 2 ++ net/ipv4/tcp_input.c | 5 ++++- net/ipv4/tcp_output.c | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-)
include/net/tcp.h +2 -0
@@ -757,6 +757,7 @@ struct tcp_skb_cb {union {struct {/* There is space for up to 20 bytes */ +__u32 in_flight;/* Bytes in flight when packet sent */ } tx;/* only used for outgoing skbs */ union {struct inet_skb_parm h4;
@@ -842,6 +843,7 @@ union tcp_cc_info;struct ack_sample {u32 pkts_acked;s32 rtt_us; +u32 in_flight; };struct tcp_congestion_ops {
net/ipv4/tcp_input.c +4 -1
@@ -3068,6 +3068,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets,long ca_rtt_us =-1L ;struct sk_buff *skb;u32 pkts_acked =0 ; +u32 last_in_flight =0 ;bool rtt_update;int flag =0 ;
@@ -3107,6 +3108,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets,if (!first_ackt.v64) first_ackt = last_ackt; + last_in_flight =TCP_SKB_CB (skb)->tx.in_flight; reord =min (pkts_acked, reord);if (!after (scb->end_seq, tp->high_seq)) flag |=FLAG_ORIG_SACK_ACKED ;
@@ -3196,7 +3198,8 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets, }if (icsk->icsk_ca_ops->pkts_acked) { -struct ack_sample sample = {pkts_acked, ca_rtt_us}; +struct ack_sample sample = {pkts_acked, ca_rtt_us, + last_in_flight}; icsk->icsk_ca_ops->pkts_acked (sk, &sample); }
net/ipv4/tcp_output.c +3 -1
@@ -920,9 +920,12 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,int err;BUG_ON (!skb || !tcp_skb_pcount (skb)); + tp =tcp_sk (sk);if (clone_it) {skb_mstamp_get (&skb->skb_mstamp); +TCP_SKB_CB (skb)->tx.in_flight =TCP_SKB_CB (skb)->end_seq + - tp->snd_una;if (unlikely (skb_cloned (skb))) skb =pskb_copy (skb, gfp_mask);
@@ -933,7 +936,6 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it, } inet =inet_sk (sk); - tp =tcp_sk (sk); tcb =TCP_SKB_CB (skb);memset (&opts,0 ,sizeof (opts));
Signature · 1 line
1.8.1
RFC PATCH v4 4/4 tcp: add NV congestion control
In reply to Lawrence BrakmoThis is a request for comments.
TCP-NV (New Vegas) is a major update to TCP-Vegas. An earlier version of NV was presented at 2010's LPC. It is a delayed based congestion avoidance for the data center. This version has been tested within a 10G rack where the HW RTTs are 20-50us.
A description of TCP-NV, including implementation details as well as experimental results, can be found at:
http://www.brakmo.org/networking/tcp-nv/TCPNV.html
The current version includes many module parameters to support experimentation with the parameters.
--- net/ipv4/Kconfig | 16 ++ net/ipv4/Makefile | 1 + net/ipv4/tcp_nv.c | 479 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 496 insertions(+) create mode 100644 net/ipv4/tcp_nv.c
net/ipv4/Kconfig +16 -0
@@ -539,6 +539,22 @@ config TCP_CONG_VEGAS window. TCP Vegas should provide less packet loss, but it is not as aggressive as TCP Reno. +config TCP_CONG_NV + tristate "TCP NV" + default n + ---help--- + TCP NV is a follow up to TCP Vegas. It has been modified to deal with + 10G networks, measurement noise introduced by LRO, GRO and interrupt + coalescence. In addition, it will decrease its cwnd multiplicatively + instead of linearly. + + Note that in general congestion avoidance (cwnd decreased when # packets + queued grows) cannot coexist with congestion control (cwnd decreased only + when there is packet loss) due to fairness issues. One scenario when they + can coexist safely is when the CA flows have RTTs << CC flows RTTs. + + For further details see http://www.brakmo.org/networking/tcp-nv/ + config TCP_CONG_SCALABLE tristate "Scalable TCP" default n
net/ipv4/Makefile +1 -0
@@ -50,6 +50,7 @@ obj-$(CONFIG_TCP_CONG_HSTCP) += tcp_highspeed.o obj-$(CONFIG_TCP_CONG_HYBLA) += tcp_hybla.o obj-$(CONFIG_TCP_CONG_HTCP) += tcp_htcp.o obj-$(CONFIG_TCP_CONG_VEGAS) += tcp_vegas.o +obj-$(CONFIG_TCP_CONG_NV) += tcp_nv.o obj-$(CONFIG_TCP_CONG_VENO) += tcp_veno.o obj-$(CONFIG_TCP_CONG_SCALABLE) += tcp_scalable.o obj-$(CONFIG_TCP_CONG_LP) += tcp_lp.o
net/ipv4/tcp_nv.c new file +479 -0
479 lines not on this page · raw message
Signature · 1 line
1.8.1
Re: [RFC PATCH v4 net-next 1/4] tcp: replace cnt & rtt with struct in pkts_acked()
In reply to Lawrence BrakmoQuoted 16 lines · Lawrence Brakmo
Replace 2 arguments (cnt and rtt) in the congestion control modules'
pkts_acked()function with a struct. This will allow adding more information without having to modify existing congestion control modules (tcp_nvin particular needs bytes in flight when packet was sent).include/net/tcp.h +5
-0+struct ack_sample { +u32 pkts_acked; +s32 rtt_us; +}; +struct tcp_congestion_ops {struct list_head list;u32 key;
include/net/tcp.h struct tcp_congestion_ops { · line 865
Quoted 5 lines
include/net/tcp.h +1
-1@@ -857,7 +862,7 @@ struct tcp_congestion_ops {/* new value of cwnd after loss (optional) */ u32 (*undo_cwnd)(struct sock *sk);/* hook for packet ack accounting (optional) */ -void (*pkts_acked)(struct sock *sk,u32 num_acked,s32 rtt_us); +void (*pkts_acked)(struct sock *sk,struct ack_sample *sample);
This probably should be a const struct ack_sample *sample ?
Re: [RFC PATCH v4 net-next 1/4] tcp: replace cnt & rtt with struct in pkts_acked()
In reply to Lawrence BrakmoQuoted 7 lines · On Fri, 24 Jul 2015 19:47:03 -0700 Lawrence Brakmo <[email protected]> wrote:
Replace 2 arguments (cnt and rtt) in the congestion control modules'
pkts_acked()function with a struct. This will allow adding more information without having to modify existing congestion control modules (tcp_nvin particular needs bytes in flight when packet was sent).As proposed by Neal Cardwell in his comments to the
tcp_nvpatch.
Adding a layer of indirection makes code changes easier, but makes the code slower. Arguments are passed in registers, and putting an additional level of indirection only matters if you can't change all the CC modules. Since this is the kernel and API compatability doesn't matter, just pass more arguments.
Re: [RFC PATCH v4 net-next 1/4] tcp: replace cnt & rtt with struct in pkts_acked()
Quoted 9 lines · Stephen Hemminger
Quoted 6 lines · On Fri, 24 Jul 2015 19:47:03 -0700 Lawrence Brakmo <[email protected]> wrote:
Replace 2 arguments (cnt and rtt) in the congestion control modules'
pkts_acked()function with a struct. This will allow adding more information without having to modify existing congestion control modules (tcp_nvin particular needs bytes in flight when packet was sent).
Quoted 7 lines
Quoted 1 line
As proposed by Neal Cardwell in his comments to the
tcp_nvpatch.Adding a layer of indirection makes code changes easier, but makes the code slower. Arguments are passed in registers, and putting an additional level of indirection only matters if you can't change all the CC modules. Since this is the kernel and API compatability doesn't matter, just pass more arguments.
I prefer the cleanliness of passing a structure and don¹t think the overhead will be significant enough to worry about it. Will the compiler pass struct values in registers if the struct is passed by value?
I will be happy to do it either way (I did it like Stephen proposes originally). What does everyone else think?
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH v4 net-next 1/4] tcp: replace cnt & rtt with struct in pkts_acked()
Quoted 6 lines · Lawrence Brakmo
I prefer the cleanliness of passing a structure and don¹t think the overhead will be significant enough to worry about it. Will the compiler pass struct values in registers if the struct is passed by value?
In passing struct by value it's not a matter of optimization but C abi. On sparc even 4-byte structs are passed by reference which creates an extra copy of the same struct on stack.
Struct returns are even worse. I would always pass structs by reference in C. C++ is different matter.