From patchwork Wed Jun 21 09:37:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9801345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DD11E60329 for ; Wed, 21 Jun 2017 09:40:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0606E28511 for ; Wed, 21 Jun 2017 09:39:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EEAFC2853C; Wed, 21 Jun 2017 09:39:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5769A28511 for ; Wed, 21 Jun 2017 09:39:34 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNc4t-0000Zn-Ud; Wed, 21 Jun 2017 09:37:35 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNc4t-0000ZU-5Z for xen-devel@lists.xenproject.org; Wed, 21 Jun 2017 09:37:35 +0000 Received: from [85.158.137.68] by server-4.bemta-3.messagelabs.com id 44/0E-31580-E5E3A495; Wed, 21 Jun 2017 09:37:34 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrHIsWRWlGSWpSXmKPExsXS6fjDSzfWziv SYPdNOYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNePKhnlMBS9kKs6tvcnawHhVrIuRk0NIIE/i wO5DrCA2r4CdxIZNexhBbAkBQ4nTC2+ygNgsAqoSX3dNB7PZBNQl2p5tB6rn4BARMJA4dzSpi 5GLg1lgLZPExVl3mUBqhAWCJNbtucMKMb9IYuuB1ewgNqeAvcScZa/ZQHp5BQQl/u4QBgkzA6 19s/M/0wRGnlkImVlIMhC2lsTDX7dYIGxtiWULXzODlDMLSEss/8cBEXaVmHh0DROqEhA7QKL 32hS2BYwcqxg1ilOLylKLdI0N9JKKMtMzSnITM3N0DQ2M9XJTi4sT01NzEpOK9ZLzczcxAsO1 noGBcQdj5wm/Q4ySHExKorwXZL0ihfiS8lMqMxKLM+KLSnNSiw8xynBwKEnwnrcBygkWpaanV qRl5gAjByYtwcGjJMK7zBwozVtckJhbnJkOkTrFqCglztsD0icAksgozYNrg0XrJUZZKWFeRg YGBiGegtSi3MwSVPlXjOIcjErCvAEgU3gy80rgpr8CWswEtPjFEQ+QxSWJCCmpBsYVq1b/vrP qYfnRTXKZe6uXLD/J9On4z9DwdG3d+Wduf1sfuDT4tGQdh0pkUI3bp8+nQ+69L7APOH85/emf k1G+WaXvfdvSbgc17ynftuvjnH7b9sP9J60rHzHP5PXjDVIpXLvV/O3nX/55m7Y8Zb9cMDfiW tenv53pd+ZuSlm+UM9CP37OE7PnSizFGYmGWsxFxYkA4cEUA9ECAAA= X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-11.tower-31.messagelabs.com!1498037851!75797424!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 52383 invoked from network); 21 Jun 2017 09:37:33 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-11.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 21 Jun 2017 09:37:33 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Wed, 21 Jun 2017 03:37:31 -0600 Message-Id: <594A5A7902000078001650BA@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.2 Date: Wed, 21 Jun 2017 03:37:29 -0600 From: "Jan Beulich" To: "xen-devel" References: <594A57B10200007800165012@prv-mh.provo.novell.com> <594A57B10200007800165012@prv-mh.provo.novell.com> In-Reply-To: <594A57B10200007800165012@prv-mh.provo.novell.com> Mime-Version: 1.0 Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan Subject: [Xen-devel] [PATCH 09/11] gnttab: avoid spurious maptrack handle allocation failures X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP When no memory is available in the hypervisor, rather than immediately failing the request try to steal a handle from another vCPU. Reported-by: George Dunlap Signed-off-by: Jan Beulich gnttab: avoid spurious maptrack handle allocation failures When no memory is available in the hypervisor, rather than immediately failing the request try to steal a handle from another vCPU. Reported-by: George Dunlap Signed-off-by: Jan Beulich --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -397,7 +397,7 @@ get_maptrack_handle( struct vcpu *curr = current; unsigned int i, head; grant_handle_t handle; - struct grant_mapping *new_mt; + struct grant_mapping *new_mt = NULL; handle = __get_maptrack_handle(lgt, curr); if ( likely(handle != -1) ) @@ -408,8 +408,13 @@ get_maptrack_handle( /* * If we've run out of frames, try stealing an entry from another * VCPU (in case the guest isn't mapping across its VCPUs evenly). + * Also use this path in case we're out of memory, to avoid spurious + * failures. */ - if ( nr_maptrack_frames(lgt) >= max_maptrack_frames ) + if ( nr_maptrack_frames(lgt) < max_maptrack_frames ) + new_mt = alloc_xenheap_page(); + + if ( !new_mt ) { /* * Can drop the lock since no other VCPU can be adding a new @@ -432,12 +437,6 @@ get_maptrack_handle( return steal_maptrack_handle(lgt, curr); } - new_mt = alloc_xenheap_page(); - if ( !new_mt ) - { - spin_unlock(&lgt->maptrack_lock); - return -1; - } clear_page(new_mt); /* --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -397,7 +397,7 @@ get_maptrack_handle( struct vcpu *curr = current; unsigned int i, head; grant_handle_t handle; - struct grant_mapping *new_mt; + struct grant_mapping *new_mt = NULL; handle = __get_maptrack_handle(lgt, curr); if ( likely(handle != -1) ) @@ -408,8 +408,13 @@ get_maptrack_handle( /* * If we've run out of frames, try stealing an entry from another * VCPU (in case the guest isn't mapping across its VCPUs evenly). + * Also use this path in case we're out of memory, to avoid spurious + * failures. */ - if ( nr_maptrack_frames(lgt) >= max_maptrack_frames ) + if ( nr_maptrack_frames(lgt) < max_maptrack_frames ) + new_mt = alloc_xenheap_page(); + + if ( !new_mt ) { /* * Can drop the lock since no other VCPU can be adding a new @@ -432,12 +437,6 @@ get_maptrack_handle( return steal_maptrack_handle(lgt, curr); } - new_mt = alloc_xenheap_page(); - if ( !new_mt ) - { - spin_unlock(&lgt->maptrack_lock); - return -1; - } clear_page(new_mt); /*