From patchwork Thu Apr 20 09:48:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 1771185 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=web.de header.i=lukasstraub2@web.de header.a=rsa-sha256 header.s=s29768273 header.b=BmkuCidW; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q2CYK0rmvz1ybF for ; Thu, 20 Apr 2023 19:49:25 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppQtt-0007Op-RL; Thu, 20 Apr 2023 05:48:25 -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 1ppQtr-00079h-UP for qemu-devel@nongnu.org; Thu, 20 Apr 2023 05:48:23 -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 1ppQtl-000848-C4 for qemu-devel@nongnu.org; Thu, 20 Apr 2023 05:48:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1681984091; i=lukasstraub2@web.de; bh=PE/+RPtZ58nDtwqM02B/f1sR/LpHOgbdvtCrUvSs5Vw=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=BmkuCidWQO2uw8qgazUrnGxXpiJOMAJfhEXKFZhtnsqhlJgMpBz5QU0jR/IT8IZRU gL1nRJiV+qvX+AscZO/MOQBNcVkGcAUOn5DThBdhZ+AxXqhSIINRynHSIXL2HKJTKT g9tRAUFXxEDjm0ZpjLN8IdbdGZrvmu8UoRCn4jW39PPEuwru5OGJ8PiAX6FhZm+qK5 BgLV7IeacFOVSns1/dnhvIceAP8OlVoGoodIhWtTW5K/wEAE8/i9gsjX8MR4MYBFAh 4yNk4Kxsi2pSHLJp3sL6uRTreMnALUb4FAp1Aa2QcE7+0/lqOMWbLPLORXcYxPqaGY rP5ptt4SA0i6w== 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 1Mt8kX-1q99hi2Em1-00tR9A; Thu, 20 Apr 2023 11:48:11 +0200 Date: Thu, 20 Apr 2023 11:48:10 +0200 From: Lukas Straub To: qemu-devel Cc: Juan Quintela , Peter Xu , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v2 06/13] ram.c: Call update_compress_thread_counts from compress_send_queued_data Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:RhZnjKHprqgazYTV1zVudc/4tkllovOkx3q1qgiyEjdmUJjXTf5 uMQEyw2dzncdqqf/v8qvGow56P1U5j1VvQBa1IO9xqpyPYA/cG/XJyS68uzNfMMRkiUYA+r ETNwWETy9jkcdcuIpG1H3bW5YTagK//aBYKFswsoIm8i4Hno8ucH78Psy/I8D0Qwx4E3Knq 5SSy2EOeXKeX4+Yoqn49A== UI-OutboundReport: notjunk:1;M01:P0:GeJZdyX0q7Y=;XFgMhJqAyLPCy6w0meht5jSEi4W 1DSa9RhsFxugh0BVEcjT82qydLG+et4x1JlaPxpQ96PL6RKdrs3R2nsQ1qj99gE3V+PUsY+xe TMoMW6NQBpi+ZXco2+A2v82CcMcJI7QNnJW/HITYznT80lWh2+7sSMJiZZsihSs2PfPJO0RaE 4QBwUPUFGmmJ6gQe4eI5ZO5S0hdOeeBEl01e3vEbaJte1w09+OutMhWp7nz55++MIdVVa3sDc 1sjtlHaGJxIR3krTiLwRLn00PMlmGCRAdRzkeLQipLrwIYKNE0KuCynHAhfVfwLfx7ps+kij4 C1UdhK/IwUL2XYInT7VaUlVp1eUojR15gCdvKCwav9h8hLAJRmdavV7znGA4QqA/FDGt1PJTO C8MwFIve/p70hpNBRJzokYPYWVVY+tieu8qOVhhwkW2Gd/aZfWpjPAt5WMba065aEBVBUI1hc Yr5BxNEZrpB29pk2xPLhgG1WHZrXQHnkYjspKXv/IfgWSi1uo6IXfBSVeTnRfwU1jUOTLrMoL DcLr5fsLknKyWYdZ/hz9+trGtGDeBhnMTu6esatUcG5Nb3k3KerBhBotMBhbt1DTOWXRqeoBu p2gEA98u9DCmjFjgVIoYAv80HQxfWOrbOnolgdYiH4QxO3SuJL+SUVcLmS3H2TGRVQSut8RaS CyHw0A5Bu+VsqoR+xZDqyucnRdf6T7niND+DW07qNuGTP55TyviJqNL4cu253Z6lvRgD4B+Se QczWM/XmeQiYlOU1LuQRuX3OQ0oE9QixTVbfclqi9edYz5CcVvPaiVDp31X9qa2f87ln7rImw BtBKiMSy5XDShVZZ/lC1jn+pL4kCijHVq2E7ogi72LllJMtCsrMOR3ZhLHFyWLFy2K9jUdHL6 a2w/bwvKK/Nx/HJCrj9RyGWcrNFqcuATfrM+GG9JUjdEMeUc5RUCU66HRFIGjjTQj/OAZQMCN kJ5QWrkDzXantKCp37PMRj/mB/I= Received-SPF: pass client-ip=212.227.15.3; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This makes the core compress code more independend from ram.c. Signed-off-by: Lukas Straub Reviewed-by: Juan Quintela --- migration/ram.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) -- 2.40.0 diff --git a/migration/ram.c b/migration/ram.c index d248e1f062..3894d0ae79 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1551,12 +1551,14 @@ static int send_queued_data(CompressParam *param) abort(); } + update_compress_thread_counts(param, len); + return len; } static void flush_compressed_data(RAMState *rs) { - int idx, len, thread_count; + int idx, thread_count; if (!save_page_use_compression(rs)) { return; @@ -1575,15 +1577,8 @@ static void flush_compressed_data(RAMState *rs) qemu_mutex_lock(&comp_param[idx].mutex); if (!comp_param[idx].quit) { CompressParam *param = &comp_param[idx]; - len = send_queued_data(param); + send_queued_data(param); compress_reset_result(param); - - /* - * it's safe to fetch zero_page without holding comp_done_lock - * as there is no further request submitted to the thread, - * i.e, the thread should be waiting for a request at this point. - */ - update_compress_thread_counts(param, len); } qemu_mutex_unlock(&comp_param[idx].mutex); } @@ -1599,7 +1594,7 @@ static inline void set_compress_params(CompressParam *param, RAMBlock *block, static int compress_page_with_multi_thread(RAMBlock *block, ram_addr_t offset) { - int idx, thread_count, bytes_xmit = -1, pages = -1; + int idx, thread_count, pages = -1; bool wait = migrate_compress_wait_thread(); thread_count = migrate_compress_threads(); @@ -1610,11 +1605,10 @@ retry: CompressParam *param = &comp_param[idx]; qemu_mutex_lock(¶m->mutex); param->done = false; - bytes_xmit = send_queued_data(param); + send_queued_data(param); compress_reset_result(param); set_compress_params(param, block, offset); - update_compress_thread_counts(param, bytes_xmit); qemu_cond_signal(¶m->cond); qemu_mutex_unlock(¶m->mutex); pages = 1;