From patchwork Tue Jul 31 08:35:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10550415 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 4EF5013BF for ; Tue, 31 Jul 2018 08:37:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3877C2A96C for ; Tue, 31 Jul 2018 08:37:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2BFAA2A988; Tue, 31 Jul 2018 08:37:00 +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 DA4D82A96C for ; Tue, 31 Jul 2018 08:36:59 +0000 (UTC) Received: from localhost ([::1]:57584 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fkQ9L-0000C0-4T for patchwork-qemu-devel@patchwork.kernel.org; Tue, 31 Jul 2018 04:36:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fkQ8B-0000A0-Vk for qemu-devel@nongnu.org; Tue, 31 Jul 2018 04:35:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fkQ8B-00006l-6u for qemu-devel@nongnu.org; Tue, 31 Jul 2018 04:35:48 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:38531) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fkQ8B-00006L-0U for qemu-devel@nongnu.org; Tue, 31 Jul 2018 04:35:47 -0400 Received: by mail-pg1-x541.google.com with SMTP id k3-v6so8725334pgq.5 for ; Tue, 31 Jul 2018 01:35:46 -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=O0FuSzckHTa/XpGZseB2OgD4F6YK1e+d6dFXfg0grew=; b=BAPtvS3/WTwrUkANmcFKqVh5zdCrW/UIi7WapJGxYpGiIoV5FU1IJxaBkY+2rAwKFG FsrjBZ9DrFwBKV/Eq3zNqaWhlOeuoauAuJ6II+QJRmnRBDwbbAbF5xucKO+37lEbWzri VVdIRAy8zo1hyeE/TRtYbHSsWOITaIAOoZDyKDOnwmU6M5PhHltk8qDqkZK7orQuacl+ 444Tctnsu5su1E9p1qGBw/ag9VbJ72O59cQt01D/Les3saMZDuM6G4VqXmHMgJ5P46d2 xZzsByuENRMDjJTXc1XQ1XDpGSwkycHMCc+z9nDaQMOBPinQmzARD2SpDc56jLq0qQ9o SCjg== 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=O0FuSzckHTa/XpGZseB2OgD4F6YK1e+d6dFXfg0grew=; b=aRvTpBLGavN+i4eQHwtRS+MS3746V7cGxRi3cA841nhoDk4EWM54KQtY1yvLVcYzxM vQ8RFJP6PTi33xblJqYvIAT3ww3l3K3/5LVKm7UerbjozgztSBV8nHZIU1xVq8wBRvqp FoauyzCDt3O69/xw2BJJI4DtsULVGfINyhAJUksbHpuPlnxJn0knQ5cNWCwLG/fRC3HQ Nxanht/+AmT6luMoMFsRwCYGEpxjzxxZOI2D+/wPv0fXBfbrPB9Bff3YhS81nzBb/P92 dPxOI6WCnMCqWxzXIWq29C5crZq58i5NdWYCxoYTlZKd1W1jfAUggI6PJ/q//kx8d5Aj D86w== X-Gm-Message-State: AOUpUlEn5vCjUlvnqh2VTd9hTbdS9ZZEpvaMND6sQBbr5iV9dBd5NGh2 a3BNjzFIyq4IKJFeqSc8Yv0= X-Google-Smtp-Source: AAOMgpfb/2vB89bpYyZaoeqzquUUNE1xsLZLGnfm2qqUxjwPDVys/xKlcwa0DTZlNTqGWJBMXt2gGQ== X-Received: by 2002:a62:d842:: with SMTP id e63-v6mr21487876pfg.88.1533026146205; Tue, 31 Jul 2018 01:35:46 -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.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Jul 2018 01:35:45 -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:22 -0700 Message-Id: <1533026124-6740-2-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::541 Subject: [Qemu-devel] [PATCH 1/3] migrate: replace the cpu throttle percentage max with a variable 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 So we can config it using qmp. Signed-off-by: Li Qiang --- cpus.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cpus.c b/cpus.c index b5844b7103..6569c73d24 100644 --- a/cpus.c +++ b/cpus.c @@ -83,6 +83,8 @@ static unsigned int throttle_percentage; #define CPU_THROTTLE_PCT_MAX 99 #define CPU_THROTTLE_TIMESLICE_NS 10000000 +static unsigned int throttle_percentage_max = CPU_THROTTLE_PCT_MAX; + bool cpu_is_stopped(CPUState *cpu) { return cpu->stopped || !runstate_is_running(); @@ -754,7 +756,7 @@ static void cpu_throttle_timer_tick(void *opaque) void cpu_throttle_set(int new_throttle_pct) { /* Ensure throttle percentage is within valid range */ - new_throttle_pct = MIN(new_throttle_pct, CPU_THROTTLE_PCT_MAX); + new_throttle_pct = MIN(new_throttle_pct, throttle_percentage_max); new_throttle_pct = MAX(new_throttle_pct, CPU_THROTTLE_PCT_MIN); atomic_set(&throttle_percentage, new_throttle_pct);