From patchwork Wed May 30 09:43:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: 858585 jemmy X-Patchwork-Id: 10438087 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3B31D602BD for ; Wed, 30 May 2018 09:49:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A4382887F for ; Wed, 30 May 2018 09:49:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D2E2288B7; Wed, 30 May 2018 09:49:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7C4F22887F for ; Wed, 30 May 2018 09:49:19 +0000 (UTC) Received: from localhost ([::1]:37258 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNxjK-0003j0-GU for patchwork-qemu-devel@patchwork.kernel.org; Wed, 30 May 2018 05:49:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40288) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNxeD-0000Lr-AL for qemu-devel@nongnu.org; Wed, 30 May 2018 05:44:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fNxeC-0006pD-Bn for qemu-devel@nongnu.org; Wed, 30 May 2018 05:44:01 -0400 Received: from mail-pf0-x236.google.com ([2607:f8b0:400e:c00::236]:42785) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fNxeC-0006os-5z for qemu-devel@nongnu.org; Wed, 30 May 2018 05:44:00 -0400 Received: by mail-pf0-x236.google.com with SMTP id p14-v6so8747432pfh.9 for ; Wed, 30 May 2018 02:44:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=x2zpONDew4zxYxDoGbW2jWHb5JmyqrNqYpXGAuo66Z4=; b=roxv0BCWE62TimcJpiCZRAr1pV8dI+cd5O0WxiQRBJGxDevfeQXDYqQC822ue9r+WT rPczU/SM89+M+Y694BN1Nw2yvENp590Q3yGzmRK6AblKT8lvpPq45faT/8g5MDKOkUNz BB46/jCd4Ox+N6fMoGtQRAD4Hd2TFmTxAhq0GNS7hrfZSew/eopjOYO822VdyzHd5JGC F8LDLiXxf7OLcWY8ko5LcoWDIzoyZi145bz/OyES54V6kgDTWUmqQgnAMCTApyalkzbV U3mTj+xTjVgZZrdM4tR8zM/p8hcq0ESgStXb7eLaHakurkL5zObVeNrCLKUXanTpRmlb r8YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x2zpONDew4zxYxDoGbW2jWHb5JmyqrNqYpXGAuo66Z4=; b=Cq4HBPrcEKuqO1m1BDLH5iqaFfszQ6n7eGezy48dDgfUp7MGMpbs7njYN5HPhwFQeR wrKkxq709GKxBuTyxrj7Zedf44UOSugH4fdXArX3PiuchicwJMl0QJmW2pZS1m/HhyRw Ex0lHa57jYh3DRDWmjOaCSsptRl4UyFeaW3mxR8PVMPLky3ojBOF6OQPU0sTkMy7pLMu Iv9RUPu8k5nSc8aURuEFU0j5CPf8Nq9XFCEph8A+BUpP98blkeesU4MJDYmkEmzIDd+1 lqhYz3XPkucVr+wwKpSTMITirIHQ6kqWBBvB2ApVKYl7Hu5kEqe49HY4WCVIT9HKwGlu +zNw== X-Gm-Message-State: ALKqPwc0nXs6ubDZ/yPJoOQ5iKNXPJLHRlQ+vayI9S7oEE2AO19OHqPh KqHjKFI6Y7C/yvBxCadIVX0= X-Google-Smtp-Source: ADUXVKJRIDFs42TGQtuQu2N0JvgvVtFp2fDhJRR42Vy4x1fZ9Pn2ZqRQjg8u7MszCvfMXQeMf3fSkg== X-Received: by 2002:a65:4ecc:: with SMTP id w12-v6mr1663707pgq.214.1527673439350; Wed, 30 May 2018 02:43:59 -0700 (PDT) Received: from VM_93_245_centos.localdomain ([150.109.57.149]) by smtp.gmail.com with ESMTPSA id 29-v6sm60565257pfj.14.2018.05.30.02.43.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 May 2018 02:43:58 -0700 (PDT) From: Lidong Chen X-Google-Original-From: Lidong Chen To: zhang.zhanghailiang@huawei.com, quintela@redhat.com, dgilbert@redhat.com, berrange@redhat.com, aviadye@mellanox.com, pbonzini@redhat.com Date: Wed, 30 May 2018 17:43:27 +0800 Message-Id: <1527673416-31268-4-git-send-email-lidongchen@tencent.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1527673416-31268-1-git-send-email-lidongchen@tencent.com> References: <1527673416-31268-1-git-send-email-lidongchen@tencent.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::236 Subject: [Qemu-devel] [PATCH v4 03/12] migration: remove unnecessary variables len in QIOChannelRDMA 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: Lidong Chen , adido@mellanox.com, qemu-devel@nongnu.org, Lidong Chen Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Lidong Chen Because qio_channel_rdma_writev and qio_channel_rdma_readv maybe invoked by different threads concurrently, this patch removes unnecessary variables len in QIOChannelRDMA and use local variable instead. Signed-off-by: Lidong Chen Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Daniel P. Berrangé --- migration/rdma.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index ec4bbff..9b6da4d 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -404,7 +404,6 @@ struct QIOChannelRDMA { QIOChannel parent; RDMAContext *rdma; QEMUFile *file; - size_t len; bool blocking; /* XXX we don't actually honour this yet */ }; @@ -2643,6 +2642,7 @@ static ssize_t qio_channel_rdma_writev(QIOChannel *ioc, int ret; ssize_t done = 0; size_t i; + size_t len = 0; CHECK_ERROR_STATE(); @@ -2662,10 +2662,10 @@ static ssize_t qio_channel_rdma_writev(QIOChannel *ioc, while (remaining) { RDMAControlHeader head; - rioc->len = MIN(remaining, RDMA_SEND_INCREMENT); - remaining -= rioc->len; + len = MIN(remaining, RDMA_SEND_INCREMENT); + remaining -= len; - head.len = rioc->len; + head.len = len; head.type = RDMA_CONTROL_QEMU_FILE; ret = qemu_rdma_exchange_send(rdma, &head, data, NULL, NULL, NULL); @@ -2675,8 +2675,8 @@ static ssize_t qio_channel_rdma_writev(QIOChannel *ioc, return ret; } - data += rioc->len; - done += rioc->len; + data += len; + done += len; } } @@ -2771,8 +2771,7 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *ioc, } } } - rioc->len = done; - return rioc->len; + return done; } /*