Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp70576pxu; Tue, 24 Nov 2020 19:08:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwzrdLXTMU0mz4ZeNAAbgEYI1CUS2oxHNth6Npog9N0VGBSP6ibum7AHzMJWD+FcRHMg33l X-Received: by 2002:a50:da08:: with SMTP id z8mr1509463edj.170.1606273700036; Tue, 24 Nov 2020 19:08:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606273700; cv=none; d=google.com; s=arc-20160816; b=hVVRZkgGMaKrEXvPWD6Ho0fRn7lq35ZEszMCgCknjyZRrgy94bkHmQbVJvc3kvuRuA JrbRoTNp6KaI5WdVOU1TVU71Jj4Nici5ezXaaGe06V8YwhO0DwZk7xcKOKxXuHnUHkX3 18POjaJJjGhVLwFvCMorXcTOiwMR2nf3kF6wjG2DL8tGoyJtijWUv3oq37ToMCAJi6bb gpevb66yxtyh08Po2CDNDl2bU4w28cbXRcj7jSwKW8ou5i0perwtXaeL3llg7gkkEn6d fW5SWXLeOo0DQwkFC3/km9btKuZb+3FNm9MhRYbdZBIyukMH92ePkNYuNkfDNdb++EPk P1Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lrse4+nNFUKe7VgNSIyyWmMRrmZU02LZX7oRvPXq/Pw=; b=KTuhY4XAOLqbnCuz71WD/OyjbrEo6XRoZvq65n7Zx++LI0A67ZNyekZnij+hZ9SlOZ 6r+6B9rnjsMBHm58Zlpg5WKdmeCIKWVPV6vYy7YCgbikJk69sxa8N4vV3FAxtY1P7cHB RkI6E4JL7e9H/aVnpTip/YsrH0cHFX63qlAkdF7e2JPL+ZRbZkDbzWTt8j37x1+gpbhN cwlHI3x3gCqgCdVsYlPeDqxgUYplsWhhwstSIoYCt32SBRzr1+3syhlgX8cA1jRVVFKx IZ+jOPLRXIl/UWgud7FooNCxlHAoYjH17IYjneNsOQsgBiXJK4kNushlMufErR16UCp/ kx0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=hnjlZipI; 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 h8si499606ejf.410.2020.11.24.19.07.57; Tue, 24 Nov 2020 19:08:20 -0800 (PST) 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=hnjlZipI; 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 S1728502AbgKYDDS (ORCPT + 99 others); Tue, 24 Nov 2020 22:03:18 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:64252 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727375AbgKYDBb (ORCPT ); Tue, 24 Nov 2020 22:01:31 -0500 Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0AP2sxkc004055 for ; Tue, 24 Nov 2020 19:01:30 -0800 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=lrse4+nNFUKe7VgNSIyyWmMRrmZU02LZX7oRvPXq/Pw=; b=hnjlZipI17tkIWMdf5bFsFN68lJzJgULtxJs9hvcqQDrLzw5deagNfNSBCjLly1AVtRM JVD73JW3m7dfLYsPz60BurNQCExR/1iZJk968SceLNuFFGas5MPJTPfUk0mZ9gj4kRH4 9QP7LcS3ri9vWMhJ0rz/wXrKfgleqah2UdQ= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com with ESMTP id 3516xbsv6p-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 24 Nov 2020 19:01:30 -0800 Received: from intmgw002.06.prn3.facebook.com (2620:10d:c085:208::f) by mail.thefacebook.com (2620:10d:c085:21d::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Tue, 24 Nov 2020 19:01:27 -0800 Received: by devvm3388.prn0.facebook.com (Postfix, from userid 111017) id 54DE916A18AF; Tue, 24 Nov 2020 19:01:22 -0800 (PST) From: Roman Gushchin To: CC: , , , , , , , Subject: [PATCH bpf-next v8 23/34] bpf: eliminate rlimit-based memory accounting for hashtab maps Date: Tue, 24 Nov 2020 19:01:08 -0800 Message-ID: <20201125030119.2864302-24-guro@fb.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20201125030119.2864302-1-guro@fb.com> References: <20201125030119.2864302-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.312,18.0.737 definitions=2020-11-24_11:2020-11-24,2020-11-24 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 mlxlogscore=882 clxscore=1015 bulkscore=0 spamscore=0 suspectscore=38 impostorscore=0 phishscore=0 malwarescore=0 adultscore=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011250018 X-FB-Internal: deliver 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 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 2b8bbdbec872..eed12427ddd5 100644 --- a/kernel/bpf/hashtab.c +++ b/kernel/bpf/hashtab.c @@ -443,7 +443,6 @@ static struct bpf_map *htab_map_alloc(union bpf_attr = *attr) bool prealloc =3D !(attr->map_flags & BPF_F_NO_PREALLOC); struct bpf_htab *htab; int err, i; - u64 cost; =20 htab =3D kzalloc(sizeof(*htab), GFP_USER | __GFP_ACCOUNT); if (!htab) @@ -481,26 +480,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 for (i =3D 0; i < HASHTAB_MAP_LOCK_COUNT; i++) { htab->map_locked[i] =3D __alloc_percpu_gfp(sizeof(int), @@ -539,8 +524,6 @@ static struct bpf_map *htab_map_alloc(union bpf_attr = *attr) for (i =3D 0; i < HASHTAB_MAP_LOCK_COUNT; i++) free_percpu(htab->map_locked[i]); bpf_map_area_free(htab->buckets); -free_charge: - bpf_map_charge_finish(&htab->map.memory); free_htab: lockdep_unregister_key(&htab->lockdep_key); kfree(htab); --=20 2.26.2