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: 10670235 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A1D814BD for ; Tue, 6 Nov 2018 12:20:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A7052A406 for ; Tue, 6 Nov 2018 12:20:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F27DB2A40C; Tue, 6 Nov 2018 12:20:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B5C52A40D for ; Tue, 6 Nov 2018 12:20:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730465AbeKFVpb (ORCPT ); Tue, 6 Nov 2018 16:45:31 -0500 Received: from mail-pl1-f170.google.com ([209.85.214.170]:39494 "EHLO mail-pl1-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726976AbeKFVpb (ORCPT ); Tue, 6 Nov 2018 16:45:31 -0500 Received: by mail-pl1-f170.google.com with SMTP id b5-v6so6131724pla.6 for ; Tue, 06 Nov 2018 04:20:33 -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=d8XHZHME9haNdUJl/DUDrM1q4Fz/jrDot7rldm9+WXkKyJsYqOp67J/6goriJNJx9X ngNaFREhxW1OTxafHpizFKJ3tVdtLj1Bbn5H0o5Qmyld7gg+TLe5Zf95bE8u7JFieBg+ y9ezREd17zsTVYEjJ386ozXZKhh0vDjnuGApm1J8y5GDxjxksb4O31VXPZKUuViszAV0 eo3TVKcHFKcqPqwPzBD1rIBa8h8soJVaw6PeiNMDTKdVVc1v2cw94QCcaK34Yq8m4Xew kKOUOL7AJPZNkiSsq46N/awUt4U9EdMH2C9lrSu83TpTbMQnaPLgH9pX33Q4b18o2Gfe F/lw== X-Gm-Message-State: AGRZ1gI900+F7GGQT8MDL76D0hPjTDHhXKJZobN/UtO3qOEPcdaAgNHq WIQC7WotjfcCQ9tZpUSe+7Q= 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 Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, dgilbert@redhat.com, peterx@redhat.com, wei.w.wang@intel.com, jiang.biao2@zte.com.cn, eblake@redhat.com, quintela@redhat.com, cota@braap.org, Xiao Guangrong Subject: [PATCH v2 0/5] migration: improve multithreads 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 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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