From patchwork Tue Jul 31 08:35:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10550421 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 6166913BF for ; Tue, 31 Jul 2018 08:38:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BB902A8FB for ; Tue, 31 Jul 2018 08:38:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FBEE2A915; Tue, 31 Jul 2018 08:38:56 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D41882A8FB for ; Tue, 31 Jul 2018 08:38:55 +0000 (UTC) Received: from localhost ([::1]:57595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fkQBD-0002FM-6P for patchwork-qemu-devel@patchwork.kernel.org; Tue, 31 Jul 2018 04:38:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fkQ8G-0000DO-B6 for qemu-devel@nongnu.org; Tue, 31 Jul 2018 04:35:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fkQ8F-0000AH-65 for qemu-devel@nongnu.org; Tue, 31 Jul 2018 04:35:52 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:40076) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fkQ8F-00009Z-05 for qemu-devel@nongnu.org; Tue, 31 Jul 2018 04:35:51 -0400 Received: by mail-pg1-x542.google.com with SMTP id x5-v6so8722150pgp.7 for ; Tue, 31 Jul 2018 01:35:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tgPoCzVnHx+FKfFKPylUp7RhmK8Uge938yvUzvn0/g0=; b=MVeq8I77SgEMGgU+Jqx9v3MPGXcpzwMBWkO2rLiHX5FHqi7lXkIPBbmEnkRhnHsrLG vpxBVWoSRw9/zehiF6hwQoooq6eRROnuXMkRaoTYH8ys2mlI/eUT1TN0Jz0/+dVqUJNF n+5QumFR7tDLqj6zqdoOwrDMnbzVfAl9YJuJZVZiULxWfizalhFCDma/TeAmjGChHLwt qJi7pE6mEeavGwg+FIgPDm8XXb9XZAzQUDgShkXrY6WKVM1hf/xeK15v54FDQmJYhpcK 2+Y7q0WzdQD2k4E2hazW1uxUxUNmWmhbmuHpUQfNV6fqOaLaxq67PyQigdm+2y/TEHYY CkKA== 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:in-reply-to :references; bh=tgPoCzVnHx+FKfFKPylUp7RhmK8Uge938yvUzvn0/g0=; b=uORuJQLIn5mPID0cV1tBUOvVSeh/pTKy1HEwkdTgBYp3Q6euuuStWGAU7tWYt096CU biz6rgtTRH83IWRWM3kTl9OE2WZJnDKlszJAIg7OvYRriAiUKDSlx9Siq/SC6AOW5s9g beatQ/IWgOthn4SxXhGWS9aSt2oP9d5YRhiGTlFLNvg7DW8VZysyN21DiD3ICMK0kRDk z1ixmaV3FEnKifoy2VmkuBaXcJ/FSO+f1N13OYwCYYtAtfRYcQBCuL4FmPuhlUP0SFz0 Zg5iGVdqaxV2QOGHHHxX0ed6X0Yp7sPe+APzwLTBS5gOdRTpJM5160NG7E/iOBP4pAjZ nIrg== X-Gm-Message-State: AOUpUlH2Vd32tWzkYH8BJmIYNo6X061/DNs93+PLkFfc9dbdKRNcREOL wyvm/WRJFW5a2yhQQnTXitUx01ZP X-Google-Smtp-Source: AAOMgpdoTshiShQhxGHwq8w6tbyrMu1y9rCLPnTmQE+wDBlDwROOnp5yQyrP3tinbvFHNQ8YGjQo5w== X-Received: by 2002:a63:440a:: with SMTP id r10-v6mr19524717pga.27.1533026150231; Tue, 31 Jul 2018 01:35:50 -0700 (PDT) Received: from localhost.localdomain.localdomain ([103.65.40.100]) by smtp.gmail.com with ESMTPSA id f19-v6sm23406069pfd.147.2018.07.31.01.35.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Jul 2018 01:35:49 -0700 (PDT) From: Li Qiang To: pbonzini@redhat.com, crosthwaite.peter@gmail.com, rth@twiddle.net, quintela@redhat.com, dgilbert@redhat.com, eblake@redhat.com, armbru@redhat.com Date: Tue, 31 Jul 2018 01:35:23 -0700 Message-Id: <1533026124-6740-3-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1533026124-6740-1-git-send-email-liq3ea@gmail.com> References: <1533026124-6740-1-git-send-email-liq3ea@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH 2/3] migration: Add qmp command for migrate_set_max_cpu_throttle 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: liqiang02@corp.netease.com, Li Qiang , hzliuyingdong@corp.netease.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The default max cpu throttle is 99, this is too big that may influence the guest loads. Add a qmp to config it can make it more flexible. Signed-off-by: Li Qiang --- cpus.c | 5 +++++ include/qom/cpu.h | 8 ++++++++ migration/migration.c | 10 ++++++++++ qapi/migration.json | 13 +++++++++++++ 4 files changed, 36 insertions(+) diff --git a/cpus.c b/cpus.c index 6569c73d24..0505477086 100644 --- a/cpus.c +++ b/cpus.c @@ -765,6 +765,11 @@ void cpu_throttle_set(int new_throttle_pct) CPU_THROTTLE_TIMESLICE_NS); } +void set_cpu_max_throttle(int64_t max_pct) +{ + throttle_percentage_max = max_pct; +} + void cpu_throttle_stop(void) { atomic_set(&throttle_percentage, 0); diff --git a/include/qom/cpu.h b/include/qom/cpu.h index bd796579ee..4328d2e8ad 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -816,6 +816,14 @@ CPUState *cpu_by_arch_id(int64_t id); void cpu_throttle_set(int new_throttle_pct); /** + * set_cpu_max_throttle: + * @max_pct: the max percent of sleep time. Valid range is 1 to 99. + * + * Set the max throttle percentage. + */ +void set_cpu_max_throttle(int64_t max_pct); + +/** * cpu_throttle_stop: * * Stops the vcpu throttling started by cpu_throttle_set. diff --git a/migration/migration.c b/migration/migration.c index b7d9854bda..9c7a6f7477 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1774,6 +1774,16 @@ void qmp_migrate_set_speed(int64_t value, Error **errp) qmp_migrate_set_parameters(&p, errp); } +void qmp_migrate_set_max_cpu_throttle(int64_t value, Error **errp) +{ + if (value > 99 || value < 1) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, " max cpu throttle", + "not in 1 between 99"); + return; + } + set_cpu_max_throttle(value); +} + void qmp_migrate_set_downtime(double value, Error **errp) { if (value < 0 || value > MAX_MIGRATE_DOWNTIME_SECONDS) { diff --git a/qapi/migration.json b/qapi/migration.json index 186e8a7303..2ef3ddfe43 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -997,6 +997,19 @@ { 'command': 'migrate_set_speed', 'data': {'value': 'int'} } ## +# @migrate_set_max_cpu_throttle: +# +# Set maximum cpu throttle for migration. +# +# @value: maximum cpu throttle. +# +# Returns: nothing on success +# +# Since: 2.12 +## +{ 'command': 'migrate_set_max_cpu_throttle', 'data': {'value': 'int'} } + +## # @migrate-set-cache-size: # # Set cache size to be used by XBZRLE migration