From patchwork Wed Jun 27 21:51:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 10492717 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5803E601A0 for ; Wed, 27 Jun 2018 21:51:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C0812A003 for ; Wed, 27 Jun 2018 21:51:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F58E2A384; Wed, 27 Jun 2018 21:51:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6DD12A3A1 for ; Wed, 27 Jun 2018 21:51:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C6E7E6B0010; Wed, 27 Jun 2018 17:51:19 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C1DA86B0266; Wed, 27 Jun 2018 17:51:19 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE7716B0269; Wed, 27 Jun 2018 17:51:19 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f197.google.com (mail-pf0-f197.google.com [209.85.192.197]) by kanga.kvack.org (Postfix) with ESMTP id 6ED8A6B0010 for ; Wed, 27 Jun 2018 17:51:19 -0400 (EDT) Received: by mail-pf0-f197.google.com with SMTP id l2-v6so1632664pff.3 for ; Wed, 27 Jun 2018 14:51:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:to:cc:references:from :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=5AEZF4lANcLAKHGNlxd9Ewy5EYRIsBNb3ZL1b/n8DSY=; b=V5o/iz0F1zDVQFbm2qPfTnSqmFTA6rRbMRImE8rECMpvbPO6zMN8FwcIr9mGicX1B1 9BXXZP1O3JHcMY2+I60y7LMgDlTnjZii3+r0H7mRgA3f/Axt3DOfIuQ7aNsZBYIX9cqV +uv4NoAv8yPV9rkzssegWdtc5vIXI3PtXWTNGAUV5ouH6V2XmMJPs9g957EzQxuKlR1T bNCzkHDSC1FUQCquPLeFVzMnj3WQ+6H/ToIXxgYsMvvtdFi+4WKhgGguj+ZPSOFo9od+ reiUpm15U99Py0nWkf/xyp58h7cBomWSvaYMVxyflkFSdp9aDlmCytCHBbkWpE+w0Mnz Z71w== X-Gm-Message-State: APt69E34uDIxEqneA0KIQgFCCNLG0Z8Z3HTotbeEVflYcAO9xXn8dtTN u6zwzcy866l2KdNlKR9r4mm+VfD34BtiKgAvz3kkpzfSBkkC9yokDdBLHbSsCMMb68G6bLXzqjB VmQw8s2D+pCWOF9EJ6OHgVylFX7AbK//TG+WhmVJCyUmm22l+kwcTsMEvDoI+b52XE+yXJH1H7P x1jVvRdvRgDhsFIhl2vY/VIH/nk10EaidxBkMYtR6LLAsOcukLc8E8arX9wOOWnm3Hrvu/Z5ev9 Wb2vBArx3QOHJxKbLZ/CePrXu8v5xszeqMLq04RB6vCuQJ5lJ9D3iUUprGfe1xWA3J6YLIC1TDc u7RLGwH9ER9IPFeE1EIIGaUUK06Tg1acdWd9ZvzGIIdlzyXyFarqZBMTTmN9EM+lw2MLhZt1qrW K X-Received: by 2002:a63:7252:: with SMTP id c18-v6mr6441377pgn.186.1530136279035; Wed, 27 Jun 2018 14:51:19 -0700 (PDT) X-Received: by 2002:a63:7252:: with SMTP id c18-v6mr6441359pgn.186.1530136278206; Wed, 27 Jun 2018 14:51:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530136278; cv=none; d=google.com; s=arc-20160816; b=OAS4kXPmQbkwgIvSQ/S0q7FkXHBi7e6VIPCPX0KlMcISGLaXbvB6jyDO8DsNiLCQnk urX7OjeyrmKS5Mz4zl/JJsh0p9dR/jaibhKoDlTxJDwLvSxpUivZiLlEF0jEXXZOwHVG 4I4VJdtUQRUSbQCBykbrUKgZgWptbW/wxsbdMMWe1luJGnzx9XZp2GBiuBaT57LqRGxe l3cwCbAAadHfBMrErmDN/0H02jh7YGyeyM8pmQi2H9bHYTLEBNgYZot3V/bhFPPhx4D6 0ujBMnGbOxn1Xi1FTzKykmpcKYR5ha3tL1tbYqf1HkZudyy874yUQKLlpR8Um9MpcxPl EueQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject :dkim-signature:arc-authentication-results; bh=5AEZF4lANcLAKHGNlxd9Ewy5EYRIsBNb3ZL1b/n8DSY=; b=z7fwbMIdVuIz/2rzjQxPNU2rHvPNf0qKeSsGnQYzcmuvlkCmSdSe+wdU6mT8BkOJQb N1Nimiv3+TPNSe36XYR/bZiwhez9jraMe92RiiEJ0Sa433rkTXenH+69JIEX8umdsvhT rmeHOxcKmskGaXL1mprIvsMRmQXyrFukwMj7oercZgByCfFuLHm0KzPd8JxtB2iFvbuP UxK+Wz76v2Uw5WaVmTBOfLBcEVwAFXRT75Cqi5Qi/DA4eR8JLO4y/Hng7yF39icE0a/P tFUEIy/li9wArmvjf3W/Nu9p0PiLeEjXfIfPiUhogYbOgyi5XPycC71pOHGxVKG5LAr4 HTaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RH7OtFHh; spf=pass (google.com: domain of eric.dumazet@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=eric.dumazet@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id b1-v6sor1294928pgb.171.2018.06.27.14.51.18 for (Google Transport Security); Wed, 27 Jun 2018 14:51:18 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.dumazet@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RH7OtFHh; spf=pass (google.com: domain of eric.dumazet@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=eric.dumazet@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=5AEZF4lANcLAKHGNlxd9Ewy5EYRIsBNb3ZL1b/n8DSY=; b=RH7OtFHhh+qzDMODwq/FxGZ/FQVz+8Fy+85+ps/PzwnIawF4z2DjCV9sfJFN28aBi8 qSjL6c5W3JxF9c3ektFgKdgguj47zHWsv6PPkxHQIru1xsSGIPv5BPIAqEgE23hHaRkO yCmvSNCi3+sA2I5QcP92Vn6FTL4SGYMIY0mDT3itk6cGrjvrFhnUAAhT7SVny3Auhy6Y cuOFdXmiPJgi33du2KGNPBXgmzXj235/I1fBgLDt7Jz4xkmaC/d8EcO/+QUm5KN1qvWT 7ccElnBXUCkA+kf+YzAaYFdgNcKSwrp5rP1A57NNbs0Lw7DrVTZo9GhMOtzey/FFDf2c zpkg== X-Google-Smtp-Source: ADUXVKKnelQjd9zcRVt7m2zhztLV5Hfin3KF6lBZxyBrdPA/7RnsEfe7iLCNcosd/DKS9aB5cBM/tQ== X-Received: by 2002:a65:608c:: with SMTP id t12-v6mr6753601pgu.159.1530136277764; Wed, 27 Jun 2018 14:51:17 -0700 (PDT) Received: from ?IPv6:2620:15c:2c1:200:55c7:81e6:c7d8:94b? ([2620:15c:2c1:200:55c7:81e6:c7d8:94b]) by smtp.gmail.com with ESMTPSA id y33-v6sm4834796pga.41.2018.06.27.14.51.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 14:51:17 -0700 (PDT) Subject: Re: [RFC PATCH] net, mm: account sock objects to kmemcg To: Shakeel Butt , Andrew Morton Cc: Johannes Weiner , Vladimir Davydov , Greg Thelen , Roman Gushchin , "David S . Miller" , Eric Dumazet , Kirill Tkhai , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-mm@kvack.org References: <20180627204139.225988-1-shakeelb@google.com> From: Eric Dumazet Message-ID: Date: Wed, 27 Jun 2018 14:51:15 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180627204139.225988-1-shakeelb@google.com> Content-Language: en-US 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: X-Virus-Scanned: ClamAV using ClamSMTP On 06/27/2018 01:41 PM, Shakeel Butt wrote: > Currently the kernel accounts the memory for network traffic through > mem_cgroup_[un]charge_skmem() interface. However the memory accounted > only includes the truesize of sk_buff which does not include the size of > sock objects. In our production environment, with opt-out kmem > accounting, the sock kmem caches (TCP[v6], UDP[v6], RAW[v6], UNIX) are > among the top most charged kmem caches and consume a significant amount > of memory which can not be left as system overhead. So, this patch > converts the kmem caches of more important sock objects to SLAB_ACCOUNT. > > Signed-off-by: Shakeel Butt > --- > net/ipv4/raw.c | 1 + > net/ipv4/tcp_ipv4.c | 2 +- > net/ipv4/udp.c | 1 + > net/ipv6/raw.c | 1 + > net/ipv6/tcp_ipv6.c | 2 +- > net/ipv6/udp.c | 1 + > net/unix/af_unix.c | 1 + > 7 files changed, 7 insertions(+), 2 deletions(-) Hey, you just disclosed we do not use DCCP ;) Joke aside, what about simply factorizing this stuff ? diff --git a/net/core/sock.c b/net/core/sock.c index bcc41829a16d50714bdd3c25c976c0b7296fab84..b6714f8d7e9ba313723a6f619799c56230ff5fd4 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -3243,7 +3243,8 @@ static int req_prot_init(const struct proto *prot) rsk_prot->slab = kmem_cache_create(rsk_prot->slab_name, rsk_prot->obj_size, 0, - prot->slab_flags, NULL); + SLAB_ACCOUNT | prot->slab_flags, + NULL); if (!rsk_prot->slab) { pr_crit("%s: Can't create request sock SLAB cache!\n", @@ -3258,7 +3259,8 @@ int proto_register(struct proto *prot, int alloc_slab) if (alloc_slab) { prot->slab = kmem_cache_create_usercopy(prot->name, prot->obj_size, 0, - SLAB_HWCACHE_ALIGN | prot->slab_flags, + SLAB_HWCACHE_ALIGN | SLAB_ACCOUNT | + prot->slab_flags, prot->useroffset, prot->usersize, NULL);