From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 067A5C433E1 for ; Fri, 21 Aug 2020 15:12:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6E81207C3 for ; Fri, 21 Aug 2020 15:12:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="FV5U5alB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727940AbgHUPMV (ORCPT ); Fri, 21 Aug 2020 11:12:21 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:34736 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727903AbgHUPLs (ORCPT ); Fri, 21 Aug 2020 11:11:48 -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 07LFB82i019499 for ; Fri, 21 Aug 2020 08:11:48 -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=udpGeYf8q+l+ASarFEdC30XPubknG8mRFf9ZLYmoWRU=; b=FV5U5alBk7qVZ3xtJMt9PlAHyy1FyTvhVNteFg12oTOa/Q3t5v1+EGeTuXIJVg0wTFkk CCvuvYm8q8EL0vlDtY7Ap2dC5yRjpWL+pZ4axqY8bce5dSVDwGUwKGeK8aWmCJmfAzol iTZ2butnNVYxtTpjoLdRVnVr9w6JvYx7Ae4= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 3304p3w5qp-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 21 Aug 2020 08:11:48 -0700 Received: from intmgw004.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; Fri, 21 Aug 2020 08:11:46 -0700 Received: by devvm1096.prn0.facebook.com (Postfix, from userid 111017) id 57C5C3441059; Fri, 21 Aug 2020 08:01:35 -0700 (PDT) Smtp-Origin-Hostprefix: devvm From: Roman Gushchin Smtp-Origin-Hostname: devvm1096.prn0.facebook.com To: CC: , Alexei Starovoitov , Daniel Borkmann , , , Johannes Weiner , Shakeel Butt , , Roman Gushchin , Song Liu Smtp-Origin-Cluster: prn0c01 Subject: [PATCH bpf-next v4 10/30] bpf: memcg-based memory accounting for bpf ringbuffer Date: Fri, 21 Aug 2020 08:01:14 -0700 Message-ID: <20200821150134.2581465-11-guro@fb.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200821150134.2581465-1-guro@fb.com> References: <20200821150134.2581465-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-08-21_08:2020-08-21,2020-08-21 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 mlxlogscore=663 spamscore=0 mlxscore=0 clxscore=1015 suspectscore=13 adultscore=0 bulkscore=0 impostorscore=0 phishscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008210143 X-FB-Internal: deliver Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@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 002f8a5c9e51..e8e2c39cbdc9 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