Skip to content

Commit 013dc9d

Browse files
committed
Merge branch 'tipc-tracepoints'
Tuong Lien says: ==================== tipc: tracepoints and trace_events in TIPC The patch series is the first step of introducing a tracing framework in TIPC, which will assist in collecting complete & plentiful data for post analysis, even in the case of a single failure occurrence e.g. when the failure is unreproducible. The tracing code in TIPC utilizes the powerful kernel tracepoints, trace events features along with particular dump functions to trace the TIPC object data and events (incl. bearer, link, socket, node, etc.). The tracing code should generate zero-load to TIPC when the trace events are not enabled. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 4a54877 + cf5f55f commit 013dc9d

File tree

12 files changed

+1121
-12
lines changed

12 files changed

+1121
-12
lines changed

net/tipc/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ tipc-y += addr.o bcast.o bearer.o \
99
core.o link.o discover.o msg.o \
1010
name_distr.o subscr.o monitor.o name_table.o net.o \
1111
netlink.o netlink_compat.o node.o socket.o eth_media.o \
12-
topsrv.o socket.o group.o
12+
topsrv.o socket.o group.o trace.o
13+
14+
CFLAGS_trace.o += -I$(src)
1315

1416
tipc-$(CONFIG_TIPC_MEDIA_UDP) += udp_media.o
1517
tipc-$(CONFIG_TIPC_MEDIA_IB) += ib_media.o

net/tipc/bearer.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "bcast.h"
4444
#include "netlink.h"
4545
#include "udp_media.h"
46+
#include "trace.h"
4647

4748
#define MAX_ADDR_STR 60
4849

@@ -99,7 +100,7 @@ static struct tipc_media *media_find_id(u8 type)
99100
/**
100101
* tipc_media_addr_printf - record media address in print buffer
101102
*/
102-
void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a)
103+
int tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a)
103104
{
104105
char addr_str[MAX_ADDR_STR];
105106
struct tipc_media *m;
@@ -114,9 +115,10 @@ void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a)
114115

115116
ret = scnprintf(buf, len, "UNKNOWN(%u)", a->media_id);
116117
for (i = 0; i < sizeof(a->value); i++)
117-
ret += scnprintf(buf - ret, len + ret,
118-
"-%02x", a->value[i]);
118+
ret += scnprintf(buf + ret, len - ret,
119+
"-%x", a->value[i]);
119120
}
121+
return ret;
120122
}
121123

122124
/**
@@ -607,6 +609,7 @@ static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt,
607609
if (!b)
608610
return NOTIFY_DONE;
609611

612+
trace_tipc_l2_device_event(dev, b, evt);
610613
switch (evt) {
611614
case NETDEV_CHANGE:
612615
if (netif_carrier_ok(dev) && netif_oper_up(dev)) {

net/tipc/bearer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ int __tipc_nl_media_set(struct sk_buff *skb, struct genl_info *info);
207207

208208
int tipc_media_set_priority(const char *name, u32 new_value);
209209
int tipc_media_set_window(const char *name, u32 new_value);
210-
void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a);
210+
int tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a);
211211
int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b,
212212
struct nlattr *attrs[]);
213213
void tipc_disable_l2_media(struct tipc_bearer *b);

net/tipc/link.c

Lines changed: 152 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "discover.h"
4444
#include "netlink.h"
4545
#include "monitor.h"
46+
#include "trace.h"
4647

4748
#include <linux/pkt_sched.h>
4849

@@ -356,9 +357,11 @@ void tipc_link_remove_bc_peer(struct tipc_link *snd_l,
356357
rcv_l->bc_peer_is_up = true;
357358
rcv_l->state = LINK_ESTABLISHED;
358359
tipc_link_bc_ack_rcv(rcv_l, ack, xmitq);
360+
trace_tipc_link_reset(rcv_l, TIPC_DUMP_ALL, "bclink removed!");
359361
tipc_link_reset(rcv_l);
360362
rcv_l->state = LINK_RESET;
361363
if (!snd_l->ackers) {
364+
trace_tipc_link_reset(snd_l, TIPC_DUMP_ALL, "zero ackers!");
362365
tipc_link_reset(snd_l);
363366
snd_l->state = LINK_RESET;
364367
__skb_queue_purge(xmitq);
@@ -522,6 +525,7 @@ bool tipc_link_bc_create(struct net *net, u32 ownnode, u32 peer,
522525

523526
l = *link;
524527
strcpy(l->name, tipc_bclink_name);
528+
trace_tipc_link_reset(l, TIPC_DUMP_ALL, "bclink created!");
525529
tipc_link_reset(l);
526530
l->state = LINK_RESET;
527531
l->ackers = 0;
@@ -546,6 +550,7 @@ bool tipc_link_bc_create(struct net *net, u32 ownnode, u32 peer,
546550
int tipc_link_fsm_evt(struct tipc_link *l, int evt)
547551
{
548552
int rc = 0;
553+
int old_state = l->state;
549554

550555
switch (l->state) {
551556
case LINK_RESETTING:
@@ -692,10 +697,12 @@ int tipc_link_fsm_evt(struct tipc_link *l, int evt)
692697
default:
693698
pr_err("Unknown FSM state %x in %s\n", l->state, l->name);
694699
}
700+
trace_tipc_link_fsm(l->name, old_state, l->state, evt);
695701
return rc;
696702
illegal_evt:
697703
pr_err("Illegal FSM event %x in state %x on link %s\n",
698704
evt, l->state, l->name);
705+
trace_tipc_link_fsm(l->name, old_state, l->state, evt);
699706
return rc;
700707
}
701708

@@ -740,6 +747,18 @@ static void link_profile_stats(struct tipc_link *l)
740747
l->stats.msg_length_profile[6]++;
741748
}
742749

750+
/**
751+
* tipc_link_too_silent - check if link is "too silent"
752+
* @l: tipc link to be checked
753+
*
754+
* Returns true if the link 'silent_intv_cnt' is about to reach the
755+
* 'abort_limit' value, otherwise false
756+
*/
757+
bool tipc_link_too_silent(struct tipc_link *l)
758+
{
759+
return (l->silent_intv_cnt + 2 > l->abort_limit);
760+
}
761+
743762
/* tipc_link_timeout - perform periodic task as instructed from node timeout
744763
*/
745764
int tipc_link_timeout(struct tipc_link *l, struct sk_buff_head *xmitq)
@@ -753,6 +772,8 @@ int tipc_link_timeout(struct tipc_link *l, struct sk_buff_head *xmitq)
753772
u16 bc_acked = l->bc_rcvlink->acked;
754773
struct tipc_mon_state *mstate = &l->mon_state;
755774

