Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp5079599pjb; Mon, 27 Jul 2020 12:23:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/wXsLXArKekkdW63Rk2lrvaJPva+mh4Szrr25ytrlA5jBaCIVuqi3JiYMpqbabDcUCyQJ X-Received: by 2002:a17:906:3e4f:: with SMTP id t15mr8769677eji.368.1595877798791; Mon, 27 Jul 2020 12:23:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595877798; cv=none; d=google.com; s=arc-20160816; b=dvKYt6ZHERHaPJmquipgibl72l9KqEEQXZvKtS03/RNLT22VkBL/0ViXdsSQtfYBj4 UCOkIyUUdydHsShODZmqtBHt5QEk4kT2FX+TkVdKZxzPEuG+RWqcJNHn1EYmh/CPKdUQ oRcuYN2zPklZj0H7CyiIY337DZC0fnKbYExp7DLHleuYwcsv1uSxnptjlfTy46sGKNec nkAWAIqZa3OxRIn8CUhdOJMSiK9hp/5CRMjdL+tOfgFxSpXTi/8j+sIXIhr6XiiQu1nq 8SAdT0O+wbYjL+G9TMyH54bAYEdfxlIcB0qFaajSlBJph1z/tu8zvReQevV7ZgG/pdkb 5mfA== 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=FZ1DOw1vo++OQPipKOASN/39lL70IFORFCBolHWaCPQ=; b=oO3Xu4bkhrREEdHWQoMCzOj6ogoS72Jy0ntt3lsJLcWqOgpDuKEbIO8pXD0OMaMglO RTzK5983hSQ5eRnWONpWUQyoJLMKbHgqX6n+8bk7PvMTjgIOIchikZKaljfh8OF6az2a CJ51qN5YtF/jLyyIDKlLV8jHBgOZqSZn/PGRy13pTNZeNFI4R41kGN1Y3JPxr4ssYkf6 rcYatmz35zpydGbIruIGV5bufsNKSGLE8gedZEQqUfX1ftJnezsM4tRmCPa7Ab6OlEvu KG9IJvn2eHnb8JUoDCuKaMaP8+EJn7wpZLW1wTBzxR6pPT28IhqFPHyhsDy/XIR1VHdE 2kjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=ZxjQ1h3a; 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 w12si6272550ejz.421.2020.07.27.12.22.57; Mon, 27 Jul 2020 12:23:18 -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=ZxjQ1h3a; 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 S1729359AbgG0Sqp (ORCPT + 99 others); Mon, 27 Jul 2020 14:46:45 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:7124 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732068AbgG0Spv (ORCPT ); Mon, 27 Jul 2020 14:45:51 -0400 Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06RIjgE8027163 for ; Mon, 27 Jul 2020 11:45:51 -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=FZ1DOw1vo++OQPipKOASN/39lL70IFORFCBolHWaCPQ=; b=ZxjQ1h3asDooozb+DjP1jhTxk24LX5X10eNiBQTScd2JpRMSGzIZ1sJy3VwGQJDtgT00 4ONyMDz6414q57h8Duin1UYY6C5N2cMqnk1IfH6qwMblvWj9leH2Uqm346YuJ6Ds8pKT CyEh/6wObzFYn91DCvalNIzBAiEHGPHnraI= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com with ESMTP id 32h50vnsy2-10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 27 Jul 2020 11:45:51 -0700 Received: from intmgw001.41.prn1.facebook.com (2620:10d:c085:208::f) by mail.thefacebook.com (2620:10d:c085:21d::6) 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:17 -0700 Received: by devvm1096.prn0.facebook.com (Postfix, from userid 111017) id 035E51DAFE9D; Mon, 27 Jul 2020 11:45:11 -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 22/35] bpf: eliminate rlimit-based memory accounting for bpf ringbuffer Date: Mon, 27 Jul 2020 11:44:53 -0700 Message-ID: <20200727184506.2279656-23-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 suspectscore=38 phishscore=0 mlxscore=0 lowpriorityscore=0 spamscore=0 impostorscore=0 malwarescore=0 bulkscore=0 mlxlogscore=890 priorityscore=1501 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007270127 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 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 --- 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 e8e2c39cbdc9..e687b798d097 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