public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Chuck Lever <chuck.lever-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Linux NFS Mailing List
	<linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH v2 01/24] mlx4-ib: Use coherent memory for priv pages
Date: Thu, 16 Jun 2016 17:35:18 +0300	[thread overview]
Message-ID: <20160616143518.GX5408@leon.nu> (raw)
In-Reply-To: <68F7CD80-0092-4B55-9FAD-4C54D284BCA3-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 1312 bytes --]

On Wed, Jun 15, 2016 at 12:40:07PM -0400, Chuck Lever wrote:
> 
> > On Jun 15, 2016, at 12:28 AM, Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
> > 
> > On Tue, Jun 14, 2016 at 11:15:25PM -0400, Chuck Lever wrote:
> >> From: Sagi Grimberg <sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
> >> 
> >> kmalloc doesn't guarantee the returned memory is all on one page.
> > 
> > IMHO, the patch posted by Christoph at that thread is best way to go,
> > because you changed streaming DMA mappings to be coherent DMA mappings [1].
> > 
> > "The kernel developers recommend the use of streaming mappings over
> > coherent mappings whenever possible" [1].
> > 
> > [1] http://www.makelinux.net/ldd3/chp-15-sect-4
> 
> Hi Leon-
> 
> I'll happily drop this patch from my 4.8 series as soon
> as an official mlx4/mlx5 fix is merged.
> 
> Meanwhile, I notice some unexplained instability (driver
> resets, list corruption, and so on) when I test NFS/RDMA
> without this patch included. So it is attached to the
> series for anyone with mlx4 who wants to pull my topic
> branch and try it out.

hi Chuck,

We plan to send attached patch during our second round of fixes for
mlx4/mlx5 and would be grateful to you if you could provide your
Tested-by tag before.

Thanks

[-- Attachment #1.2: 213f61b4.diff --]
[-- Type: text/x-diff, Size: 2929 bytes --]

From 213f61b44b54edbcbf272e694e889c61412be579 Mon Sep 17 00:00:00 2001
From: Yishai Hadas <yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Date: Thu, 16 Jun 2016 11:13:41 +0300
Subject: [PATCH] IB/mlx4: Ensure cache line boundaries for dma_map_single

"In order for memory mapped by this API to operate
correctly, the mapped region must begin exactly on a cache line
boundary and end exactly on one (to prevent two separately mapped
regions from sharing a single cache line).
Therefore, it is recommended that driver writers who
don't take special care to determine the cache line size at run time
only map virtual regions that begin and end on page boundaries (which
are guaranteed also to be cache line boundaries)." [1]

This patch uses __get_free_pages instead of kzalloc
to be sure that above will be true in all ARCHs and in all
SLUBs debug configurations.

[1] https://www.kernel.org/doc/Documentation/DMA-API.txt

issue: 802618
Change-Id: Iee8176b183290213b1b4e66f1835f5c90f067075
Fixes: 1b2cd0fc673c ('IB/mlx4: Support the new memory registration API')
Reported-by: Chuck Lever <chuck.lever-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Christoph Hellwig <hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
Signed-off-by: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Signed-off-by: Yishai Hadas <yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---

diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index 6c5ac5d..4a8bbe4 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -139,7 +139,6 @@
 	u32			max_pages;
 	struct mlx4_mr		mmr;
 	struct ib_umem	       *umem;
-	void			*pages_alloc;
 };
 
 struct mlx4_ib_mw {
diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c
index 6312721..56b8d87 100644
--- a/drivers/infiniband/hw/mlx4/mr.c
+++ b/drivers/infiniband/hw/mlx4/mr.c
@@ -278,16 +278,12 @@
 		      int max_pages)
 {
 	int size = max_pages * sizeof(u64);
-	int add_size;
 	int ret;
 
-	add_size = max_t(int, MLX4_MR_PAGES_ALIGN - ARCH_KMALLOC_MINALIGN, 0);
-
-	mr->pages_alloc = kzalloc(size + add_size, GFP_KERNEL);
-	if (!mr->pages_alloc)
+	mr->pages = (__be64 *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
+					       get_order(size));
+	if (!mr->pages)
 		return -ENOMEM;
-
-	mr->pages = PTR_ALIGN(mr->pages_alloc, MLX4_MR_PAGES_ALIGN);
 
 	mr->page_map = dma_map_single(device->dma_device, mr->pages,
 				      size, DMA_TO_DEVICE);
@@ -299,7 +295,7 @@
 
 	return 0;
 err:
-	kfree(mr->pages_alloc);
+	free_pages((unsigned long)mr->pages, get_order(size));
 
 	return ret;
 }
