systemtap查看udp rcvbuf满导致丢包

折腾了老半天,被atomic_t坑惨啦,匿名结构体必须要用cast转换类型,然后再访问成员,用来排查udp buffer满,导致丢失日志的场景

#!/usr/bin/env stap

probe kernel.statement("udp_queue_rcv_skb@net/ipv4/udp.c")
{
    printf("rmem_alloc:%d rcv_buf:%d drops:%d\n", @cast(&$sk->sk_backlog->rmem_alloc, "atomic_t", "kernel<linux/types.h>")->counter,  $sk->sk_rcvbuf, @cast(&$sk->sk_drops, "atomic_t", "kernel<linux/types.h>")->counter)
}

 

此条目发表在debug, 好玩的linux分类目录。将固定链接加入收藏夹。