linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Gaël PORTAY" <gael.portay@collabora.com>
To: Laura Abbott <labbott@redhat.com>
Cc: Alan Stern <stern@rowland.harvard.edu>,
	linux-mm@kvack.org, usb-storage@lists.one-eyed-alien.net
Subject: Re: [usb-storage] Re: cma: deadlock using usb-storage and fs
Date: Thu, 3 Jan 2019 13:54:53 -0500	[thread overview]
Message-ID: <20190103185452.pwsl7xsf4cp4curz@archlinux.localdomain> (raw)
In-Reply-To: <c3ab7935-8d8d-27a0-99a7-0dab51244a42@redhat.com>

Laura,

On Mon, Dec 17, 2018 at 01:57:37PM -0800, Laura Abbott wrote:
> (...)
> 
> The ARM dma layer uses gfpflags_allow_blocking to decide if it should
> use CMA vs. the atomic pool:
> 
> static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags)
> {
>         return !!(gfp_flags & __GFP_DIRECT_RECLAIM);
> }
> 
> That's not sufficient to cover the writeback case. This is
> used in multiple DMA allocations (arm64 and intel-iommu at
> first pass) so I think we need a new gfpflags_allow_writeback
> for deciding if CMA should be used.
> 
> Thanks,
> Laura

To let you know, in a first instance, I hacked the function
__dma_alloc() to take the GPF_NOIO flag into consideration (which is
likely the same fix you mention above; except that it applies only to
that function, in order to make sure it does not break things
somewherelse that I do not control).

        *handle = ARM_MAPPING_ERROR;
        allowblock = gfpflags_allow_blocking(gfp);
+       /* Following is a work-around to prevent from deadlock in CMA
+        * allocator when a task triggers for a page migration. Others
+        * tasks may wants to migrate theirs pages using CMA but get
+        * locked because the first task already holds the mutex.
+        *
+        * Because CMA is blocking, it refuses to go for CMA if GFP_NOIO
+        * flag is set.
+        */
+       if (allowblock)
+               allowblock = !!(gfp & GFP_NOIO);
        cma = allowblock ? dev_get_cma_area(dev) : false;

I thought it was not working until I decided to give it a retry today...
and it works!

Regards,
Gael

  parent reply	other threads:[~2019-01-03 18:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-16 22:21 Gaël PORTAY
2018-12-17 15:45 ` Alan Stern
2018-12-17 18:29   ` [usb-storage] " Gaël PORTAY
2018-12-17 21:57     ` Laura Abbott
2018-12-18 19:42       ` Mike Kravetz
2018-12-18 21:14         ` Laura Abbott
2018-12-27 19:29           ` Gaël PORTAY
2018-12-27 19:29             ` Gaël PORTAY
2019-01-07 18:13           ` Gaël PORTAY
2019-01-07 18:13             ` Gaël PORTAY
2019-01-08  2:06             ` Mike Kravetz
2019-01-11 13:55               ` Gaël PORTAY
2019-01-11 13:55                 ` Gaël PORTAY
2019-01-14 23:47                 ` Mike Kravetz
2019-01-03 18:54       ` Gaël PORTAY [this message]
2019-01-03 21:56         ` Gaël PORTAY
2019-01-03 21:56           ` Gaël PORTAY

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=20190103185452.pwsl7xsf4cp4curz@archlinux.localdomain \
    --to=gael.portay@collabora.com \
    --cc=labbott@redhat.com \
    --cc=linux-mm@kvack.org \
    --cc=stern@rowland.harvard.edu \
    --cc=usb-storage@lists.one-eyed-alien.net \
    /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