Message ID | 20220818143118.17733-9-laoar.shao@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94C25C32773 for <linux-mm@archiver.kernel.org>; Thu, 18 Aug 2022 20:20:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 055C28D0003; Thu, 18 Aug 2022 16:20:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 005098D0002; Thu, 18 Aug 2022 16:20:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE8598D0003; Thu, 18 Aug 2022 16:20:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D13CA8D0002 for <linux-mm@kvack.org>; Thu, 18 Aug 2022 16:20:50 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id AEA5B1A1F1C for <linux-mm@kvack.org>; Thu, 18 Aug 2022 20:20:50 +0000 (UTC) X-FDA: 79813831860.09.BE4F8CA Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by imf22.hostedemail.com (Postfix) with ESMTP id DADEDC136B for <linux-mm@kvack.org>; Thu, 18 Aug 2022 20:12:14 +0000 (UTC) Received: by mail-pl1-f177.google.com with SMTP id m2so2418823pls.4 for <linux-mm@kvack.org>; Thu, 18 Aug 2022 13:12:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=6MxaJVkVqzqq1Kknlzxc81EzIkRTYeOwRhc2SFg8N/c=; b=UwVG/VSP0500nvEMvFgAFhuzl7jOoNgmsUjHA03AL7Loq4gte3g3tEw92bhEq4R3/I 9BO87zC4T+n1Isqcj6XWQaRGJh9dVeNMeVJHqNXReWmH1FFppfSnTUWTSsii0f4j8Mrf fGspLs9apHqZWT6hmOW66VERvD64fONYTuCqCPRfLJttOt8GaR/XXzexgSDul6/v8Qzc 1s22qNFwBX3yTFKyIH6vIVN7bV7rvuxaShBZH4Xkp/O0XDbckHuH/goksJJndgMlSnA/ 0RjflanMCjl9/cLUXSUkd7M15JXVuotakDNoBl5I76iaQJTxRzCgDXb1/eXTG13AGKqP 3ThA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=6MxaJVkVqzqq1Kknlzxc81EzIkRTYeOwRhc2SFg8N/c=; b=bManadum2yklEogMmy9PwP5R+bO8umx+F3tFgNjxeoXFO9tmyI6QAbWe3TS5XT16/w 2iqP5OkWLXn4u17Dp0epEcGCZruSR6r8wUVrta29KYMNjDruK9oEZUsVScjIPN0JWCwq ldZmYc9OSZPg12aD3S3beARdf9/OIPf3GeWcEUkPPgylHvYSg5b/0Ym4yQhZsIvaMOCI 5SEAk4D7YvQtUbtxgLwewBASuH8mlWW1zzjI/zFkxDyiamhZ5civg/seZ4xcCOZGfCRJ t1/tkSecaYTmoX+TxWoOr43BxOaxSZxNbaxwNSvLSfjmZH36nJNNqhNThPDGmj+WOZuA 835w== X-Gm-Message-State: ACgBeo2qJJlWLgVHy9yEhnRIFZOfcGbVYAgHmNLo4+04GePg/6gSsOac J3GbyBcLoIMtg2DK75JIM7n574oUbN/IANp/ X-Google-Smtp-Source: AA6agR72M8P6pJtUCoBgO4ikpegsRLjp2RJjn9maPzCVOcuC6aNzZXvVy3iAP3lFIy0mTaP+56rrqQ== X-Received: by 2002:a17:902:8e8c:b0:171:2a36:e390 with SMTP id bg12-20020a1709028e8c00b001712a36e390mr3080551plb.77.1660833122298; Thu, 18 Aug 2022 07:32:02 -0700 (PDT) Received: from vultr.guest ([45.32.72.237]) by smtp.gmail.com with ESMTPSA id h5-20020a63f905000000b003fdc16f5de2sm1379124pgi.15.2022.08.18.07.31.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Aug 2022 07:32:01 -0700 (PDT) From: Yafang Shao <laoar.shao@gmail.com> To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev, shakeelb@google.com, songmuchun@bytedance.com, akpm@linux-foundation.org, tj@kernel.org, lizefan.x@bytedance.com Cc: cgroups@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-mm@kvack.org, Yafang Shao <laoar.shao@gmail.com> Subject: [PATCH bpf-next v2 08/12] bpf: Use bpf_map_kzalloc in arraymap Date: Thu, 18 Aug 2022 14:31:14 +0000 Message-Id: <20220818143118.17733-9-laoar.shao@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220818143118.17733-1-laoar.shao@gmail.com> References: <20220818143118.17733-1-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660853535; a=rsa-sha256; cv=none; b=DONcL7EWAoxceR6dz6puYutEV6opy0EDbRO06YLgcgoUemPMiqpnxPSo7DAz/uqn7pVBOM MCMtIyz29zYxVav3A3jGb2tjDh9CbRA/gLePAs/zTT4UK6c8KLCB91N4nBoxIhpraZqcNQ K13O9su3DbZCZrjNB0FMXkeTQGjN/Ro= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="UwVG/VSP"; spf=pass (imf22.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660853535; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6MxaJVkVqzqq1Kknlzxc81EzIkRTYeOwRhc2SFg8N/c=; b=erWl8ozZn0Iet36YF5U5DI26SA+tOsBzQ4AX2HRcN97MCzHPFT6UjHXh9U+B07JD9eotFw efF7NMx8IRV6pf/BezhXOU4Gzg2IeZDtdOU/L1oU/OShCz6g4UcrDMKLEv2uW/BQfgFq2y sWk09FxGpWgebB5/fnQFbRyJ2WGPlOU= X-Rspamd-Server: rspam11 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="UwVG/VSP"; spf=pass (imf22.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Stat-Signature: y6ysm1oxqt3jhs71biwwc4834f4o4ga3 X-Rspamd-Queue-Id: DADEDC136B X-HE-Tag: 1660853534-462956 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: <linux-mm.kvack.org> |
Series |
bpf: Introduce selectable memcg for bpf map
|
expand
|
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c index 80974c5..3039832 100644 --- a/kernel/bpf/arraymap.c +++ b/kernel/bpf/arraymap.c @@ -1090,20 +1090,20 @@ static struct bpf_map *prog_array_map_alloc(union bpf_attr *attr) struct bpf_array_aux *aux; struct bpf_map *map; - aux = kzalloc(sizeof(*aux), GFP_KERNEL_ACCOUNT); - if (!aux) + map = array_map_alloc(attr); + if (IS_ERR(map)) return ERR_PTR(-ENOMEM); + aux = bpf_map_kzalloc(map, sizeof(*aux), GFP_KERNEL); + if (!aux) { + array_map_free(map); + return ERR_PTR(-ENOMEM); + } + INIT_WORK(&aux->work, prog_array_map_clear_deferred); INIT_LIST_HEAD(&aux->poke_progs); mutex_init(&aux->poke_mutex); - map = array_map_alloc(attr); - if (IS_ERR(map)) { - kfree(aux); - return map; - } - container_of(map, struct bpf_array, map)->aux = aux; aux->map = map;
Allocates memory after map creation, then we can use the generic helper bpf_map_kzalloc() instead of the open-coded kzalloc(). Signed-off-by: Yafang Shao <laoar.shao@gmail.com> --- kernel/bpf/arraymap.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)