Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1295756

[RFC] theoretical race between memory hotplug and pfn iterator

From Joonsoo Kim <iamjoonsoo.kim@lge.com>
Newsgroups linux.kernel
Subject [RFC] theoretical race between memory hotplug and pfn iterator
Date 2015-12-21 04:20 +0100
Message-ID <qHZaV-13Z-3@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


Hello, memory-hotplug folks.

I found theoretical problems between memory hotplug and pfn iterator.
For example, pfn iterator works something like below.

for (pfn = zone_start_pfn; pfn < zone_end_pfn; pfn++) {
        if (!pfn_valid(pfn))
                continue;

        page = pfn_to_page(pfn);
        /* Do whatever we want */
}

Sequence of hotplug is something like below.

1) add memmap (after then, pfn_valid will return valid)
2) memmap_init_zone()

So, if pfn iterator runs between 1) and 2), it could access
uninitialized page information.

This problem could be solved by re-ordering initialization steps.

Hot-remove also has a problem. If memory is hot-removed after
pfn_valid() succeed in pfn iterator, access to page would cause NULL
deference because hot-remove frees corresponding memmap. There is no
guard against free in any pfn iterators.

This problem can be solved by inserting get_online_mems() in all pfn
iterators but this looks error-prone for future usage. Another idea is
that delaying free corresponding memmap until synchronization point such
as system suspend. It will guarantee that there is no running pfn
iterator. Do any have a better idea?

Btw, I tried to memory-hotremove with QEMU 2.5.5 but it didn't work. I
followed sequences in doc/memory-hotplug. Do you have any comment on this?

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[RFC] theoretical race between memory hotplug and pfn iterator Joonsoo Kim <iamjoonsoo.kim@lge.com> - 2015-12-21 04:20 +0100
  Re: [RFC] theoretical race between memory hotplug and pfn iterator Zhu Guihua <zhugh.fnst@cn.fujitsu.com> - 2015-12-21 08:10 +0100
    Re: [RFC] theoretical race between memory hotplug and pfn iterator Joonsoo Kim <iamjoonsoo.kim@lge.com> - 2015-12-21 08:20 +0100
      Re: [RFC] theoretical race between memory hotplug and pfn iterator Zhu Guihua <zhugh.fnst@cn.fujitsu.com> - 2015-12-21 09:10 +0100
        Re: [RFC] theoretical race between memory hotplug and pfn iterator Joonsoo Kim <js1304@gmail.com> - 2015-12-21 13:10 +0100

csiph-web