From patchwork Tue Nov 6 12:20:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 993653 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VnFMgKBU"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42q7v63gtlz9sBN for ; Tue, 6 Nov 2018 23:21:21 +1100 (AEDT) Received: from localhost ([::1]:40660 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK0MB-0002nb-Bs for incoming@patchwork.ozlabs.org; Tue, 06 Nov 2018 07:21:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43319) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK0LZ-0002mR-4Z for qemu-devel@nongnu.org; Tue, 06 Nov 2018 07:20:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gK0LV-0001c1-Dj for qemu-devel@nongnu.org; Tue, 06 Nov 2018 07:20:41 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:36290) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gK0LT-0001XW-MH for qemu-devel@nongnu.org; Tue, 06 Nov 2018 07:20:36 -0500 Received: by mail-pl1-x62a.google.com with SMTP id w24-v6so6133996plq.3 for ; Tue, 06 Nov 2018 04:20:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ooj19jq71V11Zi5HetnC26XyEjIGc265F+GyfKemw0k=; b=VnFMgKBUsa4on0BHyqEovAtqDClHAXiNxQOlGREIZerxMNRyNJE9HmP/DLPL/m0uQh 03VhhneOhjOJqxmzjOWjWHbGwJdC3pmkYXnvGp6ZUsBQo/+QwsGNVwqCEC7OooWaRRyp EciBvD8wBhBwJl+3nXemaUb02IZBuof/YF01fAMxV5m/CyiwRQGxkXwdPWZ5B+FxRHKK seRqQmne4RNdCXncY1vF1i04MMizOCbaGoXE0CCXTUbIiDE05p8V1+IMdWNd9Kmh900i UhisQdlNCu6eb72FSf0/0QodWoFdkr0VOqONg9txpBlrazIHqDEPYU1il1nZCFeeo93g YsHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ooj19jq71V11Zi5HetnC26XyEjIGc265F+GyfKemw0k=; b=EWZBGDGSwXpmOl+iwSsjUktHFAf+1HFE5VTcdRoube4xl0dl1rIH4b2u+3YuHQt96x jZhHTy2ZALz1VTO6ZjBsjbCi9kMWt8NibxmSbljQ9SSW32SKhlisNcC26aXnSFfJjNE0 JBsP9TVQr8pCXm9iNy+zYZbpnU5jB/ySelX479BIDa/8ShNbLne/S67hEhOBkKhGUB68 7z0FE8pCn+R6xEOISDskJZt1ayCfvY0NfaMCQL15ziYF8uYgX1osP7pTlhm6YVtgBf0q b8jQE0jKicuSiXwOU4RII3E3j8prJniTsZEwFDZTRXxN/g3udcnSQKHbsbs+tuRie2/r 6DSA== X-Gm-Message-State: AGRZ1gIo6nzaIMKRl6ItgXFEtN8KdM3Jf6OtfH0buVhdezK9cuFk9sh1 buN6/oNXpYbjlTaQXZZcxGQ= X-Google-Smtp-Source: AJdET5fn1lq59ABvFFYNJd8j9P1HL3vs3SuWe/s4OkVlVdmL6RBn4k/YI/EjQAcdeR2JVINfKRmLew== X-Received: by 2002:a17:902:64c1:: with SMTP id y1-v6mr26240201pli.210.1541506833189; Tue, 06 Nov 2018 04:20:33 -0800 (PST) Received: from localhost.localdomain ([203.205.141.52]) by smtp.gmail.com with ESMTPSA id v4-v6sm19050021pff.9.2018.11.06.04.20.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Nov 2018 04:20:32 -0800 (PST) From: guangrong.xiao@gmail.com X-Google-Original-From: xiaoguangrong@tencent.com To: pbonzini@redhat.com, mst@redhat.com, mtosatti@redhat.com Date: Tue, 6 Nov 2018 20:20:20 +0800 Message-Id: <20181106122025.3487-1-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.14.5 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::62a Subject: [Qemu-devel] [PATCH v2 0/5] migration: improve multithreads X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, quintela@redhat.com, Xiao Guangrong , qemu-devel@nongnu.org, peterx@redhat.com, dgilbert@redhat.com, wei.w.wang@intel.com, cota@braap.org, jiang.biao2@zte.com.cn Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Xiao Guangrong Changelog in v2: These changes are based on Paolo's suggestion: 1) rename the lockless multithreads model to threaded workqueue 2) hugely improve the internal design, that make all the request be a large array, properly partition it, assign requests to threads respectively and use bitmaps to sync up threads and the submitter, after that ptr_ring and spinlock are dropped 3) introduce event wait for the submitter These changes are based on Emilio's review: 4) make more detailed description for threaded workqueue 5) add a benchmark for threaded workqueue The previous version can be found at https://marc.info/?l=kvm&m=153968821910007&w=2 There's the simple performance measurement comparing these two versions, the environment is the same as we listed in the previous version. Use 8 threads to compress the data in the source QEMU - with compress-wait-thread = off total time busy-ratio -------------------------------------------------- v1 125066 0.38 v2 120444 0.35 - with compress-wait-thread = on total time busy-ratio -------------------------------------------------- v1 164426 0 v2 142609 0 The v2 win slightly. Xiao Guangrong (5): bitops: introduce change_bit_atomic util: introduce threaded workqueue migration: use threaded workqueue for compression migration: use threaded workqueue for decompression tests: add threaded-workqueue-bench include/qemu/bitops.h | 13 + include/qemu/threaded-workqueue.h | 94 +++++++ migration/ram.c | 538 ++++++++++++++------------------------ tests/Makefile.include | 5 +- tests/threaded-workqueue-bench.c | 256 ++++++++++++++++++ util/Makefile.objs | 1 + util/threaded-workqueue.c | 466 +++++++++++++++++++++++++++++++++ 7 files changed, 1030 insertions(+), 343 deletions(-) create mode 100644 include/qemu/threaded-workqueue.h create mode 100644 tests/threaded-workqueue-bench.c create mode 100644 util/threaded-workqueue.c