From patchwork Wed Aug 10 15:18:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12940664 Return-Path: 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 A55F8C25B07 for ; Wed, 10 Aug 2022 15:18:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4AE006B0074; Wed, 10 Aug 2022 11:18:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 438006B0075; Wed, 10 Aug 2022 11:18:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1ED7C6B0078; Wed, 10 Aug 2022 11:18:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0B0A96B0074 for ; Wed, 10 Aug 2022 11:18:51 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id DD246413DF for ; Wed, 10 Aug 2022 15:18:50 +0000 (UTC) X-FDA: 79784040420.20.7268701 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by imf17.hostedemail.com (Postfix) with ESMTP id 757D54017A for ; Wed, 10 Aug 2022 15:18:50 +0000 (UTC) Received: by mail-pj1-f42.google.com with SMTP id o3-20020a17090a0a0300b001f7649cd317so2545678pjo.0 for ; Wed, 10 Aug 2022 08:18:50 -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=HeJKAK+ncLW0QpMLm4IDJ4E+/yPQHa8h30kUW/Dj5Mc=; b=XtiAQU2TKOS4SFca4YmsB1FpaWpYM2uRBKRRXuKoFk8dmJQVocIHaqj3ViB9MwYNUP NBs9Rmgm25dnnSiiqjPij5pMXxWkvby2d/sDHS2LrRilzeYCq1WQrg6ulCSBcaqqH8nI ObPSlTLt7qhtGBFV6wm8DFWftcaVT0BgLNWu9ZnchCHKrai7RndnuJwifJfnWPyieeWV DX+GuMMHDCxpM1jo7NfqSnIFXUpfqlbCw1Q6dyqzLRwJy+8vVF8+SaPwsrvx52kKG4d9 uj0X2EiNlDGextq0j9+3TYfBYgoAaVHcJRh3kMVYCui7IgZxR0Jzu/tPF3dY7BsQahJx FrXA== 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=HeJKAK+ncLW0QpMLm4IDJ4E+/yPQHa8h30kUW/Dj5Mc=; b=VeHR0NJOLLTfBG+bCcpXsNY20NJo5ayNfumiVtjOjEJxEQTLNnfB2l2yGCCp22iP/O VAEDZFOnjmfsenTz9TPGXX4D/lY0kRpBwqvh30GCWrrB7966Rq1rn2XnJrK90xosaXvy KpZWeZDujh6H0A9FBOgFzG52LFjjREGf4FTB/cFSuSRS0PLF9HlT0N6xGYOav5FVYFmw L4wubVak4w741e86LIALTRYzQiGQ4JquMrh2O1/IZmb3L1bDMxlSNbM6KQUdoSBOeiam r0d0x6J3jRIvJoykzmAJpJ/as757uRj/4TwHUvpKzLhAtQqPZ7oUhGlcUy23+q+wFeYH FRrA== X-Gm-Message-State: ACgBeo0I1/Tw/tAobW+oZn3JTGxjjr8SXPCaddzknYSBnxOyow+xsjbV zGc9pnw4MRrXhLrLf7lqkIk= X-Google-Smtp-Source: AA6agR7VMBFj+U1/fWThTC6WnTI2GpLS9sPyCIsBQYq/J78+ZCvY7sLBGx8dOi6DBEUy14frCPJ19g== X-Received: by 2002:a17:902:e5c6:b0:16e:f3b6:ddb5 with SMTP id u6-20020a170902e5c600b0016ef3b6ddb5mr28394737plf.122.1660144729610; Wed, 10 Aug 2022 08:18:49 -0700 (PDT) Received: from vultr.guest ([2001:19f0:6001:5c3e:5400:4ff:fe19:c3bc]) by smtp.gmail.com with ESMTPSA id 85-20020a621558000000b0052b6ed5ca40sm2071935pfv.192.2022.08.10.08.18.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Aug 2022 08:18:48 -0700 (PDT) From: Yafang Shao 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 Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, linux-mm@kvack.org, Yafang Shao Subject: [PATCH bpf-next 03/15] bpf: Make __GFP_NOWARN consistent in bpf map creation Date: Wed, 10 Aug 2022 15:18:28 +0000 Message-Id: <20220810151840.16394-4-laoar.shao@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220810151840.16394-1-laoar.shao@gmail.com> References: <20220810151840.16394-1-laoar.shao@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660144730; a=rsa-sha256; cv=none; b=XsHeYS+2lhoW+9D3CUmw9YGmUglqvW1Ob+DbtMHj6KD4veqJF9yeHkiNaq5KBfw+IqsGWf QeZ0KvvfItS89xxn3SPlVQzoNhpYfsZLdPz5bMdiBnBfSKlwNuSXO+c72wb+GdjOdSzRKz ekcH2YqxWtWJ1RTYzF08XcrwrXA9wQ4= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=XtiAQU2T; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.216.42 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660144730; 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=HeJKAK+ncLW0QpMLm4IDJ4E+/yPQHa8h30kUW/Dj5Mc=; b=zRB5fP1467GREb+1ryQjg1xfwh5/C16fCaHi/GpNiovDpQfLVgQOPphaigudsZBIXCjrlD rSVWGGugQKOQoT0zJHCecVK8v/O3gR5lgW5HiwhDp2zM7L5g+qqwshJYbuqiBu2VDzNowJ IQ7SYCk4T0ruSvhkCmXKCEMlAh4oxC4= X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 757D54017A X-Rspam-User: X-Stat-Signature: rg85mskcdbnhj5u4ez3m4iykma1ig5nu Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=XtiAQU2T; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.216.42 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com X-HE-Tag: 1660144730-814421 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: Some of the bpf maps are created with __GFP_NOWARN, i.e. arraymap, bloom_filter, bpf_local_storage, bpf_struct_ops, lpm_trie, queue_stack_maps, reuseport_array, stackmap and xskmap, while others are created without __GFP_NOWARN, i.e. cpumap, devmap, hashtab, local_storage, offload, ringbuf and sock_map. But there are not key differences between the creation of these maps. So let make this allocation flag consistent in all bpf maps creation. Then we can use a generic helper to alloc all bpf maps. Signed-off-by: Yafang Shao --- kernel/bpf/cpumap.c | 2 +- kernel/bpf/devmap.c | 2 +- kernel/bpf/hashtab.c | 2 +- kernel/bpf/local_storage.c | 4 ++-- kernel/bpf/offload.c | 2 +- kernel/bpf/ringbuf.c | 2 +- net/core/sock_map.c | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c index f4860ac..b25ca9d 100644 --- a/kernel/bpf/cpumap.c +++ b/kernel/bpf/cpumap.c @@ -97,7 +97,7 @@ static struct bpf_map *cpu_map_alloc(union bpf_attr *attr) attr->map_flags & ~BPF_F_NUMA_NODE) return ERR_PTR(-EINVAL); - cmap = kzalloc(sizeof(*cmap), GFP_USER | __GFP_ACCOUNT); + cmap = kzalloc(sizeof(*cmap), GFP_USER | __GFP_NOWARN | __GFP_ACCOUNT); if (!cmap) return ERR_PTR(-ENOMEM); diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c index a0e02b0..88feaa0 100644 --- a/kernel/bpf/devmap.c +++ b/kernel/bpf/devmap.c @@ -163,7 +163,7 @@ static struct bpf_map *dev_map_alloc(union bpf_attr *attr) if (!capable(CAP_NET_ADMIN)) return ERR_PTR(-EPERM); - dtab = kzalloc(sizeof(*dtab), GFP_USER | __GFP_ACCOUNT); + dtab = kzalloc(sizeof(*dtab), GFP_USER | __GFP_NOWARN | __GFP_ACCOUNT); if (!dtab) return ERR_PTR(-ENOMEM); diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c index da75784..f1e5303 100644 --- a/kernel/bpf/hashtab.c +++ b/kernel/bpf/hashtab.c @@ -495,7 +495,7 @@ static struct bpf_map *htab_map_alloc(union bpf_attr *attr) struct bpf_htab *htab; int err, i; - htab = kzalloc(sizeof(*htab), GFP_USER | __GFP_ACCOUNT); + htab = kzalloc(sizeof(*htab), GFP_USER | __GFP_NOWARN | __GFP_ACCOUNT); if (!htab) return ERR_PTR(-ENOMEM); diff --git a/kernel/bpf/local_storage.c b/kernel/bpf/local_storage.c index 49ef0ce..a64255e 100644 --- a/kernel/bpf/local_storage.c +++ b/kernel/bpf/local_storage.c @@ -313,8 +313,8 @@ static struct bpf_map *cgroup_storage_map_alloc(union bpf_attr *attr) /* max_entries is not used and enforced to be 0 */ return ERR_PTR(-EINVAL); - map = kmalloc_node(sizeof(struct bpf_cgroup_storage_map), - __GFP_ZERO | GFP_USER | __GFP_ACCOUNT, numa_node); + map = kzalloc_node(sizeof(struct bpf_cgroup_storage_map), + GFP_USER | __GFP_NOWARN | __GFP_ACCOUNT, numa_node); if (!map) return ERR_PTR(-ENOMEM); diff --git a/kernel/bpf/offload.c b/kernel/bpf/offload.c index bd09290..5a629a1 100644 --- a/kernel/bpf/offload.c +++ b/kernel/bpf/offload.c @@ -372,7 +372,7 @@ struct bpf_map *bpf_map_offload_map_alloc(union bpf_attr *attr) attr->map_type != BPF_MAP_TYPE_HASH) return ERR_PTR(-EINVAL); - offmap = kzalloc(sizeof(*offmap), GFP_USER); + offmap = kzalloc(sizeof(*offmap), GFP_USER | __GFP_NOWARN); if (!offmap) return ERR_PTR(-ENOMEM); diff --git a/kernel/bpf/ringbuf.c b/kernel/bpf/ringbuf.c index 3fb54fe..df8062c 100644 --- a/kernel/bpf/ringbuf.c +++ b/kernel/bpf/ringbuf.c @@ -164,7 +164,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 | __GFP_ACCOUNT); + rb_map = kzalloc(sizeof(*rb_map), GFP_USER | __GFP_NOWARN | __GFP_ACCOUNT); if (!rb_map) return ERR_PTR(-ENOMEM); diff --git a/net/core/sock_map.c b/net/core/sock_map.c index 028813d..763d771 100644 --- a/net/core/sock_map.c +++ b/net/core/sock_map.c @@ -41,7 +41,7 @@ static struct bpf_map *sock_map_alloc(union bpf_attr *attr) attr->map_flags & ~SOCK_CREATE_FLAG_MASK) return ERR_PTR(-EINVAL); - stab = kzalloc(sizeof(*stab), GFP_USER | __GFP_ACCOUNT); + stab = kzalloc(sizeof(*stab), GFP_USER | __GFP_NOWARN | __GFP_ACCOUNT); if (!stab) return ERR_PTR(-ENOMEM); @@ -1076,7 +1076,7 @@ static struct bpf_map *sock_hash_alloc(union bpf_attr *attr) if (attr->key_size > MAX_BPF_STACK) return ERR_PTR(-E2BIG); - htab = kzalloc(sizeof(*htab), GFP_USER | __GFP_ACCOUNT); + htab = kzalloc(sizeof(*htab), GFP_USER | __GFP_NOWARN | __GFP_ACCOUNT); if (!htab) return ERR_PTR(-ENOMEM);