From patchwork Sat May 5 14:35:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: 858585 jemmy X-Patchwork-Id: 10382177 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 A3D606053F for ; Sat, 5 May 2018 14:38:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 937B828A73 for ; Sat, 5 May 2018 14:38:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8803428C11; Sat, 5 May 2018 14:38:09 +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 AC1C728A73 for ; Sat, 5 May 2018 14:38:08 +0000 (UTC) Received: from localhost ([::1]:39038 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEyK8-0000rm-0Y for patchwork-qemu-devel@patchwork.kernel.org; Sat, 05 May 2018 10:38:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEyIF-0008Qs-BB for qemu-devel@nongnu.org; Sat, 05 May 2018 10:36:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fEyIC-000896-7A for qemu-devel@nongnu.org; Sat, 05 May 2018 10:36:11 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:40465) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fEyIC-00087t-1U for qemu-devel@nongnu.org; Sat, 05 May 2018 10:36:08 -0400 Received: by mail-pf0-x242.google.com with SMTP id f189so19575124pfa.7 for ; Sat, 05 May 2018 07:36:07 -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=KI7yza/CX80Qu1nB/Rg7RbScxhHCIvUGBOeuuYrplns=; b=bpyDzY6Oc2dgBa5cwKr0EOnU4rGrWDfwlgx17Y6C4VgSDW/zZGLkLiwoLsyJpUGKiv HqEVTDC7i1+Ntis2znU75Y8wxcp0lkSbinGH1m0YYOFWHWj6G/+Se2hymtIEHOlXCcOX DlCqXzHOcD0DxL1XQV9jRmfnMZVsK8zez0TzBzx97eYwAEjOqHQ9YSw7j9Yf8Dz47pWT X/u5NFbxSAcEiyOoGItX4nxY+y+t5uOj01W0mtkp2SKt6jRnMuYSHp49rKG63d6Oru2R lBxnl5xx0d9LvJ5fs3qJwo7IUHs6e8JwVH+/dTnrswt+MsMv+d4t4UNR3LvymsuTmxq2 zcPA== 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=KI7yza/CX80Qu1nB/Rg7RbScxhHCIvUGBOeuuYrplns=; b=AGuWRmPuZ35gkhYG1EYK+FwcRMSuV+N1NtPR0tMgpPCcH/de464+ZyNDCvZoyUODKv pZ39BOdJCin3bkWbtu1DuespfDHu/xYQbekhwQwP2FaEU7Tk7WmcD099QQn4zYMnUQcT 4+c//QgQtX/sbsKueJcEohJTAv6J/Wldx2xiqOWjOxHFQzdIWxVa5DxfJ/EGS85Liew1 +mjI3AK/+0kVOqc/B/TPw4Gq4ZMFiP5qzflexeZxKz53Ciqc8cALNP5t4eBJZvsN3eT1 Y1JVVbmsyuQBMMF9yWG8zI8Lh7Zf4Pd1CLUN+WDvmpDJO/3DDmt604JFkOwgbIU3HZi7 5GGQ== X-Gm-Message-State: ALQs6tCb2ZpDg4ydrxJ5ko0RclRPUyV9qGj+aKoJksO2z77kSxK21Vz9 XdO2jwxCemi5+kKYox6Ahv4= X-Google-Smtp-Source: AB8JxZqGg+tzc7HyS32HL2m6fmLTh0QDfUcBchsTTGLPHz3Wm+uU4CRZjkyQ0O4rCXslQkoqF72fYQ== X-Received: by 10.98.76.202 with SMTP id e71mr30321261pfj.171.1525530967223; Sat, 05 May 2018 07:36:07 -0700 (PDT) Received: from VM_127_91_centos.localdomain ([119.28.195.137]) by smtp.gmail.com with ESMTPSA id n67sm38529640pfh.188.2018.05.05.07.36.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 May 2018 07:36:06 -0700 (PDT) From: Lidong Chen X-Google-Original-From: Lidong Chen To: quintela@redhat.com, dgilbert@redhat.com, berrange@redhat.com Date: Sat, 5 May 2018 22:35:33 +0800 Message-Id: <1525530936-21835-4-git-send-email-lidongchen@tencent.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1525530936-21835-1-git-send-email-lidongchen@tencent.com> References: <1525530936-21835-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::242 Subject: [Qemu-devel] [PATCH v3 3/6] 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: adido@mellanox.com, galsha@mellanox.com, aviadye@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 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éberrange@redhat.com> --- migration/rdma.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index c745427..f5c1d02 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 */ }; @@ -2640,6 +2639,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(); @@ -2659,10 +2659,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); @@ -2672,8 +2672,8 @@ static ssize_t qio_channel_rdma_writev(QIOChannel *ioc, return ret; } - data += rioc->len; - done += rioc->len; + data += len; + done += len; } } @@ -2768,8 +2768,7 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *ioc, } } } - rioc->len = done; - return rioc->len; + return done; } /*