Skip to content

Commit

Permalink
rxrpc: Make the call timeouts use the event tree instead of a system …
Browse files Browse the repository at this point in the history
…timer
  • Loading branch information
dhowells committed Nov 3, 2022
1 parent dfc1371 commit eead87b
Show file tree
Hide file tree
Showing 16 changed files with 295 additions and 400 deletions.
4 changes: 2 additions & 2 deletions fs/afs/afs.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#define AFSPATHMAX 1024 /* Maximum length of a pathname plus NUL */
#define AFSOPAQUEMAX 1024 /* Maximum length of an opaque field */

#define AFS_VL_MAX_LIFESPAN (120 * HZ)
#define AFS_PROBE_MAX_LIFESPAN (30 * HZ)
#define AFS_VL_MAX_LIFESPAN 120 /* secs */
#define AFS_PROBE_MAX_LIFESPAN 30 /* secs */

typedef u64 afs_volid_t;
typedef u64 afs_vnodeid_t;
Expand Down
2 changes: 1 addition & 1 deletion include/net/af_rxrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ bool rxrpc_kernel_check_life(const struct socket *, const struct rxrpc_call *);
u32 rxrpc_kernel_get_epoch(struct socket *, struct rxrpc_call *);
bool rxrpc_kernel_call_is_complete(struct rxrpc_call *);
void rxrpc_kernel_set_max_life(struct socket *, struct rxrpc_call *,
unsigned long);
unsigned int);

int rxrpc_sock_set_min_security_level(struct sock *sk, unsigned int val);

Expand Down
119 changes: 38 additions & 81 deletions include/trace/events/rxrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,27 +342,26 @@
E_(rxrpc_rtt_rx_requested_ack, "RACK")

#define rxrpc_timer_traces \
EM(rxrpc_timer_begin, "Begin ") \
EM(rxrpc_timer_exp_ack, "ExpAck") \
EM(rxrpc_timer_exp_hard, "ExpHrd") \
EM(rxrpc_timer_exp_idle, "ExpIdl") \
EM(rxrpc_timer_exp_keepalive, "ExpKA ") \
EM(rxrpc_timer_exp_lost_ack, "ExpLoA") \
EM(rxrpc_timer_exp_normal, "ExpNml") \
EM(rxrpc_timer_exp_ping, "ExpPng") \
EM(rxrpc_timer_exp_resend, "ExpRsn") \
EM(rxrpc_timer_init_for_reply, "IniRpl") \
EM(rxrpc_timer_init_for_send_reply, "SndRpl") \
EM(rxrpc_timer_cancel_delay_ack_at, "Can DlyA") \
EM(rxrpc_timer_exp_ack_lost_at, "Exp LoAk") \
EM(rxrpc_timer_exp_delay_ack_at, "Exp DlyA") \
EM(rxrpc_timer_exp_expect_req_by, "Exp RqBy") \
EM(rxrpc_timer_exp_expect_rx_by, "Exp RxBy") \
EM(rxrpc_timer_exp_expect_term_by, "Exp Term") \
EM(rxrpc_timer_exp_keepalive_at, "Exp Keep") \
EM(rxrpc_timer_exp_ping_at, "Exp Ping") \
EM(rxrpc_timer_exp_resend_at, "Exp Rsnd") \
EM(rxrpc_timer_init_delay_ack_at, "Ini DlyA") \
EM(rxrpc_timer_reset_for_resend, "Rst Rsnd") \
EM(rxrpc_timer_restart, "Restrt") \
EM(rxrpc_timer_set_for_ack, "SetAck") \
EM(rxrpc_timer_set_for_hard, "SetHrd") \
EM(rxrpc_timer_set_for_idle, "SetIdl") \
EM(rxrpc_timer_set_for_keepalive, "KeepAl") \
EM(rxrpc_timer_set_for_lost_ack, "SetLoA") \
EM(rxrpc_timer_set_for_normal, "SetNml") \
EM(rxrpc_timer_set_for_ping, "SetPng") \
EM(rxrpc_timer_set_for_resend, "SetRTx") \
E_(rxrpc_timer_set_for_send, "SetSnd")
EM(rxrpc_timer_set_ack_lost_at, "Set AckL") \
EM(rxrpc_timer_set_delay_ack_at, "Set DlyA") \
EM(rxrpc_timer_set_expect_req_by, "Set RqBy") \
EM(rxrpc_timer_set_expect_rx_by, "Set RxBy") \
EM(rxrpc_timer_set_expect_term_by, "Set Hard") \
EM(rxrpc_timer_set_keepalive_at, "Set Keep") \
EM(rxrpc_timer_set_ping_at, "Set Ping") \
E_(rxrpc_timer_set_resend_at, "Set Rsnd")

