From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by mail.toke.dk (Postfix) with ESMTPS id D156B9D2907 for ; Tue, 20 Dec 2022 23:20:52 +0100 (CET) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=nZPyP6eg Received: by mail-pl1-x64a.google.com with SMTP id n5-20020a170902d2c500b00189e5b86fe2so9961669plc.16 for ; Tue, 20 Dec 2022 14:20:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=1ansIL1FRceEaunvjXWkRml8VwJxoztX53tFJV02UIM=; b=nZPyP6eghnLsL3cHnT5phCwQAWoEeXv50rN1953ECPYOLu62c9Es/WNqaliQRtOq6W U4IDLaWkwt+Eo2JlbBsBoZU9LhMUJQMIns5LQKsa0qJUoYceD0eVFh2g24b9234ArQ5E V5MJPDtRENWt6xMFfeX69PggqXOtzgyMoHWXMAQHfUZs/PQqTyOkmQ7/siKKmVcbxCFg MJwSkLnkaAVeS40fxDG7LfDxK+0hv6vYZ6kXvT1LLtfOuH0D8trT4Zcm62S/xfpYF0sa pXR2EZJcQlPnrN2ABiFBNo+F2whxen4W0G74FK3LNLxP+/RNKvP1foBCd1H48GwpiuEb JORA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1ansIL1FRceEaunvjXWkRml8VwJxoztX53tFJV02UIM=; b=0JJoK64TKVeo0XdZLIGF/vpzZDlj50ESQvALL8xT52uA5jNLh36s14o+WtdDOipzUC uQiLvkwz6gIao8TARXKvMMcAArcLuZXMOWbdOlVDs9y8OdhQV7oCSOdktRrbrtF1OiwV YeYb0t4uGTWa+9xJ4Ooytfn9a9ZdLOMzRHn1HNBiiCXw+TVrVXclZ+hrE9IVgB4SiX1u AMFxeAT1BMcQWdnxSeh8bNhWqil0qQ/vmHrANOwWTBe4WxneJ+42uWs0SVidjCO88Eru /KX91Vwr+bBFuCE9th0M1KDVLuax5H1y8gr0YyEttFRd6BidZbtSK1Q7SZsvP7/B7lRV dQig== X-Gm-Message-State: ANoB5pnLJkgnGmRsKFEXRY/cIWgcEq0piwMo++f0P7L3F760GazEqaE3 8hYTUVrvp9fFKt3kcp+xZlOwJlQ= X-Google-Smtp-Source: AA0mqf7DpHAbO99wZ4lDlUEBNVYC9QB4S33u2/k25knHa2xibKe+tWCLGxQNIck6RlK6ZMWrbgath6g= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a63:481e:0:b0:46b:27b0:c245 with SMTP id v30-20020a63481e000000b0046b27b0c245mr70566944pga.611.1671574850829; Tue, 20 Dec 2022 14:20:50 -0800 (PST) Date: Tue, 20 Dec 2022 14:20:29 -0800 In-Reply-To: <20221220222043.3348718-1-sdf@google.com> Mime-Version: 1.0 References: <20221220222043.3348718-1-sdf@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20221220222043.3348718-4-sdf@google.com> From: Stanislav Fomichev To: bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: 6IFEJ33DZDMFSUCWKQAG3VSBHGTVCE3K X-Message-ID-Hash: 6IFEJ33DZDMFSUCWKQAG3VSBHGTVCE3K X-MailFrom: 3QjWiYwMKCVkJ467FF7C5.3FDO4G-89EKJO4G-GIFA53K.E5K@flex--sdf.bounces.google.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, David Ahern , Jakub Kicinski , Willem de Bruijn , Jesper Dangaard Brouer , Anatoly Burakov , Alexander Lobakin , Magnus Karlsson , Maryam Tahhan , xdp-hints@xdp-project.net, netdev@vger.kernel.org X-Mailman-Version: 3.3.7 Precedence: list Subject: [xdp-hints] [PATCH bpf-next v5 03/17] bpf: Move offload initialization into late_initcall List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: So we don't have to initialize it manually from several paths. Cc: John Fastabend Cc: David Ahern Cc: Martin KaFai Lau Cc: Jakub Kicinski Cc: Willem de Bruijn Cc: Jesper Dangaard Brouer Cc: Anatoly Burakov Cc: Alexander Lobakin Cc: Magnus Karlsson Cc: Maryam Tahhan Cc: xdp-hints@xdp-project.net Cc: netdev@vger.kernel.org Signed-off-by: Stanislav Fomichev --- kernel/bpf/offload.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/kernel/bpf/offload.c b/kernel/bpf/offload.c index f5769a8ecbee..621e8738f304 100644 --- a/kernel/bpf/offload.c +++ b/kernel/bpf/offload.c @@ -56,7 +56,6 @@ static const struct rhashtable_params offdevs_params = { }; static struct rhashtable offdevs; -static bool offdevs_inited; static int bpf_dev_offload_check(struct net_device *netdev) { @@ -72,8 +71,6 @@ bpf_offload_find_netdev(struct net_device *netdev) { lockdep_assert_held(&bpf_devs_lock); - if (!offdevs_inited) - return NULL; return rhashtable_lookup_fast(&offdevs, &netdev, offdevs_params); } @@ -673,18 +670,6 @@ struct bpf_offload_dev * bpf_offload_dev_create(const struct bpf_prog_offload_ops *ops, void *priv) { struct bpf_offload_dev *offdev; - int err; - - down_write(&bpf_devs_lock); - if (!offdevs_inited) { - err = rhashtable_init(&offdevs, &offdevs_params); - if (err) { - up_write(&bpf_devs_lock); - return ERR_PTR(err); - } - offdevs_inited = true; - } - up_write(&bpf_devs_lock); offdev = kzalloc(sizeof(*offdev), GFP_KERNEL); if (!offdev) @@ -710,3 +695,10 @@ void *bpf_offload_dev_priv(struct bpf_offload_dev *offdev) return offdev->priv; } EXPORT_SYMBOL_GPL(bpf_offload_dev_priv); + +static int __init bpf_offload_init(void) +{ + return rhashtable_init(&offdevs, &offdevs_params); +} + +late_initcall(bpf_offload_init); -- 2.39.0.314.g84b9a713c41-goog