Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3477355pxu; Sun, 11 Oct 2020 11:05:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBs9h9wULuUEIxAKj/RhX0uAIkoA9wfQNphItfyNFbuSi0putn8Sd4fdeyd41QNcVfE3MI X-Received: by 2002:a17:906:8519:: with SMTP id i25mr24391014ejx.76.1602439543663; Sun, 11 Oct 2020 11:05:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602439543; cv=none; d=google.com; s=arc-20160816; b=PoUrTj+pfKt2vAG3J1tgOj+VQdtrEf6hU3o7zPU24Bh7oo7XKFnqDvPtP47W75t61n 7amJ+IXEOAdr35Dc4nEksVDZswKQCCNd6RlrsdM6bwem31eYo+ioEQ2czGZ2y3H7mmRQ xFVAuSIbUcdQCr1vIcvX6A2NRaWBrrxrDaOlYq4y27ruby4UT7s7QEhiQm1HqZh5GJQ/ mh1vey/S8j+FzJeMaWUEqwPu7Co74AvfSnDiCms/26/kSk1F4givq5jjEhI2DhH5KZXo 46SgKTCR8lED5xpOPIkq4cb1ggYUZbUobb0QvMRPe3V6+t79y+G3b3Gk2dadGMjdqij7 vHtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=XfQdvv0hoShKATRsAkQY+0bVLw0VryanYyxxn/jG6go=; b=kccuuoUmvEHORgEMjoHjBn0Omun/j1PzoFUmFZRrTVkI/tm2brf+vkNG72EpwrYzQ/ MgMWoIP2b1fCMT16JMY1XINFltx1n0jm83xC6eVML1UDawK+QQ7kmzyLpCRfvTMKMQxg 8ziJu7/kccI/wI3mq0Skpp6tQE94XIorFiPjQDXk9kEAzpWxx69Ed+eTRv+kgdhngFAF 5RPY2xzT4zbZ/QniAN+T8cS4gebpZHQNd0B4t5sKXNeGSwRhT+kq/ioP1kyivUbKSYf2 dStKfU1W8HI5VIIqHSld0F2fJecyC8AvRxYx9CXpQjs5t/8cKPQaPB7uU0amEO3xBgo9 uabQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="UAw/nF8a"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v17si10769189eds.593.2020.10.11.11.05.20; Sun, 11 Oct 2020 11:05:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="UAw/nF8a"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387944AbgJKNxD (ORCPT + 99 others); Sun, 11 Oct 2020 09:53:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:45900 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387885AbgJKNxC (ORCPT ); Sun, 11 Oct 2020 09:53:02 -0400 Received: from kernel.org (unknown [87.71.73.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D931A20781; Sun, 11 Oct 2020 13:52:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602424381; bh=2Z3/Dy7FEwrXfEg2TjMmQHOqWceXblc0T+c5Wxpj1U8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UAw/nF8aokc1l4l36U/F7cHL2FRVa52GO2I1c+bjqrpYD6A4QERDCFghM+VOvbFg/ 2IfNrSJOcz5zaPQKqECb88Gc7lvuqurNhQGFphzM87mvTDm6p38Ze7ofZr56Gqv7II hpuOunWqeWcakghdfenflbfcBgmRzso0JM6XKOJA= Date: Sun, 11 Oct 2020 16:52:44 +0300 From: Mike Rapoport To: Muchun Song Cc: gregkh@linuxfoundation.org, rafael@kernel.org, mst@redhat.com, jasowang@redhat.com, davem@davemloft.net, kuba@kernel.org, adobriyan@gmail.com, akpm@linux-foundation.org, edumazet@google.com, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, steffen.klassert@secunet.com, herbert@gondor.apana.org.au, shakeelb@google.com, will@kernel.org, mhocko@suse.com, guro@fb.com, neilb@suse.de, samitolvanen@google.com, kirill.shutemov@linux.intel.com, feng.tang@intel.com, pabeni@redhat.com, willemb@google.com, rdunlap@infradead.org, fw@strlen.de, gustavoars@kernel.org, pablo@netfilter.org, decui@microsoft.com, jakub@cloudflare.com, peterz@infradead.org, christian.brauner@ubuntu.com, ebiederm@xmission.com, tglx@linutronix.de, dave@stgolabs.net, walken@google.com, jannh@google.com, chenqiwu@xiaomi.com, christophe.leroy@c-s.fr, minchan@kernel.org, kafai@fb.com, ast@kernel.org, daniel@iogearbox.net, linmiaohe@huawei.com, keescook@chromium.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] mm: proc: add Sock to /proc/meminfo Message-ID: <20201011135244.GC4251@kernel.org> References: <20201010103854.66746-1-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201010103854.66746-1-songmuchun@bytedance.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Oct 10, 2020 at 06:38:54PM +0800, Muchun Song wrote: > The amount of memory allocated to sockets buffer can become significant. > However, we do not display the amount of memory consumed by sockets > buffer. In this case, knowing where the memory is consumed by the kernel > is very difficult. On our server with 500GB RAM, sometimes we can see > 25GB disappear through /proc/meminfo. After our analysis, we found the > following memory allocation path which consumes the memory with page_owner > enabled. I have a high lelel question. There is accounting of the socket memory for memcg that gets called from the networking layer. Did you check if the same call sites can be used for the system-wide accounting as well? > 849698 times: > Page allocated via order 3, mask 0x4052c0(GFP_NOWAIT|__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP) > __alloc_pages_nodemask+0x11d/0x290 > skb_page_frag_refill+0x68/0xf0 > sk_page_frag_refill+0x19/0x70 > tcp_sendmsg_locked+0x2f4/0xd10 > tcp_sendmsg+0x29/0xa0 > sock_sendmsg+0x30/0x40 > sock_write_iter+0x8f/0x100 > __vfs_write+0x10b/0x190 > vfs_write+0xb0/0x190 > ksys_write+0x5a/0xd0 > do_syscall_64+0x5d/0x110 > entry_SYSCALL_64_after_hwframe+0x44/0xa9 > > Signed-off-by: Muchun Song > --- > drivers/base/node.c | 2 ++ > drivers/net/virtio_net.c | 3 +-- Is virtio-net the only dirver that requred an update? > fs/proc/meminfo.c | 1 + > include/linux/mmzone.h | 1 + > include/linux/skbuff.h | 43 ++++++++++++++++++++++++++++++++++++++-- > kernel/exit.c | 3 +-- > mm/page_alloc.c | 7 +++++-- > mm/vmstat.c | 1 + > net/core/sock.c | 8 ++++---- > net/ipv4/tcp.c | 3 +-- > net/xfrm/xfrm_state.c | 3 +-- > 11 files changed, 59 insertions(+), 16 deletions(-) >