All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme-pci: another 64-bit division for the host memory buffer code
@ 2017-06-13 15:31 Christoph Hellwig
  2017-06-15  8:55 ` Sagi Grimberg
  2017-06-15 17:04 ` Keith Busch
  0 siblings, 2 replies; 4+ messages in thread
From: Christoph Hellwig @ 2017-06-13 15:31 UTC (permalink / raw)


[to be folded into "nvme-pci: implement host memory buffer support"]

Signed-off-by: Christoph Hellwig <hch at lst.de>

---

Now tested with a full i386 build, sigh..
---
 drivers/nvme/host/pci.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 788bb2c479d0..4b50fef1fa1b 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1591,12 +1591,14 @@ static int nvme_alloc_host_mem(struct nvme_dev *dev, u64 min, u64 preferred)
 	struct nvme_host_mem_buf_desc *descs;
 	u32 chunk_size, max_entries, i = 0;
 	void **bufs;
-	u64 size;
+	u64 size, tmp;
 
 	/* start big and work our way down */
 	chunk_size = min(preferred, (u64)PAGE_SIZE << MAX_ORDER);
 retry:
-	max_entries = DIV_ROUND_UP(preferred, chunk_size);
+	tmp = (preferred + chunk_size - 1);
+	do_div(tmp, chunk_size);
+	max_entries = tmp;
 	descs = kcalloc(max_entries, sizeof(*descs), GFP_KERNEL);
 	if (!descs)
 		goto out;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] nvme-pci: another 64-bit division for the host memory buffer code
  2017-06-13 15:31 [PATCH] nvme-pci: another 64-bit division for the host memory buffer code Christoph Hellwig
@ 2017-06-15  8:55 ` Sagi Grimberg
  2017-06-15 12:10   ` Christoph Hellwig
  2017-06-15 17:04 ` Keith Busch
  1 sibling, 1 reply; 4+ messages in thread
From: Sagi Grimberg @ 2017-06-15  8:55 UTC (permalink / raw)


This looks fine, but is there a good reason why
shouldn't DIV_ROUND_UP take care of that instead of you
open-coding it?

Reviewed-by: Sagi Grimberg <sagi at rimberg.me>

On 13/06/17 18:31, Christoph Hellwig wrote:
> [to be folded into "nvme-pci: implement host memory buffer support"]
> 
> Signed-off-by: Christoph Hellwig <hch at lst.de>
> 
> ---
> 
> Now tested with a full i386 build, sigh..
> ---
>   drivers/nvme/host/pci.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index 788bb2c479d0..4b50fef1fa1b 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -1591,12 +1591,14 @@ static int nvme_alloc_host_mem(struct nvme_dev *dev, u64 min, u64 preferred)
>   	struct nvme_host_mem_buf_desc *descs;
>   	u32 chunk_size, max_entries, i = 0;
>   	void **bufs;
> -	u64 size;
> +	u64 size, tmp;
>   
>   	/* start big and work our way down */
>   	chunk_size = min(preferred, (u64)PAGE_SIZE << MAX_ORDER);
>   retry:
> -	max_entries = DIV_ROUND_UP(preferred, chunk_size);
> +	tmp = (preferred + chunk_size - 1);
> +	do_div(tmp, chunk_size);
> +	max_entries = tmp;
>   	descs = kcalloc(max_entries, sizeof(*descs), GFP_KERNEL);
>   	if (!descs)
>   		goto out;
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] nvme-pci: another 64-bit division for the host memory buffer code
  2017-06-15  8:55 ` Sagi Grimberg
@ 2017-06-15 12:10   ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2017-06-15 12:10 UTC (permalink / raw)


On Thu, Jun 15, 2017@11:55:28AM +0300, Sagi Grimberg wrote:
> This looks fine, but is there a good reason why
> shouldn't DIV_ROUND_UP take care of that instead of you
> open-coding it?

Because it uses a plain division, and Linux on most 32-bit architectures
doesn't support that, as Linus doesn't want the required libgcc helpers
in the kernel.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] nvme-pci: another 64-bit division for the host memory buffer code
  2017-06-13 15:31 [PATCH] nvme-pci: another 64-bit division for the host memory buffer code Christoph Hellwig
  2017-06-15  8:55 ` Sagi Grimberg
@ 2017-06-15 17:04 ` Keith Busch
  1 sibling, 0 replies; 4+ messages in thread
From: Keith Busch @ 2017-06-15 17:04 UTC (permalink / raw)


Looks fine.

Reviewed-by: Keith Busch <keith.busch at intel.com>

On Tue, Jun 13, 2017@05:31:30PM +0200, Christoph Hellwig wrote:
> [to be folded into "nvme-pci: implement host memory buffer support"]
> 
> Signed-off-by: Christoph Hellwig <hch at lst.de>
> 
> ---
> 
> Now tested with a full i386 build, sigh..
> ---
>  drivers/nvme/host/pci.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index 788bb2c479d0..4b50fef1fa1b 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -1591,12 +1591,14 @@ static int nvme_alloc_host_mem(struct nvme_dev *dev, u64 min, u64 preferred)
>  	struct nvme_host_mem_buf_desc *descs;
>  	u32 chunk_size, max_entries, i = 0;
>  	void **bufs;
> -	u64 size;
> +	u64 size, tmp;
>  
>  	/* start big and work our way down */
>  	chunk_size = min(preferred, (u64)PAGE_SIZE << MAX_ORDER);
>  retry:
> -	max_entries = DIV_ROUND_UP(preferred, chunk_size);
> +	tmp = (preferred + chunk_size - 1);
> +	do_div(tmp, chunk_size);
> +	max_entries = tmp;
>  	descs = kcalloc(max_entries, sizeof(*descs), GFP_KERNEL);
>  	if (!descs)
>  		goto out;
> -- 
> 2.11.0
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-06-15 17:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-13 15:31 [PATCH] nvme-pci: another 64-bit division for the host memory buffer code Christoph Hellwig
2017-06-15  8:55 ` Sagi Grimberg
2017-06-15 12:10   ` Christoph Hellwig
2017-06-15 17:04 ` Keith Busch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.