All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3.16, 4.4, 4.9] dm bufio: drop the lock when doing GFP_NOIO allocation
@ 2018-07-04 14:39 Mikulas Patocka
  2018-07-10 14:16 ` Greg Kroah-Hartman
  2018-11-10 23:15 ` Ben Hutchings
  0 siblings, 2 replies; 3+ messages in thread
From: Mikulas Patocka @ 2018-07-04 14:39 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Ben Hutchings, stable
  Cc: jing xia, David Rientjes, Guenter Roeck, Douglas Anderson, Mike Snitzer

This is backport of the upstream patch 
41c73a49df31151f4ff868f28fe4f129f113fa2c. It should be backported to 
stable kernels because this performance problem was seen on the android 
4.4 kernel.


commit 41c73a49df31151f4ff868f28fe4f129f113fa2c
Author: Mikulas Patocka <mpatocka@redhat.com>
Date:   Wed Nov 23 17:04:00 2016 -0500

    dm bufio: drop the lock when doing GFP_NOIO allocation
    
    If the first allocation attempt using GFP_NOWAIT fails, drop the lock
    and retry using GFP_NOIO allocation (lock is dropped because the
    allocation can take some time).
    
    Note that we won't do GFP_NOIO allocation when we loop for the second
    time, because the lock shouldn't be dropped between __wait_for_free_buffer
    and __get_unclaimed_buffer.
    
    Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
    Signed-off-by: Mike Snitzer <snitzer@redhat.com>

diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
index 9ef88f0e2382..1c2e1dd7ca16 100644
--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -822,6 +822,7 @@ enum new_flag {
 static struct dm_buffer *__alloc_buffer_wait_no_callback(struct dm_bufio_client *c, enum new_flag nf)
 {
 	struct dm_buffer *b;
+	bool tried_noio_alloc = false;
 
 	/*
 	 * dm-bufio is resistant to allocation failures (it just keeps
@@ -846,6 +847,15 @@ static struct dm_buffer *__alloc_buffer_wait_no_callback(struct dm_bufio_client
 		if (nf == NF_PREFETCH)
 			return NULL;
 
+		if (dm_bufio_cache_size_latch != 1 && !tried_noio_alloc) {
+			dm_bufio_unlock(c);
+			b = alloc_buffer(c, GFP_NOIO | __GFP_NORETRY | __GFP_NOMEMALLOC | __GFP_NOWARN);
+			dm_bufio_lock(c);
+			if (b)
+				return b;
+			tried_noio_alloc = true;
+		}
+
 		if (!list_empty(&c->reserved_buffers)) {
 			b = list_entry(c->reserved_buffers.next,
 				       struct dm_buffer, lru_list);

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

* Re: [PATCH 3.16, 4.4, 4.9] dm bufio: drop the lock when doing GFP_NOIO allocation
  2018-07-04 14:39 [PATCH 3.16, 4.4, 4.9] dm bufio: drop the lock when doing GFP_NOIO allocation Mikulas Patocka
@ 2018-07-10 14:16 ` Greg Kroah-Hartman
  2018-11-10 23:15 ` Ben Hutchings
  1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2018-07-10 14:16 UTC (permalink / raw)
  To: Mikulas Patocka
  Cc: Ben Hutchings, stable, jing xia, David Rientjes, Guenter Roeck,
	Douglas Anderson, Mike Snitzer

On Wed, Jul 04, 2018 at 10:39:40AM -0400, Mikulas Patocka wrote:
> This is backport of the upstream patch 
> 41c73a49df31151f4ff868f28fe4f129f113fa2c. It should be backported to 
> stable kernels because this performance problem was seen on the android 
> 4.4 kernel.

Now applied, thanks.

greg k-h

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

* Re: [PATCH 3.16, 4.4, 4.9] dm bufio: drop the lock when doing GFP_NOIO allocation
  2018-07-04 14:39 [PATCH 3.16, 4.4, 4.9] dm bufio: drop the lock when doing GFP_NOIO allocation Mikulas Patocka
  2018-07-10 14:16 ` Greg Kroah-Hartman
@ 2018-11-10 23:15 ` Ben Hutchings
  1 sibling, 0 replies; 3+ messages in thread
From: Ben Hutchings @ 2018-11-10 23:15 UTC (permalink / raw)
  To: Mikulas Patocka, Greg Kroah-Hartman, stable
  Cc: jing xia, David Rientjes, Guenter Roeck, Douglas Anderson, Mike Snitzer

[-- Attachment #1: Type: text/plain, Size: 2521 bytes --]

On Wed, 2018-07-04 at 10:39 -0400, Mikulas Patocka wrote:
> This is backport of the upstream patch 
> 41c73a49df31151f4ff868f28fe4f129f113fa2c. It should be backported to 
> stable kernels because this performance problem was seen on the android 
> 4.4 kernel.

Also queued this up for 3.16, thanks.

Ben.

> commit 41c73a49df31151f4ff868f28fe4f129f113fa2c
> Author: Mikulas Patocka <mpatocka@redhat.com>
> Date:   Wed Nov 23 17:04:00 2016 -0500
> 
>     dm bufio: drop the lock when doing GFP_NOIO allocation
>     
>     If the first allocation attempt using GFP_NOWAIT fails, drop the lock
>     and retry using GFP_NOIO allocation (lock is dropped because the
>     allocation can take some time).
>     
>     Note that we won't do GFP_NOIO allocation when we loop for the second
>     time, because the lock shouldn't be dropped between __wait_for_free_buffer
>     and __get_unclaimed_buffer.
>     
>     Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
>     Signed-off-by: Mike Snitzer <snitzer@redhat.com>
> 
> diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
> index 9ef88f0e2382..1c2e1dd7ca16 100644
> --- a/drivers/md/dm-bufio.c
> +++ b/drivers/md/dm-bufio.c
> @@ -822,6 +822,7 @@ enum new_flag {
>  static struct dm_buffer *__alloc_buffer_wait_no_callback(struct dm_bufio_client *c, enum new_flag nf)
>  {
>         struct dm_buffer *b;
> +       bool tried_noio_alloc = false;
>  
>         /*
>          * dm-bufio is resistant to allocation failures (it just keeps
> @@ -846,6 +847,15 @@ static struct dm_buffer *__alloc_buffer_wait_no_callback(struct dm_bufio_client
>                 if (nf == NF_PREFETCH)
>                         return NULL;
>  
> +               if (dm_bufio_cache_size_latch != 1 && !tried_noio_alloc) {
> +                       dm_bufio_unlock(c);
> +                       b = alloc_buffer(c, GFP_NOIO | __GFP_NORETRY | __GFP_NOMEMALLOC | __GFP_NOWARN);
> +                       dm_bufio_lock(c);
> +                       if (b)
> +                               return b;
> +                       tried_noio_alloc = true;
> +               }
> +
>                 if (!list_empty(&c->reserved_buffers)) {
>                         b = list_entry(c->reserved_buffers.next,
>                                        struct dm_buffer, lru_list);
-- 
Ben Hutchings
Kids!  Bringing about Armageddon can be dangerous.  Do not attempt it
in your own home. - Terry Pratchett and Neil Gaiman, `Good Omens'


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2018-11-11  9:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-04 14:39 [PATCH 3.16, 4.4, 4.9] dm bufio: drop the lock when doing GFP_NOIO allocation Mikulas Patocka
2018-07-10 14:16 ` Greg Kroah-Hartman
2018-11-10 23:15 ` Ben Hutchings

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.