Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp7162920imm; Wed, 27 Jun 2018 22:01:08 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfm18fFCgrkuYnsoOLGs0w79uDBiq2yhaRx1rVVgrJjIhTrNFIlG5mtwzT86nmSThLk1GWh X-Received: by 2002:a62:104e:: with SMTP id y75-v6mr8636620pfi.109.1530162068394; Wed, 27 Jun 2018 22:01:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530162068; cv=none; d=google.com; s=arc-20160816; b=UNJYZWLWZJUzZehXL18+WVW1bRRSc+PbxalJfkV7RGKIGMP3vMCGsM3q6hnmrZmgwd kytTYLh5G8+fn4UAGtbPbU9VFwI68/pjX/Har0rm5FIcQAq7t6D1/5Zb/3N3kSPUExH6 wpG/PEU7N4/jQWB8osMz22LOYuelkFVS/bFeGgK7zIsFNCb+hTQSTaIpRXyGsY+xEFIO FQAAgOXK3Tk4QxRfB3xU/3wHcaMr67SmmgvtLEB7OiE0uC2Mbo0j6dhHFpwNarQED0Vv DQhTjdiZ3h3XSxUYSktE/60m7hBO7+HcWE4W8UPa1JuaUMRXn3ypfwYXkoUC6CVcrAaz xYYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=80oQ5BXM/Zqa4PsJVTYoHlyaKq7RnK4JoIQmTlYc7gM=; b=VkN62aciiUZNNLqhIZf9vkBRp/uD+feZiJl+iz8132XLNkACLfKnteIuIi/Jhz3bNI dfmCHaGrckNxg++Da3AbdP2iodYEYZ3KApoJT/4y0pYueDqE//zj9r5eqUJlc9WjUK+8 Ac72F5+D3RgnwDASBGsbt4nziVdyYMylT7InWcm3RMb1vtxqlGafIVdyutgVvdVeq4qs 7K9PnzbEMDtGchPWhgxEx80+Q8rDrhnhQboM6cgshDqnmfvJn9tApMttMx6Jlk6TQMs+ dfeWOSk/hVg9kAk8MGpohWoX01NlB5M0Zl1pP669BfZdCS8rWWFS1ptgVc0f284lz1/Q ucuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PLlTop09; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v20-v6si110698pga.28.2018.06.27.22.00.53; Wed, 27 Jun 2018 22:01:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PLlTop09; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752700AbeF1EXf (ORCPT + 99 others); Thu, 28 Jun 2018 00:23:35 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:39472 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751414AbeF1EXe (ORCPT ); Thu, 28 Jun 2018 00:23:34 -0400 Received: by mail-pl0-f66.google.com with SMTP id s24-v6so2104804plq.6; Wed, 27 Jun 2018 21:23:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=80oQ5BXM/Zqa4PsJVTYoHlyaKq7RnK4JoIQmTlYc7gM=; b=PLlTop092VwwaQgrRhEVAniO5BZJi62Pj0lk4WUCt3DwzFt1zJ3s0qUOKVqLWB/J2Z i/YIkHuzDaBUjFCJWgthdjIM8Box6qC/oWHtMP6jZ9zcVqXsgBMYhggKRrLZvLwisRlJ YpSLRXIFWMJevXNLKe38ZZXsIZQjeKQs/lWwLz66aS4YPD4ClZJi2pgvgsSg+IDWPHHV u0YjXrItiTkefKrVqURNuReIXbZW93sTFnHZMYtWiXoWPyR25FbfUleY+k9vHtjQmwkD w9WmHeSrDq0dv7IWc7HlaGOHvapjzmRdStVmi0Gd51q/1eAgnmyWGOrOr5HxKDaA940r LvxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=80oQ5BXM/Zqa4PsJVTYoHlyaKq7RnK4JoIQmTlYc7gM=; b=QQlB/7PslyQM+7ry2YBIgp+zmCfG+Ju72KU07Ir197lkGu9YibNZIPTcdMqD1/2U+0 54eLnJDNnhkbN/KfPhsD1dlsbEXDoQmPyMxZrdrIC9dVz1TMDTN1RqsDt5ao+TG8awKn vQvLeEfEg008fGkPttyiHXnNaB0ZX784kEJ71+RUgRFg1jlouW+UUTk7XPOk1Rvarc3o Sa1J2AZaCqaagiEgzVIi1FDU4kpr4d2W7kN/ljazk6Cq0h6s6mLtlnje0Y+uIhiz/cMa GUmD+phG6eB4ov9b2Qg0QW2tp7mYH+cEmxBcbbQmySSGgpzMncZThNgRs6Q0YmZtIPsH LY6A== X-Gm-Message-State: APt69E3kmDo/HG08LT4CjovNFc2Rr/MBiBC8w0x1ndZUsMc5Ev5aewHN TcOhmVGHemGmKg5eqhr00FA= X-Received: by 2002:a17:902:a9:: with SMTP id a38-v6mr9045270pla.102.1530159813684; Wed, 27 Jun 2018 21:23:33 -0700 (PDT) Received: from localhost.didichuxing.com ([13.94.31.177]) by smtp.gmail.com with ESMTPSA id h13-v6sm8371307pgp.13.2018.06.27.21.23.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 21:23:33 -0700 (PDT) From: Yafang Shao To: edumazet@google.com Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yafang Shao Subject: [PATCH v2 net-next] tcp: add new SNMP counter for drops when try to queue in rcv queue Date: Thu, 28 Jun 2018 00:22:56 -0400 Message-Id: <1530159776-29919-1-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When sk_rmem_alloc is larger than the receive buffer and we can't schedule more memory for it, the skb will be dropped. In above situation, if this skb is put into the ofo queue, LINUX_MIB_TCPOFODROP is incremented to track it. While if this skb is put into the receive queue, there's no record. So a new SNMP counter is introduced to track this behavior. LINUX_MIB_TCPRCVQDROP: Number of packets meant to be queued in rcv queue but dropped because socket rcvbuf limit hit. Signed-off-by: Yafang Shao --- include/uapi/linux/snmp.h | 1 + net/ipv4/proc.c | 1 + net/ipv4/tcp_input.c | 8 ++++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/snmp.h b/include/uapi/linux/snmp.h index 97517f3..e5ebc83 100644 --- a/include/uapi/linux/snmp.h +++ b/include/uapi/linux/snmp.h @@ -280,6 +280,7 @@ enum LINUX_MIB_TCPDELIVEREDCE, /* TCPDeliveredCE */ LINUX_MIB_TCPACKCOMPRESSED, /* TCPAckCompressed */ LINUX_MIB_TCPZEROWINDOWDROP, /* TCPZeroWindowDrop */ + LINUX_MIB_TCPRCVQDROP, /* TCPRcvQDrop */ __LINUX_MIB_MAX }; diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index 225ef34..b46e4cf 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c @@ -288,6 +288,7 @@ static int sockstat_seq_show(struct seq_file *seq, void *v) SNMP_MIB_ITEM("TCPDeliveredCE", LINUX_MIB_TCPDELIVEREDCE), SNMP_MIB_ITEM("TCPAckCompressed", LINUX_MIB_TCPACKCOMPRESSED), SNMP_MIB_ITEM("TCPZeroWindowDrop", LINUX_MIB_TCPZEROWINDOWDROP), + SNMP_MIB_ITEM("TCPRcvQDrop", LINUX_MIB_TCPRCVQDROP), SNMP_MIB_SENTINEL }; diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 9c5b341..eecd359 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4611,8 +4611,10 @@ int tcp_send_rcvq(struct sock *sk, struct msghdr *msg, size_t size) skb->data_len = data_len; skb->len = size; - if (tcp_try_rmem_schedule(sk, skb, skb->truesize)) + if (tcp_try_rmem_schedule(sk, skb, skb->truesize)) { + NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPRCVQDROP); goto err_free; + } err = skb_copy_datagram_from_iter(skb, 0, &msg->msg_iter, size); if (err) @@ -4677,8 +4679,10 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) queue_and_out: if (skb_queue_len(&sk->sk_receive_queue) == 0) sk_forced_mem_schedule(sk, skb->truesize); - else if (tcp_try_rmem_schedule(sk, skb, skb->truesize)) + else if (tcp_try_rmem_schedule(sk, skb, skb->truesize)) { + NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPRCVQDROP); goto drop; + } eaten = tcp_queue_rcv(sk, skb, 0, &fragstolen); tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq); -- 1.8.3.1