775+
trace_tipc_link_timeout(l, TIPC_DUMP_NONE, " ");
776+
trace_tipc_link_too_silent(l, TIPC_DUMP_ALL, " ");
756777
switch (l->state) {
757778
case LINK_ESTABLISHED:
758779
case LINK_SYNCHING:
@@ -815,6 +836,7 @@ static int link_schedule_user(struct tipc_link *l, struct tipc_msg *hdr)
815836
TIPC_SKB_CB(skb)->chain_imp = msg_importance(hdr);
816837
skb_queue_tail(&l->wakeupq, skb);
817838
l->stats.link_congs++;
839+
trace_tipc_link_conges(l, TIPC_DUMP_ALL, "wakeup scheduled!");
818840
return -ELINKCONG;
819841
}
820842

@@ -1036,13 +1058,17 @@ static int tipc_link_retrans(struct tipc_link *l, struct tipc_link *r,
10361058
if (less(to, from))
10371059
return 0;
10381060

1061+
trace_tipc_link_retrans(r, from, to, &l->transmq);
10391062
/* Detect repeated retransmit failures on same packet */
10401063
if (r->prev_from != from) {
10411064
r->prev_from = from;
10421065
r->stale_limit = jiffies + msecs_to_jiffies(r->tolerance);
10431066
r->stale_cnt = 0;
10441067
} else if (++r->stale_cnt > 99 && time_after(jiffies, r->stale_limit)) {
10451068
link_retransmit_failure(l, skb);
1069+
trace_tipc_list_dump(&l->transmq, true, "retrans failure!");
1070+
trace_tipc_link_dump(l, TIPC_DUMP_NONE, "retrans failure!");
1071+
trace_tipc_link_dump(r, TIPC_DUMP_NONE, "retrans failure!");
10461072
if (link_is_bc_sndlink(l))
10471073
return TIPC_LINK_DOWN_EVT;
10481074
return tipc_link_fsm_evt(l, LINK_FAILURE_EVT);
@@ -1402,6 +1428,7 @@ static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe,
14021428
l->stats.sent_nacks++;
14031429
skb->priority = TC_PRIO_CONTROL;
14041430
__skb_queue_tail(xmitq, skb);
1431+
trace_tipc_proto_build(skb, false, l->name);
14051432
}
14061433

14071434
void tipc_link_create_dummy_tnl_msg(struct tipc_link *l,
@@ -1565,6 +1592,7 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb,
15651592
char *if_name;
15661593
int rc = 0;
15671594

1595+
trace_tipc_proto_rcv(skb, false, l->name);
15681596
if (tipc_link_is_blocked(l) || !xmitq)
15691597
goto exit;
15701598

@@ -1575,8 +1603,11 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb,
15751603
hdr = buf_msg(skb);
15761604
data = msg_data(hdr);
15771605

1578-
if (!tipc_link_validate_msg(l, hdr))
1606+
if (!tipc_link_validate_msg(l, hdr)) {
1607+
trace_tipc_skb_dump(skb, false, "PROTO invalid (1)!");
1608+
trace_tipc_link_dump(l, TIPC_DUMP_NONE, "PROTO invalid (1)!");
15791609
goto exit;
1610+
}
15801611

15811612
switch (mtyp) {
15821613
case RESET_MSG:
@@ -1819,6 +1850,7 @@ void tipc_link_bc_ack_rcv(struct tipc_link *l, u16 acked,
18191850
if (!more(acked, l->acked))
18201851
return;
18211852

1853+
trace_tipc_link_bc_ack(l, l->acked, acked, &snd_l->transmq);
18221854
/* Skip over packets peer has already acked */
18231855
skb_queue_walk(&snd_l->transmq, skb) {
18241856
if (more(buf_seqno(skb), l->acked))
@@ -2222,3 +2254,122 @@ void tipc_link_set_abort_limit(struct tipc_link *l, u32 limit)
22222254
{
22232255
l->abort_limit = limit;
22242256
}
2257+
2258+
char *tipc_link_name_ext(struct tipc_link *l, char *buf)
2259+
{
2260+
if (!l)
2261+
scnprintf(buf, TIPC_MAX_LINK_NAME, "null");
2262+
else if (link_is_bc_sndlink(l))
2263+
scnprintf(buf, TIPC_MAX_LINK_NAME, "broadcast-sender");
2264+
else if (link_is_bc_rcvlink(l))
2265+
scnprintf(buf, TIPC_MAX_LINK_NAME,
2266+
"broadcast-receiver, peer %x", l->addr);
2267+
else
2268+
memcpy(buf, l->name, TIPC_MAX_LINK_NAME);
2269+
2270+
return buf;
2271+
}
2272+
2273+
/**
2274+
* tipc_link_dump - dump TIPC link data
2275+
* @l: tipc link to be dumped
2276+
* @dqueues: bitmask to decide if any link queue to be dumped?
2277+
* - TIPC_DUMP_NONE: don't dump link queues
2278+
* - TIPC_DUMP_TRANSMQ: dump link transmq queue
2279+
* - TIPC_DUMP_BACKLOGQ: dump link backlog queue
2280+
* - TIPC_DUMP_DEFERDQ: dump link deferd queue
2281+
* - TIPC_DUMP_INPUTQ: dump link input queue
2282+
* - TIPC_DUMP_WAKEUP: dump link wakeup queue
2283+
* - TIPC_DUMP_ALL: dump all the link queues above
2284+
* @buf: returned buffer of dump data in format
2285+
*/
2286+
int tipc_link_dump(struct tipc_link *l, u16 dqueues, char *buf)
2287+
{
2288+
int i = 0;
2289+
size_t sz = (dqueues) ? LINK_LMAX : LINK_LMIN;
2290+
struct sk_buff_head *list;
2291+
struct sk_buff *hskb, *tskb;
2292+
u32 len;
2293+
2294+
if (!l) {
2295+
i += scnprintf(buf, sz, "link data: (null)\n");
2296+
return i;
2297+
}
2298+
2299+
i += scnprintf(buf, sz, "link data: %x", l->addr);
2300+
i += scnprintf(buf + i, sz - i, " %x", l->state);
2301+
i += scnprintf(buf + i, sz - i, " %u", l->in_session);
2302+
i += scnprintf(buf + i, sz - i, " %u", l->session);
2303+
i += scnprintf(buf + i, sz - i, " %u", l->peer_session);
2304+
i += scnprintf(buf + i, sz - i, " %u", l->snd_nxt);
2305+
i += scnprintf(buf + i, sz - i, " %u", l->rcv_nxt);
2306+
i += scnprintf(buf + i, sz - i, " %u", l->snd_nxt_state);
2307+
i += scnprintf(buf + i, sz - i, " %u", l->rcv_nxt_state);
2308+
i += scnprintf(buf + i, sz - i, " %x", l->peer_caps);
2309+
i += scnprintf(buf + i, sz - i, " %u", l->silent_intv_cnt);
2310+
i += scnprintf(buf + i, sz - i, " %u", l->rst_cnt);
2311+
i += scnprintf(buf + i, sz - i, " %u", l->prev_from);
2312+
i += scnprintf(buf + i, sz - i, " %u", l->stale_cnt);
2313+
i += scnprintf(buf + i, sz - i, " %u", l->acked);
2314+
2315+
list = &l->transmq;
2316+
len = skb_queue_len(list);
2317+
hskb = skb_peek(list);
2318+
tskb = skb_peek_tail(list);
2319+
i += scnprintf(buf + i, sz - i, " | %u %u %u", len,
2320+
(hskb) ? msg_seqno(buf_msg(hskb)) : 0,
2321+
(tskb) ? msg_seqno(buf_msg(tskb)) : 0);
2322+
2323+
list = &l->deferdq;
2324+
len = skb_queue_len(list);
2325+
hskb = skb_peek(list);
2326+
tskb = skb_peek_tail(list);
2327+
i += scnprintf(buf + i, sz - i, " | %u %u %u", len,
2328+
(hskb) ? msg_seqno(buf_msg(hskb)) : 0,
2329+
(tskb) ? msg_seqno(buf_msg(tskb)) : 0);
2330+
2331+
list = &l->backlogq;
2332+
len = skb_queue_len(list);
2333+
hskb = skb_peek(list);
2334+
tskb = skb_peek_tail(list);
2335+
i += scnprintf(buf + i, sz - i, " | %u %u %u", len,
2336+
(hskb) ? msg_seqno(buf_msg(hskb)) : 0,
2337+
(tskb) ? msg_seqno(buf_msg(tskb)) : 0);
2338+
2339+
list = l->inputq;
2340+
len = skb_queue_len(list);
2341+
hskb = skb_peek(list);
2342+
tskb = skb_peek_tail(list);
2343+
i += scnprintf(buf + i, sz - i, " | %u %u %u\n", len,
2344+
(hskb) ? msg_seqno(buf_msg(hskb)) : 0,
2345+
(tskb) ? msg_seqno(buf_msg(tskb)) : 0);
2346+
2347+
if (dqueues & TIPC_DUMP_TRANSMQ) {
2348+
i += scnprintf(buf + i, sz - i, "transmq: ");
2349+
i += tipc_list_dump(&l->transmq, false, buf + i);
2350+
}
2351+
if (dqueues & TIPC_DUMP_BACKLOGQ) {
2352+
i += scnprintf(buf + i, sz - i,
2353+
"backlogq: <%u %u %u %u %u>, ",
2354+
l->backlog[TIPC_LOW_IMPORTANCE].len,
2355+
l->backlog[TIPC_MEDIUM_IMPORTANCE].len,
2356+
l->backlog[TIPC_HIGH_IMPORTANCE].len,
2357+
l->backlog[TIPC_CRITICAL_IMPORTANCE].len,
2358+
l->backlog[TIPC_SYSTEM_IMPORTANCE].len);
2359+
i += tipc_list_dump(&l->backlogq, false, buf + i);
2360+
}
2361+
if (dqueues & TIPC_DUMP_DEFERDQ) {
2362+
i += scnprintf(buf + i, sz - i, "deferdq: ");
2363+
i += tipc_list_dump(&l->deferdq, false, buf + i);
2364+
}
2365+
if (dqueues & TIPC_DUMP_INPUTQ) {
2366+
i += scnprintf(buf + i, sz - i, "inputq: ");
2367+
i += tipc_list_dump(l->inputq, false, buf + i);
2368+
}
2369+
if (dqueues & TIPC_DUMP_WAKEUP) {
2370+
i += scnprintf(buf + i, sz - i, "wakeup: ");
2371+
i += tipc_list_dump(&l->wakeupq, false, buf + i);
2372+
}
2373+
2374+
return i;
2375+
}

net/tipc/link.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ u16 tipc_link_rcv_nxt(struct tipc_link *l);
109109
u16 tipc_link_acked(struct tipc_link *l);
110110
u32 tipc_link_id(struct tipc_link *l);
111111
char *tipc_link_name(struct tipc_link *l);
112+
char *tipc_link_name_ext(struct tipc_link *l, char *buf);
112113
u32 tipc_link_state(struct tipc_link *l);
113114
char tipc_link_plane(struct tipc_link *l);
114115
int tipc_link_prio(struct tipc_link *l);
@@ -147,4 +148,5 @@ int tipc_link_bc_sync_rcv(struct tipc_link *l, struct tipc_msg *hdr,
147148
struct sk_buff_head *xmitq);
148149
int tipc_link_bc_nack_rcv(struct tipc_link *l, struct sk_buff *skb,
149150
struct sk_buff_head *xmitq);
151+
bool tipc_link_too_silent(struct tipc_link *l);
150152
#endif

0 commit comments

Comments
 (0)