Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp106238ybg; Mon, 27 Jul 2020 17:05:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0CtbPBgvcKrprdeOTbLFt7T7wdKmBgajz4iRuibxii1xW04OSlpAtPL1crS2tbGe+lv+2 X-Received: by 2002:a17:906:3789:: with SMTP id n9mr24523833ejc.512.1595894752182; Mon, 27 Jul 2020 17:05:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595894752; cv=none; d=google.com; s=arc-20160816; b=Mzv2xr1Kbcq6sSSfjd2zgthCDadJ96Dj//Nj0/M5wK4Kgi1ZWii3/jHhBuuZwoyGQm NjbVFms1S25yzOJRR8WgDU2WlwvkEgOZd0Jq3EJj7mo9SgmcHv40Ec6DkxXKLjiBapP8 8CItLjhYp/PfrtX7hA9XvedzEmO/M4FSPAVZPj/FMJChYrt3vTwZvjaaFLYAggJDlT7W eBjdphf8IPWUJ2BsKYZHV/57pdYacLCkVf9oiDelA/06QMCRkhxUK6A+NEdN43LGTN69 J4t8sY4gIjFG/9sCi8FtuOw34QPu6u/ciBKLcr76EjCeGNSwxvob2FGuGZ5JP+qOUY+m t9+Q== 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=+sTbObBjQwL/I6sySIKwfYrcne3tmIDmmnBTNFNXrF4=; b=Vr99eZRoXGeusyca2CBBPQ85FhIj8IQ6Z+mcio20cE06MrVoxp98ihMy3zqq02dGml o1kl8SPMG3cPnw6zX2cnC4n2mJxbhm97tNPRjmUzGZZ/AMNu4nq1jrYGFam0T+zpLhll BTdCm26E99NQrz2wzNaqmKBCku+6+PaWg6yRMosQtkdAZDhMnWtVFJorWxyoEis9PxsA 9IELRq+GMaG7Quve5cnHNM6tifRnFrNNIGkxxBSxa9ADB8U6a/MkaDWiOAsLrpKNuDSW BfKPnucjxUxf5+eig6xQsT78YH9tfJA2LWDXtXqLm0/j3rK6rcaTqB2rcCf+vwq1DPWd HI3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LT14dCnc; 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 v14si6669361edy.162.2020.07.27.17.05.30; Mon, 27 Jul 2020 17:05:52 -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=LT14dCnc; 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 S1726676AbgG1AEo (ORCPT + 99 others); Mon, 27 Jul 2020 20:04:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:47634 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726171AbgG1AEo (ORCPT ); Mon, 27 Jul 2020 20:04:44 -0400 Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (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 5511D20809; Tue, 28 Jul 2020 00:04:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595894683; bh=l/v3wxr7DfRlZSAwzqZ2d8rPdbvhZ52OfzYMf5im19w=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=LT14dCnc1/2/BhPrwC2GaEYdAEUfwpckWQwNNZmrYd1UXPw2yzn2NtdRQGmSpi5yQ r+CiXsRFIjw9+3ty1J9Y3nBMxnpau3EPpKug7F2k7ob8bhCZeWjaIv/lTseJa9hBj1 /6gavrtdP/Y+6SY/+ZSJWu2x6dZ6flvgWN0BNc34= Received: by mail-lj1-f181.google.com with SMTP id x9so19189193ljc.5; Mon, 27 Jul 2020 17:04:43 -0700 (PDT) X-Gm-Message-State: AOAM531aIcqMEVH9V2vcRQCyJM4xYVab+wY2WpmodBZX8SQIhyqPes5p W1apEbEAMJztmsKEXVozCle4QvOcRPm81qEd7/w= X-Received: by 2002:a2e:81c2:: with SMTP id s2mr2792328ljg.10.1595894681673; Mon, 27 Jul 2020 17:04:41 -0700 (PDT) MIME-Version: 1.0 References: <20200727184506.2279656-1-guro@fb.com> <20200727184506.2279656-14-guro@fb.com> In-Reply-To: <20200727184506.2279656-14-guro@fb.com> From: Song Liu Date: Mon, 27 Jul 2020 17:04:30 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH bpf-next v2 13/35] bpf: eliminate rlimit-based memory accounting for arraymap maps 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:26 PM Roman Gushchin wrote: > > Do not use rlimit-based memory accounting for arraymap maps. > It has been replaced with the memcg-based memory accounting. > > Signed-off-by: Roman Gushchin Acked-by: Song Liu > --- > kernel/bpf/arraymap.c | 24 ++++-------------------- > 1 file changed, 4 insertions(+), 20 deletions(-) > > diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c > index 9597fecff8da..41581c38b31d 100644 > --- a/kernel/bpf/arraymap.c > +++ b/kernel/bpf/arraymap.c > @@ -75,11 +75,10 @@ int array_map_alloc_check(union bpf_attr *attr) > static struct bpf_map *array_map_alloc(union bpf_attr *attr) > { > bool percpu = attr->map_type == BPF_MAP_TYPE_PERCPU_ARRAY; > - int ret, numa_node = bpf_map_attr_numa_node(attr); > + int numa_node = bpf_map_attr_numa_node(attr); > u32 elem_size, index_mask, max_entries; > bool bypass_spec_v1 = bpf_bypass_spec_v1(); > - u64 cost, array_size, mask64; > - struct bpf_map_memory mem; > + u64 array_size, mask64; > struct bpf_array *array; > > elem_size = round_up(attr->value_size, 8); > @@ -120,44 +119,29 @@ static struct bpf_map *array_map_alloc(union bpf_attr *attr) > } > } > > - /* make sure there is no u32 overflow later in round_up() */ > - cost = array_size; > - if (percpu) > - cost += (u64)attr->max_entries * elem_size * num_possible_cpus(); > - > - ret = bpf_map_charge_init(&mem, cost); > - if (ret < 0) > - return ERR_PTR(ret); > - > /* allocate all map elements and zero-initialize them */ > if (attr->map_flags & BPF_F_MMAPABLE) { > void *data; > > /* kmalloc'ed memory can't be mmap'ed, use explicit vmalloc */ > data = bpf_map_area_mmapable_alloc(array_size, numa_node); > - if (!data) { > - bpf_map_charge_finish(&mem); > + if (!data) > return ERR_PTR(-ENOMEM); > - } > array = data + PAGE_ALIGN(sizeof(struct bpf_array)) > - offsetof(struct bpf_array, value); > } else { > array = bpf_map_area_alloc(array_size, numa_node); > } > - if (!array) { > - bpf_map_charge_finish(&mem); > + if (!array) > return ERR_PTR(-ENOMEM); > - } > array->index_mask = index_mask; > array->map.bypass_spec_v1 = bypass_spec_v1; > > /* copy mandatory map attributes */ > bpf_map_init_from_attr(&array->map, attr); > - bpf_map_charge_move(&array->map.memory, &mem); > array->elem_size = elem_size; > > if (percpu && bpf_array_alloc_percpu(array)) { > - bpf_map_charge_finish(&array->map.memory); > bpf_map_area_free(array); > return ERR_PTR(-ENOMEM); > } > -- > 2.26.2 >