Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp5078429pjb; Mon, 27 Jul 2020 12:21:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwo7JN9CJz6fju9CfQtL8ttxyLTOsBwtUmq86X5DXSJwz7RQgBCQnCt9KhA/2qiBGCc5KX7 X-Received: by 2002:a17:906:ce39:: with SMTP id sd25mr3854248ejb.80.1595877678544; Mon, 27 Jul 2020 12:21:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595877678; cv=none; d=google.com; s=arc-20160816; b=a7q8RKRjP3yFllm+H36taopwKNKSPzkg9cEd2Zv5d2bFx+3UM2AnK+am7gqYjVuoti XPwzCu7SdBoO1L5uaRvosI/Vbbv/u8knJireMGIS5E6NEe2KFF/egIvCa+Igcmp2xxFI IbTrzw+n31xh1DG60Hy1EDnIU/qQNiYDE9Y13RERaZrvxms4ioabXa3zFIppTY1tF0iq YBGOwq3nnsBAItvYuWJGxGxGUlDflElQmVBGys4sKZ7eVEdES8th4EozhfWXYk0I4vj+ /A9SQaN/C6btShpR7eN0QY9Hf/HN/a7CuUd8OJCNeW6t+weBzwaw4jf+OoBPQ5tF3M7/ 6Bng== 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=8ycK9dyk0krVtM84IjwRBzsABNq6gvRDOeD6Zv8pbc0=; b=H91VMWv6H6CGmFKzmrv0P+dpMbj/QZfLiq4cl8JRDsZixTyoT8r+WHFiroES0IRUD1 HUiMbbVXq7dx45Ofao0xh442FEvGHN1ht/LaJq2np1zNoj0onaO6/On1+HUBPaoC80DI o96ynH6JysBdONMlo3YAWWkUC/DSpFPmvgTwPhgnWa7p65moVp4rCj1zGgDdftNHXpR0 xM6ZYU2Fs8ucoBnngsbV7DTjRR8FgkLg5+I7VUnb0l/dpDco/mkvCXJjl1lODjL/iDFw byqP9Sxzi61YFyykTtT6U6KUUMqCYAPKPZ3ZAMC7Y4PJaPN6VvXHNvmslB5s5d3HVmyr 9WDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=NcOSkFbl; 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 o17si1441872ejg.485.2020.07.27.12.20.55; Mon, 27 Jul 2020 12:21: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=NcOSkFbl; 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 S1731933AbgG0Spi (ORCPT + 99 others); Mon, 27 Jul 2020 14:45:38 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:2586 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731904AbgG0Spg (ORCPT ); Mon, 27 Jul 2020 14:45:36 -0400 Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06RIiO5V009882 for ; Mon, 27 Jul 2020 11:45:35 -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=8ycK9dyk0krVtM84IjwRBzsABNq6gvRDOeD6Zv8pbc0=; b=NcOSkFblB9A3Ytc1QcLC+Kmib/cxnnjTPHRcqAOSe+FQ45pffpMzYt/sq9CZlpttgdjz qFGb/ksZr/if87JawsamKyZm0dnSYV5OVzWCn4kKgjwtN9Dn46246purrlGTiSJiOA1b y/axxqX6uAPqn5JHu4T22YylbhO7odnTfUk= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 32gj8kga56-9 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 27 Jul 2020 11:45:35 -0700 Received: from intmgw001.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:16 -0700 Received: by devvm1096.prn0.facebook.com (Postfix, from userid 111017) id B72F71DAFE83; Mon, 27 Jul 2020 11:45:10 -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 09/35] bpf: memcg-based memory accounting for bpf ringbuffer Date: Mon, 27 Jul 2020 11:44:40 -0700 Message-ID: <20200727184506.2279656-10-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 adultscore=0 mlxlogscore=686 spamscore=0 impostorscore=0 malwarescore=0 suspectscore=13 bulkscore=0 priorityscore=1501 clxscore=1015 phishscore=0 mlxscore=0 lowpriorityscore=0 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 Enable the memcg-based memory accounting for the memory used by the bpf ringbuffer. Signed-off-by: Roman Gushchin --- 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