From patchwork Mon Oct 2 12:59:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114602 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp653680qgn; Mon, 2 Oct 2017 06:02:04 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDUywJynEejWMR6xSFelxa3r+LHCZTUxV7OSEil4d+eNhFxrnbk88PGr4+bR6tb4WAoYTf1 X-Received: by 10.107.19.139 with SMTP id 11mr23785901iot.286.1506949323975; Mon, 02 Oct 2017 06:02:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506949323; cv=none; d=google.com; s=arc-20160816; b=mjajx8RQs/a+vg5ETcjYqmLRo/T1pS8PXye7eASOR4driuNBc4mPSlzFRofIrhIKAZ UDLveJ+qAGHHAKG9eFW68qcorZpB2YxHKZg7BgaFjl++r9SJJIxUB/+DfGkZTPLnZ5mB EM8crGDyeuLUHLEX1Qpk4jktFlLj0v4dEV4qRdTrirwLp3zjGhxA0EeWX7pLt/56suKS rjh9+lw2ELmhAeAsT3wUtirO3hRwWHI8H1XkqUSy2Byj31GPTwcEAE3PwQS/rSd2y1Bm n0ty84MiCdJ8cv2E8IHAiN8iwjGnyDJ8Sx0nvM0Xvt+y3HpFnFzevOf2NilVPY0xGRef mE6A== 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=1IDh8lf0d3NHYTC7S9T/bvZNw9XXMKDwRzWWdwCocKw=; b=c6tLnUSIf3/N40d+eFPDvJVnJTzBaPdTajnbXR2cuxoBcMjDG3xY7SR1mgLnkiCnDa 4u1CCfo15yS9iITwpjrOOUspk1uNaJzUYuGSCSLu4F0mOeW6tBV1GiDk79i69gZY6vQc IjsXnWNM46Ig1fy9EHImfpECrJx1wuGUb4bl9l3XryP5T+Mvr0bIt5GtW4+GAEmWzQmJ hlng/vb2JrZarUz/4QgB0I9B0XfiuFKyPiqcoDAICdpAiE2TqLRuuNcT5gJqM2tfUI9i XTDFT0EL1bHpHTOD2LdcI0OMJOOtN/B67oqLcZubN47GpapVZmN6ADXcyoGUwMoKxUVe x36w== 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 c3si9019218iog.153.2017.10.02.06.02.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 06:02:03 -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 1dz0KS-0004Ia-8i; Mon, 02 Oct 2017 13:00:12 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz0KQ-0004Er-RC for xen-devel@lists.xen.org; Mon, 02 Oct 2017 13:00:10 +0000 Received: from [85.158.139.211] by server-13.bemta-5.messagelabs.com id 96/D0-01784-A5832D95; Mon, 02 Oct 2017 13:00:10 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTTfS4lK kwZnD0hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0bP7gtsBefFK15sWcvSwHhfsIuRk0NIYDOj xNrZ+V2MXED2aUaJFXtPsIAk2AQ0Je58/sQEYosISEtc+3yZEaSIWWAxo8Tn/b3MIAlhgQyJm Sv+gdksAqoSEx9uBmvgFbCS+LXyDyOILSEgL7Gr7SIriM0JFH9//CMrxGZLiePdk5gmMHIvYG RYxahRnFpUllqka2isl1SUmZ5RkpuYmaNraGCql5taXJyYnpqTmFSsl5yfu4kR6GEGINjB+G+ b5yFGSQ4mJVFeZsNLkUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeFPMgXKCRanpqRVpmTnAUINJ S3DwKInwmoKkeYsLEnOLM9MhUqcYdTk6bt79wyTEkpeflyolzlsBUiQAUpRRmgc3Ahb2lxhlp YR5GYGOEuIpSC3KzSxBlX/FKM7BqCTMywUyhSczrwRu0yugI5iAjpjTdQHkiJJEhJRUA2NSf6 1yTXLCvIkXn/7JPnNMTaeq2v3pl71mmkwBjz+ePa0o/4jrpPykd9+VErY0TmI5U8iU2vNpm69 xwhX2ZP3ZyWEnFvWLMc5eXrB8Y/CmZzFyBqGNRY4bVubvf1VofvKKoa/kZMuc++9t7/caftPa pP4gcta1rwxMZ15l/vgcou3Pr6JzIkGJpTgj0VCLuag4EQCEDLbSdgIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-5.tower-206.messagelabs.com!1506949208!112539087!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 64879 invoked from network); 2 Oct 2017 13:00:09 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-5.tower-206.messagelabs.com with SMTP; 2 Oct 2017 13:00:09 -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 A7B37165D; Mon, 2 Oct 2017 06:00:08 -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 987903F53D; Mon, 2 Oct 2017 06:00:07 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 13:59:40 +0100 Message-Id: <20171002125941.11274-15-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171002125941.11274-1-julien.grall@arm.com> References: <20171002125941.11274-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v3 14/15] 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 Reviewed-by: George Dunlap --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v3: - Add Wei's reviewed-by 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 55f2fa4f18..8d50a0db85 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