mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-08-09 06:14:34 +02:00
Sashiko points out that, due to rereg_mr, the PD is actually variable and
all the touches in nldev are racy.
Use mr->device instead of mr->pd->device.
Getting the PD restrack ID is more tricky. To avoid disturbing all the
happy paths, add an rdma_restrack_sync() operation which is sort of like
flush_workqueue() or synchronize_irq(): after it returns, all the old
nldev touches to the mr are gone and everything sees the new PD. This
makes it safe to reach into the PD pointer.
Fixes: da5c850782 ("RDMA/nldev: add driver-specific resource tracking")
Link: https://patch.msgid.link/r/4-v1-29ebd2c229b5+fd5-ib_mr_pd_jgg@nvidia.com
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
38 lines
1.1 KiB
C
38 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
|
|
/*
|
|
* Copyright (c) 2017-2019 Mellanox Technologies. All rights reserved.
|
|
*/
|
|
|
|
#ifndef _RDMA_CORE_RESTRACK_H_
|
|
#define _RDMA_CORE_RESTRACK_H_
|
|
|
|
#include <linux/mutex.h>
|
|
|
|
/**
|
|
* struct rdma_restrack_root - main resource tracking management
|
|
* entity, per-device
|
|
*/
|
|
struct rdma_restrack_root {
|
|
/**
|
|
* @xa: Array of XArray structure to hold restrack entries.
|
|
*/
|
|
struct xarray xa;
|
|
/**
|
|
* @next_id: Next ID to support cyclic allocation
|
|
*/
|
|
u32 next_id;
|
|
};
|
|
|
|
int rdma_restrack_init(struct ib_device *dev);
|
|
void rdma_restrack_clean(struct ib_device *dev);
|
|
void rdma_restrack_add(struct rdma_restrack_entry *res);
|
|
void rdma_restrack_del(struct rdma_restrack_entry *res);
|
|
void rdma_restrack_sync(struct rdma_restrack_entry *res);
|
|
void rdma_restrack_new(struct rdma_restrack_entry *res,
|
|
enum rdma_restrack_type type);
|
|
void rdma_restrack_set_name(struct rdma_restrack_entry *res,
|
|
const char *caller);
|
|
void rdma_restrack_parent_name(struct rdma_restrack_entry *dst,
|
|
const struct rdma_restrack_entry *parent);
|
|
#endif /* _RDMA_CORE_RESTRACK_H_ */
|