From nobody Sat Dec 28 06:43:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1733158798; cv=none; d=zohomail.com; s=zohoarc; b=NAEqd+XfuvcI4paxm1D5uvlxo/vLdEXRmqazFMJgs3bbaFKXdLIVGecUVw0/sH49Bk/d4FGKTkTetu9RM9U319ZBjngkkjzs+RpkgCkMB6nNWzgwDh8O+UCn7dCHAHjw24QbDnHu4NtGRaHNacoQ079JpwPZW9SIujUFXb5vDCM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733158798; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Jo1+hlLxBc+2E+3aaQJBdv0vb2kf6V0j/TqdNW1tAOE=; b=HfvlOi0xF6AEwjVEqU+VqBWXI/fz1dV9zeRhRQvotWB9d8Iir6R2Uep0YcTcuVlz1k3UoPeAqzGuhHQHCozeiUtMNTQuztuq8lyo9CgyI/Qka4bpKI9aYnyBI0uN1WvGuszbflUZg1mDVSP31/kC+pbye//b0wOqeU7ylc7y9bw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1733158798527815.3591308613416; Mon, 2 Dec 2024 08:59:58 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.846771.1261981 (Exim 4.92) (envelope-from ) id 1tI9lp-0000UF-0V; Mon, 02 Dec 2024 16:59:37 +0000 Received: by outflank-mailman (output) from mailman id 846771.1261981; Mon, 02 Dec 2024 16:59:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tI9lo-0000Tz-Pz; Mon, 02 Dec 2024 16:59:36 +0000 Received: by outflank-mailman (input) for mailman id 846771; Mon, 02 Dec 2024 16:59:35 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tI9ln-0006x4-9c for xen-devel@lists.xenproject.org; Mon, 02 Dec 2024 16:59:35 +0000 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [2a00:1450:4864:20::634]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id cdcea3f1-b0ce-11ef-99a3-01e77a169b0f; Mon, 02 Dec 2024 17:59:33 +0100 (CET) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-aa543c4db92so666974066b.0 for ; Mon, 02 Dec 2024 08:59:33 -0800 (PST) Received: from carlo-ubuntu.home.arpa (host-95-230-250-178.business.telecomitalia.it. [95.230.250.178]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa5998e64c4sm526802666b.97.2024.12.02.08.59.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 08:59:32 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: cdcea3f1-b0ce-11ef-99a3-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=minervasys-tech.20230601.gappssmtp.com; s=20230601; t=1733158773; x=1733763573; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Jo1+hlLxBc+2E+3aaQJBdv0vb2kf6V0j/TqdNW1tAOE=; b=V/hCI906gyUME2CtsMSrQvcJpfmcETVyGJyIWfdJCJ+Dmym0H4sLHnF3tUIZFPceER 2GVX5lzZCB/8ugVb6p6YTsWq2tQTjF3Br+4i5XzTbqAanJgYcguTlGIWucwPXXCk6O7F lKcjmwA2cCWk6CKcx5vkUBPhfegSZ3uY3zC+7FrL1ZPRAIMQyAYf3y04sWMUcF3OXrCS RHMW6y1oAUDBiLTlnU0NmoM8nySXBwMDVaod62TdtfGYLcXyaC8Kz8czeb5D+BccA0Xf Z87eMwkquz8ktO4fEYodQm0d6ip5sKNfnDrIjkhCbX0Q9RXsIS22PSkh+NfMvapFJ3r5 hefw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733158773; x=1733763573; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Jo1+hlLxBc+2E+3aaQJBdv0vb2kf6V0j/TqdNW1tAOE=; b=MkhlMgIE5XcyS4l01fnLbpSAwzugFjHML9K3zW4p7br0ihAOxvy0x3ZUZTwgf2lCaL SCCWSsGHp82n4Ggbuy+F4Mq5WQO0ltIwWstRnxznKUiMK9ZOfV++ZCbHO6Y1PsIACsBW IMj98SfHRmasXmTYx49MiNiVa9N+DKwAoW9ZdlxNX0WYWMKmkRdrNt+OEZ2SYnKWxerb 3rW7nPIS0YD/qiRrmQZ4XOjcEH/hH71Y2RweZ4NAm+LU3mdNZ+HXY8MIB66kU3WrIGtZ f7U192j5yhKBQFW6QpQz/gmCd6nRyVTxo2Tsj54GFriIFYmdkQtitgRFqo/nXGf9gtp5 Pi5w== X-Gm-Message-State: AOJu0YxHs1u1CcQVcflK9Jv55ZTbhxDzqRHYKu2+qfFOwownz3yKiHtU dZ4EhIh6xgnKb65DiJdpxjtkNfRH9nWpQUxZATO6QoN12hd4juOcYcTmFYLeTe8fD6Aj0+ck4hP a X-Gm-Gg: ASbGnctdbcww/jxqsw2j/Eq4YEiNDH3qRe14jxvZ0t5gZCKbw8Q/J2P3DRHyb/NcOXA +i9+hyzduPqoT3V17SDFA3DtS2OfCqy8Jwl5PiJbk9WjJz0xZcEIqrPsdLTdDf7JePF0mZryHdz IpXxj/RX7hbJuX7tV5hlWShNvCb9vgNm6yoI78Hx4LLP10mDXAC1ELEjwsYPvIcV3u7gLQHZ7P/ Fv9yJ4D5uSSR8nAWyrn5YabPQDQJ6gxZgNZaosu8/Eq/8PHKdnwf2VYpVDv4KlYuW1HZTS60iOe ajbhl36QYp3LK7iEvzjLnVsj84yECE+xvJxP+EC0JbMIr5byEAPg X-Google-Smtp-Source: AGHT+IFR0lxo0qW7rgGGz6p/lTSVqQksARCF+uwg/BOh7xiEKCWmRLJ2vEox2DuIuRXNxSvX4lKEFQ== X-Received: by 2002:a17:906:329a:b0:aa5:1d08:dacf with SMTP id a640c23a62f3a-aa580f01a6amr2077894266b.13.1733158772840; Mon, 02 Dec 2024 08:59:32 -0800 (PST) From: Carlo Nonato To: xen-devel@lists.xenproject.org Cc: andrea.bastoni@minervasys.tech, marco.solieri@minervasys.tech, Carlo Nonato , Andrew Cooper , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH v11 08/12] xen/page_alloc: introduce preserved page flags macro Date: Mon, 2 Dec 2024 17:59:17 +0100 Message-ID: <20241202165921.249585-9-carlo.nonato@minervasys.tech> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241202165921.249585-1-carlo.nonato@minervasys.tech> References: <20241202165921.249585-1-carlo.nonato@minervasys.tech> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @minervasys-tech.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1733158799377116600 Content-Type: text/plain; charset="utf-8" PGC_static and PGC_extra need to be preserved when assigning a page. Define a new macro that groups those flags and use it instead of or'ing every time. Signed-off-by: Carlo Nonato --- v11: - removed PGC_broken from PGC_preserved - removed PGC preservation from mark_page_free() v10: - fixed commit message v9: - add PGC_broken to PGC_preserved - clear PGC_extra in alloc_domheap_pages() only if MEMF_no_refcount is set v8: - fixed PGC_extra ASSERT fail in alloc_domheap_pages() by removing PGC_extra before freeing v7: - PGC_preserved used also in mark_page_free() v6: - preserved_flags renamed to PGC_preserved - PGC_preserved is used only in assign_pages() v5: - new patch --- xen/common/page_alloc.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 55d561e93c..e73b404169 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -161,6 +161,7 @@ #endif =20 #define PGC_no_buddy_merge PGC_static +#define PGC_preserved (PGC_extra | PGC_static) =20 #ifndef PGT_TYPE_INFO_INITIALIZER #define PGT_TYPE_INFO_INITIALIZER 0 @@ -1447,8 +1448,7 @@ static bool mark_page_free(struct page_info *pg, mfn_= t mfn) break; =20 case PGC_state_offlining: - pg->count_info =3D (pg->count_info & PGC_broken) | - PGC_state_offlined; + pg->count_info =3D (pg->count_info & PGC_broken) | PGC_state_offli= ned; pg_offlined =3D true; break; =20 @@ -2382,7 +2382,7 @@ int assign_pages( =20 for ( i =3D 0; i < nr; i++ ) { - ASSERT(!(pg[i].count_info & ~(PGC_extra | PGC_static))); + ASSERT(!(pg[i].count_info & ~PGC_preserved)); if ( pg[i].count_info & PGC_extra ) extra_pages++; } @@ -2442,7 +2442,7 @@ int assign_pages( page_set_owner(&pg[i], d); smp_wmb(); /* Domain pointer must be visible before updating refcn= t. */ pg[i].count_info =3D - (pg[i].count_info & (PGC_extra | PGC_static)) | PGC_allocated = | 1; + (pg[i].count_info & PGC_preserved) | PGC_allocated | 1; =20 page_list_add_tail(&pg[i], page_to_list(d, &pg[i])); } @@ -2501,6 +2501,14 @@ struct page_info *alloc_domheap_pages( } if ( assign_page(pg, order, d, memflags) ) { + if ( memflags & MEMF_no_refcount ) + { + unsigned long i; + + for ( i =3D 0; i < (1UL << order); i++ ) + pg[i].count_info &=3D ~PGC_extra; + } + free_heap_pages(pg, order, memflags & MEMF_no_scrub); return NULL; } @@ -2555,6 +2563,7 @@ void free_domheap_pages(struct page_info *pg, unsigne= d int order) { ASSERT(d->extra_pages); d->extra_pages--; + pg[i].count_info &=3D ~PGC_extra; } } =20 --=20 2.43.0