From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4E5AC2B9F8 for ; Tue, 25 May 2021 10:59:58 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 310096141B for ; Tue, 25 May 2021 10:59:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 310096141B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llUmz-0008Fd-3X for qemu-devel@archiver.kernel.org; Tue, 25 May 2021 06:59:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llUm7-00076m-I5 for qemu-devel@nongnu.org; Tue, 25 May 2021 06:59:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24184) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llUm4-0003Zv-Nj for qemu-devel@nongnu.org; Tue, 25 May 2021 06:59:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621940337; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RGYMs+tt57UNm8Qyvtm3ydQu+35y0HzWju3ZTmMKt3s=; b=AFWuOmGhTigycGaoKVOpkFziQnbiAatO/BR9ShsAoJoOtGieY0X4NsPOc90ffyjFxaF7HX G9di4XqZWBrS+ac8XTB7AjCrmWNEMpwP6Exskh7mh1rVxdMr2jpguOeqre/Ad4OfWig5rp zVCyslDT0rsyHrnU1S+07QhyGRfRgAo= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-314-1zYiWwMaOyuOAw-jqKOtpw-1; Tue, 25 May 2021 06:58:55 -0400 X-MC-Unique: 1zYiWwMaOyuOAw-jqKOtpw-1 Received: by mail-ed1-f72.google.com with SMTP id b8-20020a05640202c8b029038f1782a77eso8644544edx.15 for ; Tue, 25 May 2021 03:58:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=RGYMs+tt57UNm8Qyvtm3ydQu+35y0HzWju3ZTmMKt3s=; b=biFuexHuj1oYHX39YDK7OQs+eaFiB+LSb2+IzmjdO3NlSK9ocgs0/06wPdDTY0BFir dvmiwrXJFPcZPZzsiJxLGhrwv37Yd18x8eQxVUVfMtwTC7yK1MkkI5g4eGos9fB5b2HN NpIICwLcrKWhuBGbPRUFwrni7wmi7cynL1FYyPa3eCK2jR8KQKNLAexkoB9qQF+8JL03 XLQgG5/WIwEPMIZXUhqlHO2oz/I1OgS4jN++mCZNizkF/oNa4Johk7qCTuzmD2rkicKy fJsW30tlQUvaCZENRMdyfmtVfyjMrVMqCWMIISbeySugnNVOlGwx6VSIJqDaqp8KJMyE NovA== X-Gm-Message-State: AOAM531LgfRivVyl2o4qU9ZVg2eKr6xI55BqNDCIBW3uItjUmVEdQgvQ uCqHcJ3+D4lIMwoKCm9kegX3CFZnXwTSrkM4EjuHey9a/WN0usKMHcj1o31nYBF0KrSma29crAV +ajOTyyxwc+rS3LLWDjcqRivUcKHjeZGpABd5A+iSaUcRq2rhHt0XZzrYwlzehMy2ftY= X-Received: by 2002:a17:907:1b20:: with SMTP id mp32mr28696890ejc.495.1621940334522; Tue, 25 May 2021 03:58:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyz/lIK2C07JYXBdRF5r50uaHMYk06lgG4V75GmgX7iG5Lp+YFjSt+oiDa28eaUAfvaLlUWZg== X-Received: by 2002:a17:907:1b20:: with SMTP id mp32mr28696871ejc.495.1621940334315; Tue, 25 May 2021 03:58:54 -0700 (PDT) Received: from localhost.localdomain ([2a04:ee41:4:31cb:e591:1e1e:abde:a8f1]) by smtp.gmail.com with ESMTPSA id g4sm10630552edm.83.2021.05.25.03.58.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 May 2021 03:58:53 -0700 (PDT) Subject: Re: [PATCH v2 5/7] block-copy: add QemuMutex lock for BlockCopyCallState list To: Paolo Bonzini , Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org References: <20210518100757.31243-1-eesposit@redhat.com> <20210518100757.31243-6-eesposit@redhat.com> From: Emanuele Giuseppe Esposito Message-ID: <72b73ec2-da87-f672-6a7d-bba008df9871@redhat.com> Date: Tue, 25 May 2021 12:58:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eesposit@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=170.10.133.124; envelope-from=eesposit@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , John Snow , qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 21/05/2021 17:01, Paolo Bonzini wrote: > On 20/05/21 17:30, Vladimir Sementsov-Ogievskiy wrote: >> 18.05.2021 13:07, Emanuele Giuseppe Esposito wrote: >>> As for BlockCopyTask, add a lock to protect BlockCopyCallState >>> ret and sleep_state fields. Also move ret, finished and cancelled >>> in the OUT fields of BlockCopyCallState. >>> >>> Here a QemuMutex is used to protect QemuCoSleep field, since it >>> can be concurrently invoked also from outside threads. Actually I don't even protect it here, I should have deleted the above line. I left a TODO for the QemuCoSleep field. >>> >>> .finished, .cancelled and reads to .ret and .error_is_read will be >>> protected in the following patch. >>> >>> .sleep state is handled in the series "coroutine: new sleep/wake API" >> >> Could we live with one mutex for all needs? Why to add one more? > > This patch should just go away; the QemuMutex will not be needed once > QemuCoSleep is thread safe, while right now it is still racy. At this point, I would just rename the other lock (tasks_lock) in "lock" or "state_lock", and substitute it in the calls_lock usages of this patch. Depending on how it comes out, I may merge this with the previous patch. Thank you, Emanuele