if (IS_ERR(ptr))
                return PTR_ERR(ptr);
 
+       /* The htab bucket lock is always held during update operations in fd
+        * htab map, and the following rcu_read_lock() is only used to avoid
+        * the WARN_ON_ONCE in htab_map_update_elem().
+        */
+       rcu_read_lock();
        ret = htab_map_update_elem(map, key, &ptr, map_flags);
+       rcu_read_unlock();
        if (ret)
                map->ops->map_fd_put_ptr(map, ptr, false);
 
 
                err = bpf_percpu_cgroup_storage_update(map, key, value,
                                                       flags);
        } else if (IS_FD_ARRAY(map)) {
-               rcu_read_lock();
                err = bpf_fd_array_map_update_elem(map, map_file, key, value,
                                                   flags);
-               rcu_read_unlock();
        } else if (map->map_type == BPF_MAP_TYPE_HASH_OF_MAPS) {
-               rcu_read_lock();
                err = bpf_fd_htab_map_update_elem(map, map_file, key, value,
                                                  flags);
-               rcu_read_unlock();
        } else if (map->map_type == BPF_MAP_TYPE_REUSEPORT_SOCKARRAY) {
                /* rcu_read_lock() is not needed */
                err = bpf_fd_reuseport_array_update_elem(map, key, value,