Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1235364 > unrolled thread

[PATCH] misc/genwqe: get rid of atomic allocations

Started bySebastian Ott <sebott@linux.vnet.ibm.com>
First post2015-09-29 18:30 +0200
Last post2015-09-30 11:30 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] misc/genwqe: get rid of atomic allocations Sebastian Ott <sebott@linux.vnet.ibm.com> - 2015-09-29 18:30 +0200
    Re: [PATCH] misc/genwqe: get rid of atomic allocations Frank Haverkamp <haver@linux.vnet.ibm.com> - 2015-09-30 11:30 +0200

#1235364 — [PATCH] misc/genwqe: get rid of atomic allocations

FromSebastian Ott <sebott@linux.vnet.ibm.com>
Date2015-09-29 18:30 +0200
Subject[PATCH] misc/genwqe: get rid of atomic allocations
Message-ID<qe5WW-3k4-17@gated-at.bofh.it>
Hi,

we received reports of failed allocations in genwqe code:

[  733.550955] genwqe_gzip: page allocation failure: order:1, mode:0x20
[  733.550964] CPU: 2 PID: 1846 Comm: genwqe_gzip Not tainted 4.3.0-rc3-00042-g3225031 #78
[  733.550968]        000000002782b830 000000002782b8c0 0000000000000002 0000000000000000
       000000002782b960 000000002782b8d8 000000002782b8d8 00000000001134a0
       0000000000000000 0000000000892b2a 0000000000871d0a 000000000000000b
       000000002782b920 000000002782b8c0 0000000000000000 0000000000000000
       0000000000000000 00000000001134a0 000000002782b8c0 000000002782b920
[  733.551003] Call Trace:
[  733.551013] ([<0000000000113388>] show_trace+0xf8/0x158)
[  733.551018]  [<0000000000113452>] show_stack+0x6a/0xe8
[  733.551024]  [<00000000004611d4>] dump_stack+0x7c/0xd8
[  733.551031]  [<000000000024dc22>] warn_alloc_failed+0xda/0x150
[  733.551036]  [<000000000025268e>] __alloc_pages_nodemask+0x94e/0xbc0
[  733.551041]  [<000000000012bcd8>] s390_dma_alloc+0x70/0x1a0
[  733.551054]  [<000003ff804d8e8c>] __genwqe_alloc_consistent+0x84/0xd0 [genwqe_card]
[  733.551063]  [<000003ff804d90c2>] genwqe_alloc_sync_sgl+0x13a/0x328 [genwqe_card]
[  733.551066]  [<000003ff804d41a0>] do_execute_ddcb+0x1f8/0x388 [genwqe_card]
[  733.551069]  [<000003ff804d48c8>] genwqe_ioctl+0x598/0xd50 [genwqe_card]
[  733.551072]  [<00000000002cc90c>] do_vfs_ioctl+0x3f4/0x590
[  733.551074]  [<00000000002ccb46>] SyS_ioctl+0x9e/0xb0
[  733.551078]  [<00000000006c8166>] system_call+0xd6/0x258
[  733.551080]  [<000003fffd25819a>] 0x3fffd25819a
[  733.551082] no locks held by genwqe_gzip/1846.

This specific allocation and some others in genwqe are unnecessary flagged
as atomic.

Regards,
Sebastian
---->8
misc/genwqe: get rid of atomic allocations

All of genwqe's atomic allocations happen in a context where it's allowed
to sleep. Change these to use GFP_KERNEL.

Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
---
 drivers/misc/genwqe/card_ddcb.c  |    2 +-
 drivers/misc/genwqe/card_dev.c   |    4 ++--
 drivers/misc/genwqe/card_utils.c |    5 +++--
 3 files changed, 6 insertions(+), 5 deletions(-)

