From: Dave Jiang <dave.jiang@intel.com>
To: Stefan Hajnoczi <stefanha@redhat.com>, linux-nvdimm@lists.01.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] device-dax: avoid hang on error before devm_memremap_pages()
Date: Tue, 31 Jul 2018 17:26:23 -0700 [thread overview]
Message-ID: <499a3093-3781-7a8a-abd0-8b240db11dce@intel.com> (raw)
In-Reply-To: <20180731143246.16915-1-stefanha@redhat.com>
On 7/31/2018 7:32 AM, Stefan Hajnoczi wrote:
> dax_pmem_percpu_exit() waits for dax_pmem_percpu_release() to invoke the
> dax_pmem->cmp completion. Unfortunately this approach to cleaning up
> the percpu_ref only works after devm_memremap_pages() was successful.
>
> If devm_add_action_or_reset() or devm_memremap_pages() fails,
> dax_pmem_percpu_release() is not invoked. Therefore
> dax_pmem_percpu_exit() hangs waiting for the completion:
>
> rc = devm_add_action_or_reset(dev, dax_pmem_percpu_exit,
> &dax_pmem->ref);
> if (rc)
> return rc;
>
> dax_pmem->pgmap.ref = &dax_pmem->ref;
> addr = devm_memremap_pages(dev, &dax_pmem->pgmap);
>
> Avoid the hang by calling percpu_ref_exit() in the error paths instead
> of going through dax_pmem_percpu_exit().
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Applied
> ---
> Found by code inspection. Compile-tested only.
> ---
> drivers/dax/pmem.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/dax/pmem.c b/drivers/dax/pmem.c
> index fd49b24fd6af..99e2aace8078 100644
> --- a/drivers/dax/pmem.c
> +++ b/drivers/dax/pmem.c
> @@ -105,15 +105,19 @@ static int dax_pmem_probe(struct device *dev)
> if (rc)
> return rc;
>
> - rc = devm_add_action_or_reset(dev, dax_pmem_percpu_exit,
> - &dax_pmem->ref);
> - if (rc)
> + rc = devm_add_action(dev, dax_pmem_percpu_exit, &dax_pmem->ref);
> + if (rc) {
> + percpu_ref_exit(&dax_pmem->ref);
> return rc;
> + }
>
> dax_pmem->pgmap.ref = &dax_pmem->ref;
> addr = devm_memremap_pages(dev, &dax_pmem->pgmap);
> - if (IS_ERR(addr))
> + if (IS_ERR(addr)) {
> + devm_remove_action(dev, dax_pmem_percpu_exit, &dax_pmem->ref);
> + percpu_ref_exit(&dax_pmem->ref);
> return PTR_ERR(addr);
> + }
>
> rc = devm_add_action_or_reset(dev, dax_pmem_percpu_kill,
> &dax_pmem->ref);
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
next prev parent reply other threads:[~2018-08-01 0:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-31 14:32 [PATCH] device-dax: avoid hang on error before devm_memremap_pages() Stefan Hajnoczi
2018-08-01 0:26 ` Dave Jiang [this message]
2018-09-11 6:02 ` Dan Williams
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=499a3093-3781-7a8a-abd0-8b240db11dce@intel.com \
--to=dave.jiang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvdimm@lists.01.org \
--cc=stefanha@redhat.com \
/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