From nobody Tue May 21 07:57:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1553156922985655.0214148505578; Thu, 21 Mar 2019 01:28:42 -0700 (PDT) Received: from localhost ([127.0.0.1]:33158 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6t42-000108-Tp for importer@patchew.org; Thu, 21 Mar 2019 04:28:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46501) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6t21-0008ET-OE for qemu-devel@nongnu.org; Thu, 21 Mar 2019 04:26:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6t20-0000y3-Nc for qemu-devel@nongnu.org; Thu, 21 Mar 2019 04:26:33 -0400 Received: from mga09.intel.com ([134.134.136.24]:44135) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6t20-0000wP-8b for qemu-devel@nongnu.org; Thu, 21 Mar 2019 04:26:32 -0400 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Mar 2019 01:26:30 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga006.fm.intel.com with ESMTP; 21 Mar 2019 01:26:29 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,252,1549958400"; d="scan'208";a="329280542" From: Wei Yang To: qemu-devel@nongnu.org Date: Thu, 21 Mar 2019 16:25:50 +0800 Message-Id: <20190321082555.21118-2-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190321082555.21118-1-richardw.yang@linux.intel.com> References: <20190321082555.21118-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.24 Subject: [Qemu-devel] [PATCH 1/6] exec.c: replace hwaddr with uint64_t for better understanding X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, mst@redhat.com, Wei Yang , rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Function phys_page_set() and phys_page_set_level() 's argument *nb* stands for number of pages to set instead of hardware address. This would be more proper to use uint64_t instead of hwaddr for its type. Signed-off-by: Wei Yang --- exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exec.c b/exec.c index 86a38d3b3b..98ebd0dd1d 100644 --- a/exec.c +++ b/exec.c @@ -254,7 +254,7 @@ static uint32_t phys_map_node_alloc(PhysPageMap *map, b= ool leaf) } =20 static void phys_page_set_level(PhysPageMap *map, PhysPageEntry *lp, - hwaddr *index, hwaddr *nb, uint16_t leaf, + hwaddr *index, uint64_t *nb, uint16_t leaf, int level) { PhysPageEntry *p; @@ -280,7 +280,7 @@ static void phys_page_set_level(PhysPageMap *map, PhysP= ageEntry *lp, } =20 static void phys_page_set(AddressSpaceDispatch *d, - hwaddr index, hwaddr nb, + hwaddr index, uint64_t nb, uint16_t leaf) { /* Wildly overreserve - it doesn't matter much. */ --=20 2.19.1 From nobody Tue May 21 07:57:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1553156921229673.6900267653658; Thu, 21 Mar 2019 01:28:41 -0700 (PDT) Received: from localhost ([127.0.0.1]:33156 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6t41-0000yd-75 for importer@patchew.org; Thu, 21 Mar 2019 04:28:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46511) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6t22-0008Ep-BD for qemu-devel@nongnu.org; Thu, 21 Mar 2019 04:26:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6t21-0000z3-FE for qemu-devel@nongnu.org; Thu, 21 Mar 2019 04:26:34 -0400 Received: from mga09.intel.com ([134.134.136.24]:44135) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6t21-0000wP-1Q for qemu-devel@nongnu.org; Thu, 21 Mar 2019 04:26:33 -0400 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Mar 2019 01:26:32 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga006.fm.intel.com with ESMTP; 21 Mar 2019 01:26:31 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,252,1549958400"; d="scan'208";a="329280547" From: Wei Yang To: qemu-devel@nongnu.org Date: Thu, 21 Mar 2019 16:25:51 +0800 Message-Id: <20190321082555.21118-3-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190321082555.21118-1-richardw.yang@linux.intel.com> References: <20190321082555.21118-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.24 Subject: [Qemu-devel] [PATCH 2/6] exec.c: remove an unnecessary assert on PHYS_MAP_NODE_NIL in phys_map_node_alloc() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, mst@redhat.com, Wei Yang , rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" PHYS_MAP_NODE_NIL is assigned to PhysPageEntry.ptr in case this is not a leaf entry, while map->nodes_nb range in [0, nodes_nb_alloc). Seems we are asserting on two different things, just remove it. Signed-off-by: Wei Yang --- exec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/exec.c b/exec.c index 98ebd0dd1d..8e8b6bb1f9 100644 --- a/exec.c +++ b/exec.c @@ -242,7 +242,6 @@ static uint32_t phys_map_node_alloc(PhysPageMap *map, b= ool leaf) =20 ret =3D map->nodes_nb++; p =3D map->nodes[ret]; - assert(ret !=3D PHYS_MAP_NODE_NIL); assert(ret !=3D map->nodes_nb_alloc); =20 e.skip =3D leaf ? 0 : 1; --=20 2.19.1 From nobody Tue May 21 07:57:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1553156921965916.4485989354184; Thu, 21 Mar 2019 01:28:41 -0700 (PDT) Received: from localhost ([127.0.0.1]:33162 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6t42-00010k-So for importer@patchew.org; Thu, 21 Mar 2019 04:28:38 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46550) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6t24-0008Fq-VN for qemu-devel@nongnu.org; Thu, 21 Mar 2019 04:26:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6t23-00010i-FP for qemu-devel@nongnu.org; Thu, 21 Mar 2019 04:26:36 -0400 Received: from mga09.intel.com ([134.134.136.24]:44135) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6t22-0000wP-Vk for qemu-devel@nongnu.org; Thu, 21 Mar 2019 04:26:35 -0400 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Mar 2019 01:26:34 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga006.fm.intel.com with ESMTP; 21 Mar 2019 01:26:33 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,252,1549958400"; d="scan'208";a="329280562" From: Wei Yang To: qemu-devel@nongnu.org Date: Thu, 21 Mar 2019 16:25:52 +0800 Message-Id: <20190321082555.21118-4-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190321082555.21118-1-richardw.yang@linux.intel.com> References: <20190321082555.21118-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.24 Subject: [Qemu-devel] [PATCH 3/6] exec.c: get nodes_nb_alloc with one MAX calculation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, mst@redhat.com, Wei Yang , rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The purpose of these two MAX here is to get the maximum of these three variables: A: map->nodes_nb + nodes B: map->nodes_nb_alloc C: alloc_hint We can write it like MAX(A, B, C). Since the if condition says A > B, this means MAX(A, B, C) =3D MAX(A, C). This patch just simplify the calculation a bit. Signed-off-by: Wei Yang --- exec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/exec.c b/exec.c index 8e8b6bb1f9..78bf810ae8 100644 --- a/exec.c +++ b/exec.c @@ -226,8 +226,7 @@ static void phys_map_node_reserve(PhysPageMap *map, uns= igned nodes) { static unsigned alloc_hint =3D 16; if (map->nodes_nb + nodes > map->nodes_nb_alloc) { - map->nodes_nb_alloc =3D MAX(map->nodes_nb_alloc, alloc_hint); - map->nodes_nb_alloc =3D MAX(map->nodes_nb_alloc, map->nodes_nb + n= odes); + map->nodes_nb_alloc =3D MAX(alloc_hint, map->nodes_nb + nodes); map->nodes =3D g_renew(Node, map->nodes, map->nodes_nb_alloc); alloc_hint =3D map->nodes_nb_alloc; } --=20 2.19.1 From nobody Tue May 21 07:57:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1553157116362933.7510124672222; Thu, 21 Mar 2019 01:31:56 -0700 (PDT) Received: from localhost ([127.0.0.1]:33213 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6t7B-0003TB-Bh for importer@patchew.org; Thu, 21 Mar 2019 04:31:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6t27-0008IN-Kl for qemu-devel@nongnu.org; Thu, 21 Mar 2019 04:26:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6t25-00013N-O5 for qemu-devel@nongnu.org; Thu, 21 Mar 2019 04:26:39 -0400 Received: from mga09.intel.com ([134.134.136.24]:44135) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6t24-0000wP-Uy for qemu-devel@nongnu.org; Thu, 21 Mar 2019 04:26:37 -0400 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Mar 2019 01:26:36 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga006.fm.intel.com with ESMTP; 21 Mar 2019 01:26:35 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,252,1549958400"; d="scan'208";a="329280585" From: Wei Yang To: qemu-devel@nongnu.org Date: Thu, 21 Mar 2019 16:25:53 +0800 Message-Id: <20190321082555.21118-5-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190321082555.21118-1-richardw.yang@linux.intel.com> References: <20190321082555.21118-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.24 Subject: [Qemu-devel] [PATCH 4/6] exec.c: subpage->sub_section is already initialized to 0 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, mst@redhat.com, Wei Yang , rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" In subpage_init(), we will set subpage->sub_section to PHYS_SECTION_UNASSIGNED by subpage_register. Since PHYS_SECTION_UNASSIGNED is defined to be 0, and we allocate subpage with g_malloc0, this means subpage->sub_section is already initialized to 0. This patch removes the redundant setup for a new subpage and also fix the code style. Signed-off-by: Wei Yang --- exec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/exec.c b/exec.c index 78bf810ae8..788a8c3f69 100644 --- a/exec.c +++ b/exec.c @@ -1494,8 +1494,8 @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu, =20 #if !defined(CONFIG_USER_ONLY) =20 -static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end, - uint16_t section); +static int subpage_register(subpage_t *mmio, uint32_t start, uint32_t end, + uint16_t section); static subpage_t *subpage_init(FlatView *fv, hwaddr base); =20 static void *(*phys_mem_alloc)(size_t size, uint64_t *align, bool shared) = =3D @@ -2943,8 +2943,8 @@ static const MemoryRegionOps subpage_ops =3D { .endianness =3D DEVICE_NATIVE_ENDIAN, }; =20 -static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end, - uint16_t section) +static int subpage_register(subpage_t *mmio, uint32_t start, uint32_t end, + uint16_t section) { int idx, eidx; =20 @@ -2967,6 +2967,7 @@ static subpage_t *subpage_init(FlatView *fv, hwaddr b= ase) { subpage_t *mmio; =20 + /* mmio->sub_section is set to PHYS_SECTION_UNASSIGNED with g_malloc0 = */ mmio =3D g_malloc0(sizeof(subpage_t) + TARGET_PAGE_SIZE * sizeof(uint1= 6_t)); mmio->fv =3D fv; mmio->base =3D base; @@ -2977,7 +2978,6 @@ static subpage_t *subpage_init(FlatView *fv, hwaddr b= ase) printf("%s: %p base " TARGET_FMT_plx " len %08x\n", __func__, mmio, base, TARGET_PAGE_SIZE); #endif - subpage_register(mmio, 0, TARGET_PAGE_SIZE-1, PHYS_SECTION_UNASSIGNED); =20 return mmio; } --=20 2.19.1 From nobody Tue May 21 07:57:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1553157058920967.5506009330188; Thu, 21 Mar 2019 01:30:58 -0700 (PDT) Received: from localhost ([127.0.0.1]:33207 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6t6B-0002sW-SS for importer@patchew.org; Thu, 21 Mar 2019 04:30:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6t2D-0008Mv-DS for qemu-devel@nongnu.org; Thu, 21 Mar 2019 04:26:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6t2B-00017l-EO for qemu-devel@nongnu.org; Thu, 21 Mar 2019 04:26:45 -0400 Received: from mga09.intel.com ([134.134.136.24]:44135) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6t27-0000wP-Nm for qemu-devel@nongnu.org; Thu, 21 Mar 2019 04:26:41 -0400 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Mar 2019 01:26:38 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga006.fm.intel.com with ESMTP; 21 Mar 2019 01:26:37 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,252,1549958400"; d="scan'208";a="329280589" From: Wei Yang To: qemu-devel@nongnu.org Date: Thu, 21 Mar 2019 16:25:54 +0800 Message-Id: <20190321082555.21118-6-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190321082555.21118-1-richardw.yang@linux.intel.com> References: <20190321082555.21118-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.24 Subject: [Qemu-devel] [PATCH 5/6] exec.c: correct the maximum skip value during compact X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, mst@redhat.com, Wei Yang , rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" skip is defined with 6 bits. So the maximum value should be (1 << 6). Signed-off-by: Wei Yang --- exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exec.c b/exec.c index 788a8c3f69..6c660f656c 100644 --- a/exec.c +++ b/exec.c @@ -322,7 +322,7 @@ static void phys_page_compact(PhysPageEntry *lp, Node *= nodes) assert(valid_ptr < P_L2_SIZE); =20 /* Don't compress if it won't fit in the # of bits we have. */ - if (lp->skip + p[valid_ptr].skip >=3D (1 << 3)) { + if (lp->skip + p[valid_ptr].skip >=3D (1 << 6)) { return; } =20 --=20 2.19.1 From nobody Tue May 21 07:57:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1553157177385554.885819031395; Thu, 21 Mar 2019 01:32:57 -0700 (PDT) Received: from localhost ([127.0.0.1]:33219 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6t8A-000439-FS for importer@patchew.org; Thu, 21 Mar 2019 04:32:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6t2F-0008Ot-EZ for qemu-devel@nongnu.org; Thu, 21 Mar 2019 04:26:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6t2D-00019k-DV for qemu-devel@nongnu.org; Thu, 21 Mar 2019 04:26:47 -0400 Received: from mga09.intel.com ([134.134.136.24]:44141) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6t29-00015V-IO for qemu-devel@nongnu.org; Thu, 21 Mar 2019 04:26:43 -0400 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Mar 2019 01:26:40 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga006.fm.intel.com with ESMTP; 21 Mar 2019 01:26:39 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,252,1549958400"; d="scan'208";a="329280592" From: Wei Yang To: qemu-devel@nongnu.org Date: Thu, 21 Mar 2019 16:25:55 +0800 Message-Id: <20190321082555.21118-7-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190321082555.21118-1-richardw.yang@linux.intel.com> References: <20190321082555.21118-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.24 Subject: [Qemu-devel] [PATCH 6/6] exec.c: add a check between constants to see whether we could skip X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, mst@redhat.com, Wei Yang , rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The maximum level is defined as P_L2_LEVELS and skip is defined with 6 bits, which means if P_L2_LEVELS < (1 << 6), skip never exceeds the boundary. Since this check is between two constants, which leverages compiler to optimize the code based on different configuration. Signed-off-by: Wei Yang --- exec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exec.c b/exec.c index 6c660f656c..5d71fdb89f 100644 --- a/exec.c +++ b/exec.c @@ -322,7 +322,8 @@ static void phys_page_compact(PhysPageEntry *lp, Node *= nodes) assert(valid_ptr < P_L2_SIZE); =20 /* Don't compress if it won't fit in the # of bits we have. */ - if (lp->skip + p[valid_ptr].skip >=3D (1 << 6)) { + if (P_L2_LEVELS >=3D (1 << 6) && + lp->skip + p[valid_ptr].skip >=3D (1 << 6)) { return; } =20 --=20 2.19.1