From patchwork Tue Feb 4 13:33:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 11364607 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3E45A1395 for ; Tue, 4 Feb 2020 13:34:57 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 23CD920661 for ; Tue, 4 Feb 2020 13:34:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 23CD920661 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iyyL6-0006ad-H2; Tue, 04 Feb 2020 13:34:04 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iyyL5-0006aW-FE for xen-devel@lists.xenproject.org; Tue, 04 Feb 2020 13:34:03 +0000 X-Inumbo-ID: 01a34fee-4753-11ea-8396-bc764e2007e4 Received: from mail-wr1-f68.google.com (unknown [209.85.221.68]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 01a34fee-4753-11ea-8396-bc764e2007e4; Tue, 04 Feb 2020 13:34:02 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id y17so23081474wrh.5 for ; Tue, 04 Feb 2020 05:34:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=dZKewUkbLsCOhasPhP3rj9eI9c2B1QYPQ9THXqty9y8=; b=rDCw+SFlSQGQ5O2x8qTk4AbWNy5pDyaujBosZm5Kp0gIDMzQeRkR28GlxXAW6Yk0Me 51wcvSag3+GsJ5p4IW8suuiDICShoMG5xpoA3jWqPuN/1WbqaLGdDS/qg5MRFO86QoHX b3D3FXAbOcsZWvD8d39L50ESELpDlpFOFRCXYe1LkWLHXRNnHn+cNtv97YBwhxu3PUX7 Hgo0+NIGQKtWL/5Xko5ZkutUVQEolP9QOYYfvS710DEUmS5oppaA12/J9vb29UtcJaWx aOZsqtyTRbKVog0zKIDHjXLoyF5r/9EVEfPdqwgBEP4eV6Rt9yp8W54VZQeDrKsjCjaV yj8Q== X-Gm-Message-State: APjAAAVD6vJrSWUXccQJxwZGoMXoeucQdyOPtvNvLunK1iLW7P3KGj/D 9w8NSRh2gCrfodsQ27StHitWiiyw4AM= X-Google-Smtp-Source: APXvYqzQc8Q5MwRE8gBaL4g7Mb+5BJBRSrHRHvDFklPacM7VIBAprHZr/Q3G4QZ6iJ4u342yIWtucQ== X-Received: by 2002:a5d:5347:: with SMTP id t7mr22001356wrv.401.1580823241792; Tue, 04 Feb 2020 05:34:01 -0800 (PST) Received: from ufe34d9ed68d054.ant.amazon.com (54-240-197-235.amazon.com. [54.240.197.235]) by smtp.gmail.com with ESMTPSA id a184sm3966727wmf.29.2020.02.04.05.34.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 05:34:01 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 4 Feb 2020 13:33:57 +0000 Message-Id: <20200204133357.32101-1-julien@xen.org> X-Mailer: git-send-email 2.17.1 Subject: [Xen-devel] [PATCH] xen/mm: Avoid assuming PG_state_inuse == 0 in assign_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: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Julien Grall , Ian Jackson , Jan Beulich MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Julien Grall At the moment, assign_pages() relies on PG_state_inuse to be 0. This makes the code slightly more difficult to understand. Rework the code to explicitly check against PG_state_inuse. Signed-off-by: Julien Grall --- xen/common/page_alloc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 97902d42c1..54773bc42f 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -2286,10 +2286,11 @@ int assign_pages( for ( i = 0; i < (1 << order); i++ ) { ASSERT(page_get_owner(&pg[i]) == NULL); - ASSERT(!pg[i].count_info); + ASSERT(page_state_is(&pg[i], inuse)); + ASSERT(!(pg[i].count_info & (~PGC_state))); page_set_owner(&pg[i], d); smp_wmb(); /* Domain pointer must be visible before updating refcnt. */ - pg[i].count_info = PGC_allocated | 1; + pg[i].count_info = PGC_state_inuse | PGC_allocated | 1; page_list_add_tail(&pg[i], &d->page_list); }