From nobody Fri Oct 25 17:33:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1718092944; cv=none; d=zohomail.com; s=zohoarc; b=J22XpAfGkBzMZGD6Ez7HoKa44iXVEhPk5rRMS0rcXDnHBQZdVowyhmZDnm3VMDuyfUOs0QZrCuwKuDjIw8lntkjUwvg6/mLZ4/1jRmZlVJg1tPyWXl51S3srr5dE0+T7mBxdalifVR/wQYaN7WhxQMAuYUbBq8GrfvXQ4QiRNJY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718092944; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=z3/fHtAbxkymm4EMi9s3+lNFEPFIiZrw/wVQSyTinXo=; b=eFdqZ3bKJ3EfpEFX0JbAGYjnPsXJm+UvcGXVdQ4UTrSbBDGaSf/XCvqcVSoT+VZlVoYQvLTYXzCCbl2kgP4W3UVwyyew0kjOg4ZTp6urJI62xH8JQzA1m/2uIvhS+pQzpa19cl8s256k2qWeXM6NloJEJ51w2mTp7WZ0lq+v0JU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718092944828643.0923288495794; Tue, 11 Jun 2024 01:02:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sGwQv-0008Am-FO; Tue, 11 Jun 2024 04:00:45 -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 1sGwQt-00089G-8b for qemu-devel@nongnu.org; Tue, 11 Jun 2024 04:00:43 -0400 Received: from mgamail.intel.com ([192.198.163.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sGwQp-0006jb-Sf for qemu-devel@nongnu.org; Tue, 11 Jun 2024 04:00:42 -0400 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2024 01:00:37 -0700 Received: from sae-gw02.sh.intel.com (HELO localhost) ([10.239.45.110]) by fmviesa007.fm.intel.com with ESMTP; 11 Jun 2024 01:00:33 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718092840; x=1749628840; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yZclYataE8oUk3+OrIlf/wHgyHNC2yjRy371bVDuXoc=; b=TmnwfV3/kgIKOzBuR9vboMG+Dh2dgYyupubtZFq9d0n+6b9/MriyYgqx EGvX+LH+0uKhPqCG5c3FcANTDiEwlBAnq2BY2l19gAsiacuAxDXD1qX5K rTrB0atBjOpmWYUHLPXrZKOeTSGSvhestHMqqKE8/vC9/AVvncZDGiUd8 yWr8ZmcjDSPuFlLapqyJEerAsnNW+KQ8vqTx/fwxPtS+5jlhzWGX81FDd UJVfwhz00tHkyLNmp4pLqYhI9WSYNJoGqZwv54X0gSgRtuQLbQaANsIsi hrRTvZGmeQrAra87pqQXFJL7HLSaGO8GpaKXKL+aCpzWHGmW1BUIfkG1W Q==; X-CSE-ConnectionGUID: 9mnQJZvTTQmcNBTfxcyqDg== X-CSE-MsgGUID: PmAQjLNDRFmiwUm8ITR+kA== X-IronPort-AV: E=McAfee;i="6600,9927,11099"; a="14510006" X-IronPort-AV: E=Sophos;i="6.08,229,1712646000"; d="scan'208";a="14510006" X-CSE-ConnectionGUID: n7I6srg6SaaI9CPOgDLfcg== X-CSE-MsgGUID: 4xgPB4ARQ2WsrOJPl8Smew== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,229,1712646000"; d="scan'208";a="39184810" From: Yuan Liu To: peterx@redhat.com, farosas@suse.de, pbonzini@redhat.com, marcandre.lureau@redhat.com, berrange@redhat.com, thuth@redhat.com, philmd@linaro.org Cc: qemu-devel@nongnu.org, yuan1.liu@intel.com, nanhai.zou@intel.com, shameerali.kolothum.thodi@huawei.com Subject: [PATCH v8 1/7] docs/migration: add qpl compression feature Date: Mon, 10 Jun 2024 18:21:04 +0800 Message-ID: <20240610102110.900410-2-yuan1.liu@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240610102110.900410-1-yuan1.liu@intel.com> References: <20240610102110.900410-1-yuan1.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.198.163.18; envelope-from=yuan1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_12_24=1.049, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1718092945929100001 Content-Type: text/plain; charset="utf-8" add Intel Query Processing Library (QPL) compression method introduction Signed-off-by: Yuan Liu Reviewed-by: Nanhai Zou Reviewed-by: Fabiano Rosas Acked-by: Peter Xu --- docs/devel/migration/features.rst | 1 + docs/devel/migration/qpl-compression.rst | 260 +++++++++++++++++++++++ 2 files changed, 261 insertions(+) create mode 100644 docs/devel/migration/qpl-compression.rst diff --git a/docs/devel/migration/features.rst b/docs/devel/migration/featu= res.rst index d5ca7b86d5..bc98b65075 100644 --- a/docs/devel/migration/features.rst +++ b/docs/devel/migration/features.rst @@ -12,3 +12,4 @@ Migration has plenty of features to support different use= cases. virtio mapped-ram CPR + qpl-compression diff --git a/docs/devel/migration/qpl-compression.rst b/docs/devel/migratio= n/qpl-compression.rst new file mode 100644 index 0000000000..990992d786 --- /dev/null +++ b/docs/devel/migration/qpl-compression.rst @@ -0,0 +1,260 @@ +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +QPL Compression +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +The Intel Query Processing Library (Intel ``QPL``) is an open-source libra= ry to +provide compression and decompression features and it is based on deflate +compression algorithm (RFC 1951). + +The ``QPL`` compression relies on Intel In-Memory Analytics Accelerator(``= IAA``) +and Shared Virtual Memory(``SVM``) technology, they are new features suppo= rted +from Intel 4th Gen Intel Xeon Scalable processors, codenamed Sapphire Rapi= ds +processor(``SPR``). + +For more ``QPL`` introduction, please refer to `QPL Introduction +`_ + +QPL Compression Framework +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D + +:: + + +----------------+ +------------------+ + | MultiFD Thread | |accel-config tool | + +-------+--------+ +--------+---------+ + | | + | | + |compress/decompress | + +-------+--------+ | Setup IAA + | QPL library | | Resources + +-------+---+----+ | + | | | + | +-------------+-------+ + | Open IAA | + | Devices +-----+-----+ + | |idxd driver| + | +-----+-----+ + | | + | | + | +-----+-----+ + +-----------+IAA Devices| + Submit jobs +-----------+ + via enqcmd + + +QPL Build And Installation +-------------------------- + +.. code-block:: shell + + $git clone --recursive https://github.com/intel/qpl.git qpl + $mkdir qpl/build + $cd qpl/build + $cmake -DCMAKE_BUILD_TYPE=3DRelease -DCMAKE_INSTALL_PREFIX=3D/usr -DQPL_= LIBRARY_TYPE=3DSHARED .. + $sudo cmake --build . --target install + +For more details about ``QPL`` installation, please refer to `QPL Installa= tion +`_ + +IAA Device Management +--------------------- + +The number of ``IAA`` devices will vary depending on the Xeon product mode= l. +On a ``SPR`` server, there can be a maximum of 8 ``IAA`` devices, with up = to +4 devices per socket. + +By default, all ``IAA`` devices are disabled and need to be configured and +enabled by users manually. + +Check the number of devices through the following command + +.. code-block:: shell + + #lspci -d 8086:0cfe + 6a:02.0 System peripheral: Intel Corporation Device 0cfe + 6f:02.0 System peripheral: Intel Corporation Device 0cfe + 74:02.0 System peripheral: Intel Corporation Device 0cfe + 79:02.0 System peripheral: Intel Corporation Device 0cfe + e7:02.0 System peripheral: Intel Corporation Device 0cfe + ec:02.0 System peripheral: Intel Corporation Device 0cfe + f1:02.0 System peripheral: Intel Corporation Device 0cfe + f6:02.0 System peripheral: Intel Corporation Device 0cfe + +IAA Device Configuration And Enabling +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The ``accel-config`` tool is used to enable ``IAA`` devices and configure +``IAA`` hardware resources(work queues and engines). One ``IAA`` device +has 8 work queues and 8 processing engines, multiple engines can be assign= ed +to a work queue via ``group`` attribute. + +For ``accel-config`` installation, please refer to `accel-config installat= ion +`_ + +One example of configuring and enabling an ``IAA`` device. + +.. code-block:: shell + + #accel-config config-engine iax1/engine1.0 -g 0 + #accel-config config-engine iax1/engine1.1 -g 0 + #accel-config config-engine iax1/engine1.2 -g 0 + #accel-config config-engine iax1/engine1.3 -g 0 + #accel-config config-engine iax1/engine1.4 -g 0 + #accel-config config-engine iax1/engine1.5 -g 0 + #accel-config config-engine iax1/engine1.6 -g 0 + #accel-config config-engine iax1/engine1.7 -g 0 + #accel-config config-wq iax1/wq1.0 -g 0 -s 128 -p 10 -b 1 -t 128 -m shar= ed -y user -n app1 -d user + #accel-config enable-device iax1 + #accel-config enable-wq iax1/wq1.0 + +.. note:: + IAX is an early name for IAA + +- The ``IAA`` device index is 1, use ``ls -lh /sys/bus/dsa/devices/iax*`` + command to query the ``IAA`` device index. + +- 8 engines and 1 work queue are configured in group 0, so all compression= jobs + submitted to this work queue can be processed by all engines at the same= time. + +- Set work queue attributes including the work mode, work queue size and s= o on. + +- Enable the ``IAA1`` device and work queue 1.0 + +.. note:: + + Set work queue mode to shared mode, since ``QPL`` library only supports + shared mode + +For more detailed configuration, please refer to `IAA Configuration Samples +`_ + +IAA Unit Test +^^^^^^^^^^^^^ + +- Enabling ``IAA`` devices for Xeon platform, please refer to `IAA User Gu= ide + `_ + +- ``IAA`` device driver is Intel Data Accelerator Driver (idxd), it is + recommended that the minimum version of Linux kernel is 5.18. + +- Add ``"intel_iommu=3Don,sm_on"`` parameter to kernel command line + for ``SVM`` feature enabling. + +Here is an easy way to verify ``IAA`` device driver and ``SVM`` with `iaa_= test +`_ + +.. code-block:: shell + + #./test/iaa_test + [ info] alloc wq 0 shared size 128 addr 0x7f26cebe5000 batch sz 0xfffff= ffe xfer sz 0x80000000 + [ info] test noop: tflags 0x1 num_desc 1 + [ info] preparing descriptor for noop + [ info] Submitted all noop jobs + [ info] verifying task result for 0x16f7e20 + [ info] test with op 0 passed + + +IAA Resources Allocation For Migration +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +There is no ``IAA`` resource configuration parameters for migration and +``accel-config`` tool configuration cannot directly specify the ``IAA`` +resources used for migration. + +The multifd migration with ``QPL`` compression method will use all work +queues that are enabled and shared mode. + +.. note:: + + Accessing IAA resources requires ``sudo`` command or ``root`` privileges + by default. Administrators can modify the IAA device node ownership + so that QEMU can use IAA with specified user permissions. + + For example + + #chown -R qemu /dev/iax + +Shared Virtual Memory(SVM) Introduction +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +An ability for an accelerator I/O device to operate in the same virtual +memory space of applications on host processors. It also implies the +ability to operate from pageable memory, avoiding functional requirements +to pin memory for DMA operations. + +When using ``SVM`` technology, users do not need to reserve memory for the +``IAA`` device and perform pin memory operation. The ``IAA`` device can +directly access data using the virtual address of the process. + +For more ``SVM`` technology, please refer to +`Shared Virtual Addressing (SVA) with ENQCMD +`_ + + +How To Use QPL Compression In Migration +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +1 - Installation of ``QPL`` library and ``accel-config`` library if using = IAA + +2 - Configure and enable ``IAA`` devices and work queues via ``accel-confi= g`` + +3 - Build ``QEMU`` with ``--enable-qpl`` parameter + + E.g. configure --target-list=3Dx86_64-softmmu --enable-kvm ``--enable-qp= l`` + +4 - Enable ``QPL`` compression during migration + + Set ``migrate_set_parameter multifd-compression qpl`` when migrating, the + ``QPL`` compression does not support configuring the compression level, = it + only supports one compression level. + +The Difference Between QPL And ZLIB +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Although both ``QPL`` and ``ZLIB`` are based on the deflate compression +algorithm, and ``QPL`` can support the header and tail of ``ZLIB``, ``QPL`` +is still not fully compatible with the ``ZLIB`` compression in the migrati= on. + +``QPL`` only supports 4K history buffer, and ``ZLIB`` is 32K by default. +``ZLIB`` compresses data that ``QPL`` may not decompress correctly and +vice versa. + +``QPL`` does not support the ``Z_SYNC_FLUSH`` operation in ``ZLIB`` stream= ing +compression, current ``ZLIB`` implementation uses ``Z_SYNC_FLUSH``, so each +``multifd`` thread has a ``ZLIB`` streaming context, and all page compress= ion +and decompression are based on this stream. ``QPL`` cannot decompress such= data +and vice versa. + +The introduction for ``Z_SYNC_FLUSH``, please refer to `Zlib Manual +`_ + +The Best Practices +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +When user enables the IAA device for ``QPL`` compression, it is recommended +to add ``-mem-prealloc`` parameter to the destination boot parameters. This +parameter can avoid the occurrence of I/O page fault and reduce the overhe= ad +of IAA compression and decompression. + +The example of booting with ``-mem-prealloc`` parameter + +.. code-block:: shell + + $qemu-system-x86_64 --enable-kvm -cpu host --mem-prealloc ... + + +An example about I/O page fault measurement of destination without +``-mem-prealloc``, the ``svm_prq`` indicates the number of I/O page fault +occurrences and processing time. + +.. code-block:: shell + + #echo 1 > /sys/kernel/debug/iommu/intel/dmar_perf_latency + #echo 2 > /sys/kernel/debug/iommu/intel/dmar_perf_latency + #echo 3 > /sys/kernel/debug/iommu/intel/dmar_perf_latency + #echo 4 > /sys/kernel/debug/iommu/intel/dmar_perf_latency + #cat /sys/kernel/debug/iommu/intel/dmar_perf_latency + IOMMU: dmar18 Register Base Address: c87fc000 + <0.1us 0.1us-1us 1us-10us 10us-100us 100us-1ms = 1ms-10ms >=3D10ms min(us) max(us) average(us) + inv_iotlb 0 286 123 0 0 = 0 0 0 1 0 + inv_devtlb 0 276 133 0 0 = 0 0 0 2 0 + inv_iec 0 0 0 0 0 = 0 0 0 0 0 + svm_prq 0 0 25206 364 395 = 0 0 1 556 9 --=20 2.43.0 From nobody Fri Oct 25 17:33:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1718092956; cv=none; d=zohomail.com; s=zohoarc; b=e28sgKOP3mDxYaRA4VHlNlP60XEqTCl4GpPHGSFuo+dN8B2sOmY/31QdfC5H33Rbu3LmvzuR7++6wM2vnA7SeHqxANukr6BP9H01cvUtKUCPXjKm/DpaCpxobQdvozQ91z89yRp4aUbSViQ/7ofjvIiVsTMXaVAXL5VuDiU8ux0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718092956; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=02djlx1tVU8cSCFFwvvcNUcpfsVwvFiVhtzL9yfXxrM=; b=fnWznzcJo9vrUFiOURnV8Rv6VPjZVyas84YADNbuFPEXc+gVxoITwaU4IsxywYDykUYQgdogX5O/R5hrKkmY4RmdAB5QJt7J2DkkPIRsCB/Itpa+wF6zxJfcLTYpRM5zEKPx+Jhmc2mYAoFXb9CTEVRWTNhQCWAqcGuKjjuToQo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718092956321332.5650069561236; Tue, 11 Jun 2024 01:02:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sGwQv-0008Ao-Pa; Tue, 11 Jun 2024 04:00:45 -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 1sGwQu-00089z-GC for qemu-devel@nongnu.org; Tue, 11 Jun 2024 04:00:44 -0400 Received: from mgamail.intel.com ([192.198.163.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sGwQr-0006l9-P3 for qemu-devel@nongnu.org; Tue, 11 Jun 2024 04:00:44 -0400 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2024 01:00:40 -0700 Received: from sae-gw02.sh.intel.com (HELO localhost) ([10.239.45.110]) by fmviesa007.fm.intel.com with ESMTP; 11 Jun 2024 01:00:37 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718092842; x=1749628842; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XL3qUJ/s4JKxW1z/Q1moGl6f6RxBIByPE7Pu6LcLU94=; b=Q92XVMt63PSf5Dbu026+jDj8FgKH3mY6/XBM7e8zt9E+FlhDXppnmiRt tsY4E4pKO2ZfsL/lGikGJD8NVHjL3Nh+Fxfy9vqVYk8MDpO5zkJTvpEJk YtTal00CpN+JV+hWv/83IfUsIW9BUIlLpK8DiQSBDLH5Zropsq/YyTxSr 91uz1TpWsaGLX/DREVzifuSlH8lCPNSoztZypa1uLzVk0Ye6OrIonNQaE ZT5pCUVIKHAedcErMLX4dsZAJeqGt9j5V2wX9w5AQuAd+7CCq3v7rSqYp WgMXPLGg3jhsC/9Z2V5Dx9z6rzHchL8YUhPV2EVDB3tye902DvQ1BJZsx w==; X-CSE-ConnectionGUID: KXLGkQJZSniSDVO1UfX2HQ== X-CSE-MsgGUID: gzNh1/GdRO2iJyUzGSvkGg== X-IronPort-AV: E=McAfee;i="6600,9927,11099"; a="14510014" X-IronPort-AV: E=Sophos;i="6.08,229,1712646000"; d="scan'208";a="14510014" X-CSE-ConnectionGUID: 1hO77vkqRuaHSkN5OMn+Lg== X-CSE-MsgGUID: +iiORHKoSDSUpnBjyVmkKQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,229,1712646000"; d="scan'208";a="39184817" From: Yuan Liu To: peterx@redhat.com, farosas@suse.de, pbonzini@redhat.com, marcandre.lureau@redhat.com, berrange@redhat.com, thuth@redhat.com, philmd@linaro.org Cc: qemu-devel@nongnu.org, yuan1.liu@intel.com, nanhai.zou@intel.com, shameerali.kolothum.thodi@huawei.com Subject: [PATCH v8 2/7] migration/multifd: put IOV initialization into compression method Date: Mon, 10 Jun 2024 18:21:05 +0800 Message-ID: <20240610102110.900410-3-yuan1.liu@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240610102110.900410-1-yuan1.liu@intel.com> References: <20240610102110.900410-1-yuan1.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.198.163.18; envelope-from=yuan1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_12_24=1.049, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1718092957925100003 Content-Type: text/plain; charset="utf-8" Different compression methods may require different numbers of IOVs. Based on streaming compression of zlib and zstd, all pages will be compressed to a data block, so two IOVs are needed for packet header and compressed data block. Signed-off-by: Yuan Liu Reviewed-by: Nanhai Zou Reviewed-by: Fabiano Rosas Reviewed-by: Peter Xu --- migration/multifd-zlib.c | 7 +++++++ migration/multifd-zstd.c | 8 +++++++- migration/multifd.c | 22 ++++++++++++---------- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/migration/multifd-zlib.c b/migration/multifd-zlib.c index 737a9645d2..2ced69487e 100644 --- a/migration/multifd-zlib.c +++ b/migration/multifd-zlib.c @@ -70,6 +70,10 @@ static int zlib_send_setup(MultiFDSendParams *p, Error *= *errp) goto err_free_zbuff; } p->compress_data =3D z; + + /* Needs 2 IOVs, one for packet header and one for compressed data */ + p->iov =3D g_new0(struct iovec, 2); + return 0; =20 err_free_zbuff: @@ -101,6 +105,9 @@ static void zlib_send_cleanup(MultiFDSendParams *p, Err= or **errp) z->buf =3D NULL; g_free(p->compress_data); p->compress_data =3D NULL; + + g_free(p->iov); + p->iov =3D NULL; } =20 /** diff --git a/migration/multifd-zstd.c b/migration/multifd-zstd.c index 256858df0a..ca17b7e310 100644 --- a/migration/multifd-zstd.c +++ b/migration/multifd-zstd.c @@ -52,7 +52,6 @@ static int zstd_send_setup(MultiFDSendParams *p, Error **= errp) struct zstd_data *z =3D g_new0(struct zstd_data, 1); int res; =20 - p->compress_data =3D z; z->zcs =3D ZSTD_createCStream(); if (!z->zcs) { g_free(z); @@ -77,6 +76,10 @@ static int zstd_send_setup(MultiFDSendParams *p, Error *= *errp) error_setg(errp, "multifd %u: out of memory for zbuff", p->id); return -1; } + p->compress_data =3D z; + + /* Needs 2 IOVs, one for packet header and one for compressed data */ + p->iov =3D g_new0(struct iovec, 2); return 0; } =20 @@ -98,6 +101,9 @@ static void zstd_send_cleanup(MultiFDSendParams *p, Erro= r **errp) z->zbuff =3D NULL; g_free(p->compress_data); p->compress_data =3D NULL; + + g_free(p->iov); + p->iov =3D NULL; } =20 /** diff --git a/migration/multifd.c b/migration/multifd.c index f317bff077..d82885fdbb 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -137,6 +137,13 @@ static int nocomp_send_setup(MultiFDSendParams *p, Err= or **errp) p->write_flags |=3D QIO_CHANNEL_WRITE_FLAG_ZERO_COPY; } =20 + if (multifd_use_packets()) { + /* We need one extra place for the packet header */ + p->iov =3D g_new0(struct iovec, p->page_count + 1); + } else { + p->iov =3D g_new0(struct iovec, p->page_count); + } + return 0; } =20 @@ -150,6 +157,8 @@ static int nocomp_send_setup(MultiFDSendParams *p, Erro= r **errp) */ static void nocomp_send_cleanup(MultiFDSendParams *p, Error **errp) { + g_free(p->iov); + p->iov =3D NULL; return; } =20 @@ -228,6 +237,7 @@ static int nocomp_send_prepare(MultiFDSendParams *p, Er= ror **errp) */ static int nocomp_recv_setup(MultiFDRecvParams *p, Error **errp) { + p->iov =3D g_new0(struct iovec, p->page_count); return 0; } =20 @@ -240,6 +250,8 @@ static int nocomp_recv_setup(MultiFDRecvParams *p, Erro= r **errp) */ static void nocomp_recv_cleanup(MultiFDRecvParams *p) { + g_free(p->iov); + p->iov =3D NULL; } =20 /** @@ -783,8 +795,6 @@ static bool multifd_send_cleanup_channel(MultiFDSendPar= ams *p, Error **errp) p->packet_len =3D 0; g_free(p->packet); p->packet =3D NULL; - g_free(p->iov); - p->iov =3D NULL; multifd_send_state->ops->send_cleanup(p, errp); =20 return *errp =3D=3D NULL; @@ -1179,11 +1189,6 @@ bool multifd_send_setup(void) p->packet =3D g_malloc0(p->packet_len); p->packet->magic =3D cpu_to_be32(MULTIFD_MAGIC); p->packet->version =3D cpu_to_be32(MULTIFD_VERSION); - - /* We need one extra place for the packet header */ - p->iov =3D g_new0(struct iovec, page_count + 1); - } else { - p->iov =3D g_new0(struct iovec, page_count); } p->name =3D g_strdup_printf("multifdsend_%d", i); p->page_size =3D qemu_target_page_size(); @@ -1353,8 +1358,6 @@ static void multifd_recv_cleanup_channel(MultiFDRecvP= arams *p) p->packet_len =3D 0; g_free(p->packet); p->packet =3D NULL; - g_free(p->iov); - p->iov =3D NULL; g_free(p->normal); p->normal =3D NULL; g_free(p->zero); @@ -1602,7 +1605,6 @@ int multifd_recv_setup(Error **errp) p->packet =3D g_malloc0(p->packet_len); } p->name =3D g_strdup_printf("multifdrecv_%d", i); - p->iov =3D g_new0(struct iovec, page_count); p->normal =3D g_new0(ram_addr_t, page_count); p->zero =3D g_new0(ram_addr_t, page_count); p->page_count =3D page_count; --=20 2.43.0 From nobody Fri Oct 25 17:33:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1718092896; cv=none; d=zohomail.com; s=zohoarc; b=Y68dqtNTfpBSP/ZVGST0WXPI9V47LRWctD+kz/CHLyvenWhMe06zs6npqheMjgoqkI8bMplbD8PTbcKvPjwObFRF89DanQvbjoMwLM66YSz2GQzu+duW9Xzh/LuKe3aZHi4MTknSuQoyrOB6I0Y3aw+EyXZKwstsVdnjNjt2zsA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718092896; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3ElLcZTbgd2WGaCYfkA4nNYL8il8cKsslVy3OPze5vc=; b=cqSp5AoGozEoj0621dbQteU20ro3EZSmjTAdMF8Gnuk1SZ43LN7xP/gd84DpkXasmsq7HECjC/b6+thmalDemcLLilsM0vjqyCiptK4BSt+RpsJVvgf2SIFnQKIDj/3KPRdXebCB0YHqkB+CCy9U5DKEKu/Kq33/MtGyFXG5bEo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718092896319102.54391463391528; Tue, 11 Jun 2024 01:01:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sGwQy-0008CZ-OE; Tue, 11 Jun 2024 04:00:48 -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 1sGwQw-0008BT-CE for qemu-devel@nongnu.org; Tue, 11 Jun 2024 04:00:46 -0400 Received: from mgamail.intel.com ([192.198.163.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sGwQu-0006lp-KM for qemu-devel@nongnu.org; Tue, 11 Jun 2024 04:00:46 -0400 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2024 01:00:43 -0700 Received: from sae-gw02.sh.intel.com (HELO localhost) ([10.239.45.110]) by fmviesa007.fm.intel.com with ESMTP; 11 Jun 2024 01:00:40 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718092845; x=1749628845; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LOkAr6o97zLVwWYMK4M28np6yAyG6953SoDn1P7ED0w=; b=lz0uyEsteveE4ReANmej6qcsDSy4G6SrFUn74J2PmQP3KaQg0sBRO+KR y5sh2hyEMYcnUccSWac1kSVoQV/GlCMWdDEHdMZN0+BPRqZ+FUdBIonIa mDJbgnbYaaO8zYuKfAk2IG3CXwP9ppLi0JrEjVZL8wJj4KhUG2zgF46M8 V2PlOPV2a0o/seVj+fSgakoM2xS86kKVXecdt+hzPIJfJoVO1kaBm0+wT GwChgQKQHapaGghFEu3x+cQS9603KxD1VRvdDFiVWKfUkwfcQhNpPzXBW DqT9NRB1U/ihf3NoSTMmyLY6YM+GfsvyowA82pSuDpaVnz7jvNv/3zpLr w==; X-CSE-ConnectionGUID: Xt21gwtMR1S82QVZRH4VPQ== X-CSE-MsgGUID: bWRgwMSyTteO1+211G1TEw== X-IronPort-AV: E=McAfee;i="6600,9927,11099"; a="14510025" X-IronPort-AV: E=Sophos;i="6.08,229,1712646000"; d="scan'208";a="14510025" X-CSE-ConnectionGUID: ABpeTSbfR+O8ZkPCBIaYHw== X-CSE-MsgGUID: Kv/OpcjeS8SLA8DP+m6bgw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,229,1712646000"; d="scan'208";a="39184822" From: Yuan Liu To: peterx@redhat.com, farosas@suse.de, pbonzini@redhat.com, marcandre.lureau@redhat.com, berrange@redhat.com, thuth@redhat.com, philmd@linaro.org Cc: qemu-devel@nongnu.org, yuan1.liu@intel.com, nanhai.zou@intel.com, shameerali.kolothum.thodi@huawei.com Subject: [PATCH v8 3/7] configure: add --enable-qpl build option Date: Mon, 10 Jun 2024 18:21:06 +0800 Message-ID: <20240610102110.900410-4-yuan1.liu@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240610102110.900410-1-yuan1.liu@intel.com> References: <20240610102110.900410-1-yuan1.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.198.163.18; envelope-from=yuan1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_12_24=1.049, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1718092897625100006 Content-Type: text/plain; charset="utf-8" add --enable-qpl and --disable-qpl options to enable and disable the QPL compression method for multifd migration. The Query Processing Library (QPL) is an open-source library that supports data compression and decompression features. It is based on the deflate compression algorithm and use Intel In-Memory Analytics Accelerator(IAA) hardware for compression and decompression acceleration. For more live migration with IAA, please refer to the document docs/devel/migration/qpl-compression.rst Signed-off-by: Yuan Liu Reviewed-by: Nanhai Zou Reviewed-by: Fabiano Rosas --- meson.build | 8 ++++++++ meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 3 +++ 3 files changed, 13 insertions(+) diff --git a/meson.build b/meson.build index ec59effca2..43f260f9eb 100644 --- a/meson.build +++ b/meson.build @@ -1201,6 +1201,12 @@ if not get_option('zstd').auto() or have_block required: get_option('zstd'), method: 'pkg-config') endif +qpl =3D not_found +if not get_option('qpl').auto() or have_system + qpl =3D dependency('qpl', version: '>=3D1.5.0', + required: get_option('qpl'), + method: 'pkg-config') +endif virgl =3D not_found =20 have_vhost_user_gpu =3D have_tools and host_os =3D=3D 'linux' and pixman.f= ound() @@ -2335,6 +2341,7 @@ config_host_data.set('CONFIG_MALLOC_TRIM', has_malloc= _trim) config_host_data.set('CONFIG_STATX', has_statx) config_host_data.set('CONFIG_STATX_MNT_ID', has_statx_mnt_id) config_host_data.set('CONFIG_ZSTD', zstd.found()) +config_host_data.set('CONFIG_QPL', qpl.found()) config_host_data.set('CONFIG_FUSE', fuse.found()) config_host_data.set('CONFIG_FUSE_LSEEK', fuse_lseek.found()) config_host_data.set('CONFIG_SPICE_PROTOCOL', spice_protocol.found()) @@ -4449,6 +4456,7 @@ summary_info +=3D {'snappy support': snappy} summary_info +=3D {'bzip2 support': libbzip2} summary_info +=3D {'lzfse support': liblzfse} summary_info +=3D {'zstd support': zstd} +summary_info +=3D {'Query Processing Library support': qpl} summary_info +=3D {'NUMA host support': numa} summary_info +=3D {'capstone': capstone} summary_info +=3D {'libpmem support': libpmem} diff --git a/meson_options.txt b/meson_options.txt index 4c1583eb40..dd680a5faf 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -259,6 +259,8 @@ option('xkbcommon', type : 'feature', value : 'auto', description: 'xkbcommon support') option('zstd', type : 'feature', value : 'auto', description: 'zstd compression support') +option('qpl', type : 'feature', value : 'auto', + description: 'Query Processing Library support') option('fuse', type: 'feature', value: 'auto', description: 'FUSE block device export') option('fuse_lseek', type : 'feature', value : 'auto', diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 6ce5a8b72a..73ae8cedfc 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -220,6 +220,7 @@ meson_options_help() { printf "%s\n" ' Xen PCI passthrough support' printf "%s\n" ' xkbcommon xkbcommon support' printf "%s\n" ' zstd zstd compression support' + printf "%s\n" ' qpl Query Processing Library support' } _meson_option_parse() { case $1 in @@ -558,6 +559,8 @@ _meson_option_parse() { --disable-xkbcommon) printf "%s" -Dxkbcommon=3Ddisabled ;; --enable-zstd) printf "%s" -Dzstd=3Denabled ;; --disable-zstd) printf "%s" -Dzstd=3Ddisabled ;; + --enable-qpl) printf "%s" -Dqpl=3Denabled ;; + --disable-qpl) printf "%s" -Dqpl=3Ddisabled ;; *) return 1 ;; esac } --=20 2.43.0 From nobody Fri Oct 25 17:33:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1718092868; cv=none; d=zohomail.com; s=zohoarc; b=ijbnM6Qwn4JrixcpvkwuSLuSx5h9lOhO6G5LthlqPpfLyOaPqe/ogfdc0hRJHbnkEEpZJ0NUjzmnfUQWNwmVlIr9hrWIzgT/40T//LSIZ5tkVAs55D55BxhKFiCSKECKSR/kyMYyMge8AQHtFhT9PgGfuFhpJ7Ere9aoP27cWpo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718092868; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RZD5UP6l9yvnavjxlf24yeB0BQ3ZByFz4PsNmmjnS20=; b=icL+ZcYOuvWVdp5aSHwuwUo7rdwawTSuS4XubVasv+47A8c7wAWeHg3hJuAf1Zb+wjQqb9CJ7kAYWMHtM86E1V0b24hu+LGxIMS5vDHUUEBR/U0+V8tLC2dEdqbfug5fxiqCd6b5it4WOqCj3OwUo/7b6k7Sv2PuETFcHU8ZZnU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718092868701252.74171175461186; Tue, 11 Jun 2024 01:01:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sGwR3-0008G2-Cp; Tue, 11 Jun 2024 04:00:53 -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 1sGwR1-0008Ez-AY for qemu-devel@nongnu.org; Tue, 11 Jun 2024 04:00:51 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sGwQz-0006mH-Am for qemu-devel@nongnu.org; Tue, 11 Jun 2024 04:00:51 -0400 Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2024 01:00:47 -0700 Received: from sae-gw02.sh.intel.com (HELO localhost) ([10.239.45.110]) by orviesa002.jf.intel.com with ESMTP; 11 Jun 2024 01:00:45 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718092849; x=1749628849; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WRf9grLHtl23f86fVCmsEJbqolIsjXAVmYr8+xyFWww=; b=dJjNEbveihBFps30x/G0EfG0Zlo3DOFP/y2f5TFskd+I41w0nwW7iH06 0ByCXQEj76oSM6zJlb2B2xm8ofaw+RBqFzYE6W3E7dGoTNMjfgMrut1Tv e1ycSs+YjJnIOjh3trbgc3w7DRJLMf4OuMhccGzEHJY0A/8Ys79ILkVij 3WnH8OkMd4bXqE5+oUU/HNqJ2QaMSQebnCMlhLdoX3PU80uaiME3NrLEg FYZT1qrAyoZAXCNfybE/K3qT5ZAx75K91/ZVloBRV94W42vfbf3yvtuhx 15DcDtSdL1FOepUEvX1+hobYVts+TqwsOL7OdaSSbE1MASMuZsEXYz/2L A==; X-CSE-ConnectionGUID: Hvv9KXudSlSFQVW+yI+5hw== X-CSE-MsgGUID: Uhmp8xEJSe2fHyMBBliD0Q== X-IronPort-AV: E=McAfee;i="6600,9927,11099"; a="32271350" X-IronPort-AV: E=Sophos;i="6.08,229,1712646000"; d="scan'208";a="32271350" X-CSE-ConnectionGUID: XZRTI5/fSmWdeTfDVmyMLA== X-CSE-MsgGUID: +dLE2fcfQQ2Ti+3W0Aj2PQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,229,1712646000"; d="scan'208";a="70140901" From: Yuan Liu To: peterx@redhat.com, farosas@suse.de, pbonzini@redhat.com, marcandre.lureau@redhat.com, berrange@redhat.com, thuth@redhat.com, philmd@linaro.org Cc: qemu-devel@nongnu.org, yuan1.liu@intel.com, nanhai.zou@intel.com, shameerali.kolothum.thodi@huawei.com Subject: [PATCH v8 4/7] migration/multifd: add qpl compression method Date: Mon, 10 Jun 2024 18:21:07 +0800 Message-ID: <20240610102110.900410-5-yuan1.liu@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240610102110.900410-1-yuan1.liu@intel.com> References: <20240610102110.900410-1-yuan1.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.10; envelope-from=yuan1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_12_24=1.049, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1718092869687100001 Content-Type: text/plain; charset="utf-8" add the Query Processing Library (QPL) compression method Introduce the qpl as a new multifd migration compression method, it can use In-Memory Analytics Accelerator(IAA) to accelerate compression and decompression, which can not only reduce network bandwidth requirement but also reduce host compression and decompression CPU overhead. How to enable qpl compression during migration: migrate_set_parameter multifd-compression qpl There is no qpl compression level parameter added since it only supports level one, users do not need to specify the qpl compression level. Signed-off-by: Yuan Liu Reviewed-by: Nanhai Zou Reviewed-by: Peter Xu Reviewed-by: Fabiano Rosas --- hw/core/qdev-properties-system.c | 2 +- migration/meson.build | 1 + migration/multifd-qpl.c | 20 ++++++++++++++++++++ migration/multifd.h | 1 + qapi/migration.json | 7 ++++++- 5 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 migration/multifd-qpl.c diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-sys= tem.c index d79d6f4b53..6ccd7224f6 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -659,7 +659,7 @@ const PropertyInfo qdev_prop_fdc_drive_type =3D { const PropertyInfo qdev_prop_multifd_compression =3D { .name =3D "MultiFDCompression", .description =3D "multifd_compression values, " - "none/zlib/zstd", + "none/zlib/zstd/qpl", .enum_table =3D &MultiFDCompression_lookup, .get =3D qdev_propinfo_get_enum, .set =3D qdev_propinfo_set_enum, diff --git a/migration/meson.build b/migration/meson.build index bdc3244bce..5f146fe8a9 100644 --- a/migration/meson.build +++ b/migration/meson.build @@ -39,6 +39,7 @@ endif =20 system_ss.add(when: rdma, if_true: files('rdma.c')) system_ss.add(when: zstd, if_true: files('multifd-zstd.c')) +system_ss.add(when: qpl, if_true: files('multifd-qpl.c')) =20 specific_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_true: files('ram.c', diff --git a/migration/multifd-qpl.c b/migration/multifd-qpl.c new file mode 100644 index 0000000000..056a68a060 --- /dev/null +++ b/migration/multifd-qpl.c @@ -0,0 +1,20 @@ +/* + * Multifd qpl compression accelerator implementation + * + * Copyright (c) 2023 Intel Corporation + * + * Authors: + * Yuan Liu + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ +#include "qemu/osdep.h" +#include "qemu/module.h" + +static void multifd_qpl_register(void) +{ + /* noop */ +} + +migration_init(multifd_qpl_register); diff --git a/migration/multifd.h b/migration/multifd.h index c9d9b09239..5b7d9b15f8 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -40,6 +40,7 @@ MultiFDRecvData *multifd_get_recv_data(void); #define MULTIFD_FLAG_NOCOMP (0 << 1) #define MULTIFD_FLAG_ZLIB (1 << 1) #define MULTIFD_FLAG_ZSTD (2 << 1) +#define MULTIFD_FLAG_QPL (4 << 1) =20 /* This value needs to be a multiple of qemu_target_page_size() */ #define MULTIFD_PACKET_SIZE (512 * 1024) diff --git a/qapi/migration.json b/qapi/migration.json index a351fd3714..f97bc3bb93 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -554,11 +554,16 @@ # # @zstd: use zstd compression method. # +# @qpl: use qpl compression method. Query Processing Library(qpl) is based= on +# the deflate compression algorithm and use the Intel In-Memory Anal= ytics +# Accelerator(IAA) accelerated compression and decompression. (Since= 9.1) +# # Since: 5.0 ## { 'enum': 'MultiFDCompression', 'data': [ 'none', 'zlib', - { 'name': 'zstd', 'if': 'CONFIG_ZSTD' } ] } + { 'name': 'zstd', 'if': 'CONFIG_ZSTD' }, + { 'name': 'qpl', 'if': 'CONFIG_QPL' } ] } =20 ## # @MigMode: --=20 2.43.0 From nobody Fri Oct 25 17:33:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1718092913; cv=none; d=zohomail.com; s=zohoarc; b=hbSyP0Gm6VfYHgGI15tHES68YjvEerFLrFVwJcS06E0omDSsAXcur4dmkrakL57bo30KOPhrtBTiH+75loBTNrBc1qPJ6PYitPayADTa41BdvqSDlZGlezKfzQTyGI8QeUUpbbAnzMinsjlf0gIFvmHZw6ISwcnEBJtn8Vjc4W8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718092913; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DufJd1G+hhedVV64jKmRTAgJdThsxVs8aIyaMg5+vTg=; b=N9MM92f4NlwFMMbEVGZ+vLGx+4toxuCUI6CwMsRQ3jpTqb36y4d1szxLea/lvstubZdlJpn1RkQbMR8Mxlzd+Ju/R5lTQKtOyHzgsq9S0xE1zW+fXboYnnOKmd0yUklQswHmZX31i6VnFSsMdCRqY+YJzcQK96kcxDPbvuQ2zcA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718092913017947.2524435020335; Tue, 11 Jun 2024 01:01:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sGwR7-0008Gv-42; Tue, 11 Jun 2024 04:00:57 -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 1sGwR5-0008GL-0P for qemu-devel@nongnu.org; Tue, 11 Jun 2024 04:00:55 -0400 Received: from mgamail.intel.com ([192.198.163.14]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sGwR2-0006mp-Pj for qemu-devel@nongnu.org; Tue, 11 Jun 2024 04:00:54 -0400 Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2024 01:00:51 -0700 Received: from sae-gw02.sh.intel.com (HELO localhost) ([10.239.45.110]) by fmviesa010.fm.intel.com with ESMTP; 11 Jun 2024 01:00:48 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718092852; x=1749628852; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=h/+xzRnNIaIK2kagnHhmAQbOZqHqMq07lzV1hIPaZdI=; b=fPOJTk3XPns4/LPU8iRe/q6/RBuoM7zKP12B2DK4cSZP3fUUq9xLo7ij 9kvI2aC2hF7sy7KXzLfX4BYs67qMGDw/NJ2X9hekpm9xP+4eODJK8gaR7 18rEeHFCGVKcZPrrx9ss9l+7oopyOLVU2ZrpIIQ3a8QfnyQOvPb+71swN Or5vi2ip1W4aE3vZssubVF0R00wXaiOCIVTm8hMjpVKUzXrhPVV6je4gp 1mkTrSBOaisjBaRdH2aPCfFsnD2CzmKvTlBTDUoCAzL8nIrOph6Nwx3ZH 1vk0sITRS1UXxIVbkKR0nnr0VJ73gwKMY4U7SLeyH6wD6W7Bu8H+4eFEK A==; X-CSE-ConnectionGUID: v6nOUNvZQd2j0jUOySEp+w== X-CSE-MsgGUID: iHZd2CJeTY2FaAq5TG7qbg== X-IronPort-AV: E=McAfee;i="6600,9927,11099"; a="15013827" X-IronPort-AV: E=Sophos;i="6.08,229,1712646000"; d="scan'208";a="15013827" X-CSE-ConnectionGUID: +UMOR6IUR2qTe77u36fVLw== X-CSE-MsgGUID: CKu+Pw1ER/SPjPJG4p0L/g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,229,1712646000"; d="scan'208";a="39415830" From: Yuan Liu To: peterx@redhat.com, farosas@suse.de, pbonzini@redhat.com, marcandre.lureau@redhat.com, berrange@redhat.com, thuth@redhat.com, philmd@linaro.org Cc: qemu-devel@nongnu.org, yuan1.liu@intel.com, nanhai.zou@intel.com, shameerali.kolothum.thodi@huawei.com Subject: [PATCH v8 5/7] migration/multifd: implement initialization of qpl compression Date: Mon, 10 Jun 2024 18:21:08 +0800 Message-ID: <20240610102110.900410-6-yuan1.liu@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240610102110.900410-1-yuan1.liu@intel.com> References: <20240610102110.900410-1-yuan1.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.198.163.14; envelope-from=yuan1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_12_24=1.049, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1718092913780100001 Content-Type: text/plain; charset="utf-8" during initialization, a software job is allocated to each channel for software path fallabck when the IAA hardware is unavailable or the hardware job submission fails. If the IAA hardware is available, multiple hardware jobs are allocated for batch processing. Signed-off-by: Yuan Liu Reviewed-by: Nanhai Zou Reviewed-by: Fabiano Rosas --- migration/multifd-qpl.c | 328 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 327 insertions(+), 1 deletion(-) diff --git a/migration/multifd-qpl.c b/migration/multifd-qpl.c index 056a68a060..6791a204d5 100644 --- a/migration/multifd-qpl.c +++ b/migration/multifd-qpl.c @@ -9,12 +9,338 @@ * This work is licensed under the terms of the GNU GPL, version 2 or late= r. * See the COPYING file in the top-level directory. */ + #include "qemu/osdep.h" #include "qemu/module.h" +#include "qapi/error.h" +#include "multifd.h" +#include "qpl/qpl.h" + +typedef struct { + /* the QPL hardware path job */ + qpl_job *job; + /* indicates if fallback to software path is required */ + bool fallback_sw_path; + /* output data from the software path */ + uint8_t *sw_output; + /* output data length from the software path */ + uint32_t sw_output_len; +} QplHwJob; + +typedef struct { + /* array of hardware jobs, the number of jobs equals the number pages = */ + QplHwJob *hw_jobs; + /* the QPL software job for the slow path and software fallback */ + qpl_job *sw_job; + /* the number of pages that the QPL needs to process at one time */ + uint32_t page_num; + /* array of compressed page buffers */ + uint8_t *zbuf; + /* array of compressed page lengths */ + uint32_t *zlen; + /* the status of the hardware device */ + bool hw_avail; +} QplData; + +/** + * check_hw_avail: check if IAA hardware is available + * + * If the IAA hardware does not exist or is unavailable, + * the QPL hardware job initialization will fail. + * + * Returns true if IAA hardware is available, otherwise false. + * + * @job_size: indicates the hardware job size if hardware is available + */ +static bool check_hw_avail(uint32_t *job_size) +{ + qpl_path_t path =3D qpl_path_hardware; + uint32_t size =3D 0; + qpl_job *job; + + if (qpl_get_job_size(path, &size) !=3D QPL_STS_OK) { + return false; + } + assert(size > 0); + job =3D g_malloc0(size); + if (qpl_init_job(path, job) !=3D QPL_STS_OK) { + g_free(job); + return false; + } + g_free(job); + *job_size =3D size; + return true; +} + +/** + * multifd_qpl_free_sw_job: clean up software job + * + * Free the software job resources. + * + * @qpl: pointer to the QplData structure + */ +static void multifd_qpl_free_sw_job(QplData *qpl) +{ + assert(qpl); + if (qpl->sw_job) { + qpl_fini_job(qpl->sw_job); + g_free(qpl->sw_job); + qpl->sw_job =3D NULL; + } +} + +/** + * multifd_qpl_free_jobs: clean up hardware jobs + * + * Free all hardware job resources. + * + * @qpl: pointer to the QplData structure + */ +static void multifd_qpl_free_hw_job(QplData *qpl) +{ + assert(qpl); + if (qpl->hw_jobs) { + for (int i =3D 0; i < qpl->page_num; i++) { + qpl_fini_job(qpl->hw_jobs[i].job); + g_free(qpl->hw_jobs[i].job); + qpl->hw_jobs[i].job =3D NULL; + } + g_free(qpl->hw_jobs); + qpl->hw_jobs =3D NULL; + } +} + +/** + * multifd_qpl_init_sw_job: initialize a software job + * + * Use the QPL software path to initialize a job + * + * @qpl: pointer to the QplData structure + * @errp: pointer to an error + */ +static int multifd_qpl_init_sw_job(QplData *qpl, Error **errp) +{ + qpl_path_t path =3D qpl_path_software; + uint32_t size =3D 0; + qpl_job *job =3D NULL; + qpl_status status; + + status =3D qpl_get_job_size(path, &size); + if (status !=3D QPL_STS_OK) { + error_setg(errp, "qpl_get_job_size failed with error %d", status); + return -1; + } + job =3D g_malloc0(size); + status =3D qpl_init_job(path, job); + if (status !=3D QPL_STS_OK) { + error_setg(errp, "qpl_init_job failed with error %d", status); + g_free(job); + return -1; + } + qpl->sw_job =3D job; + return 0; +} + +/** + * multifd_qpl_init_jobs: initialize hardware jobs + * + * Use the QPL hardware path to initialize jobs + * + * @qpl: pointer to the QplData structure + * @size: the size of QPL hardware path job + * @errp: pointer to an error + */ +static void multifd_qpl_init_hw_job(QplData *qpl, uint32_t size, Error **e= rrp) +{ + qpl_path_t path =3D qpl_path_hardware; + qpl_job *job =3D NULL; + qpl_status status; + + qpl->hw_jobs =3D g_new0(QplHwJob, qpl->page_num); + for (int i =3D 0; i < qpl->page_num; i++) { + job =3D g_malloc0(size); + status =3D qpl_init_job(path, job); + /* the job initialization should succeed after check_hw_avail */ + assert(status =3D=3D QPL_STS_OK); + qpl->hw_jobs[i].job =3D job; + } +} + +/** + * multifd_qpl_init: initialize QplData structure + * + * Allocate and initialize a QplData structure + * + * Returns a QplData pointer on success or NULL on error + * + * @num: the number of pages + * @size: the page size + * @errp: pointer to an error + */ +static QplData *multifd_qpl_init(uint32_t num, uint32_t size, Error **errp) +{ + uint32_t job_size =3D 0; + QplData *qpl; + + qpl =3D g_new0(QplData, 1); + qpl->page_num =3D num; + if (multifd_qpl_init_sw_job(qpl, errp) !=3D 0) { + g_free(qpl); + return NULL; + } + qpl->hw_avail =3D check_hw_avail(&job_size); + if (qpl->hw_avail) { + multifd_qpl_init_hw_job(qpl, job_size, errp); + } + qpl->zbuf =3D g_malloc0(size * num); + qpl->zlen =3D g_new0(uint32_t, num); + return qpl; +} + +/** + * multifd_qpl_deinit: clean up QplData structure + * + * Free jobs, buffers and the QplData structure + * + * @qpl: pointer to the QplData structure + */ +static void multifd_qpl_deinit(QplData *qpl) +{ + if (qpl) { + multifd_qpl_free_sw_job(qpl); + multifd_qpl_free_hw_job(qpl); + g_free(qpl->zbuf); + g_free(qpl->zlen); + g_free(qpl); + } +} + +/** + * multifd_qpl_send_setup: set up send side + * + * Set up the channel with QPL compression. + * + * Returns 0 on success or -1 on error + * + * @p: Params for the channel being used + * @errp: pointer to an error + */ +static int multifd_qpl_send_setup(MultiFDSendParams *p, Error **errp) +{ + QplData *qpl; + + qpl =3D multifd_qpl_init(p->page_count, p->page_size, errp); + if (!qpl) { + return -1; + } + p->compress_data =3D qpl; + + /* + * the page will be compressed independently and sent using an IOV. The + * additional two IOVs are used to store packet header and compressed = data + * length + */ + p->iov =3D g_new0(struct iovec, p->page_count + 2); + return 0; +} + +/** + * multifd_qpl_send_cleanup: clean up send side + * + * Close the channel and free memory. + * + * @p: Params for the channel being used + * @errp: pointer to an error + */ +static void multifd_qpl_send_cleanup(MultiFDSendParams *p, Error **errp) +{ + multifd_qpl_deinit(p->compress_data); + p->compress_data =3D NULL; + g_free(p->iov); + p->iov =3D NULL; +} + +/** + * multifd_qpl_send_prepare: prepare data to be able to send + * + * Create a compressed buffer with all the pages that we are going to + * send. + * + * Returns 0 on success or -1 on error + * + * @p: Params for the channel being used + * @errp: pointer to an error + */ +static int multifd_qpl_send_prepare(MultiFDSendParams *p, Error **errp) +{ + /* Implement in next patch */ + return -1; +} + +/** + * multifd_qpl_recv_setup: set up receive side + * + * Create the compressed channel and buffer. + * + * Returns 0 on success or -1 on error + * + * @p: Params for the channel being used + * @errp: pointer to an error + */ +static int multifd_qpl_recv_setup(MultiFDRecvParams *p, Error **errp) +{ + QplData *qpl; + + qpl =3D multifd_qpl_init(p->page_count, p->page_size, errp); + if (!qpl) { + return -1; + } + p->compress_data =3D qpl; + return 0; +} + +/** + * multifd_qpl_recv_cleanup: set up receive side + * + * Close the channel and free memory. + * + * @p: Params for the channel being used + */ +static void multifd_qpl_recv_cleanup(MultiFDRecvParams *p) +{ + multifd_qpl_deinit(p->compress_data); + p->compress_data =3D NULL; +} + +/** + * multifd_qpl_recv: read the data from the channel into actual pages + * + * Read the compressed buffer, and uncompress it into the actual + * pages. + * + * Returns 0 on success or -1 on error + * + * @p: Params for the channel being used + * @errp: pointer to an error + */ +static int multifd_qpl_recv(MultiFDRecvParams *p, Error **errp) +{ + /* Implement in next patch */ + return -1; +} + +static MultiFDMethods multifd_qpl_ops =3D { + .send_setup =3D multifd_qpl_send_setup, + .send_cleanup =3D multifd_qpl_send_cleanup, + .send_prepare =3D multifd_qpl_send_prepare, + .recv_setup =3D multifd_qpl_recv_setup, + .recv_cleanup =3D multifd_qpl_recv_cleanup, + .recv =3D multifd_qpl_recv, +}; =20 static void multifd_qpl_register(void) { - /* noop */ + multifd_register_ops(MULTIFD_COMPRESSION_QPL, &multifd_qpl_ops); } =20 migration_init(multifd_qpl_register); --=20 2.43.0 From nobody Fri Oct 25 17:33:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1718092881; cv=none; d=zohomail.com; s=zohoarc; b=Bvp2W/7ueHuJmSZ5RY/U3IxjKn2fwvtP6Qf714M8SODfEeVCIvi4S2G7xmh+pKbqUKyUVOM00doW43ElrOvMMpU0xboQOP+Kc9iqPj8lhTseVBY+QxNKl6TLvSrQvKyBHwaVGeqvoBPagKidZZxgTlVhPcUtzmtTgHVD7QYTSGg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718092881; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pKjCfQMOlw45r5csz7klcJic8xCH/+YUnNsvgVBz//o=; b=fdWgOeqt6xtuLGvLEv1Lx1v4FwrcMc3CkjwCM3Ox3xAIo00XRohNYx+38Ww76jSOzVDO129dUA9moAvJa/BsFj+T6Xz9/5+zeXDchgVIJTEsco99QpDq5Qq5ACrc1sSw7jxLzO9k7L9mX2AGAcMA25cX1Dntu2RQNpOxTFF0B8s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718092881446867.7287268383024; Tue, 11 Jun 2024 01:01:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sGwR9-0008IC-RZ; Tue, 11 Jun 2024 04:00:59 -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 1sGwR8-0008Hf-CZ for qemu-devel@nongnu.org; Tue, 11 Jun 2024 04:00:58 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sGwR5-0006mH-OL for qemu-devel@nongnu.org; Tue, 11 Jun 2024 04:00:58 -0400 Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2024 01:00:55 -0700 Received: from sae-gw02.sh.intel.com (HELO localhost) ([10.239.45.110]) by orviesa002.jf.intel.com with ESMTP; 11 Jun 2024 01:00:52 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718092856; x=1749628856; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pOnRmrOdUfWnIsRVF+pTfoAOftL+4zH+nY0GNUlN+ls=; b=bhMjTc7GENYUSBUn68v0+hXxIOUy8BbTSUbAx3RAkzsHljmE70D8et3h Qc/yKicJTg2zuH8nKUNxX2gZ96HNCwtehuVULskghOmjc6+kddRx3lMe2 dgnPgZV70rmMd/r/Xbr1YeTZ//WofxWVdkJWjpEG/dzpBsZ1F4P2o7UnE eSV2So1UJPmyVR4kY2iOUglywebgAcrHPoLuLEBsxpybG5qpXheEg4x+8 ec/BuV7bHJSCIsjxgr+6Whc0g+pf5A1vMbCLoGuouVqqLj9P+D2sCGXf1 rLRGJAt0uzofqu7/WJTD5SG+OXG8oyOyK8gshZPCoUXBwnDetpPTdxkFU A==; X-CSE-ConnectionGUID: TEb/M32iR4iv5nDd5SUz5g== X-CSE-MsgGUID: MKquDT/3T3Sl0PyFFw3rVw== X-IronPort-AV: E=McAfee;i="6600,9927,11099"; a="32271357" X-IronPort-AV: E=Sophos;i="6.08,229,1712646000"; d="scan'208";a="32271357" X-CSE-ConnectionGUID: fpMTLqlXSPunbqlMJhwbOg== X-CSE-MsgGUID: y1nf+aQZQBOnUJaI7h8FTA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,229,1712646000"; d="scan'208";a="70140918" From: Yuan Liu To: peterx@redhat.com, farosas@suse.de, pbonzini@redhat.com, marcandre.lureau@redhat.com, berrange@redhat.com, thuth@redhat.com, philmd@linaro.org Cc: qemu-devel@nongnu.org, yuan1.liu@intel.com, nanhai.zou@intel.com, shameerali.kolothum.thodi@huawei.com Subject: [PATCH v8 6/7] migration/multifd: implement qpl compression and decompression Date: Mon, 10 Jun 2024 18:21:09 +0800 Message-ID: <20240610102110.900410-7-yuan1.liu@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240610102110.900410-1-yuan1.liu@intel.com> References: <20240610102110.900410-1-yuan1.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.10; envelope-from=yuan1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_12_24=1.049, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1718092883643100005 Content-Type: text/plain; charset="utf-8" QPL compression and decompression will use IAA hardware path if the IAA hardware is available. Otherwise the QPL library software path is used. The hardware path will automatically fall back to QPL software path if the IAA queues are busy. In some scenarios, this may happen frequently, such as configuring 4 channels but only one IAA device is available. In the case of insufficient IAA hardware resources, retry and fallback can help optimize performance: 1. Retry + SW fallback: total time: 14649 ms downtime: 25 ms throughput: 17666.57 mbps pages-per-second: 1509647 2. No fallback, always wait for work queues to become available total time: 18381 ms downtime: 25 ms throughput: 13698.65 mbps pages-per-second: 859607 If both the hardware and software paths fail, the uncompressed page is sent directly. Signed-off-by: Yuan Liu Reviewed-by: Nanhai Zou Reviewed-by: Fabiano Rosas --- migration/multifd-qpl.c | 424 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 420 insertions(+), 4 deletions(-) diff --git a/migration/multifd-qpl.c b/migration/multifd-qpl.c index 6791a204d5..9265098ee7 100644 --- a/migration/multifd-qpl.c +++ b/migration/multifd-qpl.c @@ -13,9 +13,14 @@ #include "qemu/osdep.h" #include "qemu/module.h" #include "qapi/error.h" +#include "qapi/qapi-types-migration.h" +#include "exec/ramblock.h" #include "multifd.h" #include "qpl/qpl.h" =20 +/* Maximum number of retries to resubmit a job if IAA work queues are full= */ +#define MAX_SUBMIT_RETRY_NUM (3) + typedef struct { /* the QPL hardware path job */ qpl_job *job; @@ -260,6 +265,225 @@ static void multifd_qpl_send_cleanup(MultiFDSendParam= s *p, Error **errp) p->iov =3D NULL; } =20 +/** + * multifd_qpl_prepare_job: prepare the job + * + * Set the QPL job parameters and properties. + * + * @job: pointer to the qpl_job structure + * @is_compression: indicates compression and decompression + * @input: pointer to the input data buffer + * @input_len: the length of the input data + * @output: pointer to the output data buffer + * @output_len: the length of the output data + */ +static void multifd_qpl_prepare_job(qpl_job *job, bool is_compression, + uint8_t *input, uint32_t input_len, + uint8_t *output, uint32_t output_len) +{ + job->op =3D is_compression ? qpl_op_compress : qpl_op_decompress; + job->next_in_ptr =3D input; + job->next_out_ptr =3D output; + job->available_in =3D input_len; + job->available_out =3D output_len; + job->flags =3D QPL_FLAG_FIRST | QPL_FLAG_LAST | QPL_FLAG_OMIT_VERIFY; + /* only supports compression level 1 */ + job->level =3D 1; +} + +/** + * multifd_qpl_prepare_comp_job: prepare the compression job + * + * Set the compression job parameters and properties. + * + * @job: pointer to the qpl_job structure + * @input: pointer to the input data buffer + * @output: pointer to the output data buffer + * @size: the page size + */ +static void multifd_qpl_prepare_comp_job(qpl_job *job, uint8_t *input, + uint8_t *output, uint32_t size) +{ + /* + * Set output length to less than the page size to force the job to + * fail in case it compresses to a larger size. We'll send that page + * without compression and skip the decompression operation on the + * destination. + */ + multifd_qpl_prepare_job(job, true, input, size, output, size - 1); +} + +/** + * multifd_qpl_prepare_decomp_job: prepare the decompression job + * + * Set the decompression job parameters and properties. + * + * @job: pointer to the qpl_job structure + * @input: pointer to the input data buffer + * @len: the length of the input data + * @output: pointer to the output data buffer + * @size: the page size + */ +static void multifd_qpl_prepare_decomp_job(qpl_job *job, uint8_t *input, + uint32_t len, uint8_t *output, + uint32_t size) +{ + multifd_qpl_prepare_job(job, false, input, len, output, size); +} + +/** + * multifd_qpl_fill_iov: fill in the IOV + * + * Fill in the QPL packet IOV + * + * @p: Params for the channel being used + * @data: pointer to the IOV data + * @len: The length of the IOV data + */ +static void multifd_qpl_fill_iov(MultiFDSendParams *p, uint8_t *data, + uint32_t len) +{ + p->iov[p->iovs_num].iov_base =3D data; + p->iov[p->iovs_num].iov_len =3D len; + p->iovs_num++; + p->next_packet_size +=3D len; +} + +/** + * multifd_qpl_fill_packet: fill the compressed page into the QPL packet + * + * Fill the compressed page length and IOV into the QPL packet + * + * @idx: The index of the compressed length array + * @p: Params for the channel being used + * @data: pointer to the compressed page buffer + * @len: The length of the compressed page + */ +static void multifd_qpl_fill_packet(uint32_t idx, MultiFDSendParams *p, + uint8_t *data, uint32_t len) +{ + QplData *qpl =3D p->compress_data; + + qpl->zlen[idx] =3D cpu_to_be32(len); + multifd_qpl_fill_iov(p, data, len); +} + +/** + * multifd_qpl_submit_job: submit a job to the hardware + * + * Submit a QPL hardware job to the IAA device + * + * Returns true if the job is submitted successfully, otherwise false. + * + * @job: pointer to the qpl_job structure + */ +static bool multifd_qpl_submit_job(qpl_job *job) +{ + qpl_status status; + uint32_t num =3D 0; + +retry: + status =3D qpl_submit_job(job); + if (status =3D=3D QPL_STS_QUEUES_ARE_BUSY_ERR) { + if (num < MAX_SUBMIT_RETRY_NUM) { + num++; + goto retry; + } + } + return (status =3D=3D QPL_STS_OK); +} + +/** + * multifd_qpl_compress_pages_slow_path: compress pages using slow path + * + * Compress the pages using software. If compression fails, the uncompress= ed + * page will be sent. + * + * @p: Params for the channel being used + */ +static void multifd_qpl_compress_pages_slow_path(MultiFDSendParams *p) +{ + QplData *qpl =3D p->compress_data; + uint32_t size =3D p->page_size; + qpl_job *job =3D qpl->sw_job; + uint8_t *zbuf =3D qpl->zbuf; + uint8_t *buf; + + for (int i =3D 0; i < p->pages->normal_num; i++) { + buf =3D p->pages->block->host + p->pages->offset[i]; + multifd_qpl_prepare_comp_job(job, buf, zbuf, size); + if (qpl_execute_job(job) =3D=3D QPL_STS_OK) { + multifd_qpl_fill_packet(i, p, zbuf, job->total_out); + } else { + /* send the uncompressed page */ + multifd_qpl_fill_packet(i, p, buf, size); + } + zbuf +=3D size; + } +} + +/** + * multifd_qpl_compress_pages: compress pages + * + * Submit the pages to the IAA hardware for compression. If hardware + * compression fails, it falls back to software compression. If software + * compression also fails, the uncompressed page is sent. + * + * @p: Params for the channel being used + */ +static void multifd_qpl_compress_pages(MultiFDSendParams *p) +{ + QplData *qpl =3D p->compress_data; + MultiFDPages_t *pages =3D p->pages; + uint32_t size =3D p->page_size; + QplHwJob *hw_job; + uint8_t *buf; + uint8_t *zbuf; + + for (int i =3D 0; i < pages->normal_num; i++) { + buf =3D pages->block->host + pages->offset[i]; + zbuf =3D qpl->zbuf + (size * i); + hw_job =3D &qpl->hw_jobs[i]; + multifd_qpl_prepare_comp_job(hw_job->job, buf, zbuf, size); + if (multifd_qpl_submit_job(hw_job->job)) { + hw_job->fallback_sw_path =3D false; + } else { + /* + * The IAA work queue is full, any immediate subsequent job + * submission is likely to fail, sending the page via the QPL + * software path at this point gives us a better chance of + * finding the queue open for the next pages. + */ + hw_job->fallback_sw_path =3D true; + multifd_qpl_prepare_comp_job(qpl->sw_job, buf, zbuf, size); + if (qpl_execute_job(qpl->sw_job) =3D=3D QPL_STS_OK) { + hw_job->sw_output =3D zbuf; + hw_job->sw_output_len =3D qpl->sw_job->total_out; + } else { + hw_job->sw_output =3D buf; + hw_job->sw_output_len =3D size; + } + } + } + + for (int i =3D 0; i < pages->normal_num; i++) { + buf =3D pages->block->host + pages->offset[i]; + zbuf =3D qpl->zbuf + (size * i); + hw_job =3D &qpl->hw_jobs[i]; + if (hw_job->fallback_sw_path) { + multifd_qpl_fill_packet(i, p, hw_job->sw_output, + hw_job->sw_output_len); + continue; + } + if (qpl_wait_job(hw_job->job) =3D=3D QPL_STS_OK) { + multifd_qpl_fill_packet(i, p, zbuf, hw_job->job->total_out); + } else { + /* send the uncompressed page */ + multifd_qpl_fill_packet(i, p, buf, size); + } + } +} + /** * multifd_qpl_send_prepare: prepare data to be able to send * @@ -273,8 +497,26 @@ static void multifd_qpl_send_cleanup(MultiFDSendParams= *p, Error **errp) */ static int multifd_qpl_send_prepare(MultiFDSendParams *p, Error **errp) { - /* Implement in next patch */ - return -1; + QplData *qpl =3D p->compress_data; + uint32_t len =3D 0; + + if (!multifd_send_prepare_common(p)) { + goto out; + } + + /* The first IOV is used to store the compressed page lengths */ + len =3D p->pages->normal_num * sizeof(uint32_t); + multifd_qpl_fill_iov(p, (uint8_t *) qpl->zlen, len); + if (qpl->hw_avail) { + multifd_qpl_compress_pages(p); + } else { + multifd_qpl_compress_pages_slow_path(p); + } + +out: + p->flags |=3D MULTIFD_FLAG_QPL; + multifd_send_fill_packet(p); + return 0; } =20 /** @@ -312,6 +554,140 @@ static void multifd_qpl_recv_cleanup(MultiFDRecvParam= s *p) p->compress_data =3D NULL; } =20 +/** + * multifd_qpl_process_and_check_job: process and check a QPL job + * + * Process the job and check whether the job output length is the + * same as the specified length + * + * Returns true if the job execution succeeded and the output length + * is equal to the specified length, otherwise false. + * + * @job: pointer to the qpl_job structure + * @is_hardware: indicates whether the job is a hardware job + * @len: Specified output length + * @errp: pointer to an error + */ +static bool multifd_qpl_process_and_check_job(qpl_job *job, bool is_hardwa= re, + uint32_t len, Error **errp) +{ + qpl_status status; + + status =3D (is_hardware ? qpl_wait_job(job) : qpl_execute_job(job)); + if (status !=3D QPL_STS_OK) { + error_setg(errp, "qpl job failed with error %d", status); + return false; + } + if (job->total_out !=3D len) { + error_setg(errp, "qpl decompressed len %u, expected len %u", + job->total_out, len); + return false; + } + return true; +} + +/** + * multifd_qpl_decompress_pages_slow_path: decompress pages using slow path + * + * Decompress the pages using software + * + * Returns 0 on success or -1 on error + * + * @p: Params for the channel being used + * @errp: pointer to an error + */ +static int multifd_qpl_decompress_pages_slow_path(MultiFDRecvParams *p, + Error **errp) +{ + QplData *qpl =3D p->compress_data; + uint32_t size =3D p->page_size; + qpl_job *job =3D qpl->sw_job; + uint8_t *zbuf =3D qpl->zbuf; + uint8_t *addr; + uint32_t len; + + for (int i =3D 0; i < p->normal_num; i++) { + len =3D qpl->zlen[i]; + addr =3D p->host + p->normal[i]; + /* the page is uncompressed, load it */ + if (len =3D=3D size) { + memcpy(addr, zbuf, size); + zbuf +=3D size; + continue; + } + multifd_qpl_prepare_decomp_job(job, zbuf, len, addr, size); + if (!multifd_qpl_process_and_check_job(job, false, size, errp)) { + return -1; + } + zbuf +=3D len; + } + return 0; +} + +/** + * multifd_qpl_decompress_pages: decompress pages + * + * Decompress the pages using the IAA hardware. If hardware + * decompression fails, it falls back to software decompression. + * + * Returns 0 on success or -1 on error + * + * @p: Params for the channel being used + * @errp: pointer to an error + */ +static int multifd_qpl_decompress_pages(MultiFDRecvParams *p, Error **errp) +{ + QplData *qpl =3D p->compress_data; + uint32_t size =3D p->page_size; + uint8_t *zbuf =3D qpl->zbuf; + uint8_t *addr; + uint32_t len; + qpl_job *job; + + for (int i =3D 0; i < p->normal_num; i++) { + addr =3D p->host + p->normal[i]; + len =3D qpl->zlen[i]; + /* the page is uncompressed if received length equals the page siz= e */ + if (len =3D=3D size) { + memcpy(addr, zbuf, size); + zbuf +=3D size; + continue; + } + + job =3D qpl->hw_jobs[i].job; + multifd_qpl_prepare_decomp_job(job, zbuf, len, addr, size); + if (multifd_qpl_submit_job(job)) { + qpl->hw_jobs[i].fallback_sw_path =3D false; + } else { + /* + * The IAA work queue is full, any immediate subsequent job + * submission is likely to fail, sending the page via the QPL + * software path at this point gives us a better chance of + * finding the queue open for the next pages. + */ + qpl->hw_jobs[i].fallback_sw_path =3D true; + job =3D qpl->sw_job; + multifd_qpl_prepare_decomp_job(job, zbuf, len, addr, size); + if (!multifd_qpl_process_and_check_job(job, false, size, errp)= ) { + return -1; + } + } + zbuf +=3D len; + } + + for (int i =3D 0; i < p->normal_num; i++) { + /* ignore pages that have already been processed */ + if (qpl->zlen[i] =3D=3D size || qpl->hw_jobs[i].fallback_sw_path) { + continue; + } + + job =3D qpl->hw_jobs[i].job; + if (!multifd_qpl_process_and_check_job(job, true, size, errp)) { + return -1; + } + } + return 0; +} /** * multifd_qpl_recv: read the data from the channel into actual pages * @@ -325,8 +701,48 @@ static void multifd_qpl_recv_cleanup(MultiFDRecvParams= *p) */ static int multifd_qpl_recv(MultiFDRecvParams *p, Error **errp) { - /* Implement in next patch */ - return -1; + QplData *qpl =3D p->compress_data; + uint32_t in_size =3D p->next_packet_size; + uint32_t flags =3D p->flags & MULTIFD_FLAG_COMPRESSION_MASK; + uint32_t len =3D 0; + uint32_t zbuf_len =3D 0; + int ret; + + if (flags !=3D MULTIFD_FLAG_QPL) { + error_setg(errp, "multifd %u: flags received %x flags expected %x", + p->id, flags, MULTIFD_FLAG_QPL); + return -1; + } + multifd_recv_zero_page_process(p); + if (!p->normal_num) { + assert(in_size =3D=3D 0); + return 0; + } + + /* read compressed page lengths */ + len =3D p->normal_num * sizeof(uint32_t); + assert(len < in_size); + ret =3D qio_channel_read_all(p->c, (void *) qpl->zlen, len, errp); + if (ret !=3D 0) { + return ret; + } + for (int i =3D 0; i < p->normal_num; i++) { + qpl->zlen[i] =3D be32_to_cpu(qpl->zlen[i]); + assert(qpl->zlen[i] <=3D p->page_size); + zbuf_len +=3D qpl->zlen[i]; + } + + /* read compressed pages */ + assert(in_size =3D=3D len + zbuf_len); + ret =3D qio_channel_read_all(p->c, (void *) qpl->zbuf, zbuf_len, errp); + if (ret !=3D 0) { + return ret; + } + + if (qpl->hw_avail) { + return multifd_qpl_decompress_pages(p, errp); + } + return multifd_qpl_decompress_pages_slow_path(p, errp); } =20 static MultiFDMethods multifd_qpl_ops =3D { --=20 2.43.0 From nobody Fri Oct 25 17:33:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1718092895; cv=none; d=zohomail.com; s=zohoarc; b=iD/Atjz/fH7KOoVQK8lLcJjiTspAdqOCuVg8inBEyLwhpF4VIMAmvjWXXuE56jMG75Y8P3HNRKdA+LWjAgKKyheWyCqPSXtvImYl+LOot7merj7LtJZZ3/vc57315aapyzPYq+7Mp/RvNzw7gJtv/ml8Zs+s5YLIC+Y7ffBeR4I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718092895; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lj0Q7aGLK5opPsxZEe9D12EsCC9gtQDsMgIKf5p2HEI=; b=Z1cnYzrcm45zusOIxpilM7pyhHD92mYxW88d8KuNEKhpiX3tdCWDTquahMqXT79wTnft0918K7cZ9Zm9TjnRZJZxpnYHz21vnH5SKMh9xzm7LG8cHrVmepSom7n3Cvreb8QYVSu41ivQS6PtKsrO09zgtXc67ki8RErJqzUPXmA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718092895552863.7874696165618; Tue, 11 Jun 2024 01:01:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sGwRD-0008JP-GA; Tue, 11 Jun 2024 04:01:03 -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 1sGwRB-0008In-0B for qemu-devel@nongnu.org; Tue, 11 Jun 2024 04:01:01 -0400 Received: from mgamail.intel.com ([198.175.65.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sGwR9-0006mH-7Q for qemu-devel@nongnu.org; Tue, 11 Jun 2024 04:01:00 -0400 Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2024 01:00:59 -0700 Received: from sae-gw02.sh.intel.com (HELO localhost) ([10.239.45.110]) by orviesa002.jf.intel.com with ESMTP; 11 Jun 2024 01:00:56 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718092859; x=1749628859; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WGHRQpYT3C5bZ0oqorLplTEDTqd7EbkdN8z3TwrEi70=; b=oEQg99FxtE01Euu3KyoNutEofsOJ10iH49x9iLCbvmok/Q6G5NN2EKMn exqyi6AjQTrL+0dH6LWo6bdzUNM/XPJeMD+mEuOsZ6zArFBGARnKEw62b dNuMzNJ1ePpy9ebfV5IH7s2FVk7VJ8O51tnEFt8PMYHOBnQXuWCAq1n9c 3DyzrwEs+PSSN2vUm582gfIAx9coDTZlsnlV75/scaN5yKZHh9AkGbIH1 w8MySwKp1Ywiu71FCOtqZ4BKhmvsQgJRmJWRJ6SZjpJBIlh5F0Fgu5xTP 2CHuqyP8CmWXgaaJoM26as/64SoTlCCfIMBuOoADAq/F2m07bfQ9YJzul A==; X-CSE-ConnectionGUID: SxwAqgxJTyu6A3oUDs9LYA== X-CSE-MsgGUID: I3Pf03HrSxupzOXoHHYJ/A== X-IronPort-AV: E=McAfee;i="6600,9927,11099"; a="32271360" X-IronPort-AV: E=Sophos;i="6.08,229,1712646000"; d="scan'208";a="32271360" X-CSE-ConnectionGUID: mehtDSCORVeghpBKRjLzaQ== X-CSE-MsgGUID: EF17SrGpRNuRVDW0kT2FJA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,229,1712646000"; d="scan'208";a="70140923" From: Yuan Liu To: peterx@redhat.com, farosas@suse.de, pbonzini@redhat.com, marcandre.lureau@redhat.com, berrange@redhat.com, thuth@redhat.com, philmd@linaro.org Cc: qemu-devel@nongnu.org, yuan1.liu@intel.com, nanhai.zou@intel.com, shameerali.kolothum.thodi@huawei.com Subject: [PATCH v8 7/7] tests/migration-test: add qpl compression test Date: Mon, 10 Jun 2024 18:21:10 +0800 Message-ID: <20240610102110.900410-8-yuan1.liu@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240610102110.900410-1-yuan1.liu@intel.com> References: <20240610102110.900410-1-yuan1.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.10; envelope-from=yuan1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_12_24=1.049, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1718092897617100005 Content-Type: text/plain; charset="utf-8" add qpl to compression method test for multifd migration the qpl compression supports software path and hardware path(IAA device), and the hardware path is used first by default. If the hardware path is unavailable, it will automatically fallback to the software path for testing. Signed-off-by: Yuan Liu Reviewed-by: Nanhai Zou Reviewed-by: Peter Xu Reviewed-by: Fabiano Rosas --- tests/qtest/migration-test.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index b7e3406471..ef0c3f5e28 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -2661,6 +2661,15 @@ test_migrate_precopy_tcp_multifd_zstd_start(QTestSta= te *from, } #endif /* CONFIG_ZSTD */ =20 +#ifdef CONFIG_QPL +static void * +test_migrate_precopy_tcp_multifd_qpl_start(QTestState *from, + QTestState *to) +{ + return test_migrate_precopy_tcp_multifd_start_common(from, to, "qpl"); +} +#endif /* CONFIG_QPL */ + static void test_multifd_tcp_uri_none(void) { MigrateCommon args =3D { @@ -2741,6 +2750,17 @@ static void test_multifd_tcp_zstd(void) } #endif =20 +#ifdef CONFIG_QPL +static void test_multifd_tcp_qpl(void) +{ + MigrateCommon args =3D { + .listen_uri =3D "defer", + .start_hook =3D test_migrate_precopy_tcp_multifd_qpl_start, + }; + test_precopy_common(&args); +} +#endif + #ifdef CONFIG_GNUTLS static void * test_migrate_multifd_tcp_tls_psk_start_match(QTestState *from, @@ -3626,6 +3646,10 @@ int main(int argc, char **argv) migration_test_add("/migration/multifd/tcp/plain/zstd", test_multifd_tcp_zstd); #endif +#ifdef CONFIG_QPL + migration_test_add("/migration/multifd/tcp/plain/qpl", + test_multifd_tcp_qpl); +#endif #ifdef CONFIG_GNUTLS migration_test_add("/migration/multifd/tcp/tls/psk/match", test_multifd_tcp_tls_psk_match); --=20 2.43.0