Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1577692 > unrolled thread
| Started by | Ben Hutchings <ben@decadent.org.uk> |
|---|---|
| First post | 2017-02-09 16:30 +0100 |
| Last post | 2017-02-10 06:10 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH 4.4 05/48] mm: fix devm_memremap_pages crash, use mem_hotplug_{begin, done} Ben Hutchings <ben@decadent.org.uk> - 2017-02-09 16:30 +0100
Re: [PATCH 4.4 05/48] mm: fix devm_memremap_pages crash, use mem_hotplug_{begin, done} Dan Williams <dan.j.williams@intel.com> - 2017-02-10 06:10 +0100
| From | Ben Hutchings <ben@decadent.org.uk> |
|---|---|
| Date | 2017-02-09 16:30 +0100 |
| Subject | Re: [PATCH 4.4 05/48] mm: fix devm_memremap_pages crash, use mem_hotplug_{begin, done} |
| Message-ID | <t8YPw-7PX-39@gated-at.bofh.it> |
[Multipart message — attachments visible in raw view] — view raw
On Wed, 2017-01-18 at 11:46 +0100, Greg Kroah-Hartman wrote:
> 4.4-stable review patch. If anyone has any objections, please let me know.
>
> ------------------
>
> From: Dan Williams <dan.j.williams@intel.com>
>
> commit f931ab479dd24cf7a2c6e2df19778406892591fb upstream.
>
> Both arch_add_memory() and arch_remove_memory() expect a single threaded
> context.
[...]
> The result is that two threads calling devm_memremap_pages()
> simultaneously can end up colliding on pgd initialization. This leads
> to crash signatures like the following where the loser of the race
> initializes the wrong pgd entry:
[...]
> Hold the standard memory hotplug mutex over calls to
> arch_{add,remove}_memory().
[...]
This is not a sufficient fix, because memory_hotplug.c still assumes
there's only one 'writer':
void put_online_mems(void)
{
...
if (!--mem_hotplug.refcount && unlikely(mem_hotplug.active_writer))
wake_up_process(mem_hotplug.active_writer);
...
}
void mem_hotplug_begin(void)
{
mem_hotplug.active_writer = current;
memhp_lock_acquire();
for (;;) {
mutex_lock(&mem_hotplug.lock);
if (likely(!mem_hotplug.refcount))
break;
__set_current_state(TASK_UNINTERRUPTIBLE);
mutex_unlock(&mem_hotplug.lock);
schedule();
}
}
With multiple writers, one or more of them may hang or
{get,put}_online_mems() may mess up the hotplug reference count.
Is there a good reason that memory_hotplug.c isn't using an rwsem?
Ben.
--
Ben Hutchings
All the simple programs have been written, and all the good names
taken.
[toc] | [next] | [standalone]
| From | Dan Williams <dan.j.williams@intel.com> |
|---|---|
| Date | 2017-02-10 06:10 +0100 |
| Message-ID | <t9bD3-7tZ-1@gated-at.bofh.it> |
| In reply to | #1577692 |
On Thu, Feb 9, 2017 at 7:26 AM, Ben Hutchings <ben@decadent.org.uk> wrote:
> On Wed, 2017-01-18 at 11:46 +0100, Greg Kroah-Hartman wrote:
>> 4.4-stable review patch. If anyone has any objections, please let me know.
>>
>> ------------------
>>
>> From: Dan Williams <dan.j.williams@intel.com>
>>
>> commit f931ab479dd24cf7a2c6e2df19778406892591fb upstream.
>>
>> Both arch_add_memory() and arch_remove_memory() expect a single threaded
>> context.
> [...]
>> The result is that two threads calling devm_memremap_pages()
>> simultaneously can end up colliding on pgd initialization. This leads
>> to crash signatures like the following where the loser of the race
>> initializes the wrong pgd entry:
> [...]
>> Hold the standard memory hotplug mutex over calls to
>> arch_{add,remove}_memory().
> [...]
>
> This is not a sufficient fix, because memory_hotplug.c still assumes
> there's only one 'writer':
>
> void put_online_mems(void)
> {
> ...
> if (!--mem_hotplug.refcount && unlikely(mem_hotplug.active_writer))
> wake_up_process(mem_hotplug.active_writer);
> ...
> }
>
> void mem_hotplug_begin(void)
> {
> mem_hotplug.active_writer = current;
>
> memhp_lock_acquire();
> for (;;) {
> mutex_lock(&mem_hotplug.lock);
> if (likely(!mem_hotplug.refcount))
> break;
> __set_current_state(TASK_UNINTERRUPTIBLE);
> mutex_unlock(&mem_hotplug.lock);
> schedule();
> }
> }
>
> With multiple writers, one or more of them may hang or
> {get,put}_online_mems() may mess up the hotplug reference count.
You're right. We need to hold lock_device_hotplug_sysfs() before
calling mem_hotplug_begin(). I'll take a look at a follow-on fix and
also add an assert_held_device_hotplug() helper to catch this in the
future.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web