From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by mail.toke.dk (Postfix) with ESMTPS id 03F129E04FE for ; Thu, 19 Jan 2023 23:15:44 +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=coDhL6VY Received: by mail-pf1-x449.google.com with SMTP id a18-20020a62bd12000000b0056e7b61ec78so1500492pff.17 for ; Thu, 19 Jan 2023 14:15:44 -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=EluN9RAO3/5jehFBTCxE9iis6r5nEDoqZCY8f6MRQ0c=; b=coDhL6VYgQSzRwgHAqJRrcjjR8MX6QQyphmjRgVcyygMt6NhH6yY97M8+f8YP9/BHW 8qQJmSQHHMvWcLu568tFBGwDIEcvka642kOTYOWyTJxjaFBeaBdDCcJOKsnJ/d0VCXON gK0StuznNmVH0Sf4PWHymM7P+S5DwA7psoHSmhMh8HSmGJrWT27Py+Pepa8l/HR2JIpw orYUe19thSdjXIjpSYEo//2tEM83aZFGdW+h/1+TIVksYa5z1UDfXRrehozFDxF9wqvl I1DOIqSzmrSM9wCdAmZO3dO/TxpVpqMKssL1FFsvCpnjsTOA3Ck6PeqpzwNFKLBgJ9VX v5jA== 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=EluN9RAO3/5jehFBTCxE9iis6r5nEDoqZCY8f6MRQ0c=; b=603aWCPPgyL6JakKDJpAGrWXRV/uttT+w0ecKeFtMA7tOGLaTRN3/zdbo3Bp3+/xWn 9IxlYZWjVbG/8inGvJp/gDY3fnlFKPXLgLdr2Yfj6rmG5YMUCt9HAqUqQ8/8CzCw7xKl 8jpQV+rZsHwbH10IvLP++qKqnGhydyJdsw4APfYLNv7vazJhPu1vcwsWZ/ooKa2opcQg j1ttGGAzvnSDpwR5jmImkzNRa1O5JuveKOfEQJcfRzn4NgJYhRlHQjXXZ61pfBYJ3yAP MvZjPbSh3fQSr2hQ/DzN94E3SopRXcjAliw7C612/OzEDUqz81JdqFMUwowfJqsQ7qGQ /E3g== X-Gm-Message-State: AFqh2ko9dh+wi/wyd337Zzn+i2rU3MdOCtEZfHzmsQqYFIKNXZ9D1oWJ u/W/HLtxyF9pzr/iw5TFIsbL+QA= X-Google-Smtp-Source: AMrXdXudGjQpd7lEynyR7gDEllPV9Fnd2xvrdsgsu/+ujzvVVHCfLARJibeKxsIHtr/nzz7/x3VIEoY= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a17:902:f7d6:b0:192:b0a0:788f with SMTP id h22-20020a170902f7d600b00192b0a0788fmr1136821plw.51.1674166542678; Thu, 19 Jan 2023 14:15:42 -0800 (PST) Date: Thu, 19 Jan 2023 14:15:22 -0800 In-Reply-To: <20230119221536.3349901-1-sdf@google.com> Mime-Version: 1.0 References: <20230119221536.3349901-1-sdf@google.com> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog Message-ID: <20230119221536.3349901-4-sdf@google.com> From: Stanislav Fomichev To: bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: PH4K5BKGD3VUXZJW3MTU3I5G2T7EE5LA X-Message-ID-Hash: PH4K5BKGD3VUXZJW3MTU3I5G2T7EE5LA X-MailFrom: 3DsHJYwMKCdsPACDLLDIB.9LJUAM-EFKQPUAM-MOLGB9Q.KBQ@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 v8 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.246.g2a6d74b583-goog