--- a/drivers/misc/genwqe/card_ddcb.c
+++ b/drivers/misc/genwqe/card_ddcb.c
@@ -203,7 +203,7 @@ struct genwqe_ddcb_cmd *ddcb_requ_alloc(
 {
 	struct ddcb_requ *req;
 
-	req = kzalloc(sizeof(*req), GFP_ATOMIC);
+	req = kzalloc(sizeof(*req), GFP_KERNEL);
 	if (!req)
 		return NULL;
 
--- a/drivers/misc/genwqe/card_dev.c
+++ b/drivers/misc/genwqe/card_dev.c
@@ -449,7 +449,7 @@ static int genwqe_mmap(struct file *filp
 	if (get_order(vsize) > MAX_ORDER)
 		return -ENOMEM;
 
-	dma_map = kzalloc(sizeof(struct dma_mapping), GFP_ATOMIC);
+	dma_map = kzalloc(sizeof(struct dma_mapping), GFP_KERNEL);
 	if (dma_map == NULL)
 		return -ENOMEM;
 
@@ -785,7 +785,7 @@ static int genwqe_pin_mem(struct genwqe_
 	map_addr = (m->addr & PAGE_MASK);
 	map_size = round_up(m->size + (m->addr & ~PAGE_MASK), PAGE_SIZE);
 
-	dma_map = kzalloc(sizeof(struct dma_mapping), GFP_ATOMIC);
+	dma_map = kzalloc(sizeof(struct dma_mapping), GFP_KERNEL);
 	if (dma_map == NULL)
 		return -ENOMEM;
 
--- a/drivers/misc/genwqe/card_utils.c
+++ b/drivers/misc/genwqe/card_utils.c
@@ -220,7 +220,8 @@ void *__genwqe_alloc_consistent(struct g
 	if (get_order(size) > MAX_ORDER)
 		return NULL;
 
-	return pci_alloc_consistent(cd->pci_dev, size, dma_handle);
+	return dma_alloc_coherent(&cd->pci_dev->dev, size, dma_handle,
+				  GFP_KERNEL);
 }
 
 void __genwqe_free_consistent(struct genwqe_dev *cd, size_t size,
@@ -229,7 +230,7 @@ void __genwqe_free_consistent(struct gen
 	if (vaddr == NULL)
 		return;
 
-	pci_free_consistent(cd->pci_dev, size, vaddr, dma_handle);
+	dma_free_coherent(&cd->pci_dev->dev, size, vaddr, dma_handle);
 }
 
 static void genwqe_unmap_pages(struct genwqe_dev *cd, dma_addr_t *dma_list,

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1235934

FromFrank Haverkamp <haver@linux.vnet.ibm.com>
Date2015-09-30 11:30 +0200
Message-ID<qelS3-Ol-19@gated-at.bofh.it>
In reply to#1235364
Hi Sebastian,

thanks for reporting this and sending the fix.

Am Dienstag, den 29.09.2015, 18:23 +0200 schrieb Sebastian Ott:
> Hi,
> 
> we received reports of failed allocations in genwqe code:
> 
> [  733.550955] genwqe_gzip: page allocation failure: order:1, mode:0x20
> [  733.550964] CPU: 2 PID: 1846 Comm: genwqe_gzip Not tainted 4.3.0-rc3-00042-g3225031 #78
> [  733.550968]        000000002782b830 000000002782b8c0 0000000000000002 0000000000000000
>        000000002782b960 000000002782b8d8 000000002782b8d8 00000000001134a0
>        0000000000000000 0000000000892b2a 0000000000871d0a 000000000000000b
>        000000002782b920 000000002782b8c0 0000000000000000 0000000000000000
>        0000000000000000 00000000001134a0 000000002782b8c0 000000002782b920
> [  733.551003] Call Trace:
> [  733.551013] ([<0000000000113388>] show_trace+0xf8/0x158)
> [  733.551018]  [<0000000000113452>] show_stack+0x6a/0xe8
> [  733.551024]  [<00000000004611d4>] dump_stack+0x7c/0xd8
> [  733.551031]  [<000000000024dc22>] warn_alloc_failed+0xda/0x150
> [  733.551036]  [<000000000025268e>] __alloc_pages_nodemask+0x94e/0xbc0
> [  733.551041]  [<000000000012bcd8>] s390_dma_alloc+0x70/0x1a0
> [  733.551054]  [<000003ff804d8e8c>] __genwqe_alloc_consistent+0x84/0xd0 [genwqe_card]
> [  733.551063]  [<000003ff804d90c2>] genwqe_alloc_sync_sgl+0x13a/0x328 [genwqe_card]
> [  733.551066]  [<000003ff804d41a0>] do_execute_ddcb+0x1f8/0x388 [genwqe_card]
> [  733.551069]  [<000003ff804d48c8>] genwqe_ioctl+0x598/0xd50 [genwqe_card]
> [  733.551072]  [<00000000002cc90c>] do_vfs_ioctl+0x3f4/0x590
> [  733.551074]  [<00000000002ccb46>] SyS_ioctl+0x9e/0xb0
> [  733.551078]  [<00000000006c8166>] system_call+0xd6/0x258
> [  733.551080]  [<000003fffd25819a>] 0x3fffd25819a
> [  733.551082] no locks held by genwqe_gzip/1846.
> 
> This specific allocation and some others in genwqe are unnecessary flagged
> as atomic.
> 
> Regards,
> Sebastian
> ---->8
> misc/genwqe: get rid of atomic allocations
> 
> All of genwqe's atomic allocations happen in a context where it's allowed
> to sleep. Change these to use GFP_KERNEL.
> 
> Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
> ---
>  drivers/misc/genwqe/card_ddcb.c  |    2 +-
>  drivers/misc/genwqe/card_dev.c   |    4 ++--
>  drivers/misc/genwqe/card_utils.c |    5 +++--
>  3 files changed, 6 insertions(+), 5 deletions(-)
> 
> --- a/drivers/misc/genwqe/card_ddcb.c
> +++ b/drivers/misc/genwqe/card_ddcb.c
> @@ -203,7 +203,7 @@ struct genwqe_ddcb_cmd *ddcb_requ_alloc(
>  {
>  	struct ddcb_requ *req;
> 
> -	req = kzalloc(sizeof(*req), GFP_ATOMIC);
> +	req = kzalloc(sizeof(*req), GFP_KERNEL);
>  	if (!req)
>  		return NULL;
> 
> --- a/drivers/misc/genwqe/card_dev.c
> +++ b/drivers/misc/genwqe/card_dev.c
> @@ -449,7 +449,7 @@ static int genwqe_mmap(struct file *filp
>  	if (get_order(vsize) > MAX_ORDER)
>  		return -ENOMEM;
> 
> -	dma_map = kzalloc(sizeof(struct dma_mapping), GFP_ATOMIC);
> +	dma_map = kzalloc(sizeof(struct dma_mapping), GFP_KERNEL);
>  	if (dma_map == NULL)
>  		return -ENOMEM;
> 
> @@ -785,7 +785,7 @@ static int genwqe_pin_mem(struct genwqe_
>  	map_addr = (m->addr & PAGE_MASK);
>  	map_size = round_up(m->size + (m->addr & ~PAGE_MASK), PAGE_SIZE);
> 
> -	dma_map = kzalloc(sizeof(struct dma_mapping), GFP_ATOMIC);
> +	dma_map = kzalloc(sizeof(struct dma_mapping), GFP_KERNEL);
>  	if (dma_map == NULL)
>  		return -ENOMEM;
> 
> --- a/drivers/misc/genwqe/card_utils.c
> +++ b/drivers/misc/genwqe/card_utils.c
> @@ -220,7 +220,8 @@ void *__genwqe_alloc_consistent(struct g
>  	if (get_order(size) > MAX_ORDER)
>  		return NULL;
> 
> -	return pci_alloc_consistent(cd->pci_dev, size, dma_handle);
> +	return dma_alloc_coherent(&cd->pci_dev->dev, size, dma_handle,
> +				  GFP_KERNEL);
>  }
> 
>  void __genwqe_free_consistent(struct genwqe_dev *cd, size_t size,
> @@ -229,7 +230,7 @@ void __genwqe_free_consistent(struct gen
>  	if (vaddr == NULL)
>  		return;
> 
> -	pci_free_consistent(cd->pci_dev, size, vaddr, dma_handle);
> +	dma_free_coherent(&cd->pci_dev->dev, size, vaddr, dma_handle);
>  }
> 
>  static void genwqe_unmap_pages(struct genwqe_dev *cd, dma_addr_t *dma_list,

We tried this out in our test-lab and it worked fine for us.

Acked-by: Frank Haverkamp <haver@linux.vnet.ibm.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web