Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp69242pxu; Tue, 24 Nov 2020 19:05:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdOhZFvz9a4CeGFQKf/w19HyeMDnlZCZUqKcEYsJPTn8fAZEXpLbp1WcqGomRb+K5M7SbV X-Received: by 2002:aa7:c049:: with SMTP id k9mr1497724edo.49.1606273528198; Tue, 24 Nov 2020 19:05:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606273528; cv=none; d=google.com; s=arc-20160816; b=EHYqNtRtxxJeRSjHjn/+AchNc5TsW0Ly3LozBj2AYAwLLT84aiaN+qPMGDqsMQRhtk Oai2DwD/ZTJGOQctEdom2gHKcun0kd4eZ1y+j49Q5GKFb2jymqPUJVkhcUb6JZCFeBAB vBi+qRqNDZ1SO7ER7FoLGPIKoeza4+t/889TsvTHXbaxN3mCx3L+EC2PYdceLI6DcztR 2cqmrE1HnU+cHbon3ScAes/+I3Vn1lZFiTd8aGt8B7num800nFlpV8/Ic/gsjVbkYa5v dXD+mo+JrGRe0iHeY/wPJnq9FdoODTTLf1KmP6Bn2VKjFS48agKD6VL/9Qu/7wa8WyjG yDQA== 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=qdqw2vIRlP2yIbod8BHIh3XnNn0ZSs325Y5RG0+0/sU=; b=tg0C5J1zkDdk1utJku+cpwV9/FfU+FNB5ZYe4p9A+IWDbFPGNhA+Y25dJEmXB9N9ay 8omUWWRmBzlxoT4c+cDnL5j/XpxhEIKdk7olkcPk8FS05c//bgBZemBq6yTsBF2EMK17 z+G6alTqJV+HpDuCFFxtmJD1HfFepODjA9wfsTU11saH0lS2vC1UsdJQUOZal4KbcgLw F2SMI8tTDk+6+8Tf9J1ADX7MkgogYZ7sndlltYKCIi3nUCmCcU3qUzlphHSyIvcySb4k Mf4ACvZEMa+EaXvc5Qf0z5pF3dJRSYPSRNUnrNdqr1+Z12o2CCI0ljCxYBCSXfm4+Dx9 JHGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b="WfDyd/M8"; 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 a23si502227ejy.682.2020.11.24.19.05.05; Tue, 24 Nov 2020 19:05:28 -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="WfDyd/M8"; 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 S1727837AbgKYDBi (ORCPT + 99 others); Tue, 24 Nov 2020 22:01:38 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:41412 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727672AbgKYDBh (ORCPT ); Tue, 24 Nov 2020 22:01:37 -0500 Received: from pps.filterd (m0109331.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0AP2sY2r031124 for ; Tue, 24 Nov 2020 19:01:36 -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=qdqw2vIRlP2yIbod8BHIh3XnNn0ZSs325Y5RG0+0/sU=; b=WfDyd/M8cMOIiaLASl3AxySq/GG+SHOqk5pJ1AfYZUWLOTnJOUelnDlW8kwHMl5RDGWK C5a2K1U2bs0YS7ZK+auwByjjdRzZgTwerrvqHdeTSePnkUI36daMUsdlfEZmzrRQTnV/ AP72FPp43+XYLhaaRxon5NHM6bbjr/M5C3o= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 34ywv0u3ck-11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 24 Nov 2020 19:01:36 -0800 Received: from intmgw002.41.prn1.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; Tue, 24 Nov 2020 19:01:29 -0800 Received: by devvm3388.prn0.facebook.com (Postfix, from userid 111017) id 68AF716A18B7; Tue, 24 Nov 2020 19:01:22 -0800 (PST) From: Roman Gushchin To: CC: , , , , , , , Subject: [PATCH bpf-next v8 27/34] bpf: eliminate rlimit-based memory accounting for bpf ringbuffer Date: Tue, 24 Nov 2020 19:01:12 -0800 Message-ID: <20201125030119.2864302-28-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 suspectscore=38 mlxlogscore=738 lowpriorityscore=0 mlxscore=0 phishscore=0 adultscore=0 bulkscore=0 clxscore=1015 impostorscore=0 spamscore=0 malwarescore=0 priorityscore=1501 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 bpf ringbuffer. It has been replaced with the memcg-based memory accounting. bpf_ringbuf_alloc() can't return anything except ERR_PTR(-ENOMEM) and a valid pointer, so to simplify the code make it return NULL in the first case. This allows to drop a couple of lines in ringbuf_map_alloc() and also makes it look similar to other memory allocating function like kmalloc(). Signed-off-by: Roman Gushchin Acked-by: Song Liu Acked-by: Andrii Nakryiko --- kernel/bpf/ringbuf.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/kernel/bpf/ringbuf.c b/kernel/bpf/ringbuf.c index ee5f55d9276e..c8892b58501e 100644 --- a/kernel/bpf/ringbuf.c +++ b/kernel/bpf/ringbuf.c @@ -48,7 +48,6 @@ struct bpf_ringbuf { =20 struct bpf_ringbuf_map { struct bpf_map map; - struct bpf_map_memory memory; struct bpf_ringbuf *rb; }; =20 @@ -135,7 +134,7 @@ static struct bpf_ringbuf *bpf_ringbuf_alloc(size_t d= ata_sz, int numa_node) =20 rb =3D bpf_ringbuf_area_alloc(data_sz, numa_node); if (!rb) - return ERR_PTR(-ENOMEM); + return NULL; =20 spin_lock_init(&rb->spinlock); init_waitqueue_head(&rb->waitq); @@ -151,8 +150,6 @@ static struct bpf_ringbuf *bpf_ringbuf_alloc(size_t d= ata_sz, int numa_node) static struct bpf_map *ringbuf_map_alloc(union bpf_attr *attr) { struct bpf_ringbuf_map *rb_map; - u64 cost; - int err; =20 if (attr->map_flags & ~RINGBUF_CREATE_FLAG_MASK) return ERR_PTR(-EINVAL); @@ -174,26 +171,13 @@ static struct bpf_map *ringbuf_map_alloc(union bpf_= attr *attr) =20 bpf_map_init_from_attr(&rb_map->map, attr); =20 - cost =3D sizeof(struct bpf_ringbuf_map) + - sizeof(struct bpf_ringbuf) + - attr->max_entries; - err =3D bpf_map_charge_init(&rb_map->map.memory, cost); - if (err) - goto err_free_map; - rb_map->rb =3D bpf_ringbuf_alloc(attr->max_entries, rb_map->map.numa_no= de); - if (IS_ERR(rb_map->rb)) { - err =3D PTR_ERR(rb_map->rb); - goto err_uncharge; + if (!rb_map->rb) { + kfree(rb_map); + return ERR_PTR(-ENOMEM); } =20 return &rb_map->map; - -err_uncharge: - bpf_map_charge_finish(&rb_map->map.memory); -err_free_map: - kfree(rb_map); - return ERR_PTR(err); } =20 static void bpf_ringbuf_free(struct bpf_ringbuf *rb) --=20 2.26.2