Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp48374ybg; Mon, 27 Jul 2020 15:13:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQBPzmucqZdDB/DGx3OYEBf7ft4JAGOgBTat4wBwZBSHhoo9+1dCenNyYwG7i4a0IhsLva X-Received: by 2002:a17:906:8517:: with SMTP id i23mr3793979ejx.287.1595887998065; Mon, 27 Jul 2020 15:13:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595887998; cv=none; d=google.com; s=arc-20160816; b=MTa04Z7j4mZQ/BNL8KVxmdezjXxgMEICHhTngrfXgxfCUWnciR3D2ylmfLJB+Itsr1 Kjd9pxIc7N3kJJgqM/SSK3XOU+fU67SNTCiJHgq5nUUmluPyx3PQsEAyVF25EcGkXQrQ Z036LOI9xY22X+C25lywrAqmioJiOwwteN+G8zj5mEV7oaHPmoyKCvfSvSwKKFWnFz3l QVqrndFzpXKggvT17S0kN+uqF3mBi1q8Nj0Sf1Tt5RAx2F6b9/1AaECv3viokhmJ4u6I UU16XeuGW3DfliLL3O+JoISLebtxB8MfHkvEq92iTBe+gAcbYKuUuwXgOqMi0TXMv/XG Acpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=z6e13qr6eb2pdHWfB0A6GKDAh7/M6iIAE1WhvEGmqiU=; b=w6qAdwHakzkXs6l5x4xuLzdEfsYD877kEa5Bp+dSmurSWjj9k2gWYzf1+j6Z1GAI7O ZsY1nuD6I2WPpTMvkPPT9oJ5SiRxE28PTlNVSMA52dsWuceWbElPVCX8lFghNjyGWjwO LlAnKTCG5ccTkj21Ob7Lx05FM2pAcnVc0r7s6cpoXKAtL4r9ax73lsM2r+vDujmCBCdI wei+q1J8qgRGijr8dTTvSxKUq01yIaSu63rioY9PfA01KyQUzweYoIY5zMIkYNPQL5d/ Oz44nBeFjEahqIJ3I63w67zx1R458vACLXyk8+UDx68IKW1Z7inT13GZ/Uhzwwn8tsvc GSTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="VEg/hiXb"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h23si3658137ejx.550.2020.07.27.15.12.55; Mon, 27 Jul 2020 15:13: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=@kernel.org header.s=default header.b="VEg/hiXb"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726739AbgG0WL5 (ORCPT + 99 others); Mon, 27 Jul 2020 18:11:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:35092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726140AbgG0WL4 (ORCPT ); Mon, 27 Jul 2020 18:11:56 -0400 Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 61CC62075D; Mon, 27 Jul 2020 22:11:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595887915; bh=YW8G5VIksYVlmPs2UYgjtPkt8iVM6SF5lgGo16m/L+s=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=VEg/hiXbEvSHn7tT7/JVBAirYrXZkHYmk4kdcPNa/scCSdEmq7h+lM4JGHAH9d+zw myLFxqOizViKGdWaCDv7NE2V+mRVuFha62/JUGkXl3qDEvwOLMqlZv7vSmZ3tN28/1 u2l0pzq8mz4u4nTf90pIJxGzq8WgUS3lr2j2ZlDM= Received: by mail-lj1-f176.google.com with SMTP id d17so18969873ljl.3; Mon, 27 Jul 2020 15:11:55 -0700 (PDT) X-Gm-Message-State: AOAM532Ps1eGbC+nJDrGtIBsymc1JQe2vBDMjwEC+JjY5LGVXnTYknuw p5fVCKfE5U3Zn9Z+oCUKbpUlKGuI7lJiPND1Eno= X-Received: by 2002:a2e:9996:: with SMTP id w22mr12043567lji.446.1595887913748; Mon, 27 Jul 2020 15:11:53 -0700 (PDT) MIME-Version: 1.0 References: <20200727184506.2279656-1-guro@fb.com> <20200727184506.2279656-2-guro@fb.com> In-Reply-To: <20200727184506.2279656-2-guro@fb.com> From: Song Liu Date: Mon, 27 Jul 2020 15:11:42 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH bpf-next v2 01/35] bpf: memcg-based memory accounting for bpf progs To: Roman Gushchin Cc: bpf , Networking , Alexei Starovoitov , Daniel Borkmann , Kernel Team , open list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 27, 2020 at 12:20 PM Roman Gushchin wrote: > > Include memory used by bpf programs into the memcg-based accounting. > This includes the memory used by programs itself, auxiliary data > and statistics. > > Signed-off-by: Roman Gushchin > --- > kernel/bpf/core.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c > index bde93344164d..daab8dcafbd4 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 > > struct bpf_prog *bpf_prog_alloc_no_stats(unsigned int size, gfp_t gfp_extra_flags) > { > - gfp_t gfp_flags = GFP_KERNEL | __GFP_ZERO | gfp_extra_flags; > + gfp_t gfp_flags = GFP_KERNEL_ACCOUNT | __GFP_ZERO | gfp_extra_flags; > struct bpf_prog_aux *aux; > struct bpf_prog *fp; > > @@ -86,7 +86,7 @@ struct bpf_prog *bpf_prog_alloc_no_stats(unsigned int size, gfp_t gfp_extra_flag > if (fp == NULL) > return NULL; > > - aux = kzalloc(sizeof(*aux), GFP_KERNEL | gfp_extra_flags); > + aux = kzalloc(sizeof(*aux), GFP_KERNEL_ACCOUNT | gfp_extra_flags); > if (aux == NULL) { > vfree(fp); > return NULL; > @@ -104,7 +104,7 @@ struct bpf_prog *bpf_prog_alloc_no_stats(unsigned int size, gfp_t gfp_extra_flag > > struct bpf_prog *bpf_prog_alloc(unsigned int size, gfp_t gfp_extra_flags) > { > - gfp_t gfp_flags = GFP_KERNEL | __GFP_ZERO | gfp_extra_flags; > + gfp_t gfp_flags = GFP_KERNEL_ACCOUNT | __GFP_ZERO | gfp_extra_flags; > struct bpf_prog *prog; > int cpu; > > @@ -217,7 +217,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 = GFP_KERNEL | __GFP_ZERO | gfp_extra_flags; > + gfp_t gfp_flags = GFP_KERNEL_ACCOUNT | __GFP_ZERO | gfp_extra_flags; > struct bpf_prog *fp; > u32 pages, delta; > int ret; > -- Do we need similar changes in bpf_prog_array_copy() bpf_prog_alloc_jited_linfo() bpf_prog_clone_create() and maybe a few more? Thanks, Song