All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rashmica <rashmica.g@gmail.com>
To: David Hildenbrand <david@redhat.com>, linux-mm@kvack.org
Cc: Kate Stewart <kstewart@linuxfoundation.org>,
	Michal Hocko <mhocko@suse.com>,
	linux-doc@vger.kernel.org,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Balbir Singh <bsingharora@gmail.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Paul Mackerras <paulus@samba.org>,
	"K. Y. Srinivasan" <kys@microsoft.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Michael Neuling <mikey@neuling.org>,
	Stephen Hemminger <sthemmin@microsoft.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Pavel Tatashin <pasha.tatashin@oracle.com>,
	linux-acpi@vger.kernel.org, xen-devel@lists.xenproject.org,
	Len Brown <lenb@kernel.org>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	Dan Williams <dan.j.williams@intel.com>,
	YASUAKI ISHIMATSU <yasu.isimatu@gmail.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Vlastimil Babka <vbabka@suse.cz>,
	Oscar Salvador <osalvador@suse.de>,
	Juergen Gross <jgross@suse.com>,
	Math
Subject: [PATCH RFCv2 3/6] mm/memory_hotplug: fix online/offline_pages called w.o. mem_hotplug_lock
Date: Mon, 3 Sep 2018 10:36:24 +1000	[thread overview]
Message-ID: <70372ef5-e332-6c07-f08c-50f8808bde6d@gmail.com> (raw)
In-Reply-To: <20180821104418.12710-4-david@redhat.com>


[-- Attachment #1.1: Type: text/plain, Size: 1721 bytes --]

Hi David,


On 21/08/18 20:44, David Hildenbrand wrote:

> There seem to be some problems as result of 30467e0b3be ("mm, hotplug:
> fix concurrent memory hot-add deadlock"), which tried to fix a possible
> lock inversion reported and discussed in [1] due to the two locks
> 	a) device_lock()
> 	b) mem_hotplug_lock
>
> While add_memory() first takes b), followed by a) during
> bus_probe_device(), onlining of memory from user space first took b),
> followed by a), exposing a possible deadlock.

Do you mean "onlining of memory from user space first took a),
followed by b)"? 

> In [1], and it was decided to not make use of device_hotplug_lock, but
> rather to enforce a locking order.
>
> The problems I spotted related to this:
>
> 1. Memory block device attributes: While .state first calls
>    mem_hotplug_begin() and the calls device_online() - which takes
>    device_lock() - .online does no longer call mem_hotplug_begin(), so
>    effectively calls online_pages() without mem_hotplug_lock.
>
> 2. device_online() should be called under device_hotplug_lock, however
>    onlining memory during add_memory() does not take care of that.
>
> In addition, I think there is also something wrong about the locking in
>
> 3. arch/powerpc/platforms/powernv/memtrace.c calls offline_pages()
>    without locks. This was introduced after 30467e0b3be. And skimming over
>    the code, I assume it could need some more care in regards to locking
>    (e.g. device_online() called without device_hotplug_lock - but I'll
>    not touch that for now).

Can you mention that you fixed this in later patches?


The series looks good to me. Feel free to add my reviewed-by:

Reviewed-by: Rashmica Gupta <rashmica.g@gmail.com>


