Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4407994pxu; Mon, 12 Oct 2020 19:19:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnDsuVC1XEWJD+M2nhawBszreNm/QHSB0ic9RRY0OHqvmTqBAF6MDI7aWjQKKrOOcDhpO0 X-Received: by 2002:aa7:c5c4:: with SMTP id h4mr17935332eds.379.1602555577052; Mon, 12 Oct 2020 19:19:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602555577; cv=none; d=google.com; s=arc-20160816; b=xOq4DH17/TxEBv5QKdGSmxM3piYQnheXi9RGFljSGR8NTLIgpkwIbKNEQtLepktwNf +VItWgDWxDodSUl+YpB5UW8M0sc8KGF+ArN7eVcarYoPMm220TTtxvjfQHU7wnJhOeXh JEvahr/2T6270Cx1BGFezTbV9VBXqjvweqAcLNSXccdYVOrvPTtGTYKyUSpwJqXluA5M S8ofPcRAzeNWVTeesWgr4go6oeRbzwvDbK7NNgB/adAIY+DI/CnS12hcVPObGiW7zig/ uB5oZpbbn2XKOREIfYpMgiFcw16ixmzgiWbPw2cw5K+CPdWDvuqSLBi/RD46Ra7JOJxE Znrw== 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=LiRTK1pn0r+YX72HhN94UTqVGuwvK727gErKq+9p5co=; b=Am7BrcZVw2Qf8Ych+xAJjlw/Xk5X+93mEF0USlBSzzWQr9o4Zsudan82/1OX37QwZ8 q4tkyrpR/NPymD+ohBflgD/UmXAPjmCTWyqruZTXgWBfHuqjPv9AzHkZUx9AISHdoVFK GLWlrJrA+h13h5Ha9Nfk2XmiJsEFbKjuEaaApwtrC3NQFrqtfEi3fiAPJ1Oc7dsEWLdR LigFkvJnpX7PI69JYUZjPf9T59fvHuKLXhhfTTI6gkZocjYTCehsmxT9b8mgd7wLN5eG iiDxZOWHGh23BrbarWgfFcAlJ50cXhVMlL9JturxdxjU04GzwID0nvd6p7NlP9Mb55ZB PRBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b="kdD+EQ/d"; 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=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h24si7512372ejf.680.2020.10.12.19.19.12; Mon, 12 Oct 2020 19:19:37 -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=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b="kdD+EQ/d"; 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=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390750AbgJLOAZ (ORCPT + 99 others); Mon, 12 Oct 2020 10:00:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388795AbgJLN76 (ORCPT ); Mon, 12 Oct 2020 09:59:58 -0400 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7AFDC0613D0 for ; Mon, 12 Oct 2020 06:59:57 -0700 (PDT) Received: by mail-qt1-x843.google.com with SMTP id c23so13651946qtp.0 for ; Mon, 12 Oct 2020 06:59:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=LiRTK1pn0r+YX72HhN94UTqVGuwvK727gErKq+9p5co=; b=kdD+EQ/dal5vV717URB/8INdiZStUkziLF+UP1/oTSbkc1xgOTizbXO5c7UxoZEPEW ciXRZScy5HT82Nv+OD2jUtLvQ9ZQUcBf5lQFSVG840aSBl/RscDr0IFlx4mq7nv7MQ35 qKKeS7bNKo7We6dmI+xlw49U9Yldi1thKV+okEC746kq4DMa7X461pF8ef+CffG9QZHZ P4KVdg4bG0zObRLP2mgNLOg61igdJOJIBA0f9nLPUnjww4ZBDnQ2ZQq2sYhk6myWpyxs kMjev9XtTo/GbPHtFljwhoUpLw1Rj5mPbkW6NIMYdXRlfoGwcEQJYFL0k3Ft/+QUy2a5 zMxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=LiRTK1pn0r+YX72HhN94UTqVGuwvK727gErKq+9p5co=; b=sbZY0o7LHahO9/14GuJhnEKDOxz5zLDe0PUSoPhODR764vznuHEHGGNeqqQKKqsl3N cZmX34HdkCa6siVPVqX5Os2t00wSaJxBZb1bOy41hahsPm+r5ibSs1mAee+Qmfn9WW30 PqmnLDS/3si9a8TXPawR/ns6kLjhy1q+I/0vd4/ZDXpCvapwVKmJpf5begToMpTy7MGC 2MCBuprjZn8f8nQzF057tD+/xJsVFow70zrG9/hIGLkZKanSeV0C0KhuKZ9kbzSWob7H LBfB7zLbGHRnYEYwAGLshBn1FD9K+1F1/fWk14sujCf+uTROvQxmW1xH8F6ZEST/+IsZ 6iGg== X-Gm-Message-State: AOAM533HOp2PZ6k0P38YEm7C/cwrOeooKqqn4OnMe8y+8q/uKA3cFe0b awrMB8SeHnrHxBOCH5A0k+xNFQ== X-Received: by 2002:ac8:5b8d:: with SMTP id a13mr9846698qta.209.1602511197075; Mon, 12 Oct 2020 06:59:57 -0700 (PDT) Received: from localhost (pool-96-232-200-60.nycmny.fios.verizon.net. [96.232.200.60]) by smtp.gmail.com with ESMTPSA id r16sm6844790qkm.1.2020.10.12.06.59.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 06:59:56 -0700 (PDT) Date: Mon, 12 Oct 2020 09:58:23 -0400 From: Johannes Weiner To: Muchun Song Cc: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, mhocko@kernel.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, shakeelb@google.com, guro@fb.com, iamjoonsoo.kim@lge.com, laoar.shao@gmail.com, chris@chrisdown.name, daniel@iogearbox.net, kafai@fb.com, ast@kernel.org, jakub@cloudflare.com, linmiaohe@huawei.com, keescook@chromium.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] mm: memcontrol: localize mem_cgroup_sockets_enabled() check Message-ID: <20201012135823.GA188876@cmpxchg.org> References: <20201010104521.67262-1-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201010104521.67262-1-songmuchun@bytedance.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Also memcg code now has to know about struct sock. I'm not quite sure that this is an overall improvement.