From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40351C43457 for ; Mon, 12 Oct 2020 16:05:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BA40D2076C for ; Mon, 12 Oct 2020 16:05:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bytedance-com.20150623.gappssmtp.com header.i=@bytedance-com.20150623.gappssmtp.com header.b="ZjmvDvxL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BA40D2076C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0D8E76B005D; Mon, 12 Oct 2020 12:05:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0634E6B0062; Mon, 12 Oct 2020 12:05:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E6BC76B0068; Mon, 12 Oct 2020 12:05:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0005.hostedemail.com [216.40.44.5]) by kanga.kvack.org (Postfix) with ESMTP id B4DFE6B005D for ; Mon, 12 Oct 2020 12:05:23 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 4CEA7180AD817 for ; Mon, 12 Oct 2020 16:05:23 +0000 (UTC) X-FDA: 77363748126.26.bread03_5c140f1271fb Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id F2B671804B66B for ; Mon, 12 Oct 2020 16:05:22 +0000 (UTC) X-HE-Tag: bread03_5c140f1271fb X-Filterd-Recvd-Size: 5024 Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Mon, 12 Oct 2020 16:05:22 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id n9so14725863pgf.9 for ; Mon, 12 Oct 2020 09:05:21 -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; bh=8I5XKTgq/Z0bLvn2YmKFNFJu3bvFZkBI41VZpa4KwVY=; b=ZjmvDvxLIavsomBf4sUVGuCczLwUrYqvKoVsenBx5ZDRysgwBdTa+1a1hCLp4Qv/HB k4Wxd5SxpANhGENEB9lk+phhkrybxUbtpj3DlcrL1Q7YuRIsYIHnjAlD+kfS0fSxfR8y 9WfbcrXwfavgTijWwW63FTK24YGHQMz+hktTJfj+1mgQCNXDExJDfFVLF00EwSS8Frz9 P3dg0bc4S4XIpcPWsub1WMZmrlYxkqIYdJNiHh9PUyVvS7Uuvo7U99bT7Pxc2Oq9qcDg 7BQxc8sXd+fJ3+GfRaJ16RG40eODbhCHJET4XmpCc9mchniOFbFOF9DU45Mv5RnpltPa ZS6w== 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; bh=8I5XKTgq/Z0bLvn2YmKFNFJu3bvFZkBI41VZpa4KwVY=; b=b/2KaJAzpzDB1B9H4fEyDw7afzYAvdgW7+ypk4BPPuIXeOnKEqOY9kjWfwmHz61UX9 Yw4Go0ID5GHHWJyysc1gJpJ8i1QlxcHcHB5Yscxi0RlSFPmlRiLdpevs3G+t3YjXXXHL 7chdY1OCz//eTvvioHwIAYJTkXQx2rEzELnjybov7pk8cwYyRP1qc85znZ0vG0xAQj57 Uxswd3/VD5an8+z7wNGN5C/JoS+spFGEzMWPM08UozGb6uFPVne6dPklZgdkxxAVgp3y giz8scRMNVd+BcrVfByBA8iJw8KbpzpGda2L1490vuSNKjwrbmW7WQG4wo77hncZiVaV 2Drw== X-Gm-Message-State: AOAM530Rm7EC3RJVOcE7Qaa1Pd1FMa/QBAOdtFe+z+Llf9NZ6+no2wyO hCfdq1tCfSfEh7z/lJvbjlnODU97V2r9hYMvTj4uSA== X-Google-Smtp-Source: ABdhPJzYe2rIzqJSmeOTfqVuMkQYjy2B4w6VyJ48z1edXwESV0BcGlpJn5MlnRrH/2xTVtTap322A3yoOEsV6GS4dck= X-Received: by 2002:a17:90a:890f:: with SMTP id u15mr20954335pjn.147.1602518720947; Mon, 12 Oct 2020 09:05:20 -0700 (PDT) MIME-Version: 1.0 References: <20201010104521.67262-1-songmuchun@bytedance.com> <20201012135823.GA188876@cmpxchg.org> In-Reply-To: <20201012135823.GA188876@cmpxchg.org> From: Muchun Song Date: Tue, 13 Oct 2020 00:04:44 +0800 Message-ID: Subject: Re: [External] Re: [PATCH] mm: memcontrol: localize mem_cgroup_sockets_enabled() check To: Johannes Weiner Cc: David Miller , kuba@kernel.org, Eric Dumazet , Michal Hocko , Vladimir Davydov , Andrew Morton , kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, Shakeel Butt , Roman Gushchin , Joonsoo Kim , laoar.shao@gmail.com, Chris Down , Daniel Borkmann , Martin KaFai Lau , Alexei Starovoitov , jakub@cloudflare.com, linmiaohe@huawei.com, Kees Cook , LKML , Networking , Cgroups , Linux Memory Management List Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Oct 12, 2020 at 9:59 PM Johannes Weiner wrote: > > On Sat, Oct 10, 2020 at 06:45:21PM +0800, Muchun Song wrote: > > Move the mem_cgroup_sockets_enabled() checks into memcg socket charge > > or uncharge functions, so the users don't have to explicitly check that > > condition. > > > > This is purely code cleanup patch without any functional change. But > > move the sk_memcg member of the sock structure to the CONFIG_MEMCG > > scope. > > > > Signed-off-by: Muchun Song > > --- > > include/linux/memcontrol.h | 78 ++++++++++++++++++++++++++------- > > include/net/sock.h | 5 ++- > > include/net/tcp.h | 3 +- > > mm/memcontrol.c | 43 +++++++++++++----- > > net/core/sock.c | 15 +++---- > > net/ipv4/inet_connection_sock.c | 6 +-- > > net/ipv4/tcp_output.c | 3 +- > > 7 files changed, 111 insertions(+), 42 deletions(-) > > Hm, this is almost 3 times as much code. > > The sk_memcg saving on !CONFIG_MEMCG is somewhat nice, but it's not > clear how many users would benefit here. And it adds ifdefs in code. The 'ifdefs in code' means the initialization of sk_memcg in the sk_clone_lock? If yes, we can add a new inline initialization function to avoid this. > > Also memcg code now has to know about struct sock. Without this patch, the memcg code also has to know about struct sock. You can see the code of mem_cgroup_sk_alloc and mem_cgroup_sk_free. Thanks. > > I'm not quite sure that this is an overall improvement. -- Yours, Muchun