[-- Attachment #1.2: Type: text/html, Size: 2277 bytes --]

[-- Attachment #2: Type: text/plain, Size: 157 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

WARNING: multiple messages have this Message-ID (diff)
From: Rashmica <rashmica.g@gmail.com>
To: David Hildenbrand <david@redhat.com>, linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org,
	xen-devel@lists.xenproject.org, devel@linuxdriverproject.org,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Len Brown <lenb@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"K. Y. Srinivasan" <kys@microsoft.com>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	Stephen Hemminger <sthemmin@microsoft.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Juergen Gross <jgross@suse.com>,
	Michael Neuling <mikey@neuling.org>,
	Balbir Singh <bsingharora@gmail.com>,
	Kate Stewart <kstewart@linuxfoundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Philippe Ombredanne <pombredanne@nexb.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Michal Hocko <mhocko@suse.com>,
	Pavel Tatashin <pasha.tatashin@oracle.com>,
	Vlastimil Babka <vbabka@suse.cz>,
	Dan Williams <dan.j.williams@intel.com>,
	Oscar Salvador <osalvador@suse.de>,
	YASUAKI ISHIMATSU <yasu.isimatu@gmail.com>,
	Mathieu Malaterre <malat@debian.org>
Subject: [PATCH RFCv2 3/6] mm/memory_hotplug: fix online/offline_pages called w.o. mem_hotplug_lock
Date: Mon, 3 Sep 2018 10:36:24 +1000	[thread overview]
Message-ID: <70372ef5-e332-6c07-f08c-50f8808bde6d@gmail.com> (raw)
In-Reply-To: <20180821104418.12710-4-david@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1721 bytes --]

Hi David,


On 21/08/18 20:44, David Hildenbrand wrote:

> There seem to be some problems as result of 30467e0b3be ("mm, hotplug:
> fix concurrent memory hot-add deadlock"), which tried to fix a possible
> lock inversion reported and discussed in [1] due to the two locks
> 	a) device_lock()
> 	b) mem_hotplug_lock
>
> While add_memory() first takes b), followed by a) during
> bus_probe_device(), onlining of memory from user space first took b),
> followed by a), exposing a possible deadlock.

Do you mean "onlining of memory from user space first took a),
followed by b)"? 

> In [1], and it was decided to not make use of device_hotplug_lock, but
> rather to enforce a locking order.
>
> The problems I spotted related to this:
>
> 1. Memory block device attributes: While .state first calls
>    mem_hotplug_begin() and the calls device_online() - which takes
>    device_lock() - .online does no longer call mem_hotplug_begin(), so
>    effectively calls online_pages() without mem_hotplug_lock.
>
> 2. device_online() should be called under device_hotplug_lock, however
>    onlining memory during add_memory() does not take care of that.
>
> In addition, I think there is also something wrong about the locking in
>
> 3. arch/powerpc/platforms/powernv/memtrace.c calls offline_pages()
>    without locks. This was introduced after 30467e0b3be. And skimming over
>    the code, I assume it could need some more care in regards to locking
>    (e.g. device_online() called without device_hotplug_lock - but I'll
>    not touch that for now).

Can you mention that you fixed this in later patches?


The series looks good to me. Feel free to add my reviewed-by:

Reviewed-by: Rashmica Gupta <rashmica.g@gmail.com>


