From patchwork Thu Sep 21 12:40:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 113254 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1846153edb; Thu, 21 Sep 2017 05:43:05 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCQoEF0mb/RV+4G2/Vuf0zn+fqvzYiFV8+hhSF7wbS9cwHK3OaPJmZ6qLnY5pkxJ/V6lJzG X-Received: by 10.107.107.17 with SMTP id g17mr2673758ioc.126.1505997785486; Thu, 21 Sep 2017 05:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505997785; cv=none; d=google.com; s=arc-20160816; b=ytKJdgxrHkYSpuDawCQL9jX4HAM27vMTaFdpeEIrmfmjdkEWl+KhZAqtshtNfTGZo5 qpDhLC3eg9U6DmMHtZjT+QmEs6OS5spfUj7TRfXPT3V6/YwzWstVoQL3pniShpwnZo66 V3O5YdgCLKrHMDKltv+ERXDBKy4kOze/67aPNY0OSOwtQlnescBL1v0PJ6ognahss/aR Q3v219vM8/4CRtgzIaA07XsxcybD7yPJYvmLgqK5MIC9s7yVF3ny5VGoext6p+91wyCT Jqan2nH5D56jVvBcc7cuJfA2FnlaTpbDuvz9g4ITXNHcBuZxCCytDTGHARspD+YWpNfI aFYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=eZxolKHnEN0FIzbRnZVf8YYlbAmI9F3VUodb+Hq2lmo=; b=Nvti4dguXU1xz9SrLL6TTnPOCwUUpEeer242286kgM+e4WTXOejLujRbRx/G3X6qz1 px1psZrZjgX7KpmjHcd3BHRMSIcEqFAY98dXqDuNSvHprWqmuWDsOBPFWVWCwzb+H0+2 6viWBcj1sAbSyBnnONd1l8xJOHBVPXH6nb+61p7z0+XD8QyILz8Yc25GTw1NgcbLm9tr dwar1EXq/GIxBVIa/Po5Pj1oxTNIQTooJ1NQdiyYhJz90RKlbVkzNfGp15AdcLBlGApo 98nSJB84IL5eIoASML1Yc/ynJn5eVGeJD3ZsF9aEhl0QZPEohyZk0s7xodyfUR3smjLg +b8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id b1si1073351iog.131.2017.09.21.05.43.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 05:43:05 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dv0mw-0001Wk-E4; Thu, 21 Sep 2017 12:41:06 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dv0mv-0001Uy-Br for xen-devel@lists.xen.org; Thu, 21 Sep 2017 12:41:05 +0000 Received: from [85.158.137.68] by server-5.bemta-3.messagelabs.com id 59/5D-02226-063B3C95; Thu, 21 Sep 2017 12:41:04 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCLMWRWlGSWpSXmKPExsVysyfVTTd+8+F Ig64TjBZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8a3S43sBR/EKn5/Ps/UwDhDsIuRi0NIYDOj xOfPh9ggnNOMEpf7XjJ1MXJysAloStz5/AnMFhGQlrj2+TIjSBGzwGKgjv29zCAJYYEMiTunH 7KD2CwCqhItjzoYQWxeAUuJ453dbCC2hIC8xK62i6wgNidQvO3wNzBbSMBC4teEE6wTGLkXMD KsYtQoTi0qSy3SNTLWSyrKTM8oyU3MzNE1NDDWy00tLk5MT81JTCrWS87P3cQI9HE9AwPjDsa +vX6HGCU5mJREed+tOxwpxJeUn1KZkVicEV9UmpNafIhRhoNDSYI3YBNQTrAoNT21Ii0zBxhs MGkJDh4lEd4mkDRvcUFibnFmOkTqFKMuR8fNu3+YhFjy8vNSpcR5zUGKBECKMkrz4EbAAv8So 6yUMC8jAwODEE9BalFuZgmq/CtGcQ5GJWFeZZApPJl5JXCbXgEdwQR0RPaGAyBHlCQipKQaGK d6Opya1FK1JcBR9uzH2Z8ttxya0HbGeWbbvJofCxouri18df1H1pPqoxGhrjf615+zvqC5cGP I3Z2Ti1OO/RLw8X6jqyEU4edUO3PaubYYM0OBpncFguHCu1/ZrredKr/pRayAKve1j4dcD19Q yPSuMuM43fHnhdT5yrCL0Q0LJuxramlvZlBiKc5INNRiLipOBAClw8tsdwIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-12.tower-31.messagelabs.com!1505997662!99078187!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30416 invoked from network); 21 Sep 2017 12:41:02 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-31.messagelabs.com with SMTP; 21 Sep 2017 12:41:02 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 44E1B1682; Thu, 21 Sep 2017 05:41:02 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 359E53F58C; Thu, 21 Sep 2017 05:41:01 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 21 Sep 2017 13:40:33 +0100 Message-Id: <20170921124035.2410-15-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170921124035.2410-1-julien.grall@arm.com> References: <20170921124035.2410-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v2 14/16] xen/x86: p2m-pod: Use typesafe gfn for the fields reclaim_single and max_guest 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Signed-off-by: Julien Grall Acked-by: Andrew Cooper Reviewed-by: Wei Liu --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v2: - Add Andrew's acked-by --- xen/arch/x86/mm/p2m-pod.c | 11 +++++------ xen/include/asm-x86/p2m.h | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index 5c79444d7b..311762b1ce 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -977,10 +977,10 @@ p2m_pod_emergency_sweep(struct p2m_domain *p2m) p2m_type_t t; - if ( p2m->pod.reclaim_single == 0 ) + if ( gfn_eq(p2m->pod.reclaim_single, _gfn(0)) ) p2m->pod.reclaim_single = p2m->pod.max_guest; - start = p2m->pod.reclaim_single; + start = gfn_x(p2m->pod.reclaim_single); limit = (start > POD_SWEEP_LIMIT) ? (start - POD_SWEEP_LIMIT) : 0; /* FIXME: Figure out how to avoid superpages */ @@ -990,7 +990,7 @@ p2m_pod_emergency_sweep(struct p2m_domain *p2m) * careful about spinlock recursion limits and POD_SWEEP_STRIDE. */ p2m_lock(p2m); - for ( i = p2m->pod.reclaim_single; i > 0 ; i-- ) + for ( i = gfn_x(p2m->pod.reclaim_single); i > 0 ; i-- ) { p2m_access_t a; (void)p2m->get_entry(p2m, _gfn(i), &t, &a, 0, NULL, NULL); @@ -1020,7 +1020,7 @@ p2m_pod_emergency_sweep(struct p2m_domain *p2m) p2m_pod_zero_check(p2m, gfns, j); p2m_unlock(p2m); - p2m->pod.reclaim_single = i ? i - 1 : i; + p2m->pod.reclaim_single = _gfn(i ? i - 1 : i); } @@ -1135,8 +1135,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn, goto out_of_memory; /* Keep track of the highest gfn demand-populated by a guest fault */ - if ( gfn_x(gfn) > p2m->pod.max_guest ) - p2m->pod.max_guest = gfn_x(gfn); + p2m->pod.max_guest = gfn_max(gfn, p2m->pod.max_guest); /* * Get a page f/ the cache. A NULL return value indicates that the diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index 1ae9216404..e8a9dca480 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -316,8 +316,8 @@ struct p2m_domain { single; /* Non-super lists */ long count, /* # of pages in cache lists */ entry_count; /* # of pages in p2m marked pod */ - unsigned long reclaim_single; /* Last gpfn of a scan */ - unsigned long max_guest; /* gpfn of max guest demand-populate */ + gfn_t reclaim_single; /* Last gfn of a scan */ + gfn_t max_guest; /* gfn of max guest demand-populate */ /* * Tracking of the most recently populated PoD pages, for eager