All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Matthew Wilcox <willy@linux.intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Jens Axboe <axboe@kernel.dk>, Boaz Harrosh <boaz@plexistor.com>,
	david <david@fromorbit.com>,
	linux-arch@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	Ross Zwisler <ross.zwisler@linux.intel.com>,
	"linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Tejun Heo <tj@kernel.org>, Paul Mackerras <paulus@samba.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"torvalds@linux-foundation.org" <torvalds@linux-foundation.org>,
	Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH v4 2/9] x86: support kmap_atomic_pfn_t() for persistent memory
Date: Wed, 10 Jun 2015 08:36:48 -0700	[thread overview]
Message-ID: <CAPcyv4hnd1JRwLYapo_s=vXFYHUA6Cv-ZpJt+Y3_tTCxQsJUPg@mail.gmail.com> (raw)
In-Reply-To: <20150610151100.GA12757@lst.de>

On Wed, Jun 10, 2015 at 8:11 AM, Christoph Hellwig <hch@lst.de> wrote:
> On Wed, Jun 10, 2015 at 11:03:35AM -0400, Matthew Wilcox wrote:
>> On Wed, Jun 10, 2015 at 02:12:02PM +0200, Christoph Hellwig wrote:
>> > Btw, I don't think this actually is safe without refcounting your kmap
>> > structure.
>> >
>> > The driver model ->remove callback can be called at any time, which
>> > will ioremap the memory and remap the kmap structure.  But at this
>> > point a user might still be using it.
>>
>> Won't the device data structures be pinned by the refcount on the bdev?
>
> An open filesystem only keeps a reference on the request_queue.  The
> underlying driver model ->remove method will still be called on
> a surprise removal.

On surprise removal my expectation is that the driver keeps the the
ioremap mapping alive for at least a synchronize_rcu() period.  With
that in place the rcu_read_lock() in kmap_atomic_pfn_t() should keep
the mapping alive for the short duration, or otherwise prevent new
mappings.  However, I missed converting the driver to order its
iounmap() with respect to the pfn range registration via devres, will
fix.

WARNING: multiple messages have this Message-ID (diff)
From: Dan Williams <dan.j.williams@intel.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Matthew Wilcox <willy@linux.intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Jens Axboe <axboe@kernel.dk>, Boaz Harrosh <boaz@plexistor.com>,
	david <david@fromorbit.com>,
	linux-arch@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	Ross Zwisler <ross.zwisler@linux.intel.com>,
	"linux-nvdimm@lists.01.org" <linux-nvdimm@ml01.01.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Tejun Heo <tj@kernel.org>, Paul Mackerras <paulus@samba.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"torvalds@linux-foundation.org" <torvalds@linux-foundation.org>,
	Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH v4 2/9] x86: support kmap_atomic_pfn_t() for persistent memory
Date: Wed, 10 Jun 2015 08:36:48 -0700	[thread overview]
Message-ID: <CAPcyv4hnd1JRwLYapo_s=vXFYHUA6Cv-ZpJt+Y3_tTCxQsJUPg@mail.gmail.com> (raw)
In-Reply-To: <20150610151100.GA12757@lst.de>

On Wed, Jun 10, 2015 at 8:11 AM, Christoph Hellwig <hch@lst.de> wrote:
> On Wed, Jun 10, 2015 at 11:03:35AM -0400, Matthew Wilcox wrote:
>> On Wed, Jun 10, 2015 at 02:12:02PM +0200, Christoph Hellwig wrote:
>> > Btw, I don't think this actually is safe without refcounting your kmap
>> > structure.
>> >
>> > The driver model ->remove callback can be called at any time, which
>> > will ioremap the memory and remap the kmap structure.  But at this
>> > point a user might still be using it.
>>
>> Won't the device data structures be pinned by the refcount on the bdev?
>
> An open filesystem only keeps a reference on the request_queue.  The
> underlying driver model ->remove method will still be called on
> a surprise removal.

On surprise removal my expectation is that the driver keeps the the
ioremap mapping alive for at least a synchronize_rcu() period.  With
that in place the rcu_read_lock() in kmap_atomic_pfn_t() should keep
the mapping alive for the short duration, or otherwise prevent new
mappings.  However, I missed converting the driver to order its
iounmap() with respect to the pfn range registration via devres, will
fix.

  reply	other threads:[~2015-06-10 15:36 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-05 21:19 [PATCH v4 0/9] introduce __pfn_t, evacuate struct page from sgls Dan Williams
2015-06-05 21:19 ` Dan Williams
2015-06-05 21:19 ` [PATCH v4 1/9] introduce __pfn_t for scatterlists and pmem Dan Williams
2015-06-05 21:19   ` Dan Williams
2015-06-05 21:37   ` Linus Torvalds
2015-06-05 21:37     ` Linus Torvalds
2015-06-05 22:12     ` Dan Williams
2015-06-05 22:12       ` Dan Williams
2015-06-05 21:19 ` [PATCH v4 2/9] x86: support kmap_atomic_pfn_t() for persistent memory Dan Williams
2015-06-05 21:19   ` Dan Williams
2015-06-09  6:50   ` Christoph Hellwig
2015-06-09  6:50     ` Christoph Hellwig
2015-06-10 12:12   ` Christoph Hellwig
2015-06-10 12:12     ` Christoph Hellwig
2015-06-10 15:03     ` Matthew Wilcox
2015-06-10 15:03       ` Matthew Wilcox
2015-06-10 15:11       ` Christoph Hellwig
2015-06-10 15:11         ` Christoph Hellwig
2015-06-10 15:36         ` Dan Williams [this message]
2015-06-10 15:36           ` Dan Williams
2015-06-10 16:11           ` Christoph Hellwig
2015-06-10 16:11             ` Christoph Hellwig
2015-06-10 16:17             ` Dan Williams
2015-06-10 16:17               ` Dan Williams
2015-06-05 21:19 ` [PATCH v4 3/9] dax: drop size parameter to ->direct_access() Dan Williams
2015-06-05 21:19   ` Dan Williams
2015-06-06 11:37   ` Matthew Wilcox
2015-06-06 11:37     ` Matthew Wilcox
2015-06-09  6:51   ` Christoph Hellwig
2015-06-09  6:51     ` Christoph Hellwig
2015-06-05 21:19 ` [PATCH v4 4/9] dax: fix mapping lifetime handling, convert to __pfn_t + kmap_atomic_pfn_t() Dan Williams
2015-06-05 21:19   ` Dan Williams
2015-06-06 11:58   ` Matthew Wilcox
2015-06-06 11:58     ` Matthew Wilcox
2015-08-07 23:54     ` Dan Williams
2015-08-07 23:54       ` Dan Williams
2015-06-08 16:29   ` Elliott, Robert (Server Storage)
2015-06-08 16:29     ` Elliott, Robert (Server Storage)
2015-06-08 16:36     ` Dan Williams
2015-06-08 16:36       ` Dan Williams
2015-06-09  6:55   ` Christoph Hellwig
2015-06-09  6:55     ` Christoph Hellwig
2015-06-05 21:19 ` [PATCH v4 5/9] dma-mapping: allow archs to optionally specify a ->map_pfn() operation Dan Williams
2015-06-05 21:19   ` Dan Williams
2015-06-05 21:19 ` [PATCH v4 6/9] scatterlist: use sg_phys() Dan Williams
2015-06-05 21:19   ` Dan Williams
2015-06-09  6:59   ` Christoph Hellwig
2015-06-09  6:59     ` Christoph Hellwig
2015-06-05 21:19 ` [PATCH v4 7/9] scatterlist: cleanup sg_chain() and sg_unmark_end() Dan Williams
2015-06-05 21:19   ` Dan Williams
2015-06-05 21:19 ` [PATCH v4 8/9] scatterlist: convert to __pfn_t Dan Williams
2015-06-05 21:19   ` Dan Williams
2015-06-05 21:19 ` [PATCH v4 9/9] x86: convert dma_map_ops to support mapping a __pfn_t Dan Williams
2015-06-05 21:19   ` Dan Williams
2015-06-09  6:58   ` Christoph Hellwig
2015-06-09  6:58     ` Christoph Hellwig
2015-06-09 13:47     ` Konrad Rzeszutek Wilk
2015-06-05 21:23 ` [PATCH v4 0/9] introduce __pfn_t, evacuate struct page from sgls Dan Williams
2015-06-05 21:23   ` 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='CAPcyv4hnd1JRwLYapo_s=vXFYHUA6Cv-ZpJt+Y3_tTCxQsJUPg@mail.gmail.com' \
    --to=dan.j.williams@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=axboe@kernel.dk \
    --cc=benh@kernel.crashing.org \
    --cc=boaz@plexistor.com \
    --cc=david@fromorbit.com \
    --cc=hch@lst.de \
    --cc=heiko.carstens@de.ibm.com \
    --cc=hpa@zytor.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvdimm@lists.01.org \
    --cc=mingo@kernel.org \
    --cc=paulus@samba.org \
    --cc=ross.zwisler@linux.intel.com \
    --cc=schwidefsky@de.ibm.com \
    --cc=tj@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=willy@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 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.