@@ -313,7 +309,7 @@
 
 		dma_unmap_single(device->dma_device, mr->page_map,
 				 size, DMA_TO_DEVICE);
-		kfree(mr->pages_alloc);
+		free_pages((unsigned long)mr->pages, get_order(size));
 		mr->pages = NULL;
 	}
 }

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2016-06-16 14:35 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-15  3:15 [PATCH v2 00/24] NFS/RDMA client patches proposed for v4.8 Chuck Lever
     [not found] ` <20160615030626.14794.43805.stgit-FYjufvaPoItvLzlybtyyYzGyq/o6K9yX@public.gmane.org>
2016-06-15  3:15   ` [PATCH v2 01/24] mlx4-ib: Use coherent memory for priv pages Chuck Lever
     [not found]     ` <20160615031525.14794.69066.stgit-FYjufvaPoItvLzlybtyyYzGyq/o6K9yX@public.gmane.org>
2016-06-15  4:28       ` Leon Romanovsky
     [not found]         ` <20160615042849.GR5408-2ukJVAZIZ/Y@public.gmane.org>
2016-06-15 16:40           ` Chuck Lever
     [not found]             ` <68F7CD80-0092-4B55-9FAD-4C54D284BCA3-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-06-16 14:35               ` Leon Romanovsky [this message]
     [not found]                 ` <20160616143518.GX5408-2ukJVAZIZ/Y@public.gmane.org>
2016-06-16 21:10                   ` Sagi Grimberg
     [not found]                     ` <576315C9.30002-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-06-16 21:58                       ` Chuck Lever
     [not found]                         ` <652EBA09-2978-414C-8606-38A96C63365A-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-06-17  9:20                           ` Leon Romanovsky
     [not found]                             ` <20160617092018.GZ5408-2ukJVAZIZ/Y@public.gmane.org>
2016-06-17 19:55                               ` Chuck Lever
     [not found]                                 ` <4D23496A-FE01-4693-B125-82CD03B8F2D4-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-06-18 10:56                                   ` Leon Romanovsky
     [not found]                                     ` <20160618105650.GD5408-2ukJVAZIZ/Y@public.gmane.org>
2016-06-18 20:08                                       ` Chuck Lever
     [not found]                                         ` <5D0A6B47-CB71-42DA-AE76-164B6A660ECC-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-06-19 10:04                                           ` Sagi Grimberg
     [not found]                                             ` <57666E14.2070802-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-06-19 19:38                                               ` Or Gerlitz
     [not found]                                                 ` <CAJ3xEMha=i5SaM+fV5XP15Fx6pymrYnvk=a8w+3h1cbBeuVX0A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-06-19 19:43                                                   ` Or Gerlitz
2016-06-19 20:02                                                   ` Chuck Lever
     [not found]                                                     ` <B62EEE84-454D-4D55-9C7E-653F564DF381-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-06-20  5:44                                                       ` Leon Romanovsky
     [not found]                                                         ` <20160620054453.GA1172-2ukJVAZIZ/Y@public.gmane.org>
2016-06-20  6:34                                                           ` Sagi Grimberg
     [not found]                                                             ` <57678E74.1070308-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2016-06-20  7:01                                                               ` Leon Romanovsky
     [not found]                                                                 ` <20160620070141.GD1172-2ukJVAZIZ/Y@public.gmane.org>
