Received: by 2002:a17:906:fc07:b0:9bd:85f7:2662 with SMTP id ov7csp2038667ejb; Tue, 24 Oct 2023 06:15:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGqPPdtKOExVhZDX5OiedXeWQ3hAJJ8q7GkJHgIfd63cRlRv0vz5nfFFKueYMAI1G6JOPyS X-Received: by 2002:a05:620a:1429:b0:778:9b93:9717 with SMTP id k9-20020a05620a142900b007789b939717mr12781212qkj.22.1698153325335; Tue, 24 Oct 2023 06:15:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698153325; cv=none; d=google.com; s=arc-20160816; b=C7MqFBBwDnzVPRyYPOTlYF3rK5Wcs2Jrv0dEtOCBKThGWNEJli0i8VOk1lAWJ90I4z xQe8AqeN6Jfo0VRhCxVPHZlS1SMUexWT0ZyB/gODoAXQygigG2hib9ONRD063Wdf13b6 KrtmidUx/+PUu53Wcyi+4F+8hZvxHZJBDYZf9HNIHHuS+tyEFvGbHQLZh1kk7ETGfuWC 1luHXfO6JV3+4nPGBB4GmhlQJKk+IybxkfnDqIq2L8ETnFX1Pxtf2Eqw4JHTtDOE6xxg +RkfdLiCqtV1In+jd9+kj28wSNmvxUkEtolmgzNFcXabcB4jcosvzTqpWutrIbFNnlUf qk7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FD/xrtx5Ex3UkXu99HPCWJPi/sgl1QuP9uITLor6Oos=; fh=0DRGwfQymzNSinv+CnmU35FvXClR1k5Tnpw/bIUVe6k=; b=tbN5N+mEbL3nDB60XEl4T2btj2U0UCU/rY/WnMXxiM2bohOChDG0IbOYL6eQGml69g wR67j8hOKaZSK2KBZR2UgKSGW9ruzFQAR5lOdoQsOWVcfLjEwuNYdTW2LmBaAdmBxPn6 PtcNKAym2/GTY+qpQ9u+EickbNTpLTm9tPXBfzYlBEKjiSd0jvBvKbCMtMymWCs3Ohiy dCOTRCUcIFdvkUEYRHXmu6AcCU5PoaZHesu4MQIn+wrX92UVp1DnbTjjV8BBJoHP1ohn E0ME2W90Q8tFlD/ZBnbdSORIHH+TcujHtM31ecvR6U02BK4IjACBnBrioAljBMorEoPA qEXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=boEUHTjX; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u8-20020a05620a454800b00767b7436df3si7015912qkp.319.2023.10.24.06.15.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Oct 2023 06:15:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=boEUHTjX; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvHFH-00064F-EW; Tue, 24 Oct 2023 09:14:55 -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 1qvHEs-000542-Hv for qemu-arm@nongnu.org; Tue, 24 Oct 2023 09:14:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvHEq-0001EQ-Jr for qemu-arm@nongnu.org; Tue, 24 Oct 2023 09:14:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698153267; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FD/xrtx5Ex3UkXu99HPCWJPi/sgl1QuP9uITLor6Oos=; b=boEUHTjX3IA6OVPvcakkZim4d8Qs5nhcQgJXjeyFSgLCJdIgTsSNwiH0cr6CJFIFD6cZH5 0w6PuNEvaihZajNWXosYKt9ybc5e3lJnptpnQ/7Vane4Lvk1jnUOJdUOmxdSxEZu/jMYyz 0TxZeAIkPkFIE9JP8oKeM2uCbm2um5M= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-441-z1Po3R-_MXSYtkX6BEgD4Q-1; Tue, 24 Oct 2023 09:14:22 -0400 X-MC-Unique: z1Po3R-_MXSYtkX6BEgD4Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1BD1928EC10B; Tue, 24 Oct 2023 13:14:21 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7C511C060AE; Tue, 24 Oct 2023 13:14:14 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Cc: Eric Blake , Richard Henderson , Corey Minyard , Li Zhijian , Marcel Apfelbaum , Hanna Reitz , John Snow , David Gibson , Gerd Hoffmann , Stefan Hajnoczi , Halil Pasic , Peter Maydell , Corey Minyard , Mark Cave-Ayland , Kevin Wolf , qemu-s390x@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-arm@nongnu.org, libvir-list@redhat.com, Stefan Weil , Nicholas Piggin , Daniel Henrique Barboza , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , Leonardo Bras , Jason Wang , Fam Zheng , Christian Borntraeger , David Hildenbrand , Thomas Huth , Fabiano Rosas , Ilya Leoshkevich , Harsh Prateek Bora , Samuel Thibault , Eric Farman , Juan Quintela , Markus Armbruster , Stefan Berger , qemu-ppc@nongnu.org, "Michael S. Tsirkin" , qemu-block@nongnu.org, Lukas Straub Subject: [PULL 10/39] migration: Make compress_data_with_multithreads return bool Date: Tue, 24 Oct 2023 15:12:36 +0200 Message-ID: <20231024131305.87468-11-quintela@redhat.com> In-Reply-To: <20231024131305.87468-1-quintela@redhat.com> References: <20231024131305.87468-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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-arm@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-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: dyuGoRFr9Arl Reviewed-by: Lukas Straub Reviewed-by: Fabiano Rosas Signed-off-by: Juan Quintela Message-ID: <20231019110724.15324-5-quintela@redhat.com> --- migration/ram-compress.h | 4 ++-- migration/ram-compress.c | 17 ++++++++++------- migration/ram.c | 3 +-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/migration/ram-compress.h b/migration/ram-compress.h index e55d3b50bd..b228640092 100644 --- a/migration/ram-compress.h +++ b/migration/ram-compress.h @@ -60,8 +60,8 @@ void compress_threads_save_cleanup(void); int compress_threads_save_setup(void); void flush_compressed_data(int (send_queued_data(CompressParam *))); -int compress_page_with_multi_thread(RAMBlock *block, ram_addr_t offset, - int (send_queued_data(CompressParam *))); +bool compress_page_with_multi_thread(RAMBlock *block, ram_addr_t offset, + int (send_queued_data(CompressParam *))); int wait_for_decompress_done(void); void compress_threads_load_cleanup(void); diff --git a/migration/ram-compress.c b/migration/ram-compress.c index d037dfe6cf..ef03d60a6d 100644 --- a/migration/ram-compress.c +++ b/migration/ram-compress.c @@ -260,10 +260,13 @@ static inline void set_compress_params(CompressParam *param, RAMBlock *block, param->trigger = true; } -int compress_page_with_multi_thread(RAMBlock *block, ram_addr_t offset, - int (send_queued_data(CompressParam *))) +/* + * Return true when it compress a page + */ +bool compress_page_with_multi_thread(RAMBlock *block, ram_addr_t offset, + int (send_queued_data(CompressParam *))) { - int thread_count, pages = -1; + int thread_count; bool wait = migrate_compress_wait_thread(); thread_count = migrate_compress_threads(); @@ -281,8 +284,8 @@ retry: qemu_cond_signal(¶m->cond); qemu_mutex_unlock(¶m->mutex); - pages = 1; - break; + qemu_mutex_unlock(&comp_done_lock); + return true; } } @@ -290,13 +293,13 @@ retry: * wait for the free thread if the user specifies 'compress-wait-thread', * otherwise we will post the page out in the main thread as normal page. */ - if (pages < 0 && wait) { + if (wait) { qemu_cond_wait(&comp_done_cond, &comp_done_lock); goto retry; } qemu_mutex_unlock(&comp_done_lock); - return pages; + return false; } /* return the size after decompression, or negative value on error */ diff --git a/migration/ram.c b/migration/ram.c index 8246663f64..63a575ae90 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2067,8 +2067,7 @@ static bool save_compress_page(RAMState *rs, PageSearchStatus *pss, return false; } - if (compress_page_with_multi_thread(pss->block, offset, - send_queued_data) > 0) { + if (compress_page_with_multi_thread(pss->block, offset, send_queued_data)) { return true; } -- 2.41.0