[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201016062444.GL86495@L-31X9LVDL-1304.local>
Date: Fri, 16 Oct 2020 14:24:44 +0800
From: Wei Yang <richard.weiyang@...ux.alibaba.com>
To: David Hildenbrand <david@...hat.com>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
virtualization@...ts.linux-foundation.org,
Andrew Morton <akpm@...ux-foundation.org>,
"Michael S . Tsirkin" <mst@...hat.com>,
Jason Wang <jasowang@...hat.com>,
Pankaj Gupta <pankaj.gupta.linux@...il.com>
Subject: Re: [PATCH v1 12/29] virtio-mem: factor out fake-offlining into
virtio_mem_fake_offline()
On Mon, Oct 12, 2020 at 02:53:06PM +0200, David Hildenbrand wrote:
>... which now matches virtio_mem_fake_online(). We'll reuse this
>functionality soon.
>
>Cc: "Michael S. Tsirkin" <mst@...hat.com>
>Cc: Jason Wang <jasowang@...hat.com>
>Cc: Pankaj Gupta <pankaj.gupta.linux@...il.com>
>Signed-off-by: David Hildenbrand <david@...hat.com>
Reviewed-by: Wei Yang <richard.weiyang@...ux.alibaba.com>
>---
> drivers/virtio/virtio_mem.c | 34 ++++++++++++++++++++++++----------
> 1 file changed, 24 insertions(+), 10 deletions(-)
>
>diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c
>index 00d1cfca4713..d132bc54ef57 100644
>--- a/drivers/virtio/virtio_mem.c
>+++ b/drivers/virtio/virtio_mem.c
>@@ -832,6 +832,27 @@ static void virtio_mem_fake_online(unsigned long pfn, unsigned long nr_pages)
> }
> }
>
>+/*
>+ * Try to allocate a range, marking pages fake-offline, effectively
>+ * fake-offlining them.
>+ */
>+static int virtio_mem_fake_offline(unsigned long pfn, unsigned long nr_pages)
>+{
>+ int rc;
>+
>+ rc = alloc_contig_range(pfn, pfn + nr_pages, MIGRATE_MOVABLE,
>+ GFP_KERNEL);
>+ if (rc == -ENOMEM)
>+ /* whoops, out of memory */
>+ return rc;
>+ if (rc)
>+ return -EBUSY;
>+
>+ virtio_mem_set_fake_offline(pfn, nr_pages, true);
>+ adjust_managed_page_count(pfn_to_page(pfn), -nr_pages);
>+ return 0;
>+}
>+
> static void virtio_mem_online_page_cb(struct page *page, unsigned int order)
> {
> const unsigned long addr = page_to_phys(page);
>@@ -1335,17 +1356,10 @@ static int virtio_mem_mb_unplug_sb_online(struct virtio_mem *vm,
>
> start_pfn = PFN_DOWN(virtio_mem_mb_id_to_phys(mb_id) +
> sb_id * vm->subblock_size);
>- rc = alloc_contig_range(start_pfn, start_pfn + nr_pages,
>- MIGRATE_MOVABLE, GFP_KERNEL);
>- if (rc == -ENOMEM)
>- /* whoops, out of memory */
>- return rc;
>- if (rc)
>- return -EBUSY;
>
>- /* Mark it as fake-offline before unplugging it */
>- virtio_mem_set_fake_offline(start_pfn, nr_pages, true);
>- adjust_managed_page_count(pfn_to_page(start_pfn), -nr_pages);
>+ rc = virtio_mem_fake_offline(start_pfn, nr_pages);
>+ if (rc)
>+ return rc;
>
> /* Try to unplug the allocated memory */
> rc = virtio_mem_mb_unplug_sb(vm, mb_id, sb_id, count);
>--
>2.26.2
--
Wei Yang
Help you, Help me
Powered by blists - more mailing lists