From patchwork Mon Dec 20 01:06:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 12686959 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1BD85C433F5 for ; Mon, 20 Dec 2021 01:18:59 +0000 (UTC) Received: from localhost ([::1]:38632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mz7KM-0001ag-Vv for qemu-devel@archiver.kernel.org; Sun, 19 Dec 2021 20:18:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mz7IT-0000N0-PQ for qemu-devel@nongnu.org; Sun, 19 Dec 2021 20:17:01 -0500 Received: from mga01.intel.com ([192.55.52.88]:46571) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mz7IR-0008OU-1q for qemu-devel@nongnu.org; Sun, 19 Dec 2021 20:17:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639963019; x=1671499019; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=viMARr3WAXsxH84iUwuTuMEvWkdL8QMoD+QKjSxoH0Y=; b=IJP/+RdtH9GYtcvJe8CtRlqoRHKoySxn5rybk2hOZgbFvVvp/hE2b0dM +AxxVeX+DXiz8vOjeK3bu+BK+7BGCh3zIsSsj8z9DFlhgk7g9enEDfO6W etIhHsmnFOwEvKXP6QPmxsAWnPfJETbcdtrqqk81MJWB/mm2gfK4LQPFy MJ0WF0IbpaEFUxDlV0SKmDot3PP/AwuyER8+KUi0kjJnk5Zr++7lVVwHe /LQiHynZDTXu48dOWGh3itQno6ZXa+kBG4yoo7aT9rkLPbKgqhHlUWP6D i82626WfUh+gfcYunDZZHve4LqU5b++jRpBOJ8m9i5TR8WR+vtO7AeEwE w==; X-IronPort-AV: E=McAfee;i="6200,9189,10203"; a="264256325" X-IronPort-AV: E=Sophos;i="5.88,219,1635231600"; d="scan'208";a="264256325" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Dec 2021 17:16:54 -0800 X-IronPort-AV: E=Sophos;i="5.88,219,1635231600"; d="scan'208";a="467210998" Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Dec 2021 17:16:52 -0800 From: Zhang Chen To: Jason Wang , Li Zhijian Subject: [PATCH 1/2] net/colo-compare.c: Optimize compare order for performance Date: Mon, 20 Dec 2021 09:06:02 +0800 Message-Id: <20211220010603.1443843-1-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.88; envelope-from=chen.zhang@intel.com; helo=mga01.intel.com X-Spam_score_int: -72 X-Spam_score: -7.3 X-Spam_bar: ------- X-Spam_report: (-7.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.204, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen , leirao , qemu-dev Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" COLO-compare use the glib function g_queue_find_custom to dump another VM's networking packet to compare. But this function always start find from the queue->head(here is the newest packet), It will reduce the success rate of comparison. So this patch reversed the order of the queues for performance. Signed-off-by: Zhang Chen Reported-by: leirao --- net/colo-compare.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index b966e7e514..216de5a12b 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -197,7 +197,7 @@ static void colo_compare_inconsistency_notify(CompareState *s) /* Use restricted to colo_insert_packet() */ static gint seq_sorter(Packet *a, Packet *b, gpointer data) { - return a->tcp_seq - b->tcp_seq; + return b->tcp_seq - a->tcp_seq; } static void fill_pkt_tcp_info(void *data, uint32_t *max_ack) @@ -421,13 +421,13 @@ pri: if (g_queue_is_empty(&conn->primary_list)) { return; } - ppkt = g_queue_pop_head(&conn->primary_list); + ppkt = g_queue_pop_tail(&conn->primary_list); sec: if (g_queue_is_empty(&conn->secondary_list)) { - g_queue_push_head(&conn->primary_list, ppkt); + g_queue_push_tail(&conn->primary_list, ppkt); return; } - spkt = g_queue_pop_head(&conn->secondary_list); + spkt = g_queue_pop_tail(&conn->secondary_list); if (ppkt->tcp_seq == ppkt->seq_end) { colo_release_primary_pkt(s, ppkt); @@ -458,7 +458,7 @@ sec: } } if (!ppkt) { - g_queue_push_head(&conn->secondary_list, spkt); + g_queue_push_tail(&conn->secondary_list, spkt); goto pri; } } @@ -477,7 +477,7 @@ sec: if (mark == COLO_COMPARE_FREE_PRIMARY) { conn->compare_seq = ppkt->seq_end; colo_release_primary_pkt(s, ppkt); - g_queue_push_head(&conn->secondary_list, spkt); + g_queue_push_tail(&conn->secondary_list, spkt); goto pri; } else if (mark == COLO_COMPARE_FREE_SECONDARY) { conn->compare_seq = spkt->seq_end; @@ -490,8 +490,8 @@ sec: goto pri; } } else { - g_queue_push_head(&conn->primary_list, ppkt); - g_queue_push_head(&conn->secondary_list, spkt); + g_queue_push_tail(&conn->primary_list, ppkt); + g_queue_push_tail(&conn->secondary_list, spkt); #ifdef DEBUG_COLO_PACKETS qemu_hexdump(stderr, "colo-compare ppkt", ppkt->data, ppkt->size); @@ -673,7 +673,7 @@ static void colo_compare_packet(CompareState *s, Connection *conn, while (!g_queue_is_empty(&conn->primary_list) && !g_queue_is_empty(&conn->secondary_list)) { - pkt = g_queue_pop_head(&conn->primary_list); + pkt = g_queue_pop_tail(&conn->primary_list); result = g_queue_find_custom(&conn->secondary_list, pkt, (GCompareFunc)HandlePacket); @@ -689,7 +689,7 @@ static void colo_compare_packet(CompareState *s, Connection *conn, * timeout, it will trigger a checkpoint request. */ trace_colo_compare_main("packet different"); - g_queue_push_head(&conn->primary_list, pkt); + g_queue_push_tail(&conn->primary_list, pkt); colo_compare_inconsistency_notify(s); break; @@ -819,7 +819,7 @@ static int compare_chr_send(CompareState *s, entry->buf = g_malloc(size); memcpy(entry->buf, buf, size); } - g_queue_push_head(&sendco->send_list, entry); + g_queue_push_tail(&sendco->send_list, entry); if (sendco->done) { sendco->co = qemu_coroutine_create(_compare_chr_send, sendco); @@ -1347,7 +1347,7 @@ static void colo_flush_packets(void *opaque, void *user_data) Packet *pkt = NULL; while (!g_queue_is_empty(&conn->primary_list)) { - pkt = g_queue_pop_head(&conn->primary_list); + pkt = g_queue_pop_tail(&conn->primary_list); compare_chr_send(s, pkt->data, pkt->size, @@ -1357,7 +1357,7 @@ static void colo_flush_packets(void *opaque, void *user_data) packet_destroy_partial(pkt, NULL); } while (!g_queue_is_empty(&conn->secondary_list)) { - pkt = g_queue_pop_head(&conn->secondary_list); + pkt = g_queue_pop_tail(&conn->secondary_list); packet_destroy(pkt, NULL); } } From patchwork Mon Dec 20 01:06:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 12686961 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6A696C433F5 for ; Mon, 20 Dec 2021 01:19:12 +0000 (UTC) Received: from localhost ([::1]:39248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mz7KZ-00021m-6C for qemu-devel@archiver.kernel.org; Sun, 19 Dec 2021 20:19:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44040) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mz7IW-0000Ns-IR for qemu-devel@nongnu.org; Sun, 19 Dec 2021 20:17:04 -0500 Received: from mga01.intel.com ([192.55.52.88]:46571) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mz7IT-0008OU-Pj for qemu-devel@nongnu.org; Sun, 19 Dec 2021 20:17:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639963021; x=1671499021; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=t5ikSlyPB3pvpKfS8XwSac3rEEMqzg/JB8Utc5zE5A8=; b=PTPWqeqKjZAFF1c+OU6ADDYV/WdfnYDNBHPx3KoiaIyTVIuzV/s7YOxW uJ2T3CWpXiiyfTrKLpMyPu7/wYz4ebz/H1ioWuQhyL7axZXp/q8EFHIQP IbMoWkF9qFjctRh4e49JqlYuUJO+BOobrB4mvSLJgTKCtXRGPbIquLwHY Q92P/nRiLWNVAcYjua8gfHGFWs5hSHAL8UgcUkhNu7fRh8uo+5KqNxx1K r2in8yCfVX1ZoFu16QanRPCb0phzQVJJZArbAoXiigruuIPYsu09pM6Re Qzco1sAuwhmjzqfRGo70bEq7PNmoz+zZ5RVAPRwNlranMMH3R7kl5Chpb w==; X-IronPort-AV: E=McAfee;i="6200,9189,10203"; a="264256328" X-IronPort-AV: E=Sophos;i="5.88,219,1635231600"; d="scan'208";a="264256328" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Dec 2021 17:16:55 -0800 X-IronPort-AV: E=Sophos;i="5.88,219,1635231600"; d="scan'208";a="467211006" Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Dec 2021 17:16:54 -0800 From: Zhang Chen To: Jason Wang , Li Zhijian Subject: [PATCH 2/2] net/colo-compare.c: Update the default value comments Date: Mon, 20 Dec 2021 09:06:03 +0800 Message-Id: <20211220010603.1443843-2-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211220010603.1443843-1-chen.zhang@intel.com> References: <20211220010603.1443843-1-chen.zhang@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.88; envelope-from=chen.zhang@intel.com; helo=mga01.intel.com X-Spam_score_int: -72 X-Spam_score: -7.3 X-Spam_bar: ------- X-Spam_report: (-7.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.204, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen , qemu-dev Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Make the comments consistent with the REGULAR_PACKET_CHECK_MS. Signed-off-by: Zhang Chen --- net/colo-compare.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 216de5a12b..62554b5b3c 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -1267,7 +1267,7 @@ static void colo_compare_complete(UserCreatable *uc, Error **errp) } if (!s->expired_scan_cycle) { - /* Set default value to 3000 MS */ + /* Set default value to 1000 MS */ s->expired_scan_cycle = REGULAR_PACKET_CHECK_MS; }