Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp5080015pjb; Mon, 27 Jul 2020 12:24:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwo13bbLz9WCL1sM6tMmOMpKMfr7pPz0quC/ajcQEEpXHwmnddDCygh9R9KbDjQ4r5lKLk7 X-Received: by 2002:a05:6402:899:: with SMTP id e25mr10581957edy.311.1595877853102; Mon, 27 Jul 2020 12:24:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595877853; cv=none; d=google.com; s=arc-20160816; b=WrU1CNplkeeBL+M4A73G54tlGFvP/5IUZ1sue5nzOzPq2yG8zWeUe30oi60blqj7zJ hIjouTAsWFLznV36zjwJg4s9Fr55T7M9LPoTbxCbbEg4zRC5yTFU3soWEdGHeCtkNka5 9E5LB4ln9I4yLyCURx+/fs2uFcjCLGU6BlLXFaCZl9K2JzwH6wSsuUjA+Cr5g523ecbI ad8UqqbO5ILuYp436Ok+YMWeMDk/8NouC1gLiAY0Xi09cL7LoITcCh74g22fVuLPtJzL uGAWMVY38C7PxWHzoSJsXVXaplnW9ZX1BV/g//xSjabZt9q5GB+2yD1r02amRHRH0K+2 gcSw== 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=80YNCeL+Zd9r13LAFwVO8PDzN4li7zYXXciecfUd7fs=; b=dVgSWNUtDzxu0DVT8ITsgitzGDiz5uXn9GQaV9mXqgMUCd6QqePQiKyp6obfhYsArU W6ab6JLYjGZpcHHTZ9DUZLcxHE6Pf/RCqcQzj0n5o5gWOgvT7KDErbmjYdJHJo3EvF+G sS8hgA8qRa1V7OikD2iXABw1Hq1dGyjQI7jtkCLXv78EJyQoYSZ8ZLVXcmuya6XDdUnC qhdd2jUjY2ElguLnrL47XkcqA4uNtcTEbx90ysMF5iVHWf87wPW0ZUm8k9UcJ5IApvZx zRdrxuGdvgHRDlZ4H9Xr4IcspZGIhwVluUfuiC1Sa1Nn/4Bf82O6h7R9N2EiaWTCP1ls 5/uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=o5CU2OCI; 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 v25si1146960ejg.91.2020.07.27.12.23.50; Mon, 27 Jul 2020 12:24:13 -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=o5CU2OCI; 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 S1732250AbgG0SqT (ORCPT + 99 others); Mon, 27 Jul 2020 14:46:19 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:50212 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732077AbgG0Sp5 (ORCPT ); Mon, 27 Jul 2020 14:45:57 -0400 Received: from pps.filterd (m0109333.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06RIjruu021093 for ; Mon, 27 Jul 2020 11:45:57 -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=80YNCeL+Zd9r13LAFwVO8PDzN4li7zYXXciecfUd7fs=; b=o5CU2OCIPAEsqib/3+QExIGTJg6L26Q+i62zFtIxkq7etiw0orG1rz2FtINVKvtYWVc1 PpUUirR0Ji5+GgTFWNTu4jnrrsW6AeWEE2F6a0pcgEDCeZauZbReiP7iatYCSSwF67wx 05iTBPKaToIMEGWNZPJm2TWbrKHqhihrx5U= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 32h4ed5u7p-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 27 Jul 2020 11:45:56 -0700 Received: from intmgw004.06.prn3.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::d) 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 07EB51DAFE9F; 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 23/35] bpf: eliminate rlimit-based memory accounting for sockmap and sockhash maps Date: Mon, 27 Jul 2020 11:44:54 -0700 Message-ID: <20200727184506.2279656-24-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 mlxscore=0 priorityscore=1501 spamscore=0 lowpriorityscore=0 impostorscore=0 adultscore=0 bulkscore=0 malwarescore=0 phishscore=0 clxscore=1015 suspectscore=38 mlxlogscore=698 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 sockmap and sockhash maps. It has been replaced with the memcg-based memory accounting. Signed-off-by: Roman Gushchin --- net/core/sock_map.c | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/net/core/sock_map.c b/net/core/sock_map.c index bc797adca44c..07c90baf8db1 100644 --- a/net/core/sock_map.c +++ b/net/core/sock_map.c @@ -26,8 +26,6 @@ struct bpf_stab { static struct bpf_map *sock_map_alloc(union bpf_attr *attr) { struct bpf_stab *stab; - u64 cost; - int err; =20 if (!capable(CAP_NET_ADMIN)) return ERR_PTR(-EPERM); @@ -45,22 +43,15 @@ static struct bpf_map *sock_map_alloc(union bpf_attr = *attr) bpf_map_init_from_attr(&stab->map, attr); raw_spin_lock_init(&stab->lock); =20 - /* Make sure page count doesn't overflow. */ - cost =3D (u64) stab->map.max_entries * sizeof(struct sock *); - err =3D bpf_map_charge_init(&stab->map.memory, cost); - if (err) - goto free_stab; - stab->sks =3D bpf_map_area_alloc(stab->map.max_entries * sizeof(struct sock *), stab->map.numa_node); - if (stab->sks) - return &stab->map; - err =3D -ENOMEM; - bpf_map_charge_finish(&stab->map.memory); -free_stab: - kfree(stab); - return ERR_PTR(err); + if (!stab->sks) { + kfree(stab); + return ERR_PTR(-ENOMEM); + } + + return &stab->map; } =20 int sock_map_get_from_fd(const union bpf_attr *attr, struct bpf_prog *pr= og) @@ -999,7 +990,6 @@ static struct bpf_map *sock_hash_alloc(union bpf_attr= *attr) { struct bpf_shtab *htab; int i, err; - u64 cost; =20 if (!capable(CAP_NET_ADMIN)) return ERR_PTR(-EPERM); @@ -1027,21 +1017,10 @@ static struct bpf_map *sock_hash_alloc(union bpf_= attr *attr) goto free_htab; } =20 - cost =3D (u64) htab->buckets_num * sizeof(struct bpf_shtab_bucket) + - (u64) htab->elem_size * htab->map.max_entries; - if (cost >=3D U32_MAX - PAGE_SIZE) { - err =3D -EINVAL; - goto free_htab; - } - err =3D bpf_map_charge_init(&htab->map.memory, cost); - if (err) - goto free_htab; - htab->buckets =3D bpf_map_area_alloc(htab->buckets_num * sizeof(struct bpf_shtab_bucket), htab->map.numa_node); if (!htab->buckets) { - bpf_map_charge_finish(&htab->map.memory); err =3D -ENOMEM; goto free_htab; } --=20 2.26.2