From patchwork Tue Nov 14 02:11:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 837667 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ybWHj4YL0z9s7G for ; Tue, 14 Nov 2017 13:12:49 +1100 (AEDT) Received: from localhost ([::1]:57260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eEQiV-0004qj-Ji for incoming@patchwork.ozlabs.org; Mon, 13 Nov 2017 21:12:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57672) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eEQhh-0004d3-F2 for qemu-devel@nongnu.org; Mon, 13 Nov 2017 21:11:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eEQhg-0000mg-En for qemu-devel@nongnu.org; Mon, 13 Nov 2017 21:11:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52324) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eEQhg-0000mH-7t for qemu-devel@nongnu.org; Mon, 13 Nov 2017 21:11:56 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 60E286A7C5; Tue, 14 Nov 2017 02:11:55 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (ovpn-12-130.pek2.redhat.com [10.72.12.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 928D55D6AE; Tue, 14 Nov 2017 02:11:52 +0000 (UTC) From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Tue, 14 Nov 2017 10:11:33 +0800 Message-Id: <1510625498-4821-4-git-send-email-jasowang@redhat.com> In-Reply-To: <1510625498-4821-1-git-send-email-jasowang@redhat.com> References: <1510625498-4821-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 14 Nov 2017 02:11:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/8] colo-compare: compare the packet in a specified Connection 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: Mao Zhongyi , Jason Wang , Li Zhijian , Zhang Chen Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Mao Zhongyi A package from pri_indev or sec_indev only belongs to a particular Connection, so we only need to compare the package in the specified Connection's primary_list and secondary_list, rather than for each the whole Connection list to compare. This is time-consuming and unnecessary. Less checkpoint more efficiency. Cc: Zhang Chen Cc: Li Zhijian Cc: Jason Wang Signed-off-by: Mao Zhongyi Signed-off-by: Jason Wang --- net/colo-compare.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 54b6347..5d2429b 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -136,7 +136,7 @@ static int colo_insert_packet(GQueue *queue, Packet *pkt) * Return 0 on success, if return -1 means the pkt * is unsupported(arp and ipv6) and will be sent later */ -static int packet_enqueue(CompareState *s, int mode) +static int packet_enqueue(CompareState *s, int mode, Connection **con) { ConnectionKey key; Packet *pkt = NULL; @@ -179,6 +179,7 @@ static int packet_enqueue(CompareState *s, int mode) "drop packet"); } } + con = &conn; return 0; } @@ -728,8 +729,9 @@ static void compare_set_vnet_hdr(Object *obj, static void compare_pri_rs_finalize(SocketReadState *pri_rs) { CompareState *s = container_of(pri_rs, CompareState, pri_rs); + Connection *conn = NULL; - if (packet_enqueue(s, PRIMARY_IN)) { + if (packet_enqueue(s, PRIMARY_IN, &conn)) { trace_colo_compare_main("primary: unsupported packet in"); compare_chr_send(s, pri_rs->buf, @@ -737,19 +739,20 @@ static void compare_pri_rs_finalize(SocketReadState *pri_rs) pri_rs->vnet_hdr_len); } else { /* compare connection */ - g_queue_foreach(&s->conn_list, colo_compare_connection, s); + colo_compare_connection(conn, s); } } static void compare_sec_rs_finalize(SocketReadState *sec_rs) { CompareState *s = container_of(sec_rs, CompareState, sec_rs); + Connection *conn = NULL; - if (packet_enqueue(s, SECONDARY_IN)) { + if (packet_enqueue(s, SECONDARY_IN, &conn)) { trace_colo_compare_main("secondary: unsupported packet in"); } else { /* compare connection */ - g_queue_foreach(&s->conn_list, colo_compare_connection, s); + colo_compare_connection(conn, s); } }