Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp5078354pjb; Mon, 27 Jul 2020 12:21:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwghVt7070m8JCNc0JnXGdkyKdXWPD2AN4iN1uvp9nQBJF2iGJb4KYRaw0Aqog8keHIMN12 X-Received: by 2002:a17:906:ef2:: with SMTP id x18mr21913290eji.547.1595877669610; Mon, 27 Jul 2020 12:21:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595877669; cv=none; d=google.com; s=arc-20160816; b=iKlIjCSzp+atoitpb+VzzGfXHSLdeWj+93dWTbW6dRyh/B9m3f+Wgt1tEIFTANJZUl 0aebW8vJ/zFi/P0nrlZw8ohCKoQa6QkPk3Bpzyl2wYCqLYU63IOyCIzCiw1C9CR7afbz 7RLrZYVYSJy0IHBH4cYkvOZhoSQE29jKpmYcR5arMMiuh88aHAvvgpFVaO5996ahJhq+ Bl4hsU1TAIM8bJNahmrgdpTQWRG9WlPWrHN8Am5Pt8Oi566RtKt8ofFN3ubmwjICwWk9 tDAlaMsAn53l9BdSakmxEOh0OzyqfCQ9xw5YF/B9J6+lCXYzPj2iho+RjbaWlMSPBPmz b2Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:smtp-origin-cluster :cc:to:smtp-origin-hostname:from:smtp-origin-hostprefix :dkim-signature; bh=FaJ1i3Jvwgzp3yQTLRS/t9DNv3oIBKU1p40msqTMQZ4=; b=nP4SC7bQQWRqUlDe155CjXIMRwLIzUrh524w0rc5Bl9YE17UuonxeNOc+xJaHJ/UnF g+nkrJ1RzD0jW1V40dQom2pP+YM1dmlhN7H+880RO0tXM0MDYWafon79Fbtqhkjq6ax4 KGO2OEY0yMWE6rEzCQe5HKmYAay3aG7TFdNVUHo+KCJHzanzT48lasRv/p1UlsMfEgEQ gpcUql1ZcUHc/QzQDcsbCY54EqrUyBaiyEgfYq8sDEk8ZnASZkylE1cEnUVfVkt75ePo e7yXU05SWPQa1uZsEe1bsPM0grxz0/Fu0YzfPz3Idue3XTw6VOlCYAsEIsUURLpV2NoE 0/4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=hXrSY6Gv; 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=REJECT sp=REJECT dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t10si6048402ejs.137.2020.07.27.12.20.47; Mon, 27 Jul 2020 12:21:09 -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=@fb.com header.s=facebook header.b=hXrSY6Gv; 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=REJECT sp=REJECT dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731961AbgG0Spk (ORCPT + 99 others); Mon, 27 Jul 2020 14:45:40 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:40712 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731881AbgG0Sph (ORCPT ); Mon, 27 Jul 2020 14:45:37 -0400 Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06RId8oX016829 for ; Mon, 27 Jul 2020 11:45:36 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=FaJ1i3Jvwgzp3yQTLRS/t9DNv3oIBKU1p40msqTMQZ4=; b=hXrSY6GvhmRXX/jZQkAUCzKxyuINAxIaYK9v8U1ScGJNMkOFQEAElw1UeJh4LJrowJP9 U1byszHbOVW8JqITdgW19jbR5LWdCQ07vGmSTNxBh2g/SqL0lTbT86Rj2S/7gp/m/bLD wINSr8scODh3TDzsIfzI6PsPh26pOTlDo5I= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 32h4q9dvku-19 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 27 Jul 2020 11:45:36 -0700 Received: from intmgw004.06.prn3.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::f) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 27 Jul 2020 11:45:22 -0700 Received: by devvm1096.prn0.facebook.com (Postfix, from userid 111017) id E3A591DAFE95; Mon, 27 Jul 2020 11:45:10 -0700 (PDT) Smtp-Origin-Hostprefix: devvm From: Roman Gushchin Smtp-Origin-Hostname: devvm1096.prn0.facebook.com To: CC: , Alexei Starovoitov , Daniel Borkmann , , , Roman Gushchin Smtp-Origin-Cluster: prn0c01 Subject: [PATCH bpf-next v2 18/35] bpf: eliminate rlimit-based memory accounting for hashtab maps Date: Mon, 27 Jul 2020 11:44:49 -0700 Message-ID: <20200727184506.2279656-19-guro@fb.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200727184506.2279656-1-guro@fb.com> References: <20200727184506.2279656-1-guro@fb.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-27_13:2020-07-27,2020-07-27 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 spamscore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 mlxlogscore=823 malwarescore=0 adultscore=0 phishscore=0 mlxscore=0 priorityscore=1501 bulkscore=0 suspectscore=38 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007270126 X-FB-Internal: deliver Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 =3D (attr->map_flags & BPF_F_NO_COMMON_LRU); bool prealloc =3D !(attr->map_flags & BPF_F_NO_PREALLOC); struct bpf_htab *htab; - u64 cost; int err; =20 htab =3D kzalloc(sizeof(*htab), GFP_USER | __GFP_ACCOUNT); @@ -459,26 +458,12 @@ static struct bpf_map *htab_map_alloc(union bpf_att= r *attr) htab->n_buckets > U32_MAX / sizeof(struct bucket)) goto free_htab; =20 - cost =3D (u64) htab->n_buckets * sizeof(struct bucket) + - (u64) htab->elem_size * htab->map.max_entries; - - if (percpu) - cost +=3D (u64) round_up(htab->map.value_size, 8) * - num_possible_cpus() * htab->map.max_entries; - else - cost +=3D (u64) htab->elem_size * num_possible_cpus(); - - /* if map size is larger than memlock limit, reject it */ - err =3D bpf_map_charge_init(&htab->map.memory, cost); - if (err) - goto free_htab; - err =3D -ENOMEM; htab->buckets =3D bpf_map_area_alloc(htab->n_buckets * sizeof(struct bucket), htab->map.numa_node); if (!htab->buckets) - goto free_charge; + goto free_htab; =20 if (htab->map.map_flags & BPF_F_ZERO_SEED) htab->hashrnd =3D 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); --=20 2.26.2