From: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
To: Christoph Hellwig <hch@infradead.org>,
Dan Williams <dan.j.williams@intel.com>,
Sachin Sant <sachinp@linux.vnet.ibm.com>
Cc: linux-nvdimm@lists.01.org
Subject: Re: negative count with static key devmap_managed_key
Date: Tue, 20 Oct 2020 14:22:05 +0530 [thread overview]
Message-ID: <87sga9jn4a.fsf@linux.ibm.com> (raw)
In-Reply-To: <87wnzljpq0.fsf@linux.ibm.com>
"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> writes:
> Hi Christoph,
>
> commit 6f42193fd86e ("memremap: don't use a separate devm action for
> devmap_managed_enable_get") changed the static key updates such that we
> are now calling devmap_managed_enable_put() without doing the equivalent
> devmap_managed_enable_get().
>
> devmap_managed_enable_get() is only called for MEMORY_DEVICE_PRIVATE and
> MEMORY_DEVICE_FS_DAX, But memunmap_pages() get called for other pgmap
> types too. This result in the below. I can recreate this by repeatedly
> switching between system-ram and devdax mode for devdax namespace.
>
>
mm/memremap.c | 19 +++++++++++++++----
modified mm/memremap.c
@@ -158,6 +158,16 @@ void memunmap_pages(struct dev_pagemap *pgmap)
{
unsigned long pfn;
int i;
+ bool need_devmap_managed = false;
+
+ switch (pgmap->type) {
+ case MEMORY_DEVICE_PRIVATE:
+ case MEMORY_DEVICE_FS_DAX:
+ need_devmap_managed = true;
+ break;
+ default:
+ break;
+ }
dev_pagemap_kill(pgmap);
for (i = 0; i < pgmap->nr_range; i++)
@@ -169,7 +179,8 @@ void memunmap_pages(struct dev_pagemap *pgmap)
pageunmap_range(pgmap, i);
WARN_ONCE(pgmap->altmap.alloc, "failed to free all reserved pages\n");
- devmap_managed_enable_put();
+ if (need_devmap_managed)
+ devmap_managed_enable_put();
}
EXPORT_SYMBOL_GPL(memunmap_pages);
@@ -307,7 +318,7 @@ void *memremap_pages(struct dev_pagemap *pgmap, int nid)
.pgprot = PAGE_KERNEL,
};
const int nr_range = pgmap->nr_range;
- bool need_devmap_managed = true;
+ bool need_devmap_managed = false;
int error, i;
if (WARN_ONCE(!nr_range, "nr_range must be specified\n"))
@@ -327,6 +338,7 @@ void *memremap_pages(struct dev_pagemap *pgmap, int nid)
WARN(1, "Missing owner\n");
return ERR_PTR(-EINVAL);
}
+ need_devmap_managed = true;
break;
case MEMORY_DEVICE_FS_DAX:
if (!IS_ENABLED(CONFIG_ZONE_DEVICE) ||
@@ -334,13 +346,12 @@ void *memremap_pages(struct dev_pagemap *pgmap, int nid)
WARN(1, "File system DAX not supported\n");
return ERR_PTR(-EINVAL);
}
+ need_devmap_managed = true;
break;
case MEMORY_DEVICE_GENERIC:
- need_devmap_managed = false;
break;
case MEMORY_DEVICE_PCI_P2PDMA:
params.pgprot = pgprot_noncached(params.pgprot);
- need_devmap_managed = false;
break;
default:
WARN(1, "Invalid pgmap type %d\n", pgmap->type);
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org
next prev parent reply other threads:[~2020-10-20 8:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-20 7:55 negative count with static key devmap_managed_key Aneesh Kumar K.V
2020-10-20 8:52 ` Aneesh Kumar K.V [this message]
2020-10-20 11:27 ` Sachin Sant
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=87sga9jn4a.fsf@linux.ibm.com \
--to=aneesh.kumar@linux.ibm.com \
--cc=dan.j.williams@intel.com \
--cc=hch@infradead.org \
--cc=linux-nvdimm@lists.01.org \
--cc=sachinp@linux.vnet.ibm.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