Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp36271ybg; Mon, 27 Jul 2020 22:35:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhlegMHSigydtGy92y1/PDzd+htbxDVczMUACOOVm3mvyISOIT9/sVFCdieg8ko1bRZdC1 X-Received: by 2002:a05:6402:1c10:: with SMTP id ck16mr365212edb.151.1595914551005; Mon, 27 Jul 2020 22:35:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595914551; cv=none; d=google.com; s=arc-20160816; b=bp22sBHfRr6kWrl2oQpwOQE7uur/DSTcgMMYA8w1oriweAzqAYrXNG5+MQFm4rF9Om dIkDNrvPQAFmG71ILVBvB8NnoISNEDx9oXdeWfPjNVQos3w3IiOZBWbNG/aL4Ise/j24 o+bo+S3BnEuy1am3p649gK7OLRomBuRrLMr8jZta4ri3glvwlOJKtqcjSU5NNPW73TvC vzmrhOyYHxwmUhtJowDE6cRiGvVIKt2bq1etVPUoa+xQsknd3tDKBRc5AvtM/d2VizR/ igwSPGlPcFGjO6ITT31bcDnLo59pQImsCXDoWXut4emqKcaTmxUoTUMD32cbWDpOrsO8 vueg== 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=Mh/osh4nI7ufAP3kipmSgXS7D8M3G9USDrwFca3GkpE=; b=hiqxrwv8HBqrWBerJ0HItPrBcT/KsDeQfq5AYom5AkaMYhNFNt8lri1e1SNBq1XR6a CV7m9Yn4OF0/h8eWTtTnQKnWPUmTsP/Z8DYvz+O/B4nNbQI75pTfqZ2VvpCibfly+qz6 +n4TDXjuFbGyjuETTuMAlfXw4rugLAjXDyVI0fHu+TzeW5A/eGYPihMo6kCgIRMCwioS ISWyY+OLk8xIsg8/TVfoeteO0hqvjvZlD+yz99TUzAb26SlH5PZm4YlL0yCTjM/SPgsZ pFiEKMfsRA+Av4m0OP5HMt4RACFJ5a2Az7vwMDtQYhLvdJRbfcLCkbS9tM+RHm5KMBR5 rddw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hBXGz0cH; 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 sb27si3569891ejb.188.2020.07.27.22.35.28; Mon, 27 Jul 2020 22:35:50 -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=hBXGz0cH; 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 S1727044AbgG1Fcd (ORCPT + 99 others); Tue, 28 Jul 2020 01:32:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:43018 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726299AbgG1Fcd (ORCPT ); Tue, 28 Jul 2020 01:32:33 -0400 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (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 DE45D21D95; Tue, 28 Jul 2020 05:32:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595914352; bh=SjP3OhxJM4KR5LPl+D64JmqvXI73XHO2Y8ZSVez5psY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=hBXGz0cHx5wyT53ywCcD0oe/PaUMXLhXm9PxYciIeycMN/N1F8/SypnySQuBUqXVU s6iSXMK9n51S+9zse+A+y4ohRBRwvnSt9sGj/bUUHVGyzvOfh4oONUwDUztkbBfKvc QMvunRhUEvDKSUefG98Dslp1MsZU6qrqsI96hfA8= Received: by mail-lf1-f42.google.com with SMTP id i80so10282090lfi.13; Mon, 27 Jul 2020 22:32:31 -0700 (PDT) X-Gm-Message-State: AOAM533fHrNNDd8JRhC8gFEOBjHm6axw72h3n4bKpOQa7nAIvdkB+o9s lPsYcmdKsmAoMy/ptNdau0vUC7GJVlNRRab4RqA= X-Received: by 2002:a19:ec12:: with SMTP id b18mr13527150lfa.52.1595914350086; Mon, 27 Jul 2020 22:32:30 -0700 (PDT) MIME-Version: 1.0 References: <20200727184506.2279656-1-guro@fb.com> <20200727184506.2279656-19-guro@fb.com> In-Reply-To: <20200727184506.2279656-19-guro@fb.com> From: Song Liu Date: Mon, 27 Jul 2020 22:32:18 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH bpf-next v2 18/35] bpf: eliminate rlimit-based memory accounting for hashtab 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:21 PM Roman Gushchin wrote: > > Do not use rlimit-based memory accounting for hashtab maps. > It has been replaced with the memcg-based memory accounting. > > Signed-off-by: Roman Gushchin Acked-by: Song Liu > --- > kernel/bpf/hashtab.c | 19 +------------------ > 1 file changed, 1 insertion(+), 18 deletions(-) > > diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c > index 9d0432170812..9372b559b4e7 100644 > --- a/kernel/bpf/hashtab.c > +++ b/kernel/bpf/hashtab.c > @@ -422,7 +422,6 @@ static struct bpf_map *htab_map_alloc(union bpf_attr *attr) > bool percpu_lru = (attr->map_flags & BPF_F_NO_COMMON_LRU); > bool prealloc = !(attr->map_flags & BPF_F_NO_PREALLOC); > struct bpf_htab *htab; > - u64 cost; > int err; > > htab = kzalloc(sizeof(*htab), GFP_USER | __GFP_ACCOUNT); > @@ -459,26 +458,12 @@ static struct bpf_map *htab_map_alloc(union bpf_attr *attr) > htab->n_buckets > U32_MAX / sizeof(struct bucket)) > goto free_htab; > > - cost = (u64) htab->n_buckets * sizeof(struct bucket) + > - (u64) htab->elem_size * htab->map.max_entries; > - > - if (percpu) > - cost += (u64) round_up(htab->map.value_size, 8) * > - num_possible_cpus() * htab->map.max_entries; > - else > - cost += (u64) htab->elem_size * num_possible_cpus(); > - > - /* if map size is larger than memlock limit, reject it */ > - err = bpf_map_charge_init(&htab->map.memory, cost); > - if (err) > - goto free_htab; > - > err = -ENOMEM; > htab->buckets = bpf_map_area_alloc(htab->n_buckets * > sizeof(struct bucket), > htab->map.numa_node); > if (!htab->buckets) > - goto free_charge; > + goto free_htab; > > if (htab->map.map_flags & BPF_F_ZERO_SEED) > htab->hashrnd = 0; > @@ -508,8 +493,6 @@ static struct bpf_map *htab_map_alloc(union bpf_attr *attr) > prealloc_destroy(htab); > free_buckets: > bpf_map_area_free(htab->buckets); > -free_charge: > - bpf_map_charge_finish(&htab->map.memory); > free_htab: > kfree(htab); > return ERR_PTR(err); > -- > 2.26.2 >