[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/3][4.17?] x86/pv-shim: correct ballooning down for compat guests


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 28 Oct 2022 09:23:11 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=B4EnGeRwXar3+da6jwqvXI51YktxFxeKbOMUsdd7OF8=; b=n3ui2QSscLcNXWx53MsSA1MFmdJ0XphkFKK6l0i5EEpO1GS2BX4BxK/LDXLCu9duLoQ7/p/NitDlRJeiPpfL3/OjGGmji+QIydr3GBScSveFlKH98TZbEDHCBlgpJkjWHFGkoXm6r+Xn+mE7slHodEaNmh2nsGLNmASjjWyfmZxosdUvpVD74BUYncfDZmDGv6jMag6WieFWxhfaQ6yZnGbTPRjtqCGVUsHV1qmSVVN+hGy7C+PO6v9iKtJfZOXkArzzab/9j7mAwgTF2+YJXWV+G9xJ9WOgPE6g2ZxTschkN21MZRis2qCwAVmqQpVWy4auvAmEySq4oZt4wDymwQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RP0MM2Dbw+SIT8P/cq1IuvqZl0F4NCrnhjtHjOh0zPefiNKUPTiJ5IFHu2DDWekt2YvMDR6JXWtdRRUs3+cgzs/QK/Z08PWOugRodB6b153wg49cSno+DspqJEBmJl7cGlSUO8YquzU1eJJzKvHXWTCbX2lLwwrb1RbQYoLD62q7UZq4LqyJCDj0f2ioRIOl1dus+5JsJ5LYPDdbbNT+1Nxa29yfaEW0m8mdFzx3H7xfM5N+fbWl/e/B4M4suBiHddQsR565JBUUVY3xbS57pwwswRTrOC1boVIQmTvP/fuiPXJnAX7XWyEjaLG9aX6dvpnAb/MNoRgUDqQycf9toQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Henry Wang <Henry.Wang@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Fri, 28 Oct 2022 07:23:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Igor Druzhinin <igor.druzhinin@xxxxxxxxxx>

The compat layer for multi-extent memory ops may need to split incoming
requests. Since the guest handles in the interface structures may not be
altered, it does so by leveraging do_memory_op()'s continuation
handling: It hands on non-initial requests with a non-zero start extent,
with the (native) handle suitably adjusted down. As a result
do_memory_op() sees only the first of potentially several requests with
start extent being zero. In order to be usable as overall result, the
function accumulates args.nr_done, i.e. it initialized the field with
the start extent. Therefore non-initial requests resulting from the
split would pass too large a number into pv_shim_offline_memory().

Address that breakage by always calling pv_shim_offline_memory()
regardless of current hypercall preemption status, with a suitably
adjusted first argument. Note that this is correct also for the native
guest case: We now simply "commit" what was completed right away, rather
than at the end of a series of preemption/re-start cycles. In fact this
improves overall preemption behavior: There's no longer a potentially
big chunk of work done non-preemptively at the end of the last
"iteration".

Fixes: b2245acc60c3 ("xen/pvshim: memory hotplug")
Signed-off-by: Igor Druzhinin <igor.druzhinin@xxxxxxxxxx>
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -1461,22 +1461,17 @@ long do_memory_op(unsigned long cmd, XEN
 
         rc = args.nr_done;
 
-        if ( args.preempted )
-            return hypercall_create_continuation(
-                __HYPERVISOR_memory_op, "lh",
-                op | (rc << MEMOP_EXTENT_SHIFT), arg);
-
 #ifdef CONFIG_X86
         if ( pv_shim && op == XENMEM_decrease_reservation )
-            /*
-             * Only call pv_shim_offline_memory when the hypercall has
-             * finished. Note that nr_done is used to cope in case the
-             * hypercall has failed and only part of the extents where
-             * processed.
-             */
-            pv_shim_offline_memory(args.nr_done, args.extent_order);
+            pv_shim_offline_memory(args.nr_done - start_extent,
+                                   args.extent_order);
 #endif
 
+        if ( args.preempted )
+           return hypercall_create_continuation(
+                __HYPERVISOR_memory_op, "lh",
+                op | (rc << MEMOP_EXTENT_SHIFT), arg);
+
         break;
 
     case XENMEM_exchange:




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.