* [PATCH rdma-next 0/9] MR cache fixes and refactoring
@ 2020-02-27 12:33 Leon Romanovsky
2020-02-27 12:33 ` [PATCH mlx5-next 1/9] RDMA/mlx5: Move asynchronous mkey creation to mlx5_ib Leon Romanovsky
0 siblings, 1 reply; 5+ messages in thread
From: Leon Romanovsky @ 2020-02-27 12:33 UTC (permalink / raw)
To: Doug Ledford, Jason Gunthorpe
Cc: Leon Romanovsky, Artemy Kovalyov, Eli Cohen, Jack Morgenstein,
linux-rdma, Michael Guralnik, netdev, Or Gerlitz, Saeed Mahameed,
Yishai Hadas
From: Leon Romanovsky <leonro@mellanox.com>
Hi,
This series fixes various corner cases in the mlx5_ib MR
cache implementation, see specific commit messages for more
information.
Thanks
Jason Gunthorpe (8):
RDMA/mlx5: Rename the tracking variables for the MR cache
RDMA/mlx5: Simplify how the MR cache bucket is located
RDMA/mlx5: Always remove MRs from the cache before destroying them
RDMA/mlx5: Fix MR cache size and limit debugfs
RDMA/mlx5: Lock access to ent->available_mrs/limit when doing
queue_work
RDMA/mlx5: Fix locking in MR cache work queue
RDMA/mlx5: Revise how the hysteresis scheme works for cache filling
RDMA/mlx5: Allow MRs to be created in the cache synchronously
Michael Guralnik (1):
RDMA/mlx5: Move asynchronous mkey creation to mlx5_ib
drivers/infiniband/hw/mlx5/mlx5_ib.h | 33 +-
drivers/infiniband/hw/mlx5/mr.c | 642 +++++++++++--------
drivers/infiniband/hw/mlx5/odp.c | 2 +-
drivers/net/ethernet/mellanox/mlx5/core/mr.c | 22 +-
include/linux/mlx5/driver.h | 6 -
5 files changed, 404 insertions(+), 301 deletions(-)
--
2.24.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH mlx5-next 1/9] RDMA/mlx5: Move asynchronous mkey creation to mlx5_ib
2020-02-27 12:33 [PATCH rdma-next 0/9] MR cache fixes and refactoring Leon Romanovsky
@ 2020-02-27 12:33 ` Leon Romanovsky
2020-02-27 19:41 ` Saeed Mahameed
0 siblings, 1 reply; 5+ messages in thread
From: Leon Romanovsky @ 2020-02-27 12:33 UTC (permalink / raw)
To: Doug Ledford, Jason Gunthorpe
Cc: Michael Guralnik, linux-rdma, netdev, Saeed Mahameed
From: Michael Guralnik <michaelgur@mellanox.com>
As mlx5_ib is the only user of the mlx5_core_create_mkey_cb, move the
logic inside mlx5_ib and cleanup the code in mlx5_core.
Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
drivers/infiniband/hw/mlx5/mr.c | 25 ++++++++++++++++----
drivers/net/ethernet/mellanox/mlx5/core/mr.c | 22 +++--------------
include/linux/mlx5/driver.h | 6 -----
3 files changed, 24 insertions(+), 29 deletions(-)
diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
index 6fa0a83c19de..dea14477a676 100644
--- a/drivers/infiniband/hw/mlx5/mr.c
+++ b/drivers/infiniband/hw/mlx5/mr.c
@@ -79,6 +79,25 @@ static bool use_umr_mtt_update(struct mlx5_ib_mr *mr, u64 start, u64 length)
length + (start & (MLX5_ADAPTER_PAGE_SIZE - 1));
}
+static int create_mkey_cb(struct mlx5_core_dev *dev, struct mlx5_ib_mr *mr,
+ struct mlx5_async_ctx *async_ctx, u32 *in, int inlen,
+ mlx5_async_cbk_t callback)
+{
+ void *mkc;
+ u8 key;
+
+ spin_lock_irq(&dev->priv.mkey_lock);
+ key = dev->priv.mkey_key++;
+ spin_unlock_irq(&dev->priv.mkey_lock);
+ mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry);
+
+ MLX5_SET(create_mkey_in, in, opcode, MLX5_CMD_OP_CREATE_MKEY);
+ MLX5_SET(mkc, mkc, mkey_7_0, key);
+
+ return mlx5_cmd_exec_cb(async_ctx, in, inlen, mr->out, sizeof(mr->out),
+ callback, &mr->cb_work);
+}
+
static void reg_mr_callback(int status, struct mlx5_async_work *context)
{
struct mlx5_ib_mr *mr =
@@ -163,10 +182,8 @@ static int add_keys(struct mlx5_ib_dev *dev, int c, int num)
spin_lock_irq(&ent->lock);
ent->pending++;
spin_unlock_irq(&ent->lock);
- err = mlx5_core_create_mkey_cb(dev->mdev, &mr->mmkey,
- &dev->async_ctx, in, inlen,
- mr->out, sizeof(mr->out),
- reg_mr_callback, &mr->cb_work);
+ err = create_mkey_cb(dev->mdev, mr, &dev->async_ctx, in, inlen,
+ reg_mr_callback);
if (err) {
spin_lock_irq(&ent->lock);
ent->pending--;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mr.c b/drivers/net/ethernet/mellanox/mlx5/core/mr.c
index 42cc3c7ac5b6..83841e4119d7 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/mr.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/mr.c
@@ -36,12 +36,9 @@
#include <linux/mlx5/cmd.h>
#include "mlx5_core.h"
-int mlx5_core_create_mkey_cb(struct mlx5_core_dev *dev,
- struct mlx5_core_mkey *mkey,
- struct mlx5_async_ctx *async_ctx, u32 *in,
- int inlen, u32 *out, int outlen,
- mlx5_async_cbk_t callback,
- struct mlx5_async_work *context)
+int mlx5_core_create_mkey(struct mlx5_core_dev *dev,
+ struct mlx5_core_mkey *mkey,
+ u32 *in, int inlen)
{
u32 lout[MLX5_ST_SZ_DW(create_mkey_out)] = {0};
u32 mkey_index;
@@ -57,10 +54,6 @@ int mlx5_core_create_mkey_cb(struct mlx5_core_dev *dev,
MLX5_SET(create_mkey_in, in, opcode, MLX5_CMD_OP_CREATE_MKEY);
MLX5_SET(mkc, mkc, mkey_7_0, key);
- if (callback)
- return mlx5_cmd_exec_cb(async_ctx, in, inlen, out, outlen,
- callback, context);
-
err = mlx5_cmd_exec(dev, in, inlen, lout, sizeof(lout));
if (err)
return err;
@@ -75,15 +68,6 @@ int mlx5_core_create_mkey_cb(struct mlx5_core_dev *dev,
mkey_index, key, mkey->key);
return 0;
}
-EXPORT_SYMBOL(mlx5_core_create_mkey_cb);
-
-int mlx5_core_create_mkey(struct mlx5_core_dev *dev,
- struct mlx5_core_mkey *mkey,
- u32 *in, int inlen)
-{
- return mlx5_core_create_mkey_cb(dev, mkey, NULL, in, inlen,
- NULL, 0, NULL, NULL);
-}
EXPORT_SYMBOL(mlx5_core_create_mkey);
int mlx5_core_destroy_mkey(struct mlx5_core_dev *dev,
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index f2b4225ed650..7225e9ca0f25 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -947,12 +947,6 @@ struct mlx5_cmd_mailbox *mlx5_alloc_cmd_mailbox_chain(struct mlx5_core_dev *dev,
gfp_t flags, int npages);
void mlx5_free_cmd_mailbox_chain(struct mlx5_core_dev *dev,
struct mlx5_cmd_mailbox *head);
-int mlx5_core_create_mkey_cb(struct mlx5_core_dev *dev,
- struct mlx5_core_mkey *mkey,
- struct mlx5_async_ctx *async_ctx, u32 *in,
- int inlen, u32 *out, int outlen,
- mlx5_async_cbk_t callback,
- struct mlx5_async_work *context);
int mlx5_core_create_mkey(struct mlx5_core_dev *dev,
struct mlx5_core_mkey *mkey,
u32 *in, int inlen);
--
2.24.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH mlx5-next 1/9] RDMA/mlx5: Move asynchronous mkey creation to mlx5_ib
2020-02-27 12:33 ` [PATCH mlx5-next 1/9] RDMA/mlx5: Move asynchronous mkey creation to mlx5_ib Leon Romanovsky
@ 2020-02-27 19:41 ` Saeed Mahameed
2020-02-27 20:00 ` Jason Gunthorpe
0 siblings, 1 reply; 5+ messages in thread
From: Saeed Mahameed @ 2020-02-27 19:41 UTC (permalink / raw)
To: Jason Gunthorpe, leon, dledford; +Cc: Michael Guralnik, netdev, linux-rdma
On Thu, 2020-02-27 at 14:33 +0200, Leon Romanovsky wrote:
> From: Michael Guralnik <michaelgur@mellanox.com>
>
> As mlx5_ib is the only user of the mlx5_core_create_mkey_cb, move the
> logic inside mlx5_ib and cleanup the code in mlx5_core.
>
I have a WIP series that is moving the whole mr.c to mlx5_ib.
https://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git/log/?h=topic/mr-relocate
> Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> ---
> drivers/infiniband/hw/mlx5/mr.c | 25 ++++++++++++++++
> ----
> drivers/net/ethernet/mellanox/mlx5/core/mr.c | 22 +++--------------
> include/linux/mlx5/driver.h | 6 -----
> 3 files changed, 24 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mlx5/mr.c
> b/drivers/infiniband/hw/mlx5/mr.c
> index 6fa0a83c19de..dea14477a676 100644
> --- a/drivers/infiniband/hw/mlx5/mr.c
> +++ b/drivers/infiniband/hw/mlx5/mr.c
> @@ -79,6 +79,25 @@ static bool use_umr_mtt_update(struct mlx5_ib_mr
> *mr, u64 start, u64 length)
> length + (start & (MLX5_ADAPTER_PAGE_SIZE - 1));
> }
>
> +static int create_mkey_cb(struct mlx5_core_dev *dev, struct
> mlx5_ib_mr *mr,
> + struct mlx5_async_ctx *async_ctx, u32 *in,
> int inlen,
> + mlx5_async_cbk_t callback)
> +{
> + void *mkc;
> + u8 key;
> +
> + spin_lock_irq(&dev->priv.mkey_lock);
> + key = dev->priv.mkey_key++;
you know i don't like mlx5_ib sniffing around mlx5_core->priv ..
this is handled correctly in my series, i can rebase it and make it
ready in a couple of days.. let me know if this will be good enough for
you.
> + spin_unlock_irq(&dev->priv.mkey_lock);
> + mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry);
> +
> + MLX5_SET(create_mkey_in, in, opcode, MLX5_CMD_OP_CREATE_MKEY);
> + MLX5_SET(mkc, mkc, mkey_7_0, key);
> +
> + return mlx5_cmd_exec_cb(async_ctx, in, inlen, mr->out,
> sizeof(mr->out),
> + callback, &mr->cb_work);
> +}
> +
> static void reg_mr_callback(int status, struct mlx5_async_work
> *context)
> {
> struct mlx5_ib_mr *mr =
> @@ -163,10 +182,8 @@ static int add_keys(struct mlx5_ib_dev *dev, int
> c, int num)
> spin_lock_irq(&ent->lock);
> ent->pending++;
> spin_unlock_irq(&ent->lock);
> - err = mlx5_core_create_mkey_cb(dev->mdev, &mr->mmkey,
> - &dev->async_ctx, in,
> inlen,
> - mr->out, sizeof(mr-
> >out),
> - reg_mr_callback, &mr-
> >cb_work);
> + err = create_mkey_cb(dev->mdev, mr, &dev->async_ctx,
> in, inlen,
> + reg_mr_callback);
> if (err) {
> spin_lock_irq(&ent->lock);
> ent->pending--;
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mr.c
> b/drivers/net/ethernet/mellanox/mlx5/core/mr.c
> index 42cc3c7ac5b6..83841e4119d7 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/mr.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/mr.c
> @@ -36,12 +36,9 @@
> #include <linux/mlx5/cmd.h>
> #include "mlx5_core.h"
>
> -int mlx5_core_create_mkey_cb(struct mlx5_core_dev *dev,
> - struct mlx5_core_mkey *mkey,
> - struct mlx5_async_ctx *async_ctx, u32 *in,
> - int inlen, u32 *out, int outlen,
> - mlx5_async_cbk_t callback,
> - struct mlx5_async_work *context)
> +int mlx5_core_create_mkey(struct mlx5_core_dev *dev,
> + struct mlx5_core_mkey *mkey,
> + u32 *in, int inlen)
> {
> u32 lout[MLX5_ST_SZ_DW(create_mkey_out)] = {0};
> u32 mkey_index;
> @@ -57,10 +54,6 @@ int mlx5_core_create_mkey_cb(struct mlx5_core_dev
> *dev,
> MLX5_SET(create_mkey_in, in, opcode, MLX5_CMD_OP_CREATE_MKEY);
> MLX5_SET(mkc, mkc, mkey_7_0, key);
>
> - if (callback)
> - return mlx5_cmd_exec_cb(async_ctx, in, inlen, out,
> outlen,
> - callback, context);
> -
> err = mlx5_cmd_exec(dev, in, inlen, lout, sizeof(lout));
> if (err)
> return err;
> @@ -75,15 +68,6 @@ int mlx5_core_create_mkey_cb(struct mlx5_core_dev
> *dev,
> mkey_index, key, mkey->key);
> return 0;
> }
> -EXPORT_SYMBOL(mlx5_core_create_mkey_cb);
> -
> -int mlx5_core_create_mkey(struct mlx5_core_dev *dev,
> - struct mlx5_core_mkey *mkey,
> - u32 *in, int inlen)
> -{
> - return mlx5_core_create_mkey_cb(dev, mkey, NULL, in, inlen,
> - NULL, 0, NULL, NULL);
> -}
> EXPORT_SYMBOL(mlx5_core_create_mkey);
>
> int mlx5_core_destroy_mkey(struct mlx5_core_dev *dev,
> diff --git a/include/linux/mlx5/driver.h
> b/include/linux/mlx5/driver.h
> index f2b4225ed650..7225e9ca0f25 100644
> --- a/include/linux/mlx5/driver.h
> +++ b/include/linux/mlx5/driver.h
> @@ -947,12 +947,6 @@ struct mlx5_cmd_mailbox
> *mlx5_alloc_cmd_mailbox_chain(struct mlx5_core_dev *dev,
> gfp_t flags, int
> npages);
> void mlx5_free_cmd_mailbox_chain(struct mlx5_core_dev *dev,
> struct mlx5_cmd_mailbox *head);
> -int mlx5_core_create_mkey_cb(struct mlx5_core_dev *dev,
> - struct mlx5_core_mkey *mkey,
> - struct mlx5_async_ctx *async_ctx, u32 *in,
> - int inlen, u32 *out, int outlen,
> - mlx5_async_cbk_t callback,
> - struct mlx5_async_work *context);
> int mlx5_core_create_mkey(struct mlx5_core_dev *dev,
> struct mlx5_core_mkey *mkey,
> u32 *in, int inlen);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH mlx5-next 1/9] RDMA/mlx5: Move asynchronous mkey creation to mlx5_ib
2020-02-27 19:41 ` Saeed Mahameed
@ 2020-02-27 20:00 ` Jason Gunthorpe
2020-02-27 20:42 ` Saeed Mahameed
0 siblings, 1 reply; 5+ messages in thread
From: Jason Gunthorpe @ 2020-02-27 20:00 UTC (permalink / raw)
To: Saeed Mahameed; +Cc: leon, dledford, Michael Guralnik, netdev, linux-rdma
On Thu, Feb 27, 2020 at 07:41:24PM +0000, Saeed Mahameed wrote:
> On Thu, 2020-02-27 at 14:33 +0200, Leon Romanovsky wrote:
> > From: Michael Guralnik <michaelgur@mellanox.com>
> >
> > As mlx5_ib is the only user of the mlx5_core_create_mkey_cb, move the
> > logic inside mlx5_ib and cleanup the code in mlx5_core.
> >
>
> I have a WIP series that is moving the whole mr.c to mlx5_ib.
> https://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git/log/?h=topic/mr-relocate
>
>
> > Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
> > Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> > drivers/infiniband/hw/mlx5/mr.c | 25 ++++++++++++++++
> > drivers/net/ethernet/mellanox/mlx5/core/mr.c | 22 +++--------------
> > include/linux/mlx5/driver.h | 6 -----
> > 3 files changed, 24 insertions(+), 29 deletions(-)
> >
> > diff --git a/drivers/infiniband/hw/mlx5/mr.c
> > b/drivers/infiniband/hw/mlx5/mr.c
> > index 6fa0a83c19de..dea14477a676 100644
> > +++ b/drivers/infiniband/hw/mlx5/mr.c
> > @@ -79,6 +79,25 @@ static bool use_umr_mtt_update(struct mlx5_ib_mr
> > *mr, u64 start, u64 length)
> > length + (start & (MLX5_ADAPTER_PAGE_SIZE - 1));
> > }
> >
> > +static int create_mkey_cb(struct mlx5_core_dev *dev, struct
> > mlx5_ib_mr *mr,
> > + struct mlx5_async_ctx *async_ctx, u32 *in,
> > int inlen,
> > + mlx5_async_cbk_t callback)
> > +{
> > + void *mkc;
> > + u8 key;
> > +
> > + spin_lock_irq(&dev->priv.mkey_lock);
> > + key = dev->priv.mkey_key++;
>
> you know i don't like mlx5_ib sniffing around mlx5_core->priv ..
>
> this is handled correctly in my series, i can rebase it and make it
> ready in a couple of days.. let me know if this will be good enough for
> you.
How about Michael just take the two relevant patches into this series
{IB,net}/mlx5: Setup mkey variant before mr create command invocation
{IB,net}/mlx5: Assign mkey variant in mlx5_ib only
And this partially moves toward your series. It will be more than a
few days to rebase and check all the parts of your series I think.
Jason
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH mlx5-next 1/9] RDMA/mlx5: Move asynchronous mkey creation to mlx5_ib
2020-02-27 20:00 ` Jason Gunthorpe
@ 2020-02-27 20:42 ` Saeed Mahameed
0 siblings, 0 replies; 5+ messages in thread
From: Saeed Mahameed @ 2020-02-27 20:42 UTC (permalink / raw)
To: Jason Gunthorpe; +Cc: Michael Guralnik, netdev, linux-rdma, leon, dledford
On Thu, 2020-02-27 at 16:00 -0400, Jason Gunthorpe wrote:
> On Thu, Feb 27, 2020 at 07:41:24PM +0000, Saeed Mahameed wrote:
> > On Thu, 2020-02-27 at 14:33 +0200, Leon Romanovsky wrote:
> > > From: Michael Guralnik <michaelgur@mellanox.com>
> > >
> > > As mlx5_ib is the only user of the mlx5_core_create_mkey_cb, move
> > > the
> > > logic inside mlx5_ib and cleanup the code in mlx5_core.
> > >
> >
> > I have a WIP series that is moving the whole mr.c to mlx5_ib.
> > https://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git/log/?h=topic/mr-relocate
> >
> >
> > > Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
> > > Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> > > drivers/infiniband/hw/mlx5/mr.c | 25
> > > ++++++++++++++++
> > > drivers/net/ethernet/mellanox/mlx5/core/mr.c | 22 +++-----------
> > > ---
> > > include/linux/mlx5/driver.h | 6 -----
> > > 3 files changed, 24 insertions(+), 29 deletions(-)
> > >
> > > diff --git a/drivers/infiniband/hw/mlx5/mr.c
> > > b/drivers/infiniband/hw/mlx5/mr.c
> > > index 6fa0a83c19de..dea14477a676 100644
> > > +++ b/drivers/infiniband/hw/mlx5/mr.c
> > > @@ -79,6 +79,25 @@ static bool use_umr_mtt_update(struct
> > > mlx5_ib_mr
> > > *mr, u64 start, u64 length)
> > > length + (start & (MLX5_ADAPTER_PAGE_SIZE - 1));
> > > }
> > >
> > > +static int create_mkey_cb(struct mlx5_core_dev *dev, struct
> > > mlx5_ib_mr *mr,
> > > + struct mlx5_async_ctx *async_ctx, u32 *in,
> > > int inlen,
> > > + mlx5_async_cbk_t callback)
> > > +{
> > > + void *mkc;
> > > + u8 key;
> > > +
> > > + spin_lock_irq(&dev->priv.mkey_lock);
> > > + key = dev->priv.mkey_key++;
> >
> > you know i don't like mlx5_ib sniffing around mlx5_core->priv ..
> >
> > this is handled correctly in my series, i can rebase it and make it
> > ready in a couple of days.. let me know if this will be good enough
> > for
> > you.
>
> How about Michael just take the two relevant patches into this series
>
> {IB,net}/mlx5: Setup mkey variant before mr create command invocation
> {IB,net}/mlx5: Assign mkey variant in mlx5_ib only
>
Also, IB/mlx5: Replace spinlock protected write with atomic var
it is a good one :)
> And this partially moves toward your series. It will be more than a
> few days to rebase and check all the parts of your series I think.
Okay.
-Saeed.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-02-27 20:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-27 12:33 [PATCH rdma-next 0/9] MR cache fixes and refactoring Leon Romanovsky
2020-02-27 12:33 ` [PATCH mlx5-next 1/9] RDMA/mlx5: Move asynchronous mkey creation to mlx5_ib Leon Romanovsky
2020-02-27 19:41 ` Saeed Mahameed
2020-02-27 20:00 ` Jason Gunthorpe
2020-02-27 20:42 ` Saeed Mahameed
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).