#define rxrpc_propose_ack_traces \
EM(rxrpc_propose_ack_client_tx_end, "ClTxEnd") \
Expand Down Expand Up @@ -1310,89 +1309,47 @@ TRACE_EVENT(rxrpc_rtt_rx,
);

TRACE_EVENT(rxrpc_timer,
TP_PROTO(struct rxrpc_call *call, enum rxrpc_timer_trace why,
unsigned long now),
TP_PROTO(struct rxrpc_call *call, enum rxrpc_timer_trace what,
s64 delay),

TP_ARGS(call, why, now),
TP_ARGS(call, what, delay),

TP_STRUCT__entry(
__field(unsigned int, call )
__field(enum rxrpc_timer_trace, why )
__field(long, now )
__field(long, ack_at )
__field(long, ack_lost_at )
__field(long, resend_at )
__field(long, ping_at )
__field(long, expect_rx_by )
__field(long, expect_req_by )
__field(long, expect_term_by )
__field(long, timer )
__field(unsigned int, call )
__field(enum rxrpc_timer_trace, what )
__field(s64, delay )
),

TP_fast_assign(
__entry->call = call->debug_id;
__entry->why = why;
__entry->now = now;
__entry->ack_at = call->delay_ack_at;
__entry->ack_lost_at = call->ack_lost_at;
__entry->resend_at = call->resend_at;
__entry->expect_rx_by = call->expect_rx_by;
__entry->expect_req_by = call->expect_req_by;
__entry->expect_term_by = call->expect_term_by;
__entry->timer = call->timer.expires;
__entry->what = what;
__entry->delay = delay;
),

TP_printk("c=%08x %s a=%ld la=%ld r=%ld xr=%ld xq=%ld xt=%ld t=%ld",
TP_printk("c=%08x %s delay=%lld",
__entry->call,
__print_symbolic(__entry->why, rxrpc_timer_traces),
__entry->ack_at - __entry->now,
__entry->ack_lost_at - __entry->now,
__entry->resend_at - __entry->now,
__entry->expect_rx_by - __entry->now,
__entry->expect_req_by - __entry->now,
__entry->expect_term_by - __entry->now,
__entry->timer - __entry->now)
__print_symbolic(__entry->what, rxrpc_timer_traces),
__entry->delay)
);

TRACE_EVENT(rxrpc_timer_expired,
TP_PROTO(struct rxrpc_call *call, unsigned long now),
TRACE_EVENT(rxrpc_timeo,
TP_PROTO(struct rxrpc_call *call, enum rxrpc_timer_trace what),

TP_ARGS(call, now),
TP_ARGS(call, what),

TP_STRUCT__entry(
__field(unsigned int, call )
__field(long, now )
__field(long, ack_at )
__field(long, ack_lost_at )
__field(long, resend_at )
__field(long, ping_at )
__field(long, expect_rx_by )
__field(long, expect_req_by )
__field(long, expect_term_by )
__field(long, timer )
__field(unsigned int, call )
__field(enum rxrpc_timer_trace, what )
),

TP_fast_assign(
__entry->call = call->debug_id;
__entry->now = now;
__entry->ack_at = call->delay_ack_at;
__entry->ack_lost_at = call->ack_lost_at;
__entry->resend_at = call->resend_at;
__entry->expect_rx_by = call->expect_rx_by;
__entry->expect_req_by = call->expect_req_by;
__entry->expect_term_by = call->expect_term_by;
__entry->timer = call->timer.expires;
__entry->what = what;
),

TP_printk("c=%08x EXPIRED a=%ld la=%ld r=%ld xr=%ld xq=%ld xt=%ld t=%ld",
TP_printk("c=%08x %s",
__entry->call,
__entry->ack_at - __entry->now,
__entry->ack_lost_at - __entry->now,
__entry->resend_at - __entry->now,
__entry->expect_rx_by - __entry->now,
__entry->expect_req_by - __entry->now,
__entry->expect_term_by - __entry->now,
__entry->timer - __entry->now)
__print_symbolic(__entry->what, rxrpc_timer_traces))
);

TRACE_EVENT(rxrpc_rx_lose,
Expand Down
3 changes: 1 addition & 2 deletions net/rxrpc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ config AF_RXRPC_INJECT_RX_DELAY
Say Y here to inject a delay into packet reception, allowing an
extended RTT time to be modelled. The delay can be configured using
/proc/sys/net/rxrpc/rxrpc_inject_rx_delay, setting a number of
milliseconds up to 0.5s (note that the granularity is actually in
jiffies).
milliseconds up to 0.5s.

config AF_RXRPC_DEBUG
bool "RxRPC dynamic debugging"
Expand Down
13 changes: 3 additions & 10 deletions net/rxrpc/af_rxrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,23 +420,16 @@ EXPORT_SYMBOL(rxrpc_kernel_new_call_notification);
* rxrpc_kernel_set_max_life - Set maximum lifespan on a call
* @sock: The socket the call is on
* @call: The call to configure
* @hard_timeout: The maximum lifespan of the call in jiffies
* @hard_timeout: The maximum lifespan of the call in seconds
*
* Set the maximum lifespan of a call. The call will end with ETIME or
* ETIMEDOUT if it takes longer than this.
*/
void rxrpc_kernel_set_max_life(struct socket *sock, struct rxrpc_call *call,
unsigned long hard_timeout)
unsigned int hard_timeout)
{
unsigned long now;

mutex_lock(&call->user_mutex);

now = jiffies;
hard_timeout += now;
WRITE_ONCE(call->expect_term_by, hard_timeout);
rxrpc_reduce_call_timer(call, hard_timeout, now, rxrpc_timer_set_for_hard);

call->hard_timo = hard_timeout;
mutex_unlock(&call->user_mutex);
}
EXPORT_SYMBOL(rxrpc_kernel_set_max_life);
Expand Down
50 changes: 25 additions & 25 deletions net/rxrpc/ar-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ struct rxrpc_peer {
u32 mdev_us; /* medium deviation */
u32 mdev_max_us; /* maximal mdev for the last rtt period */
u32 rttvar_us; /* smoothed mdev_max */
u32 rto_j; /* Retransmission timeout in jiffies */
u32 rto_us; /* Retransmission timeout in usec */
u8 backoff; /* Backoff timeout */

u8 cong_ssthresh; /* Congestion slow-start threshold */
Expand Down Expand Up @@ -564,6 +564,7 @@ enum rxrpc_call_flag {
enum rxrpc_call_event {
RXRPC_CALL_EV_ACK_LOST, /* ACK may be lost, send ping */
RXRPC_CALL_EV_INITIAL_PING, /* Send initial ping for a new service call */
RXRPC_CALL_EV_TIMEOUTS_CHANGED, /* The timeouts changed and things need rejigging */
};

/*
Expand Down Expand Up @@ -612,19 +613,19 @@ struct rxrpc_call {
const struct rxrpc_security *security; /* applied security module */
struct mutex user_mutex; /* User access mutex */
struct sockaddr_rxrpc dest_srx; /* Destination address */
unsigned long delay_ack_at; /* When DELAY ACK needs to happen */
unsigned long ack_lost_at; /* When ACK is figured as lost */
unsigned long resend_at; /* When next resend needs to happen */
unsigned long ping_at; /* When next to send a ping */
unsigned long keepalive_at; /* When next to send a keepalive ping */
unsigned long expect_rx_by; /* When we expect to get a packet by */
unsigned long expect_req_by; /* When we expect to get a request DATA packet by */
unsigned long expect_term_by; /* When we expect call termination by */
u32 next_rx_timo; /* Timeout for next Rx packet (jif) */
u32 next_req_timo; /* Timeout for next Rx request packet (jif) */
struct skcipher_request *cipher_req; /* Packet cipher request buffer */
ktime_t delay_ack_at; /* When DELAY ACK needs to happen */
ktime_t ack_lost_at; /* When ACK is figured as lost */
ktime_t resend_at; /* When next resend needs to happen */
ktime_t ping_at; /* When next to send a ping */
ktime_t keepalive_at; /* When next to send a keepalive ping */
ktime_t expect_rx_by; /* When we expect to get a packet by */
ktime_t expect_req_by; /* When we expect to get a request DATA packet by */
ktime_t expect_term_by; /* When we expect call termination by */
u32 next_rx_timo; /* Timeout for next Rx packet (msec) */
u32 next_req_timo; /* Timeout for next Rx request packet (msec) */
u32 hard_timo; /* Timeout for end of call (sec) */
struct rxrpc_event_target event; /* Call event and timeout */
struct timer_list timer; /* Combined event timer */
struct skcipher_request *cipher_req; /* Packet cipher request buffer */
rxrpc_notify_rx_t notify_rx; /* kernel service Rx notification function */
struct list_head link; /* link in master call list */
struct list_head wait_link; /* Link in local->new_client_calls */
Expand Down Expand Up @@ -844,6 +845,12 @@ int rxrpc_user_charge_accept(struct rxrpc_sock *, unsigned long);
/*
* call_event.c
*/
void rxrpc_set_call_timeout_at(struct rxrpc_call *, ktime_t *, ktime_t,
enum rxrpc_timer_trace);
void rxrpc_set_call_timeout(struct rxrpc_call *, ktime_t *, unsigned int,
enum rxrpc_timer_trace);
bool rxrpc_update_call_timeout(struct rxrpc_call *, ktime_t *, unsigned int,
enum rxrpc_timer_trace);
void rxrpc_propose_ping(struct rxrpc_call *call, u32 serial,
enum rxrpc_propose_ack_trace why);
void rxrpc_send_ACK(struct rxrpc_call *, u8, rxrpc_serial_t, enum rxrpc_propose_ack_trace);
Expand All @@ -852,17 +859,10 @@ void rxrpc_propose_delay_ACK(struct rxrpc_call *, rxrpc_serial_t,
void rxrpc_shrink_call_tx_buffer(struct rxrpc_call *);
void rxrpc_resend(struct rxrpc_call *call, struct sk_buff *ack_skb);

void rxrpc_reduce_call_timer(struct rxrpc_call *call,
unsigned long expire_at,
unsigned long now,
enum rxrpc_timer_trace why);

void rxrpc_delete_call_timer(struct rxrpc_call *call);

enum rxrpc_call_event_source {
RXRPC_CALL_EV_INPUT,
RXRPC_CALL_EV_RESEND,
RXRPC_CALL_EV_ATTEND,
RXRPC_CALL_EV_TIMEOUT,
RXRPC_CALL_EV_IMPLICIT_END,
RXRPC_CALL_EV_ERROR,
};
Expand Down Expand Up @@ -1134,13 +1134,13 @@ static inline void rxrpc_see_local(struct rxrpc_local *local,
* misc.c
*/
extern unsigned int rxrpc_max_backlog __read_mostly;
extern unsigned long rxrpc_soft_ack_delay;
extern unsigned long rxrpc_idle_ack_delay;
extern unsigned int rxrpc_soft_ack_delay_ms;
extern unsigned int rxrpc_idle_ack_delay_ms;
extern unsigned int rxrpc_rx_window_size;
extern unsigned int rxrpc_rx_mtu;
extern unsigned int rxrpc_rx_jumbo_max;
#ifdef CONFIG_AF_RXRPC_INJECT_RX_DELAY
extern unsigned long rxrpc_inject_rx_delay;
extern unsigned int rxrpc_inject_rx_delay_ms;
#endif

/*
Expand Down Expand Up @@ -1221,7 +1221,7 @@ static inline int rxrpc_abort_eproto(struct rxrpc_call *call,
*/
void rxrpc_peer_add_rtt(struct rxrpc_call *, enum rxrpc_rtt_rx_trace, int,
rxrpc_serial_t, rxrpc_serial_t, ktime_t, ktime_t);
unsigned long rxrpc_get_rto_backoff(struct rxrpc_peer *, bool);
u32 rxrpc_get_rto_backoff(struct rxrpc_peer *, bool);
void rxrpc_peer_init_rtt(struct rxrpc_peer *);

/*
Expand Down

0 comments on commit eead87b

Please sign in to comment.