[-- Attachment #2: Type: text/html, Size: 2277 bytes --]

  parent reply	other threads:[~2018-09-03  0:36 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-21 10:44 [PATCH RFCv2 0/6] mm: online/offline_pages called w.o. mem_hotplug_lock David Hildenbrand
2018-08-21 10:44 ` David Hildenbrand
2018-08-21 10:44 ` [PATCH RFCv2 1/6] mm/memory_hotplug: make remove_memory() take the device_hotplug_lock David Hildenbrand
2018-08-21 10:44 ` David Hildenbrand
2018-08-21 10:44   ` David Hildenbrand
2018-08-30 19:35   ` Pasha Tatashin
2018-08-30 19:35   ` Pasha Tatashin
2018-08-30 19:35     ` Pasha Tatashin
2018-08-30 19:35     ` Pasha Tatashin
2018-08-31 13:12     ` David Hildenbrand
2018-08-31 13:12       ` David Hildenbrand
2018-08-31 13:12     ` David Hildenbrand
2018-08-21 10:44 ` [PATCH RFCv2 2/6] mm/memory_hotplug: make add_memory() " David Hildenbrand
2018-08-21 10:44   ` David Hildenbrand
2018-08-30 19:36   ` Pasha Tatashin
2018-08-30 19:36     ` Pasha Tatashin
2018-08-30 19:36     ` Pasha Tatashin
2018-08-30 19:36   ` Pasha Tatashin
2018-08-21 10:44 ` David Hildenbrand
2018-08-21 10:44 ` [PATCH RFCv2 3/6] mm/memory_hotplug: fix online/offline_pages called w.o. mem_hotplug_lock David Hildenbrand
2018-08-21 10:44   ` David Hildenbrand
2018-08-30 19:37   ` Pasha Tatashin
2018-08-30 19:37     ` Pasha Tatashin
2018-08-30 19:37     ` Pasha Tatashin
2018-08-30 19:37   ` Pasha Tatashin
2018-09-03  0:36   ` Rashmica [this message]
2018-09-03  0:36     ` Rashmica
2018-09-17  7:32     ` David Hildenbrand
2018-09-17  7:32     ` David Hildenbrand
2018-09-17  7:32       ` David Hildenbrand
2018-09-25  1:26       ` Rashmica Gupta
2018-09-25  1:26         ` Rashmica Gupta
2018-09-25  1:26       ` Rashmica Gupta
2018-08-21 10:44 ` David Hildenbrand
2018-08-21 10:44 ` [PATCH RFCv2 4/6] powerpc/powernv: hold device_hotplug_lock when calling device_online() David Hildenbrand
2018-08-21 10:44 ` David Hildenbrand
2018-08-21 10:44   ` David Hildenbrand
2018-08-30 19:38   ` Pasha Tatashin
2018-08-30 19:38     ` Pasha Tatashin
2018-08-30 19:38   ` Pasha Tatashin
2018-08-21 10:44 ` [PATCH RFCv2 5/6] powerpc/powernv: hold device_hotplug_lock in memtrace_offline_pages() David Hildenbrand
2018-08-21 10:44 ` David Hildenbrand
2018-08-30 19:38   ` Pasha Tatashin
2018-08-30 19:38     ` Pasha Tatashin
2018-08-30 19:38   ` Pasha Tatashin
2018-08-21 10:44 ` [PATCH RFCv2 6/6] memory-hotplug.txt: Add some details about locking internals David Hildenbrand
2018-08-30 19:38   ` Pasha Tatashin
2018-08-30 19:38   ` Pasha Tatashin
2018-08-30 19:38     ` Pasha Tatashin
2018-08-30 19:38     ` Pasha Tatashin
2018-08-21 10:44 ` David Hildenbrand
2018-08-30 12:31 ` [PATCH RFCv2 0/6] mm: online/offline_pages called w.o. mem_hotplug_lock David Hildenbrand
2018-08-30 12:31   ` David Hildenbrand
2018-08-30 15:54   ` Pasha Tatashin
2018-08-30 15:54   ` Pasha Tatashin
2018-08-30 15:54     ` Pasha Tatashin
2018-08-30 15:54     ` Pasha Tatashin
2018-08-30 12:31 ` David Hildenbrand
2018-08-31 20:54 ` Oscar Salvador
2018-08-31 20:54 ` Oscar Salvador
2018-08-31 20:54   ` Oscar Salvador
2018-09-01 14:03   ` David Hildenbrand
2018-09-01 14:03   ` David Hildenbrand
2018-09-01 14:03     ` David Hildenbrand

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=70372ef5-e332-6c07-f08c-50f8808bde6d@gmail.com \
    --to=rashmica.g@gmail.com \
    --cc=benh@kernel.crashing.org \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bsingharora@gmail.com \
    --cc=dan.j.williams@intel.com \
    --cc=david@redhat.com \
    --cc=haiyangz@microsoft.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=jgross@suse.com \
    --cc=kstewart@linuxfoundation.org \
    --cc=kys@microsoft.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=mikey@neuling.org \
    --cc=mpe@ellerman.id.au \
    --cc=osalvador@suse.de \
    --cc=pasha.tatashin@oracle.com \
    --cc=paulus@samba.org \
    --cc=sthemmin@microsoft.com \
    --cc=tglx@linutronix.de \
    --cc=vbabka@suse.cz \
    --cc=xen-devel@lists.xenproject.org \
    --cc=yasu.isimatu@gmail.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.