[RHEL7,COMMIT] ms/net: add LINUX_MIB_PFMEMALLOCDROP counter

Submitted by Konstantin Khorenko on March 22, 2019, 3:46 p.m.

Details

Message ID 201903221546.x2MFkCeW020893@finist-ce7.sw.ru
State New
Series "net: add LINUX_MIB_PFMEMALLOCDROP counter"
Headers show

Commit Message

Konstantin Khorenko March 22, 2019, 3:46 p.m.
The commit is pushed to "branch-rh7-3.10.0-957.10.1.vz7.85.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.10.1.vz7.85.2
------>
commit 3393cf0cc4e4b3b017bc32556e0a4a8dc6b5e9f8
Author: Eric Dumazet <edumazet@google.com>
Date:   Fri Mar 22 18:46:11 2019 +0300

    ms/net: add LINUX_MIB_PFMEMALLOCDROP counter
    
    ms commit 8fe809a99263
    
    Debugging issues caused by pfmemalloc is often tedious.
    
    Add a new SNMP counter to more easily diagnose these problems.
    
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Cc: Josef Bacik <jbacik@fb.com>
    Acked-by: Josef Bacik <jbacik@fb.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    
    Backported in the scope of
    https://pmc.acronis.com/browse/VSTOR-21390
    
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 include/uapi/linux/snmp.h | 1 +
 net/core/filter.c         | 4 +++-
 net/ipv4/proc.c           | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/include/uapi/linux/snmp.h b/include/uapi/linux/snmp.h
index 081cc866c1bb..ee9a877f4781 100644
--- a/include/uapi/linux/snmp.h
+++ b/include/uapi/linux/snmp.h
@@ -241,6 +241,7 @@  enum
 	LINUX_MIB_SACKMERGED,
 	LINUX_MIB_SACKSHIFTFALLBACK,
 	LINUX_MIB_TCPBACKLOGDROP,
+	LINUX_MIB_PFMEMALLOCDROP,
 	LINUX_MIB_TCPMINTTLDROP, /* RFC 5082 */
 	LINUX_MIB_TCPDEFERACCEPTDROP,
 	LINUX_MIB_IPRPFILTER, /* IP Reverse Path Filter (rp_filter) */
diff --git a/net/core/filter.c b/net/core/filter.c
index dee75bd9af67..afbef368f824 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -90,8 +90,10 @@  int sk_filter_trim_cap(struct sock *sk, struct sk_buff *skb, unsigned int cap)
 	 * allow SOCK_MEMALLOC sockets to use it as this socket is
 	 * helping free memory
 	 */
-	if (skb_pfmemalloc(skb) && !sock_flag(sk, SOCK_MEMALLOC))
+	if (skb_pfmemalloc(skb) && !sock_flag(sk, SOCK_MEMALLOC)) {
+		NET_INC_STATS(sock_net(sk), LINUX_MIB_PFMEMALLOCDROP);
 		return -ENOMEM;
+	}
 
 	err = security_sock_rcv_skb(sk, skb);
 	if (err)
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
index b63cc537f1ab..89940b67083a 100644
--- a/net/ipv4/proc.c
+++ b/net/ipv4/proc.c
@@ -260,6 +260,7 @@  static const struct snmp_mib snmp4_net_list[] = {
 	SNMP_MIB_ITEM("TCPSackMerged", LINUX_MIB_SACKMERGED),
 	SNMP_MIB_ITEM("TCPSackShiftFallback", LINUX_MIB_SACKSHIFTFALLBACK),
 	SNMP_MIB_ITEM("TCPBacklogDrop", LINUX_MIB_TCPBACKLOGDROP),
+	SNMP_MIB_ITEM("PFMemallocDrop", LINUX_MIB_PFMEMALLOCDROP),
 	SNMP_MIB_ITEM("TCPMinTTLDrop", LINUX_MIB_TCPMINTTLDROP),
 	SNMP_MIB_ITEM("TCPDeferAcceptDrop", LINUX_MIB_TCPDEFERACCEPTDROP),
 	SNMP_MIB_ITEM("IPReversePathFilter", LINUX_MIB_IPRPFILTER),