From nobody Fri May 17 11:58:49 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 ARC-Seal: i=1; a=rsa-sha256; t=1556596099; cv=none; d=zoho.com; s=zohoarc; b=eEnJ09BbZwKyLg6qq8Fl0Xhut4zAhix2IfKyX4T+WXEaZ0oEDgoOM3240Je4jzMYq4OuJg+pu8A8CSDaRLyWTeVynpjvvnNBYBjtprcM8bS8oRb8PSEr57uevo1pzV5mJDTQcSzAkt3G3BXlUTVsVrSzQ2qWHYwn7N2LLmoFEl4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556596099; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=bTHO0y9gNuBWbid7JPnjKskJFnnNNYpnkUH6cBFXmRs=; b=m5Z72r75ZJve2HIkkPDYJgD73DjvbBRrQgx4Ta825jepDzoRzTszUpG1h62HiegkAiUtsqlULTUDuFQzp4wue7C44jMs17qxwpEIhpP3wYWfDhfvPaf7ls83LVKjzOWNvJSVKXefwrvtGsA4uOIMzSOE1KPcAOIkGkiu1MeXyXk= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 155659609930141.63916901432526; Mon, 29 Apr 2019 20:48:19 -0700 (PDT) Received: from localhost ([127.0.0.1]:38591 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLJkW-00069t-59 for importer@patchew.org; Mon, 29 Apr 2019 23:48:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54431) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLJj7-0005Ww-5P for qemu-devel@nongnu.org; Mon, 29 Apr 2019 23:46:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLJj3-00033d-MQ for qemu-devel@nongnu.org; Mon, 29 Apr 2019 23:46:39 -0400 Received: from mga12.intel.com ([192.55.52.136]:44779) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hLJj3-00031C-C9 for qemu-devel@nongnu.org; Mon, 29 Apr 2019 23:46:37 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Apr 2019 20:46:30 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by FMSMGA003.fm.intel.com with ESMTP; 29 Apr 2019 20:46: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,412,1549958400"; d="scan'208";a="153455296" From: Wei Yang To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 11:44:10 +0800 Message-Id: <20190430034412.12935-2-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190430034412.12935-1-richardw.yang@linux.intel.com> References: <20190430034412.12935-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: 192.55.52.136 Subject: [Qemu-devel] [PATCH 1/3] migration/ram.c: start of migration_bitmap_sync_range is always 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, Wei Yang , dgilbert@redhat.com, quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We can eliminate to pass 0. Signed-off-by: Wei Yang Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 35bd6213e9..9948b2d021 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1643,10 +1643,10 @@ static inline bool migration_bitmap_clear_dirty(RAM= State *rs, } =20 static void migration_bitmap_sync_range(RAMState *rs, RAMBlock *rb, - ram_addr_t start, ram_addr_t lengt= h) + ram_addr_t length) { rs->migration_dirty_pages +=3D - cpu_physical_memory_sync_dirty_bitmap(rb, start, length, + cpu_physical_memory_sync_dirty_bitmap(rb, 0, length, &rs->num_dirty_pages_period); } =20 @@ -1735,7 +1735,7 @@ static void migration_bitmap_sync(RAMState *rs) qemu_mutex_lock(&rs->bitmap_mutex); rcu_read_lock(); RAMBLOCK_FOREACH_NOT_IGNORED(block) { - migration_bitmap_sync_range(rs, block, 0, block->used_length); + migration_bitmap_sync_range(rs, block, block->used_length); } ram_counters.remaining =3D ram_bytes_remaining(); rcu_read_unlock(); @@ -4156,7 +4156,7 @@ static void colo_flush_ram_cache(void) memory_global_dirty_log_sync(); rcu_read_lock(); RAMBLOCK_FOREACH_NOT_IGNORED(block) { - migration_bitmap_sync_range(ram_state, block, 0, block->used_lengt= h); + migration_bitmap_sync_range(ram_state, block, block->used_length); } rcu_read_unlock(); =20 --=20 2.19.1 From nobody Fri May 17 11:58:49 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1556596094; cv=none; d=zoho.com; s=zohoarc; b=e7sgj1moEhxo4Tcv8CAddBzR0e7A/HTUK+0mzIO8hI8WYaSEG0T1KydVsKf2PFAOo5BjZ5SWXwGGM9HU2H7TQslRpf7IrmJCDXCDtD/toAh4YsDsq3Q7kFzM5bFWr8QuDWa3jXx+2sgmyXmkku8W/vKbwW+nl2CgEmHOORe9Kj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556596094; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=vOgWrEJdfIx0Kf9/MtYCItLwc9u/5BqMFkOE7+6HSGw=; b=BAtJXBPH34GcYn0ii/HokC+CxgGfJ7esCPwnoqM0I/f/tE5mUMH6D81EqX4yZzzXhLETsXRekOulMRh3BmDzteCx0ZRYtmPwKM0vQRhCIgqRS8JY2TEWJNwUrROz+GGBm+hjn/DG5B3iP8REHUIuBTvTUVKvPPLV7fd9gL+ILeo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1556596094523425.5591709039328; Mon, 29 Apr 2019 20:48:14 -0700 (PDT) Received: from localhost ([127.0.0.1]:38589 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLJkL-00065e-LJ for importer@patchew.org; Mon, 29 Apr 2019 23:47:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54433) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLJj7-0005Wy-5d for qemu-devel@nongnu.org; Mon, 29 Apr 2019 23:46:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLJj3-00033i-Mk for qemu-devel@nongnu.org; Mon, 29 Apr 2019 23:46:39 -0400 Received: from mga12.intel.com ([192.55.52.136]:44783) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hLJj3-00031f-CW for qemu-devel@nongnu.org; Mon, 29 Apr 2019 23:46:37 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Apr 2019 20:46:32 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by FMSMGA003.fm.intel.com with ESMTP; 29 Apr 2019 20:46: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,412,1549958400"; d="scan'208";a="153455302" From: Wei Yang To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 11:44:11 +0800 Message-Id: <20190430034412.12935-3-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190430034412.12935-1-richardw.yang@linux.intel.com> References: <20190430034412.12935-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: 192.55.52.136 Subject: [Qemu-devel] [PATCH 2/3] migration/ram.c: start of cpu_physical_memory_sync_dirty_bitmap is always 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, Wei Yang , dgilbert@redhat.com, quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Since start of cpu_physical_memory_sync_dirty_bitmap is always 0, we can remove this parameter and simplify the calculation a bit. Signed-off-by: Wei Yang --- include/exec/ram_addr.h | 15 ++++++--------- migration/ram.c | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index 9ecd911c3e..3dfb2d52fb 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -409,18 +409,16 @@ static inline void cpu_physical_memory_clear_dirty_ra= nge(ram_addr_t start, =20 static inline uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBlock *rb, - ram_addr_t start, ram_addr_t length, uint64_t *real_dirty_pages) { ram_addr_t addr; - unsigned long word =3D BIT_WORD((start + rb->offset) >> TARGET_PAGE_BI= TS); + unsigned long word =3D BIT_WORD(rb->offset >> TARGET_PAGE_BITS); uint64_t num_dirty =3D 0; unsigned long *dest =3D rb->bmap; =20 - /* start address and length is aligned at the start of a word? */ - if (((word * BITS_PER_LONG) << TARGET_PAGE_BITS) =3D=3D - (start + rb->offset) && + /* offset and length is aligned at the start of a word? */ + if (((word * BITS_PER_LONG) << TARGET_PAGE_BITS) =3D=3D (rb->offset) && !(length & ((BITS_PER_LONG << TARGET_PAGE_BITS) - 1))) { int k; int nr =3D BITS_TO_LONGS(length >> TARGET_PAGE_BITS); @@ -428,14 +426,13 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBlo= ck *rb, unsigned long idx =3D (word * BITS_PER_LONG) / DIRTY_MEMORY_BLOCK_= SIZE; unsigned long offset =3D BIT_WORD((word * BITS_PER_LONG) % DIRTY_MEMORY_BLOCK_SIZE); - unsigned long page =3D BIT_WORD(start >> TARGET_PAGE_BITS); =20 rcu_read_lock(); =20 src =3D atomic_rcu_read( &ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION])->blocks; =20 - for (k =3D page; k < page + nr; k++) { + for (k =3D 0; k < nr; k++) { if (src[idx][offset]) { unsigned long bits =3D atomic_xchg(&src[idx][offset], 0); unsigned long new_dirty; @@ -458,11 +455,11 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBlo= ck *rb, =20 for (addr =3D 0; addr < length; addr +=3D TARGET_PAGE_SIZE) { if (cpu_physical_memory_test_and_clear_dirty( - start + addr + offset, + addr + offset, TARGET_PAGE_SIZE, DIRTY_MEMORY_MIGRATION)) { *real_dirty_pages +=3D 1; - long k =3D (start + addr) >> TARGET_PAGE_BITS; + long k =3D addr >> TARGET_PAGE_BITS; if (!test_and_set_bit(k, dest)) { num_dirty++; } diff --git a/migration/ram.c b/migration/ram.c index 9948b2d021..1def8122e9 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1646,7 +1646,7 @@ static void migration_bitmap_sync_range(RAMState *rs,= RAMBlock *rb, ram_addr_t length) { rs->migration_dirty_pages +=3D - cpu_physical_memory_sync_dirty_bitmap(rb, 0, length, + cpu_physical_memory_sync_dirty_bitmap(rb, length, &rs->num_dirty_pages_period); } =20 --=20 2.19.1 From nobody Fri May 17 11:58:49 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 ARC-Seal: i=1; a=rsa-sha256; t=1556596243; cv=none; d=zoho.com; s=zohoarc; b=I5nMErNTMX1r2PrBpKZjtUA10qzeQmJRXjmKL3o93VrE/VVw2/IMh76H8UeXmKdipax9KNm+r94rFUcecE6YHoRUj4mmtP/fdAaQuSZugGKhEkoCOSRdTJ3q3UdXJUodunxc0/dyUZ5v8+sQqf6mqGGkCgHhZCtd9HOkGEwkZtg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556596243; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=+6vGT/GZPSZX3X5usw+hxFV4hRt8obXJtPYVlui/BN0=; b=Covz6FzCzppKCChjAgj4WmQrylAt3MJ4zHkUCJMBIaFCSECk5ULjwKL3O+WAhEHhswdP6d7QR+Wo0mDKFCVewbMpMADVJQePVaLUY1ryQbkobNkXKNfMPYCivXbKfEoRcvmzte74BEOneYQphrimo/bDm0BYMohU5AZU9sSRHD0= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1556596243622284.99780083136955; Mon, 29 Apr 2019 20:50:43 -0700 (PDT) Received: from localhost ([127.0.0.1]:38634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLJmw-0007eG-Lg for importer@patchew.org; Mon, 29 Apr 2019 23:50:38 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54457) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLJj9-0005XH-22 for qemu-devel@nongnu.org; Mon, 29 Apr 2019 23:46:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLJj7-000352-6N for qemu-devel@nongnu.org; Mon, 29 Apr 2019 23:46:43 -0400 Received: from mga12.intel.com ([192.55.52.136]:44784) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hLJj5-00032B-AZ for qemu-devel@nongnu.org; Mon, 29 Apr 2019 23:46:39 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Apr 2019 20:46:34 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by FMSMGA003.fm.intel.com with ESMTP; 29 Apr 2019 20:46: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,412,1549958400"; d="scan'208";a="153455310" From: Wei Yang To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 11:44:12 +0800 Message-Id: <20190430034412.12935-4-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190430034412.12935-1-richardw.yang@linux.intel.com> References: <20190430034412.12935-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: 192.55.52.136 Subject: [Qemu-devel] [PATCH 3/3] ram: RAMBlock->offset is always aligned to a word 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, Wei Yang , dgilbert@redhat.com, quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" RAMBlock->offset is calculated by find_ram_offset, which makes sure the offset is aligned to a word. This patch removes the alignment check on offset and unnecessary variable *word*. Signed-off-by: Wei Yang --- include/exec/ram_addr.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index 3dfb2d52fb..a7c81bdb32 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -413,18 +413,21 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBlo= ck *rb, uint64_t *real_dirty_pages) { ram_addr_t addr; - unsigned long word =3D BIT_WORD(rb->offset >> TARGET_PAGE_BITS); uint64_t num_dirty =3D 0; unsigned long *dest =3D rb->bmap; =20 - /* offset and length is aligned at the start of a word? */ - if (((word * BITS_PER_LONG) << TARGET_PAGE_BITS) =3D=3D (rb->offset) && - !(length & ((BITS_PER_LONG << TARGET_PAGE_BITS) - 1))) { + /* + * Since RAMBlock->offset is guaranteed to be aligned to a word by + * find_ram_offset(), if length is aligned at the start of a word, go = the + * fast path. + */ + if (!(length & ((BITS_PER_LONG << TARGET_PAGE_BITS) - 1))) { int k; int nr =3D BITS_TO_LONGS(length >> TARGET_PAGE_BITS); unsigned long * const *src; - unsigned long idx =3D (word * BITS_PER_LONG) / DIRTY_MEMORY_BLOCK_= SIZE; - unsigned long offset =3D BIT_WORD((word * BITS_PER_LONG) % + unsigned long idx =3D (rb->offset >> TARGET_PAGE_BITS) / + DIRTY_MEMORY_BLOCK_SIZE; + unsigned long offset =3D BIT_WORD((rb->offset >> TARGET_PAGE_BITS)= % DIRTY_MEMORY_BLOCK_SIZE); =20 rcu_read_lock(); --=20 2.19.1