From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by mail.toke.dk (Postfix) with ESMTPS id 840A49DC60E for ; Thu, 12 Jan 2023 01:32:39 +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=Upysjoe2 Received: by mail-pj1-x1049.google.com with SMTP id y2-20020a17090a784200b00225c0839b80so7115764pjl.5 for ; Wed, 11 Jan 2023 16:32:39 -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=Upysjoe2IprVdxnQ4udI09iqKOiEsIN9sZA6n/jDnNvdBUdCmAtmjIe5Fc+Kv0L4ae um5dT8+nQPm/++n5ny4+tsQlTCYhTPB6XUsgEarK+aXnOW1lMwcGhDAWxunNvITQGDd4 wJlzIhTQ5h4W3TTpK3CtkmurZQzjFXLkOvHlfQ2SLTfqYnpvBEwLqzqZhVBu3LOPB1dR my7eYId3oKV4i+FugjIwAL7Va2aGqaW1vjOorm4T2M1z8H1/wZE2VhQdeSUKmjiViICD pJRaSvRk1iG12/7YIrEdJcqrsDVvKF8wGjNeRcSgd6vb13KSipk7/AEQHHB1s7AO6F6I wfhQ== 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=iFehWXRbQEKv412rX4KeFYGY1v9ai2baKAV2s9db4V2RrA/y4CA3nrytan13dMpdW7 siOjnBLKC3vsIjjkwegBi/yl6RBtxDyDjeenztO2e8FDcr+Sywk78h15HTfZ2WKF1DHE uVor8U2r6tUJ9M3F60LmGgxyoo/P2lN4wF8mdyCrpMkieB9+02L5nvVgQeCEzOLqueLF g5PrbTSMTn+kGRwM3+CZxZrO5435fRNgs+P29b24Zi6QrOK64mAnVXaNeGo3Fe1TXWy4 nRBEnys87M6FWiflWNWbHZeaXifuJtUzQX6VSxavlYLaEwJ39LgSD9XEbu3uT/AgrtNK hHEw== X-Gm-Message-State: AFqh2kpk7hB4kwVKJJc8uM9RR1PfwZCIE13QagLYqkNrKbyDKvLkpZUE ybt+7kK4Yf1Azi41kfBI+35a98k= X-Google-Smtp-Source: AMrXdXvh9Zorlo93uTqVkZCydoCFGUn0nJc05QwoJ9sWxPeB+akdy9slAYbqo0kbqvxDpblvB7x+2cc= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a17:90a:206:b0:226:9980:67f3 with SMTP id c6-20020a17090a020600b00226998067f3mr77503pjc.1.1673483556804; Wed, 11 Jan 2023 16:32:36 -0800 (PST) Date: Wed, 11 Jan 2023 16:32:16 -0800 In-Reply-To: <20230112003230.3779451-1-sdf@google.com> Mime-Version: 1.0 References: <20230112003230.3779451-1-sdf@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20230112003230.3779451-4-sdf@google.com> From: Stanislav Fomichev To: bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: HBMXPISUFA2ILKZRNUECZUBUM7WKPYNY X-Message-ID-Hash: HBMXPISUFA2ILKZRNUECZUBUM7WKPYNY X-MailFrom: 3JFW_YwMKCe8jUWXffXcV.TfdoUg-YZekjoUg-gifaVTk.eVk@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 v7 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