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=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,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 9652BC64E7B for ; Tue, 1 Dec 2020 21:59:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CDB7722210 for ; Tue, 1 Dec 2020 21:59:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="ivtPYvrd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CDB7722210 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=fb.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0BAF46B0036; Tue, 1 Dec 2020 16:59:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E2FE58D0003; Tue, 1 Dec 2020 16:59:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C3ADB6B0068; Tue, 1 Dec 2020 16:59:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0157.hostedemail.com [216.40.44.157]) by kanga.kvack.org (Postfix) with ESMTP id A27226B005D for ; Tue, 1 Dec 2020 16:59:11 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 6CD011EE6 for ; Tue, 1 Dec 2020 21:59:11 +0000 (UTC) X-FDA: 77546079702.23.wrist97_3803eb9273ad Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id 4B97E37604 for ; Tue, 1 Dec 2020 21:59:11 +0000 (UTC) X-HE-Tag: wrist97_3803eb9273ad X-Filterd-Recvd-Size: 5140 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Tue, 1 Dec 2020 21:59:10 +0000 (UTC) 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 0B1LpZDE001936 for ; Tue, 1 Dec 2020 13:59:09 -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=O7tHJPPMX1n8XVlMLHDhzJco9LceDdYtFho1yxWVAM8=; b=ivtPYvrd2eiAnul1qx30d0xh/NYgmP1xvxKrXyYbUPxLuV16hLO1OsjLwzWIxdMXWsyI U3vjJ1A4/8l/RJbML/8/64TeibeybyFV59U7Gk3xZ4nDhEvq3rKYgcWZnXxNZrgFUI1A UKB6NUQWv5TagM/TroukytW5LVGlrz3gQh0= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com with ESMTP id 355qvjk193-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 01 Dec 2020 13:59:09 -0800 Received: from intmgw003.06.prn3.facebook.com (2620:10d:c085:108::8) 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; Tue, 1 Dec 2020 13:59:08 -0800 Received: by devvm3388.prn0.facebook.com (Postfix, from userid 111017) id 536D319702A8; Tue, 1 Dec 2020 13:59:06 -0800 (PST) From: Roman Gushchin To: CC: , , , , , , , Subject: [PATCH bpf-next v9 05/34] bpf: memcg-based memory accounting for bpf progs Date: Tue, 1 Dec 2020 13:58:31 -0800 Message-ID: <20201201215900.3569844-6-guro@fb.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20201201215900.3569844-1-guro@fb.com> References: <20201201215900.3569844-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-12-01_11:2020-11-30,2020-12-01 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 suspectscore=38 malwarescore=0 adultscore=0 spamscore=0 mlxlogscore=726 priorityscore=1501 phishscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012010131 X-FB-Internal: deliver X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Include memory used by bpf programs into the memcg-based accounting. This includes the memory used by programs itself, auxiliary data, statistics and bpf line info. A memory cgroup containing the process which loads the program is getting charged. Signed-off-by: Roman Gushchin Acked-by: Song Liu --- kernel/bpf/core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index ff55cbcfbab4..2921f58c03a8 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -77,7 +77,7 @@ void *bpf_internal_load_pointer_neg_helper(const struct= sk_buff *skb, int k, uns =20 struct bpf_prog *bpf_prog_alloc_no_stats(unsigned int size, gfp_t gfp_ex= tra_flags) { - gfp_t gfp_flags =3D GFP_KERNEL | __GFP_ZERO | gfp_extra_flags; + gfp_t gfp_flags =3D GFP_KERNEL_ACCOUNT | __GFP_ZERO | gfp_extra_flags; struct bpf_prog_aux *aux; struct bpf_prog *fp; =20 @@ -86,7 +86,7 @@ struct bpf_prog *bpf_prog_alloc_no_stats(unsigned int s= ize, gfp_t gfp_extra_flag if (fp =3D=3D NULL) return NULL; =20 - aux =3D kzalloc(sizeof(*aux), GFP_KERNEL | gfp_extra_flags); + aux =3D kzalloc(sizeof(*aux), GFP_KERNEL_ACCOUNT | gfp_extra_flags); if (aux =3D=3D NULL) { vfree(fp); return NULL; @@ -106,7 +106,7 @@ struct bpf_prog *bpf_prog_alloc_no_stats(unsigned int= size, gfp_t gfp_extra_flag =20 struct bpf_prog *bpf_prog_alloc(unsigned int size, gfp_t gfp_extra_flags= ) { - gfp_t gfp_flags =3D GFP_KERNEL | __GFP_ZERO | gfp_extra_flags; + gfp_t gfp_flags =3D GFP_KERNEL_ACCOUNT | __GFP_ZERO | gfp_extra_flags; struct bpf_prog *prog; int cpu; =20 @@ -138,7 +138,7 @@ int bpf_prog_alloc_jited_linfo(struct bpf_prog *prog) =20 prog->aux->jited_linfo =3D kcalloc(prog->aux->nr_linfo, sizeof(*prog->aux->jited_linfo), - GFP_KERNEL | __GFP_NOWARN); + GFP_KERNEL_ACCOUNT | __GFP_NOWARN); if (!prog->aux->jited_linfo) return -ENOMEM; =20 @@ -219,7 +219,7 @@ void bpf_prog_free_linfo(struct bpf_prog *prog) struct bpf_prog *bpf_prog_realloc(struct bpf_prog *fp_old, unsigned int = size, gfp_t gfp_extra_flags) { - gfp_t gfp_flags =3D GFP_KERNEL | __GFP_ZERO | gfp_extra_flags; + gfp_t gfp_flags =3D GFP_KERNEL_ACCOUNT | __GFP_ZERO | gfp_extra_flags; struct bpf_prog *fp; u32 pages, delta; int ret; --=20 2.26.2