From: Zhu Yanjun <yanjun.zhu@linux.dev>
To: Junxian Huang <huangjunxian6@hisilicon.com>,
Leon Romanovsky <leon@kernel.org>,
Jason Gunthorpe <jgg@nvidia.com>
Cc: Or Har-Toov <ohartoov@nvidia.com>,
Edward Srouji <edwards@nvidia.com>,
linux-rdma@vger.kernel.org, Maor Gottlieb <maorg@nvidia.com>,
Mark Zhang <markzhang@nvidia.com>,
Michael Guralnik <michaelgur@nvidia.com>,
Tamar Mashiah <tmashiah@nvidia.com>,
Yishai Hadas <yishaih@nvidia.com>
Subject: Re: [PATCH rdma-next 5/6] RDMA/mlx5: Change check for cacheable user mkeys
Date: Thu, 25 Jan 2024 21:30:33 +0800 [thread overview]
Message-ID: <b3ae1ecb-bf03-4a28-b2fa-058540f70180@linux.dev> (raw)
In-Reply-To: <36037101-dd46-d956-4555-d02eeb04dd0b@hisilicon.com>
在 2024/1/25 20:52, Junxian Huang 写道:
>
>
> On 2024/1/25 20:30, Leon Romanovsky wrote:
>> From: Or Har-Toov <ohartoov@nvidia.com>
>>
>> In the dereg flow, UMEM is not a good enough indication whether an MR
>> is from userspace since in mlx5_ib_rereg_user_mr there are some cases
>> when a new MR is created and the UMEM of the old MR is set to NULL.
>> Currently when mlx5_ib_dereg_mr is called on the old MR, UMEM is NULL
>> but cache_ent can be different than NULL. So, the mkey will not be
>> destroyed.
>> Therefore checking if mkey is from user application and cacheable
>> should be done by checking if rb_key or cache_ent exist and all other kind of
>> mkeys should be destroyed.
>>
>> Fixes: dd1b913fb0d0 ("RDMA/mlx5: Cache all user cacheable mkeys on dereg MR flow")
>> Signed-off-by: Or Har-Toov <ohartoov@nvidia.com>
>> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
>> ---
>> drivers/infiniband/hw/mlx5/mr.c | 15 ++++++++-------
>> 1 file changed, 8 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
>> index 12bca6ca4760..3c241898e064 100644
>> --- a/drivers/infiniband/hw/mlx5/mr.c
>> +++ b/drivers/infiniband/hw/mlx5/mr.c
>> @@ -1857,6 +1857,11 @@ static int cache_ent_find_and_store(struct mlx5_ib_dev *dev,
>> return ret;
>> }
>>
>> +static bool is_cacheable_mkey(struct mlx5_ib_mkey mkey)
>
> I think it's better using a pointer as the parameter instead of the struct itself.
Why do you think that a pointer is better that the struct itself? In
kernel doc, is there any rule about this?
Thanks.
Zhu Yanjun
>
> Junxian
>
>> +{
>> + return mkey.cache_ent || mkey.rb_key.ndescs;
>> +}
>> +
>> int mlx5_ib_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
>> {
>> struct mlx5_ib_mr *mr = to_mmr(ibmr);
>> @@ -1901,12 +1906,6 @@ int mlx5_ib_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
>> mr->sig = NULL;
>> }
>>
>> - /* Stop DMA */
>> - if (mr->umem && mlx5r_umr_can_load_pas(dev, mr->umem->length))
>> - if (mlx5r_umr_revoke_mr(mr) ||
>> - cache_ent_find_and_store(dev, mr))
>> - mr->mmkey.cache_ent = NULL;
>> -
>> if (mr->umem && mr->umem->is_peer) {
>> rc = mlx5r_umr_revoke_mr(mr);
>> if (rc)
>> @@ -1914,7 +1913,9 @@ int mlx5_ib_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
>> ib_umem_stop_invalidation_notifier(mr->umem);
>> }
>>
>> - if (!mr->mmkey.cache_ent) {
>> + /* Stop DMA */
>> + if (!is_cacheable_mkey(mr->mmkey) || mlx5r_umr_revoke_mr(mr) ||
>> + cache_ent_find_and_store(dev, mr)) {
>> rc = destroy_mkey(to_mdev(mr->ibmr.device), mr);
>> if (rc)
>> return rc;
next prev parent reply other threads:[~2024-01-25 13:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-25 12:30 [PATCH rdma-next 0/6] Collection of mlx5_ib fixes Leon Romanovsky
2024-01-25 12:30 ` [PATCH rdma-next 1/6] RDMA/mlx5: Fix fortify source warning while accessing Eth segment Leon Romanovsky
2024-01-25 12:30 ` [PATCH rdma-next 2/6] IB/mlx5: Don't expose debugfs entries for RRoCE general parameters if not supported Leon Romanovsky
2024-01-25 12:30 ` [PATCH rdma-next 3/6] RDMA/mlx5: Relax DEVX access upon modify commands Leon Romanovsky
2024-01-25 12:30 ` [PATCH rdma-next 4/6] RDMA/mlx5: Uncacheable mkey has neither rb_key or cache_ent Leon Romanovsky
2024-01-25 12:30 ` [PATCH rdma-next 5/6] RDMA/mlx5: Change check for cacheable user mkeys Leon Romanovsky
2024-01-25 12:52 ` Junxian Huang
2024-01-25 13:30 ` Zhu Yanjun [this message]
2024-01-26 1:47 ` Junxian Huang
2024-01-25 13:38 ` Jason Gunthorpe
2024-01-25 20:02 ` Leon Romanovsky
2024-01-26 2:17 ` Zhu Yanjun
2024-01-25 12:30 ` [PATCH rdma-next 6/6] RDMA/mlx5: Adding remote atomic access flag to updatable flags Leon Romanovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b3ae1ecb-bf03-4a28-b2fa-058540f70180@linux.dev \
--to=yanjun.zhu@linux.dev \
--cc=edwards@nvidia.com \
--cc=huangjunxian6@hisilicon.com \
--cc=jgg@nvidia.com \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=maorg@nvidia.com \
--cc=markzhang@nvidia.com \
--cc=michaelgur@nvidia.com \
--cc=ohartoov@nvidia.com \
--cc=tmashiah@nvidia.com \
--cc=yishaih@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox