On 5/30/22 06:05, Haris Iqbal wrote: > Hi Bob, > > I have a query. After the following patch, > > https://marc.info/?l=linux-rdma&m=163163776430842&w=2 > > If I send a IB_WR_REG_MR wr with flag set to IB_ACCESS_LOCAL_WRITE, > rxe will set the mr->rkey to 0 (mr->lkey will be set to the key I send > in wr). > > Afterwards, If I have to invalidate that mr with IB_WR_LOCAL_INV, > setting the .ex.invalidate_rkey to the key I sent previously in the > IB_WR_REG_MR wr, the invalidate would fail with the following error. > > rkey (%#x) doesn't match mr->rkey > (function rxe_invalidate_mr) > > Is this desired behaviour? If so, how would I go about invalidating > the above MR? > > Regards > -Haris I think that the first behavior is correct. If you don't do this then the MR is open for RDMA operations which you didn't allow. The second behavior is more interesting. If you are doing a send_with_invalidate from a remote node then no reason you should allow the remote node to do anything to the MR since it didn't have access to begin with. For a local invalidate MR If you read the IBA it claims that local invalidate operations should provide the lkey, rkey and memory handle as parameters to the operation and that the lkey should be invalidated and the rkey if there is one should be invalidated. But ib_verbs.h only has one parameter labeled rkey. The rxe driver follows most other providers and always makes the lkey and rkey the same if there is an rkey else the rkey is set to zero. So rxe_invalidate_mr should compare to the lkey and not the rkey for local invalidate. And then move the MR to the FREE state. This is a bug. Fortunately the majority of use cases for physical memory regions are for RDMA access. Feel free to submit a patch or I will if you don't care to. The rxe_invalidate_mr() subroutine needs have a new parameter since it is shared by local and remote invalidate operations and they need to behave differently. Easiest is to have an lkey and rkey parameter. The local operation would set the lkey and the remote operation the rkey. Bob