Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp101706ybg; Mon, 27 Jul 2020 16:58:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyBRCEaJLNeoUzEQCIDD7GsJEJwRzR2clywRL9RosRjV379uXAcDtoyOCJLkdflylGusnK X-Received: by 2002:a17:906:e0e:: with SMTP id l14mr8841178eji.398.1595894320199; Mon, 27 Jul 2020 16:58:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595894320; cv=none; d=google.com; s=arc-20160816; b=jezj4FW+ASWO05ucDKIh/ufW6Fu3j6uO4Jc9z4UFU/dF0RKKjOEWyl7h58dzLVVYBl 3dsjgIlIywzdrdY+O0VB62PL6yrCZlgIEhjjylsktpk2xskHeAHmuuZVUn20Yo8hxcYJ eqMCytoJ+0R9J8Agtz7vEd5mcFJQkCkXFFN9GQbxvmTcr0AZSbzorYXdhWXy6GMvTKqL Sw3mhSzXBHqSiLRzTJs2PYdLQylFQNqCUvYqALmoc0WVWZnCKJ8JZkzVEoRyuyIofaR1 VVuBbYeaVtj4jt+40ROoAAH9Hb97gMNac7Pz0QANeXHtRhhLQZxBCUmA2VsK3To+XPTM hvGA== 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=dBfsMmisUsyb4E6WOAgYYWEue6VF3fJIskKXMx/RZXE=; b=fqTyY/gz/zjhqYgAFXdpzNzF0frCPjxlXxNzO6bCl0+uD5RnJeoxabt1EtWDTIMA+f ntMXR8FjtaAF2TFqh0o36bIj0Yv5wsLUICIyO3nCw+c3NnIF107UNFoX2zafWCq3Sodd CfWXdodq8FU94eanVG/7YmJ9JxUccUWS4gAfnVR9mqe8sNwug8JUkmz1WC81PzEIHGvO PEM7M/ccz76eeUN0I+/MsgJOHrfTOJ1bk2uUKg5+UHpEenN+sCTdZdXZQ71zm+NUQHjX RN6E0UyHoqYW33v32xGMLvvafAMt0rUqKwQjmmaLB3Fy4y5b7TAPQLEqH7amIreUM2jq UOeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pXoMNgSF; 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 n24si6615485edt.561.2020.07.27.16.58.18; Mon, 27 Jul 2020 16:58:40 -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=pXoMNgSF; 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 S1727008AbgG0X5x (ORCPT + 99 others); Mon, 27 Jul 2020 19:57:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:46784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726171AbgG0X5x (ORCPT ); Mon, 27 Jul 2020 19:57:53 -0400 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (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 6243920729; Mon, 27 Jul 2020 23:57:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595894272; bh=64Tf54q0Uk02BH0nMofvaNqTN8uJcrlbmqOWvVtow2E=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=pXoMNgSF7CMf+LddKHhsVXTxUuMmkr96dFKcgR9rt8n/h+A2kDUOG9o/otfjcpPq3 zOgdtBNurRKkZI79+Boo2o8OfiV2K16KrqH17JAIKd6W0mBZH7k2mZriFO6+fPW7J9 ShR1jmcYvp9//qymmHw2DMAy/4d09sw/1c38qVLg= Received: by mail-lf1-f54.google.com with SMTP id h8so9964129lfp.9; Mon, 27 Jul 2020 16:57:52 -0700 (PDT) X-Gm-Message-State: AOAM532MKHRMQ1CncgbBg+u5V5JWGUrHi1vZVT09CEIUMteAksh6hmDB GX7JFBMrwl1NqWlwC0VgW1FaIMrweqJL8vaXk/M= X-Received: by 2002:a19:c501:: with SMTP id w1mr12147381lfe.172.1595894270760; Mon, 27 Jul 2020 16:57:50 -0700 (PDT) MIME-Version: 1.0 References: <20200727184506.2279656-1-guro@fb.com> <20200727184506.2279656-11-guro@fb.com> In-Reply-To: <20200727184506.2279656-11-guro@fb.com> From: Song Liu Date: Mon, 27 Jul 2020 16:57:39 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH bpf-next v2 10/35] bpf: memcg-based memory accounting for socket storage 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:28 PM Roman Gushchin wrote: > > Account memory used by the socket storage. > > Signed-off-by: Roman Gushchin Acked-by: Song Liu > --- > net/core/bpf_sk_storage.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/net/core/bpf_sk_storage.c b/net/core/bpf_sk_storage.c > index eafcd15e7dfd..fbcd03cd00d3 100644 > --- a/net/core/bpf_sk_storage.c > +++ b/net/core/bpf_sk_storage.c > @@ -130,7 +130,8 @@ static struct bpf_sk_storage_elem *selem_alloc(struct bpf_sk_storage_map *smap, > if (charge_omem && omem_charge(sk, smap->elem_size)) > return NULL; > > - selem = kzalloc(smap->elem_size, GFP_ATOMIC | __GFP_NOWARN); > + selem = kzalloc(smap->elem_size, > + GFP_ATOMIC | __GFP_NOWARN | __GFP_ACCOUNT); > if (selem) { > if (value) > memcpy(SDATA(selem)->data, value, smap->map.value_size); > @@ -337,7 +338,8 @@ static int sk_storage_alloc(struct sock *sk, > if (err) > return err; > > - sk_storage = kzalloc(sizeof(*sk_storage), GFP_ATOMIC | __GFP_NOWARN); > + sk_storage = kzalloc(sizeof(*sk_storage), > + GFP_ATOMIC | __GFP_NOWARN | __GFP_ACCOUNT); > if (!sk_storage) { > err = -ENOMEM; > goto uncharge; > @@ -677,7 +679,7 @@ static struct bpf_map *bpf_sk_storage_map_alloc(union bpf_attr *attr) > u64 cost; > int ret; > > - smap = kzalloc(sizeof(*smap), GFP_USER | __GFP_NOWARN); > + smap = kzalloc(sizeof(*smap), GFP_USER | __GFP_NOWARN | __GFP_ACCOUNT); > if (!smap) > return ERR_PTR(-ENOMEM); > bpf_map_init_from_attr(&smap->map, attr); > @@ -695,7 +697,7 @@ static struct bpf_map *bpf_sk_storage_map_alloc(union bpf_attr *attr) > } > > smap->buckets = kvcalloc(sizeof(*smap->buckets), nbuckets, > - GFP_USER | __GFP_NOWARN); > + GFP_USER | __GFP_NOWARN | __GFP_ACCOUNT); > if (!smap->buckets) { > bpf_map_charge_finish(&smap->map.memory); > kfree(smap); > @@ -1024,7 +1026,7 @@ bpf_sk_storage_diag_alloc(const struct nlattr *nla_stgs) > } > > diag = kzalloc(sizeof(*diag) + sizeof(diag->maps[0]) * nr_maps, > - GFP_KERNEL); > + GFP_KERNEL | __GFP_ACCOUNT); > if (!diag) > return ERR_PTR(-ENOMEM); > > -- > 2.26.2 >