From patchwork Thu Apr 20 09:47:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 13218252 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 40BF7C77B72 for ; Thu, 20 Apr 2023 09:49:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppQtr-00079f-AO; Thu, 20 Apr 2023 05:48:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppQte-0006kI-4i for qemu-devel@nongnu.org; Thu, 20 Apr 2023 05:48:12 -0400 Received: from mout.web.de ([212.227.15.3]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppQta-00081e-7d for qemu-devel@nongnu.org; Thu, 20 Apr 2023 05:48:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1681984081; i=lukasstraub2@web.de; bh=eLFJoHY7peL+SKZF2sPs8aKtSRtjxyC6z9ykmJRSQxE=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=db9iMjuURlMO8odNKtIdvRW5sUsr0xwGvhjeeNaNBiBAsPp67NqscWTXqNXv6CEzx 5n+U/wm54HWqFE9xP7daemXqiDVlIRw3Gu5Yb39C1Z9kE9E+f80qRvC6yvWxfy3zSP 7/96zk5fk/JbHFEPeFS6b0xG/OjfWKd28hdP0AVeo2JIv+ZK+UvVbNZ5mXlVeEV79C W40wm7N/SKiHtRQOK+qyjj6x7Fz5FqQwE3KXruZ0R3W65ZOKDhfE0HQ6lF78qUygDQ zld/t6ucsU0yZFErpoxg781zMz2YtXBbhqdnmhouxxPEUceisI9379z06LN8mYbcQh immhmCREMWbtw== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from gecko.fritz.box ([82.207.254.123]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MWzD3-1pn4R607Dt-00XJrY; Thu, 20 Apr 2023 11:48:01 +0200 Date: Thu, 20 Apr 2023 11:47:59 +0200 From: Lukas Straub To: qemu-devel Cc: Juan Quintela , Peter Xu , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v2 03/13] ram.c: Dont change param->block in the compress thread Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:VTtd6cfmwvXWYVQeM0Ep7/hvo8QQzRQK6TZtavl+2j1E3kpwmNm 3Tksjcbupkd/jPEctp46Sh+icdea2wvSc32r4qlImv0zXkE1AXnVklnZ3NNpemV95GKtL3E g/iLj1l/mpEAzQw7f30y+NYAflSJax6lXkl+XYrwcLuFk40vngNEuEoakb+VeJOMslnSlZy q/fvmK2ZXqlq3uOMOWX7A== UI-OutboundReport: notjunk:1;M01:P0:FVzsHSdw788=;HidTxsaqgeSiNQysgXZdqwOvLdV yKYjygK+fdRa0f8Bi39rAuWYW3ABlq1WEXJQbCLf1SchpRyUiidR/g2RsgYFdeOjQjPlbyiI5 VzJU/VU//Ea8Nxkhnh0a5k37/EGLGfRmQ2gZGgMaDnhBcwXeVsKNIoSuMG8GM5CF/Xa1/II0Y TpzR8pvmF4VNOqp+HLzxOmCieW6K5u+pg3pqOhdXfv8I33rxKfYJehAt4KuUoF7Ivqu8SBRMJ 6FjGxLiuZoa7+GZ8aS3kVTHYHzc5Qm8yyiqMRaM+B/tV6InwAS4AGj8Rvq9CHAFVlr63aRqXr MPJKe8CMa/AxlERlxw9UO+C1CL5zAhUzNlmw+dEZxa0liDcJG8uaPYmFlgLWAcCLRgP8sIFMA Nfq0AiJCIrLtyAYd3d0WdNx0r0DVmdUQBGeQ+Nzwiarh1xGOPEOvQsoCgO+Ux0b68aEBagkW0 /3T7ncrjKrRUkcvcUXN0r6YjJB6qfS61lTyss5LrvsoCiT2QexQE3ZXKiKVSexlGvg9zX6eDc /oMYvImBWS0KPVl005MQhANoiLHb1LMqztYTIbjMEPlHUedfq2Jc+VKvldB4V6Evb5OWMjCdr S1q0oQU4RaJxkB1cNmg9yJg5nmrN+fh38JqV5Tcm49b551wlTNuNTSM+vV9VbqooI2idfWmui 7gAq/2AsFZ7du6Awwvi7uqEvfEfFa2DCj+tkkw3hZfutctKVMxnoE4/+/4Vxc/5stYDUqOUCq sJNgNSxPAf7OdOSrpnfetnQgJ2RVTImfL6Dw/pKV+egSXt7kw8drFmiOYb4TDmY1H+uPYVjR3 QzCkjjqMsmBIgTUf956fY+U28olHKRaLrBBbrulje6Vm7/eFVP/76B6QPj+gxzdnk8QOGprlP 6l9oOELo+o3onVtNuPi+P9OfznstFcva8tA+MbFZjyni/8rKTaKSyUQDXq4I1qh9jFxlkNfKo PS1BmJdRWAiAtzT/h++6LNInOJk= Received-SPF: pass client-ip=212.227.15.3; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Instead introduce a extra parameter to trigger the compress thread. Now, when the compress thread is done, we know what RAMBlock and offset it did compress. This will be used in the next commits to move save_page_header() out of compress code. Signed-off-by: Lukas Straub Reviewed-by: Juan Quintela --- migration/ram.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.40.0 diff --git a/migration/ram.c b/migration/ram.c index ade6638a96..820b4ebaeb 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -503,6 +503,7 @@ typedef enum CompressResult CompressResult; struct CompressParam { bool done; bool quit; + bool trigger; CompressResult result; QEMUFile *file; QemuMutex mutex; @@ -576,10 +577,10 @@ static void *do_data_compress(void *opaque) qemu_mutex_lock(¶m->mutex); while (!param->quit) { - if (param->block) { + if (param->trigger) { block = param->block; offset = param->offset; - param->block = NULL; + param->trigger = false; qemu_mutex_unlock(¶m->mutex); result = do_compress_ram_page(param->file, ¶m->stream, @@ -1556,6 +1557,7 @@ static inline void set_compress_params(CompressParam *param, RAMBlock *block, { param->block = block; param->offset = offset; + param->trigger = true; } static int compress_page_with_multi_thread(RAMBlock *block, ram_addr_t offset)