Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp5079318pjb; Mon, 27 Jul 2020 12:22:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFB5RzOMqGcDMQTcE8UrK0GMRCTcNax+w71UbbyBkkNAdfOAagmIeJwAIjDjCWBUmdbNku X-Received: by 2002:a05:6402:21e6:: with SMTP id ce6mr17895666edb.275.1595877766593; Mon, 27 Jul 2020 12:22:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595877766; cv=none; d=google.com; s=arc-20160816; b=N4zDvoEr0WOMVbpPREAie33mAOSqiXZW2wP+UE7GJLh5f4rY7kP3kJszrcDcIasWGo XRUtV9wHbaNda+M7YnaUd9+41jWlQm04MnsWcj7GMgxVbufVSJdTxqbkIYCdSCFXpLt/ YsKAQc3sZv/1QpBOmY1kMi+6d8rdDzo4LTZpIECwN0s6nsm7mrHsB8yOT0zcVscBxVkq kwMydd9iAFK20Bt6gEh1u41fOe07jcd6a4hCz+xyP45hp8tbt1U+TaXVpOK7jYCXPT36 1zHQ9xQ/QJO3lDySPOx2G701kRt8qWpKjUMEMF7/AqbDK3nqqnMn5YFr9zsETyWAsNnK x+0Q== 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=LemzQmSpwUqh0yVmoBb6ZzTmt1hoW0QS3JNG8xksTno=; b=UM/y4ugXesw4KAFY29CdrMZPvMzCKyCsmbBd7Ce5VLpVr+Oaiq+fofKInkChtk6Y4G dHw6pNO4VplXv0pe8qbcB+NeLI4rh46uNn6UYkSTpxF8L6yx2aAwt1w7SLllHB5harQ9 V/870qDEoxglccY8p5dcdO2UgYGxm/fuiyi7PWL6icUPoeFaOlGLCOHEhs17zdxZIukc XiWDX5XvRzILbDqwAbuZZ/M9ll1I276zs55KONqGgiCkyslc8UslLK4F6VwXJwMld12Y uJfGR2YyKdw0hJbCnTLtA24nnsptBKpkDpzjN/42DuygQpsybmNIuzr8gkyeqFdZ/3eh d3Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=KXDilQrP; 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 r3si5739976ejr.664.2020.07.27.12.22.24; Mon, 27 Jul 2020 12:22:46 -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=KXDilQrP; 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 S1731702AbgG0SpZ (ORCPT + 99 others); Mon, 27 Jul 2020 14:45:25 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:7522 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731175AbgG0SpS (ORCPT ); Mon, 27 Jul 2020 14:45:18 -0400 Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06RIf4xq020150 for ; Mon, 27 Jul 2020 11:45:17 -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=LemzQmSpwUqh0yVmoBb6ZzTmt1hoW0QS3JNG8xksTno=; b=KXDilQrPnKyDA2J80G/p2bPPGp+jq30BZyPU6JaowXhGnr+FsGw+A2ohllf/ow+hIzQe SrM/FDcDCA5Pe3o/ul6qpVMfFpMnIqzfP96OliY/mjvit508YLR6IQ/L+0YaNBtWpM16 x+GuWqINDxrcX3vhEavlx8dzK+h8ZBYB8Wc= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 32h4k25uxf-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 27 Jul 2020 11:45:17 -0700 Received: from intmgw001.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:16 -0700 Received: by devvm1096.prn0.facebook.com (Postfix, from userid 111017) id C976C1DAFE8B; 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 13/35] bpf: eliminate rlimit-based memory accounting for arraymap maps Date: Mon, 27 Jul 2020 11:44:44 -0700 Message-ID: <20200727184506.2279656-14-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 lowpriorityscore=0 clxscore=1015 adultscore=0 malwarescore=0 bulkscore=0 phishscore=0 priorityscore=1501 mlxlogscore=874 mlxscore=0 spamscore=0 suspectscore=38 impostorscore=0 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 arraymap maps. It has been replaced with the memcg-based memory accounting. Signed-off-by: Roman Gushchin --- kernel/bpf/arraymap.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c index 9597fecff8da..41581c38b31d 100644 --- a/kernel/bpf/arraymap.c +++ b/kernel/bpf/arraymap.c @@ -75,11 +75,10 @@ int array_map_alloc_check(union bpf_attr *attr) static struct bpf_map *array_map_alloc(union bpf_attr *attr) { bool percpu =3D attr->map_type =3D=3D BPF_MAP_TYPE_PERCPU_ARRAY; - int ret, numa_node =3D bpf_map_attr_numa_node(attr); + int numa_node =3D bpf_map_attr_numa_node(attr); u32 elem_size, index_mask, max_entries; bool bypass_spec_v1 =3D bpf_bypass_spec_v1(); - u64 cost, array_size, mask64; - struct bpf_map_memory mem; + u64 array_size, mask64; struct bpf_array *array; =20 elem_size =3D round_up(attr->value_size, 8); @@ -120,44 +119,29 @@ static struct bpf_map *array_map_alloc(union bpf_at= tr *attr) } } =20 - /* make sure there is no u32 overflow later in round_up() */ - cost =3D array_size; - if (percpu) - cost +=3D (u64)attr->max_entries * elem_size * num_possible_cpus(); - - ret =3D bpf_map_charge_init(&mem, cost); - if (ret < 0) - return ERR_PTR(ret); - /* allocate all map elements and zero-initialize them */ if (attr->map_flags & BPF_F_MMAPABLE) { void *data; =20 /* kmalloc'ed memory can't be mmap'ed, use explicit vmalloc */ data =3D bpf_map_area_mmapable_alloc(array_size, numa_node); - if (!data) { - bpf_map_charge_finish(&mem); + if (!data) return ERR_PTR(-ENOMEM); - } array =3D data + PAGE_ALIGN(sizeof(struct bpf_array)) - offsetof(struct bpf_array, value); } else { array =3D bpf_map_area_alloc(array_size, numa_node); } - if (!array) { - bpf_map_charge_finish(&mem); + if (!array) return ERR_PTR(-ENOMEM); - } array->index_mask =3D index_mask; array->map.bypass_spec_v1 =3D bypass_spec_v1; =20 /* copy mandatory map attributes */ bpf_map_init_from_attr(&array->map, attr); - bpf_map_charge_move(&array->map.memory, &mem); array->elem_size =3D elem_size; =20 if (percpu && bpf_array_alloc_percpu(array)) { - bpf_map_charge_finish(&array->map.memory); bpf_map_area_free(array); return ERR_PTR(-ENOMEM); } --=20 2.26.2