From nobody Mon Feb 9 21:12:09 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1577119474; cv=none; d=zohomail.com; s=zohoarc; b=XTU4uq+mSCV4zh87t2uOFX6tN9UUJv6RVkVxq5/v587iYW0EQ/TLF+6+SChUEIQ5rYFgDdpyLD2rycVK2cS7+pQC0mbf1t0ZULChoQIM3M0Yrru9EdHibrYEJ76gadK9CHS2oAs6F5P2yuH29JUkxO6qBXXEWpvcs4zdnAhkoCQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577119474; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uvxIBt7xhOETBNjjNd3qbAIMg3JurLbg7GByXWbQ6S4=; b=m/rXibjS1ID4c4KMQWKAx3eCENTg3pZY6XljHcfJyjxMShl8OIAaZB4umeezLtTXy/ht+4/WnVFKnjk3CYTbJHjJKUPk5srRRAmKgz1dcRoGDiV/jRrnKfNV/WA8xScFx3o7gQMQezQS20alICmnJfuHxxJis+xUuhZ8sjEx0CU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 157711947448638.13102011806916; Mon, 23 Dec 2019 08:44:34 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ijQo0-0006Ht-0p; Mon, 23 Dec 2019 16:43:40 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ijQny-0006Hg-VI for xen-devel@lists.xenproject.org; Mon, 23 Dec 2019 16:43:38 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5ac53912-25a3-11ea-96fe-12813bfff9fa; Mon, 23 Dec 2019 16:43:34 +0000 (UTC) X-Inumbo-ID: 5ac53912-25a3-11ea-96fe-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1577119414; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7vWp9GkW3ug+BLCdr2aqVvMT7j7OYz0ptK5b/xJThzk=; b=JzdaddEBp2gfFrj9Sge4mRu0EsTJrDoAZZ2dmN4nP2f6w37UlcPdrr+O ni1lqLtlxuD904m9cJKYjMR9N8V9o3qRGPsMgA5G8mogU+0jPKMCmodqK b/oVARpUqyKZQhEOSJM0gRl00fIBGfsaXemsLAOrqBDEjvJP2kpO/T8+S o=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=george.dunlap@citrix.com; spf=Pass smtp.mailfrom=George.Dunlap@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of george.dunlap@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="george.dunlap@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of George.Dunlap@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="George.Dunlap@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 1ngXjC+DlOsqHUXA2V84RYcwdaRuaVODbDhbte0npTb8cVe9u0mcKyBEcYtcUlhXtBzHoQVgDJ ILjBaO49C6Mo2jJTfxcT/D3sGnR5Hoc9RpyakuSohggTk4mMTHaucVcSzroBp3HaM10lVR1gtJ w8AeWQAZ7+c1a/C54NIew76cRZ+u98qJZMblkF28sEhspZnxVCT2n1wOe5eyeoxck7IptGAfRJ FuBrgA5dUcmZ4LNavMm/YFvSqnTelgFKTS5jyZDLVRMxIUUNF0znCXGRO7djoDUOHs1Mei98sp LOo= X-SBRS: 2.7 X-MesageID: 10229660 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,348,1571716800"; d="scan'208";a="10229660" From: George Dunlap To: Date: Mon, 23 Dec 2019 16:43:28 +0000 Message-ID: <20191223164329.3113378-4-george.dunlap@citrix.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191223164329.3113378-1-george.dunlap@citrix.com> References: <20191223164329.3113378-1-george.dunlap@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 3/4] mm: Use put_old_guest_table for relinquish_pages X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , George Dunlap , Jan Beulich Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) relinquish_pages() deals with interrupted de-validation in a fairly ad-hoc way, by either re-setting PGT_pinned (in the case of EINTR) or letting the page "fall through" to the "force invalidate" loop below. This requires an extensive comment describing what needs to happen to the type and count in each case, and why each works. Additionally, it turns out that at this point, the "force invalidate" loop is only required to handle this ad-hoc continuation. Replace this with the 'standard' way of dealing with restarting pages, old_guest_table. Call put_old_guest_table(current) at the top of the function, and set current->arch.old_guest_table* as appropriate. This code is simpler, and mirrors other old_guest_table code in mm.c. It will also allow us to remove the force-invalidate loop entirely in a subsequent patch. While here, make the refcounting logic a bit easier to follow: We always drop the general reference held by PGT_pinned, regardless of what happens to the type count. Rather than manually re-dropping the refcount if put_page_and_type_preemptible() fails, just drop the refcount unconditionally, and call put_page_type_preemptible() instead. Signed-off-by: George Dunlap Reviewed-by: Jan Beulich --- CC: Andrew Cooper CC: Jan Beulich --- xen/arch/x86/domain.c | 50 +++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index d9c63379cd..b7968463cb 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1953,6 +1953,10 @@ static int relinquish_memory( unsigned long x, y; int ret =3D 0; =20 + ret =3D put_old_guest_table(current); + if ( ret ) + return ret; + /* Use a recursive lock, as we may enter 'free_domheap_page'. */ spin_lock_recursive(&d->page_alloc_lock); =20 @@ -1967,42 +1971,32 @@ static int relinquish_memory( } =20 if ( test_and_clear_bit(_PGT_pinned, &page->u.inuse.type_info) ) - ret =3D put_page_and_type_preemptible(page); + { + /* Always drop the page ref associated with PGT_pinned */ + put_page(page); + ret =3D put_page_type_preemptible(page); + } switch ( ret ) { case 0: break; - case -ERESTART: case -EINTR: - /* - * -EINTR means PGT_validated has been re-set; re-set - * PGT_pinned again so that it gets picked up next time - * around. - * - * -ERESTART, OTOH, means PGT_partial is set instead. Put - * it back on the list, but don't set PGT_pinned; the - * section below will finish off de-validation. But we do - * need to drop the general ref associated with - * PGT_pinned, since put_page_and_type_preemptible() - * didn't do it. - * - * NB we can do an ASSERT for PGT_validated, since we - * "own" the type ref; but theoretically, the PGT_partial - * could be cleared by someone else. - */ - if ( ret =3D=3D -EINTR ) - { - ASSERT(page->u.inuse.type_info & PGT_validated); - set_bit(_PGT_pinned, &page->u.inuse.type_info); - } - else - put_page(page); + ASSERT(page->u.inuse.type_info & PGT_validated); + /* Fallthrough */ + case -ERESTART: + current->arch.old_guest_ptpg =3D NULL; + current->arch.old_guest_table =3D page; + current->arch.old_guest_table_partial =3D (ret =3D=3D -ERESTAR= T); =20 ret =3D -ERESTART; =20 - /* Put the page back on the list and drop the ref we grabbed a= bove */ - page_list_add(page, list); - put_page(page); + /* Make sure we don't lose track of the page */ + page_list_add_tail(page, &d->arch.relmem_list); + + /* + * NB that we've transferred the general ref acquired at + * the top of the loop to old_guest_table. + */ goto out; default: BUG(); --=20 2.24.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel