From: Barret Rhoden <brho@google.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: linux-nvdimm@lists.01.org, hch@lst.de,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, jack@suse.cz,
ross.zwisler@linux.intel.com
Subject: Re: [PATCH v5 07/11] filesystem-dax: Introduce dax_lock_mapping_entry()
Date: Mon, 24 Sep 2018 11:57:21 -0400 [thread overview]
Message-ID: <20180924115721.75893931@gnomeregan.cam.corp.google.com> (raw)
In-Reply-To: <153074046078.27838.5465590228767136915.stgit@dwillia2-desk3.amr.corp.intel.com>
Hi Dan -
On 2018-07-04 at 14:41 Dan Williams <dan.j.williams@intel.com> wrote:
[snip]
> diff --git a/fs/dax.c b/fs/dax.c
> index 4de11ed463ce..57ec272038da 100644
> --- a/fs/dax.c
> +++ b/fs/dax.c
[snip]
> +bool dax_lock_mapping_entry(struct page *page)
> +{
> + pgoff_t index;
> + struct inode *inode;
> + bool did_lock = false;
> + void *entry = NULL, **slot;
> + struct address_space *mapping;
> +
> + rcu_read_lock();
> + for (;;) {
> + mapping = READ_ONCE(page->mapping);
> +
> + if (!dax_mapping(mapping))
> + break;
> +
> + /*
> + * In the device-dax case there's no need to lock, a
> + * struct dev_pagemap pin is sufficient to keep the
> + * inode alive, and we assume we have dev_pagemap pin
> + * otherwise we would not have a valid pfn_to_page()
> + * translation.
> + */
> + inode = mapping->host;
> + if (S_ISCHR(inode->i_mode)) {
> + did_lock = true;
> + break;
> + }
> +
> + xa_lock_irq(&mapping->i_pages);
> + if (mapping != page->mapping) {
> + xa_unlock_irq(&mapping->i_pages);
> + continue;
> + }
> + index = page->index;
> +
> + entry = __get_unlocked_mapping_entry(mapping, index, &slot,
> + entry_wait_revalidate);
> + if (!entry) {
> + xa_unlock_irq(&mapping->i_pages);
> + break;
> + } else if (IS_ERR(entry)) {
> + WARN_ON_ONCE(PTR_ERR(entry) != -EAGAIN);
> + continue;
In the IS_ERR case, do you need to xa_unlock the mapping? It looks
like you'll deadlock the next time around the loop.
> + }
> + lock_slot(mapping, slot);
> + did_lock = true;
> + xa_unlock_irq(&mapping->i_pages);
> + break;
> + }
> + rcu_read_unlock();
> +
> + return did_lock;
> +}
next prev parent reply other threads:[~2018-09-24 15:57 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-04 21:40 [PATCH v5 00/11] mm: Teach memory_failure() about ZONE_DEVICE pages Dan Williams
2018-07-04 21:40 ` [PATCH v5 01/11] device-dax: Convert to vmf_insert_mixed and vm_fault_t Dan Williams
2018-07-04 21:40 ` [PATCH v5 02/11] device-dax: Enable page_mapping() Dan Williams
2018-07-04 21:40 ` [PATCH v5 03/11] device-dax: Set page->index Dan Williams
2018-07-04 21:40 ` [PATCH v5 04/11] filesystem-dax: " Dan Williams
2018-07-04 21:40 ` [PATCH v5 05/11] mm, madvise_inject_error: Let memory_failure() optionally take a page reference Dan Williams
2018-07-13 6:31 ` Naoya Horiguchi
2018-07-14 0:34 ` Dan Williams
2018-07-04 21:40 ` [PATCH v5 06/11] mm, memory_failure: Collect mapping size in collect_procs() Dan Williams
2018-07-13 6:49 ` Naoya Horiguchi
2018-07-04 21:41 ` [PATCH v5 07/11] filesystem-dax: Introduce dax_lock_mapping_entry() Dan Williams
2018-07-05 1:07 ` kbuild test robot
2018-07-05 3:31 ` kbuild test robot
2018-07-05 3:33 ` [PATCH v6] " Dan Williams
2018-09-24 15:57 ` Barret Rhoden [this message]
2018-09-27 11:13 ` [PATCH v5 07/11] " Jan Kara
2018-07-04 21:41 ` [PATCH v5 08/11] mm, memory_failure: Teach memory_failure() about dev_pagemap pages Dan Williams
2018-07-13 8:52 ` Naoya Horiguchi
2018-07-14 0:28 ` Dan Williams
2018-07-17 6:36 ` Naoya Horiguchi
2018-07-04 21:41 ` [PATCH v5 09/11] x86/mm/pat: Prepare {reserve, free}_memtype() for "decoy" addresses Dan Williams
2018-07-04 21:41 ` [PATCH v5 10/11] x86/memory_failure: Introduce {set, clear}_mce_nospec() Dan Williams
2018-07-04 21:41 ` [PATCH v5 11/11] libnvdimm, pmem: Restore page attributes when clearing errors Dan Williams
2018-07-13 4:44 ` [PATCH v5 00/11] mm: Teach memory_failure() about ZONE_DEVICE pages 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=20180924115721.75893931@gnomeregan.cam.corp.google.com \
--to=brho@google.com \
--cc=dan.j.williams@intel.com \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nvdimm@lists.01.org \
--cc=ross.zwisler@linux.intel.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;
as well as URLs for NNTP newsgroup(s).