Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp102707ybg; Mon, 27 Jul 2020 17:00:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfc4BoPfUc4xkLfdc5y6s6uH58EC+uXOaFj+NL2T8Y82DmsnT3BrJKljE5kr7mv0JM7D7J X-Received: by 2002:a17:906:c08a:: with SMTP id f10mr13362412ejz.181.1595894443095; Mon, 27 Jul 2020 17:00:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595894443; cv=none; d=google.com; s=arc-20160816; b=kpVh/3wiVsvQnz5ujSDIkZDBQqXWDS4dfPXcaKb+A1xRlM+gy8azOP3he2xTAPX0sZ HfFS0DpFU4zsHsvIxwbyjE6pignQ3purhytzZnp25GSX2vJBHk4i/i3jUxtFs9Jr2bfT A2AqwbEKcjTR5jR9SjDBPxh0yHShaO8KUMRzKmu6YJTySvZrT9SjIqGn0lXtkm5JGRSE iyXR4JumqEBWtJWONDCZ+yCkR7GnZACV/lngvuxqiNnryRWGR+WQpHfkskvrlr36A4Vj +gtBQoUVw6xeh8tjTp4xcHp1ykE1jSipoHf/LpdLRiDvAbG79Lv6u4x7AEbbs8vb5vk6 AIOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=d9YZXSUUrf/eCt+o6GO9oMPAKiw2PrY8C2RGbiOZLT0=; b=f3FIH2flbigjL+ngpIuoOJXZzdSufwamK/Y4H4geoEnzaxPvKKuQWNSyueFAWf1JZ6 x0y1XRwYKYqXcKgxsO2j7ebafwlGnJ4w8kQx9TSbkwEDAJoLMBL+99SPWXgrcki6lVxU fgXaHW87QxyRF2R0/rtyG+084HIcVg92V7/c42WpY64nn+o4JWwMae+a9y2bVop9xABg kBTmGAuX7Ul3cZ6EZxIeI6Ytji7nXfvYmW3w2Iavj0hZMzwARfWERBCXdc3gD2u7ufey a78444GehKpyQ6nE0ie5HCsgjCojk8dmpKHJxwLxKye0duTrhjgppwRPsxyqliZcyHfR t47w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aYLfTp63; 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 12si6476607edx.70.2020.07.27.17.00.21; Mon, 27 Jul 2020 17:00: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=aYLfTp63; 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 S1727037AbgG0X6h (ORCPT + 99 others); Mon, 27 Jul 2020 19:58:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:46916 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726171AbgG0X6h (ORCPT ); Mon, 27 Jul 2020 19:58:37 -0400 Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8D91920729; Mon, 27 Jul 2020 23:58:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595894316; bh=KOHL4dqqOgt80ENeUP3fboWfrZ4Es2kGP47CsCXbxcc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=aYLfTp63EvOY7mzzhG3YX+3lCzRVUC/99sTt3Kzg6B7o1mRawcxxXeAzPgkFayaGb CtzdbutF1yLSPKl9jqguggzLu+kvTJ3tlhfvsSEdQEpRmXgdcLzM2yQkM9wkD4T5M5 P/0wVHxukuXpUMIQv/O9iXuJYx8tVa9Sqt6Ne5EA= Received: by mail-lj1-f178.google.com with SMTP id s16so3947607ljc.8; Mon, 27 Jul 2020 16:58:36 -0700 (PDT) X-Gm-Message-State: AOAM5326Np0b4C1fDMHNEP0wMRbyVzd1Lran4EkIpVTnUH35UlHu9tvg aSSmexu/xEpQkaQwryyHHkA8BciZnm+iYqBPBIE= X-Received: by 2002:a2e:88c6:: with SMTP id a6mr11178609ljk.27.1595894314926; Mon, 27 Jul 2020 16:58:34 -0700 (PDT) MIME-Version: 1.0 References: <20200727184506.2279656-1-guro@fb.com> <20200727184506.2279656-12-guro@fb.com> In-Reply-To: <20200727184506.2279656-12-guro@fb.com> From: Song Liu Date: Mon, 27 Jul 2020 16:58:23 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH bpf-next v2 11/35] bpf: refine memcg-based memory accounting for sockmap and sockhash maps To: Roman Gushchin Cc: bpf , Networking , Alexei Starovoitov , Daniel Borkmann , Kernel Team , open list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 27, 2020 at 12:27 PM Roman Gushchin wrote: > > Include internal metadata into the memcg-based memory accounting. > Also include the memory allocated on updating an element. > > Signed-off-by: Roman Gushchin Acked-by: Song Liu > --- > net/core/sock_map.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/net/core/sock_map.c b/net/core/sock_map.c > index 119f52a99dc1..bc797adca44c 100644 > --- a/net/core/sock_map.c > +++ b/net/core/sock_map.c > @@ -38,7 +38,7 @@ static struct bpf_map *sock_map_alloc(union bpf_attr *attr) > attr->map_flags & ~SOCK_CREATE_FLAG_MASK) > return ERR_PTR(-EINVAL); > > - stab = kzalloc(sizeof(*stab), GFP_USER); > + stab = kzalloc(sizeof(*stab), GFP_USER | __GFP_ACCOUNT); > if (!stab) > return ERR_PTR(-ENOMEM); > > @@ -829,7 +829,8 @@ static struct bpf_shtab_elem *sock_hash_alloc_elem(struct bpf_shtab *htab, > } > } > > - new = kmalloc_node(htab->elem_size, GFP_ATOMIC | __GFP_NOWARN, > + new = kmalloc_node(htab->elem_size, > + GFP_ATOMIC | __GFP_NOWARN | __GFP_ACCOUNT, > htab->map.numa_node); > if (!new) { > atomic_dec(&htab->count); > @@ -1011,7 +1012,7 @@ static struct bpf_map *sock_hash_alloc(union bpf_attr *attr) > if (attr->key_size > MAX_BPF_STACK) > return ERR_PTR(-E2BIG); > > - htab = kzalloc(sizeof(*htab), GFP_USER); > + htab = kzalloc(sizeof(*htab), GFP_USER | __GFP_ACCOUNT); > if (!htab) > return ERR_PTR(-ENOMEM); > > -- > 2.26.2 >