2016-06-20  8:35                                                                   ` Sagi Grimberg
2016-06-20 13:41                                                           ` Yishai Hadas
     [not found]                                                             ` <12ee28bb-b838-ed4c-5f84-0cb8f1760d63-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2016-06-21 13:56                                                               ` Sagi Grimberg
     [not found]                                                                 ` <5769479C.8070605-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-06-21 14:35                                                                   ` Laurence Oberman
2016-06-19  9:58                                   ` Sagi Grimberg
2016-06-19  9:48                           ` Sagi Grimberg
2016-06-17  9:05                       ` Leon Romanovsky
     [not found]                         ` <20160617090541.GY5408-2ukJVAZIZ/Y@public.gmane.org>
2016-06-19  7:05                           ` Sagi Grimberg
2016-06-15  3:15   ` [PATCH v2 02/24] xprtrdma: Remove FMRs from the unmap list after unmapping Chuck Lever
2016-06-15  3:15   ` [PATCH v2 03/24] xprtrdma: Create common scatterlist fields in rpcrdma_mw Chuck Lever
2016-06-15  3:15   ` [PATCH v2 04/24] xprtrdma: Move init and release helpers Chuck Lever
2016-06-15  3:15   ` [PATCH v2 05/24] xprtrdma: Rename fields in rpcrdma_fmr Chuck Lever
2016-06-15  3:16   ` [PATCH v2 06/24] xprtrdma: Use scatterlist for DMA mapping and unmapping under FMR Chuck Lever
2016-06-15  3:16   ` [PATCH v2 07/24] xprtrdma: Refactor MR recovery work queues Chuck Lever
2016-06-15  3:16   ` [PATCH v2 08/24] xprtrdma: Do not leak an MW during a DMA map failure Chuck Lever
2016-06-15  3:16   ` [PATCH v2 09/24] xprtrdma: Remove ALLPHYSICAL memory registration mode Chuck Lever
2016-06-15  3:16   ` [PATCH v2 10/24] xprtrdma: Remove rpcrdma_map_one() and friends Chuck Lever
2016-06-15  3:16   ` [PATCH v2 11/24] xprtrdma: Reply buffer exhaustion can be catastrophic Chuck Lever
2016-06-15  3:16   ` [PATCH v2 12/24] xprtrdma: Honor ->send_request API contract Chuck Lever
2016-06-15  3:17   ` [PATCH v2 13/24] xprtrdma: Chunk list encoders must not return zero Chuck Lever
2016-06-15  3:17   ` [PATCH v2 14/24] xprtrdma: Allocate MRs on demand Chuck Lever
2016-06-15  3:17   ` [PATCH v2 15/24] xprtrdma: Release orphaned MRs immediately Chuck Lever
2016-06-15  3:17   ` [PATCH v2 16/24] xprtrdma: Place registered MWs on a per-req list Chuck Lever
2016-06-15  3:17   ` [PATCH v2 17/24] xprtrdma: Chunk list encoders no longer share one rl_segments array Chuck Lever
2016-06-15  3:17   ` [PATCH v2 18/24] xprtrdma: rpcrdma_inline_fixup() overruns the receive page list Chuck Lever
2016-06-15  3:17   ` [PATCH v2 19/24] xprtrdma: Do not update {head, tail}.iov_len in rpcrdma_inline_fixup() Chuck Lever
2016-06-15  3:18   ` [PATCH v2 20/24] xprtrdma: Update only specific fields in private receive buffer Chuck Lever
2016-06-15  3:18   ` [PATCH v2 21/24] xprtrdma: Clean up fixup_copy_count accounting Chuck Lever
2016-06-15  3:18   ` [PATCH v2 22/24] xprtrdma: No direct data placement with krb5i and krb5p Chuck Lever
2016-06-15  3:18   ` [PATCH v2 23/24] svc: Avoid garbage replies when pc_func() returns rpc_drop_reply Chuck Lever
2016-06-15  3:18   ` [PATCH v2 24/24] NFS: Don't drop CB requests with invalid principals Chuck Lever

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=20160616143518.GX5408@leon.nu \
    --to=leon-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=chuck.lever-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /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