Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp69280pxu; Tue, 24 Nov 2020 19:05:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJypz3XLYPsoQLcjU64Ad3FJm9yGAEbV1jOIs7dDDxoa5RfqRgkWjwOiDjcgZQnY7bz+FKeq X-Received: by 2002:a05:6402:1b19:: with SMTP id by25mr1522800edb.108.1606273532722; Tue, 24 Nov 2020 19:05:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606273532; cv=none; d=google.com; s=arc-20160816; b=KoBLe4EUAJZRhm2AiPufDGe9hyw/d+7paIYkhQ2saWF52BbnQnnaoRDBfLkbb4vLSE fSEF4+XSq0gm0gfrrtgWksSkz1SqWmmXItiSb4/jULT2Z8feuWKzLpZEhk+dGszMb58q MaGMkj8C5xBJoUfteOC6sSrVjrk8PVxVpqUCx88YBMtWPsK3t/HTqPanOFNdBcXiToLN Y00sN49mA0QSeCvqZIJ7lR7ZwZT+fSmH2z2G1ncXTeqkGe8QLl+i2T4s40cqrzdrRdQ7 QNrI9Kt0ayQmCukcpA98VP93ven2x/Hq9RnLxRbDjfqJ3CbiOzcZBU/SXnQHj0gwS6o3 +gAQ== 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=UL9KPXzaHLZpNSorKKTuhYlkZqIX5y2leBPcmirTmTo=; b=ueMayBeFmICM26ZH+t/MZ57Gsf4NH7XxcVQhFOKD9w/fQ+GrQ7dcW9BKQR7LB4/f6y GpLeLKpguzohN99zFrtYgd0SelSkggmcQ4b/8vbLmbMi5TL068MjOnxWUtQ24Fp1Mpsp /7rRvmvnjWhvnUx5q+1Y1tkslqxkN8bEF6p3F37kuxJGyVeJAVx+fSSDJmS0kyxxQJAs YiIaiz1TeVGkocVw7yIrvaywNu9yyD9N8JG/hYrCoILejR98l6RN5FYeZ5WOI3X+pqMZ TrUhOCLibHj+xXpr2/AQOrp++0awir8/XCQboXw8hKW6aTwChyd/UfWfqBsn2MiKais+ W+AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=S5oliPa0; 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 c1si484475edq.286.2020.11.24.19.05.10; Tue, 24 Nov 2020 19:05:32 -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=S5oliPa0; 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 S1728054AbgKYDCG (ORCPT + 99 others); Tue, 24 Nov 2020 22:02:06 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:58400 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727702AbgKYDBh (ORCPT ); Tue, 24 Nov 2020 22:01:37 -0500 Received: from pps.filterd (m0109332.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0AP2skx2014300 for ; Tue, 24 Nov 2020 19:01:35 -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=UL9KPXzaHLZpNSorKKTuhYlkZqIX5y2leBPcmirTmTo=; b=S5oliPa0iY27ok1KZWQALZ4rO8pZ2GNWh4EjUxk5FvkjbXPu8Dv2dRtZXv9hTfMpgBVf goGMUKI9QH9ppZX0x5aQIhQZvIHG6kKMHMDDfJ4h0baHi0HdcTVC0uw8QtVbMsk0Z8vR fCT/TQSjFXHQJHxQdhc1jc2FdROCGd96yzA= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 34ykxgmjxs-10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 24 Nov 2020 19:01:35 -0800 Received: from intmgw001.06.prn3.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::6) 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:32 -0800 Received: by devvm3388.prn0.facebook.com (Postfix, from userid 111017) id 2A87016A189D; Tue, 24 Nov 2020 19:01:22 -0800 (PST) From: Roman Gushchin To: CC: , , , , , , , Subject: [PATCH bpf-next v8 14/34] bpf: memcg-based memory accounting for bpf ringbuffer Date: Tue, 24 Nov 2020 19:00:59 -0800 Message-ID: <20201125030119.2864302-15-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 adultscore=0 lowpriorityscore=0 suspectscore=13 mlxlogscore=724 priorityscore=1501 spamscore=0 impostorscore=0 bulkscore=0 malwarescore=0 mlxscore=0 phishscore=0 clxscore=1015 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 Enable the memcg-based memory accounting for the memory used by the bpf ringbuffer. Signed-off-by: Roman Gushchin Acked-by: Song Liu --- kernel/bpf/ringbuf.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kernel/bpf/ringbuf.c b/kernel/bpf/ringbuf.c index 31cb04a4dd2d..ee5f55d9276e 100644 --- a/kernel/bpf/ringbuf.c +++ b/kernel/bpf/ringbuf.c @@ -60,8 +60,8 @@ struct bpf_ringbuf_hdr { =20 static struct bpf_ringbuf *bpf_ringbuf_area_alloc(size_t data_sz, int nu= ma_node) { - const gfp_t flags =3D GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_NOWARN | - __GFP_ZERO; + const gfp_t flags =3D GFP_KERNEL_ACCOUNT | __GFP_RETRY_MAYFAIL | + __GFP_NOWARN | __GFP_ZERO; int nr_meta_pages =3D RINGBUF_PGOFF + RINGBUF_POS_PAGES; int nr_data_pages =3D data_sz >> PAGE_SHIFT; int nr_pages =3D nr_meta_pages + nr_data_pages; @@ -89,7 +89,8 @@ static struct bpf_ringbuf *bpf_ringbuf_area_alloc(size_= t data_sz, int numa_node) */ array_size =3D (nr_meta_pages + 2 * nr_data_pages) * sizeof(*pages); if (array_size > PAGE_SIZE) - pages =3D vmalloc_node(array_size, numa_node); + pages =3D __vmalloc_node(array_size, 1, GFP_KERNEL_ACCOUNT, + numa_node, __builtin_return_address(0)); else pages =3D kmalloc_node(array_size, flags, numa_node); if (!pages) @@ -167,7 +168,7 @@ static struct bpf_map *ringbuf_map_alloc(union bpf_at= tr *attr) return ERR_PTR(-E2BIG); #endif =20 - rb_map =3D kzalloc(sizeof(*rb_map), GFP_USER); + rb_map =3D kzalloc(sizeof(*rb_map), GFP_USER | __GFP_ACCOUNT); if (!rb_map) return ERR_PTR(-ENOMEM); =20 --=20 2.26.2