Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp101375ybg; Mon, 27 Jul 2020 16:57:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1QoFnv7TIBRI/tWMKnF5ywrvMo5Y1/EGXtBRx4/cmUmaJuOOKPIUlGSpkL46KZ3eIDxGu X-Received: by 2002:a05:6402:559:: with SMTP id i25mr23258949edx.35.1595894273954; Mon, 27 Jul 2020 16:57:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595894273; cv=none; d=google.com; s=arc-20160816; b=sgJrSkjKdjPv3awMOmgWJ6newyoQt7NvCtLliyvc96RWWtW2bBzW0jxXCbk03lRTqi 9uFVjd7JnPdeTISJXGc++tpzCkoUBFpCiQVjsUeDIh2mNiavkZWit1slQgBrwET7UwOO ubvGSki6UtEEQtXo9IRb5K8cqiDcZLQVUoZadWepTOYSX5Tf3v8sTHsVSYc5BaOT4VKG bZomiLVOBoqgce+oW13F1Vyi+aefyNl/YJV4yGkYjNWJB5NsgVxh2bjXVZcDmZr+pWPM GL33fjlIR5Z6WcLzzRd25yoILFa1ceDYoN35J20CSPWwJaumwOMDPDavWK23N8WKu8eQ eGAQ== 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=C1rWNmR5eBjVlSTfFUuUmsuLhQS5anBuFI+Sm936fWc=; b=bi3c7WOY5ET0/h7/enQsQFfjSWxtD7NAAy5lDgcXti5gSPCOCSYSFmruk6HHDR8xtm MwBI7NMJR6EGqK1iS/F8LR8WkTqDOxKlUi2TTqvCpS6IyjkjD00WbJqtGl8oE9XQbc0W Y+g6aLWTh17mc/TcDElWNaEB1HNd/tCby8IpNK/0gGTn5qorvOOLfbYHU8FIFZkdzHdJ AOsPlUJZ5Jp8F9Bu1na5yJyL++4slgEHQfYMsXEulxaCCsFkC4ItxSE816SOVfwYpoKp eYnK9cujzYQuLN+7oHPFSUo4P+y4zKk8xnohKTc+JgN3qwADmwyLf66T7eCjUitie7Zn 46lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jwF1CbD0; 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 u17si6433358edy.254.2020.07.27.16.57.31; Mon, 27 Jul 2020 16:57:53 -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=jwF1CbD0; 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 S1726971AbgG0X4l (ORCPT + 99 others); Mon, 27 Jul 2020 19:56:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:46572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726171AbgG0X4l (ORCPT ); Mon, 27 Jul 2020 19:56:41 -0400 Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (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 21CC820679; Mon, 27 Jul 2020 23:56:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595894200; bh=pIvFrotDaXLQ53fI6ndW8jI8DT1JK2t5D5sC0WCfGr8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=jwF1CbD0GAuxK4wrdhWzcn+JPtunKxSvvFDxv5qAMwsY5AqtVnLIKyzChwRUJk+ET BE14SahExuO3hIHqCFE1pgPACnIuaKaomfxpyf++C4hRYBSDYmaeUauI8Btk74+lqA vCBR5Rtfhgo628/xVYhZZqeuhK8xu8QxK6183ZYw= Received: by mail-lj1-f170.google.com with SMTP id x9so19173325ljc.5; Mon, 27 Jul 2020 16:56:40 -0700 (PDT) X-Gm-Message-State: AOAM533yHzAPkZCsK4PrudF5qxalH64OMNw9u+wycKBeuDpirpZBcCEC 8j56Q9RUACjym5fHkg6F1IxlJt1YMRwV7cgvxeg= X-Received: by 2002:a2e:81c2:: with SMTP id s2mr2781767ljg.10.1595894198520; Mon, 27 Jul 2020 16:56:38 -0700 (PDT) MIME-Version: 1.0 References: <20200727184506.2279656-1-guro@fb.com> <20200727184506.2279656-10-guro@fb.com> In-Reply-To: <20200727184506.2279656-10-guro@fb.com> From: Song Liu Date: Mon, 27 Jul 2020 16:56:27 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH bpf-next v2 09/35] bpf: memcg-based memory accounting for bpf ringbuffer 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:22 PM Roman Gushchin wrote: > > 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 { > > static struct bpf_ringbuf *bpf_ringbuf_area_alloc(size_t data_sz, int numa_node) > { > - const gfp_t flags = GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_NOWARN | > - __GFP_ZERO; > + const gfp_t flags = GFP_KERNEL_ACCOUNT | __GFP_RETRY_MAYFAIL | > + __GFP_NOWARN | __GFP_ZERO; > int nr_meta_pages = RINGBUF_PGOFF + RINGBUF_POS_PAGES; > int nr_data_pages = data_sz >> PAGE_SHIFT; > int nr_pages = 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 = (nr_meta_pages + 2 * nr_data_pages) * sizeof(*pages); > if (array_size > PAGE_SIZE) > - pages = vmalloc_node(array_size, numa_node); > + pages = __vmalloc_node(array_size, 1, GFP_KERNEL_ACCOUNT, > + numa_node, __builtin_return_address(0)); > else > pages = kmalloc_node(array_size, flags, numa_node); > if (!pages) > @@ -167,7 +168,7 @@ static struct bpf_map *ringbuf_map_alloc(union bpf_attr *attr) > return ERR_PTR(-E2BIG); > #endif > > - rb_map = kzalloc(sizeof(*rb_map), GFP_USER); > + rb_map = kzalloc(sizeof(*rb_map), GFP_USER | __GFP_ACCOUNT); > if (!rb_map) > return ERR_PTR(-ENOMEM); > > -- > 2.26.2 >