Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3716318pxu; Sun, 11 Oct 2020 21:45:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMecS34lGNKe/g/JgbsKnX30XQQYqdq/q12cxUmEBqNtDJ5ZLu80Be+Wa6YC4PAlMqB3TI X-Received: by 2002:a50:c38e:: with SMTP id h14mr12671374edf.174.1602477941225; Sun, 11 Oct 2020 21:45:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602477941; cv=none; d=google.com; s=arc-20160816; b=AoOKCRSgxHIsLiEYWc0V+4OLMgzbjYe+butb0YSSKsqTLOFuXSg1v4/ZW+vLvLrPBz /+BmSCs7C2qEP14CQaGnlQ007q8YenEzQjM75OBy2mn/vMVjmCNSbmLhczb9YYzuVmt3 B6QEKfkfv4sMtgAtiTjHtD5fzpDnDYKD+3xFcyOKtorrIq9iFzSKWJMR5wtQFmlBCwNn 1MkK5zUq9BWgTUWUJxR1QlWT/dMKz2VaH3ArB6TYOMA2ISTnByYhNsbhqhV+PFeZeDDo Mp6JuYgOH6e+wi1is+qclQ+UpEwosLdCiX6skQmXt1MKclrqilDEux9K5y0g4ixdaJZ3 0vIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=86h9GnvGBi5wC9xCp0mEaMT6C/YP6RZUf0IR+KiY+mM=; b=gYFcL52oSsUKAKQS0VrC8vxVY08ELvag6bNMYyajW499sHBGwLnMwGqn1w1K4tl/Sl G7GCEHWQpr2o6glZ4U9HPzfNArX0vZVdq+5cPTNDsk9le+FxU7kgRCgZ8QfDhZseuGGR jAfaE2URsnBOOfTHNHW4FmAzIod/GAskN1c3pz/uQy2zah6Wk7b3z4KRT4RRF4fy1a9f FfIZScE9Ob2GFFrleX4gHrCKKg9u5NPKAKgHUpV9F0hd2c9Db9E+AfwmciW8vnIwsjBK vXBUhDDCy/dh7hL+TPSzCEQIopJJ8MkH1S2tEmv/iduRvMMNSd+wkisXy5NSF4PRv9VL MD8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=n5A3l84I; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h6si11806284ejk.553.2020.10.11.21.45.18; Sun, 11 Oct 2020 21:45:41 -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=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=n5A3l84I; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727904AbgJLEWx (ORCPT + 99 others); Mon, 12 Oct 2020 00:22:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726706AbgJLEWx (ORCPT ); Mon, 12 Oct 2020 00:22:53 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E96BBC0613CE for ; Sun, 11 Oct 2020 21:22:52 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id r10so13053129pgb.10 for ; Sun, 11 Oct 2020 21:22:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=86h9GnvGBi5wC9xCp0mEaMT6C/YP6RZUf0IR+KiY+mM=; b=n5A3l84IVanhAXQ+RpWAMhL2/paRrC+kBPfk32SkjMJ3AMIe+3jVIqh5wck4Qd64RH OJ1A23lm7sibahUbKhN34W8lVpaxR2Sth1OKPcLb6ZGuB6MapkRU9HNBC3XkRM4rrB/L qkKvRFLA1BpjbDhEJv4NzLXFuijYW2r+o17N5n+k4+ZaLNoO3bpDGymp68ohPmNCfJ3Z 33n6gE3eMLl3UD9fIFLUFcSbulpMADG+sOEVBQazltObrafBDS+pVXURv2NVG3AWKyVq BavLV2VLLjgz1sFHY7rqtk/5uidIKHx52b48F5hLddg4pbIQX6HpruoRh2OA+Ep8QMyS KNCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=86h9GnvGBi5wC9xCp0mEaMT6C/YP6RZUf0IR+KiY+mM=; b=bCatiZGUeUsrut7xd0Gqzw6YLcDSq6XpVkAaShoGS9lBvhWm5DiTG6HAtmzJt/gAW5 G+H8mzlU+rwwCYWZdkVypDcHDdFRyCuDo1hXIb8xpElM2mdskqnezNgOIdC+4Osvt8Yo CibEsn9jplcD0qlePjQwOS9IhNxSzLyrcGhO4lPeOTkuoSmGX5a1mNt7LFa0xIwRdd5H /3VF4ogEQSSoll2LSbxdcEgs2CxDJgePK2Ek8XlgN8H/bMT9FhV1Omyd0wNrgbBRIRiy 4bsXizaFAFD1rvYkKktpCIM05sefc5A3Qrt7yL20TD6BKJ+sRcKAJhPRsF0BRQI1qt78 FSKA== X-Gm-Message-State: AOAM530koyhEaSRuzAwh2o6UcOka+p/nTsvYv9xPJ/FR8u+wJOF/NoOG UpWaRjdMahrn9Nl/t/AKSk6ERqJuG1QeGfSYM+JYLQ== X-Received: by 2002:a17:90a:890f:: with SMTP id u15mr18101013pjn.147.1602476572410; Sun, 11 Oct 2020 21:22:52 -0700 (PDT) MIME-Version: 1.0 References: <20201010103854.66746-1-songmuchun@bytedance.com> In-Reply-To: From: Muchun Song Date: Mon, 12 Oct 2020 12:22:16 +0800 Message-ID: Subject: Re: [External] Re: [PATCH] mm: proc: add Sock to /proc/meminfo To: Cong Wang Cc: Greg KH , rafael@kernel.org, "Michael S. Tsirkin" , Jason Wang , David Miller , Jakub Kicinski , Alexey Dobriyan , Andrew Morton , Eric Dumazet , Alexey Kuznetsov , Hideaki YOSHIFUJI , Steffen Klassert , Herbert Xu , Shakeel Butt , Will Deacon , Michal Hocko , Roman Gushchin , Neil Brown , rppt@kernel.org, Sami Tolvanen , "Kirill A. Shutemov" , Feng Tang , Paolo Abeni , Willem de Bruijn , Randy Dunlap , Florian Westphal , gustavoars@kernel.org, Pablo Neira Ayuso , decui@microsoft.com, Jakub Sitnicki , Peter Zijlstra , Christian Brauner , "Eric W. Biederman" , Thomas Gleixner , dave@stgolabs.net, Michel Lespinasse , Jann Horn , chenqiwu@xiaomi.com, christophe.leroy@c-s.fr, Minchan Kim , Martin KaFai Lau , Alexei Starovoitov , Daniel Borkmann , Miaohe Lin , Kees Cook , LKML , virtualization@lists.linux-foundation.org, Linux Kernel Network Developers , linux-fsdevel , linux-mm Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 12, 2020 at 2:39 AM Cong Wang wrote: > > On Sat, Oct 10, 2020 at 3:39 AM Muchun Song wr= ote: > > > > 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 kerne= l > > We do it via `ss -m`. Is it not sufficient? And if not, why not adding it= there > rather than /proc/meminfo? If the system has little free memory, we can know where the memory is via /proc/meminfo. If a lot of memory is consumed by socket buffer, we cannot know it when the Sock is not shown in the /proc/meminfo. If the unaware use= r can't think of the socket buffer, naturally they will not `ss -m`. The end result is that we still don=E2=80=99t know where the memory is consumed. And we ad= d the Sock to the /proc/meminfo just like the memcg does('sock' item in the cgrou= p v2 memory.stat). So I think that adding to /proc/meminfo is sufficient. > > > static inline void __skb_frag_unref(skb_frag_t *frag) > > { > > - put_page(skb_frag_page(frag)); > > + struct page *page =3D skb_frag_page(frag); > > + > > + if (put_page_testzero(page)) { > > + dec_sock_node_page_state(page); > > + __put_page(page); > > + } > > } > > You mix socket page frag with skb frag at least, not sure this is exactly > what you want, because clearly skb page frags are frequently used > by network drivers rather than sockets. > > Also, which one matches this dec_sock_node_page_state()? Clearly > not skb_fill_page_desc() or __skb_frag_ref(). Yeah, we call inc_sock_node_page_state() in the skb_page_frag_refill(). So if someone gets the page returned by skb_page_frag_refill(), it must put the page via __skb_frag_unref()/skb_frag_unref(). We use PG_private to indicate that we need to dec the node page state when the refcount of page reaches zero. Thanks. > > Thanks. --=20 Yours, Muchun