From patchwork Tue Aug 29 11:46:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Zhang X-Patchwork-Id: 9927197 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BB4206022E for ; Tue, 29 Aug 2017 11:48:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A388928874 for ; Tue, 29 Aug 2017 11:48:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98027288B8; Tue, 29 Aug 2017 11:48:25 +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=-4.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, URIBL_BLACK 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 30EAB28874 for ; Tue, 29 Aug 2017 11:48:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753577AbdH2LsU (ORCPT ); Tue, 29 Aug 2017 07:48:20 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:33976 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753105AbdH2Lr1 (ORCPT ); Tue, 29 Aug 2017 07:47:27 -0400 Received: by mail-pg0-f65.google.com with SMTP id 63so2553038pgc.1; Tue, 29 Aug 2017 04:47:26 -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=XTvPFqkrcFpj5/nZV/iSXI4uEqRVBljBPK3OwDOcYj8=; b=fVbiIUGZHJED5SGS2gd+1Xkhrn4dYYwlaHrGlVD9B0SlYGsmPJItZmHZS1dpaBKY9I bu731hj0daCc5d916TdFhgJzuAPgTUWwIsGVL6CiPcJrXrTdL48x5RoHDR76/Q4c4WWU 5U0bC6v2KeScI2J1AG1jZSyaiBiIP335w1j313pxhvrlRWBAJKjrY61e3jaONQhPrzh2 +U7bSixBbxUZzq3UtMFqwlQxrqOcOQQLRvonspHA2veF+2QF2iDCSHCbQZuuSc85rGgj ppJV2uJcHKE7B9IIkZlepndwF0/6cPWN3Yi11u5HZT7kQ4M8eoXtb4vWXFykWLX3Wg4h naIw== 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=XTvPFqkrcFpj5/nZV/iSXI4uEqRVBljBPK3OwDOcYj8=; b=ndVE/SncksCcachKelL02glXS5xZ8jdw/g0FGEeS0Zpv6R+BQjPFdoTHODrBGaFfGO keDVfN8ij9DMA8znzHYJsMeKWSeLRjC1KY/TnzTj7e0wjfwuoHV7cwHHXTTAyyndRyrw WCV2gdcnbYGdb9dQHcwE3WXwkeCsrqFpTFz+2YlMR49zOQEgzb+2DH0b3H8tp2bq5VRq lr4bcksuJ5mcsGRk20MRWVK4NcHIzykL5D3oM02MYXPN9rEeRpw9ivImD+i+SZlY4C1c sQR6Ku1TKptc5FkA0MutzQDr8VWo7Z7tBGVpd8LeYrcWrg4A6FgaOyM3J+KJk/iyimqI m75Q== X-Gm-Message-State: AHYfb5i8uUyMthPVoyOAx7GQaKNopkWmmyKsW9QQ50G4f32iN4/Wt6Ku jfT/+x1wBrAvtl9/jwc= X-Received: by 10.98.149.201 with SMTP id c70mr61529pfk.30.1504007245980; Tue, 29 Aug 2017 04:47:25 -0700 (PDT) Received: from ip-172-31-39-62.us-west-2.compute.internal (ec2-52-40-99-241.us-west-2.compute.amazonaws.com. [52.40.99.241]) by smtp.googlemail.com with ESMTPSA id e90sm2550747pfb.172.2017.08.29.04.47.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Aug 2017 04:47:25 -0700 (PDT) From: Yang Zhang To: linux-kernel@vger.kernel.org Cc: kvm@vger.kernel.org, wanpeng.li@hotmail.com, mst@redhat.com, pbonzini@redhat.com, tglx@linutronix.de, rkrcmar@redhat.com, dmatlack@google.com, agraf@suse.de, peterz@infradead.org, linux-doc@vger.kernel.org, Yang Zhang , Quan Xu , Jonathan Corbet , Jeremy Fitzhardinge , Chris Wright , Alok Kataria , Rusty Russell , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, "Luis R. Rodriguez" , Kees Cook , Mauro Carvalho Chehab , Krzysztof Kozlowski , Josh Poimboeuf , Andrew Morton , Petr Mladek , Jessica Yu , Larry Finger , zijun_hu , Baoquan He , Johannes Berg , Ian Abbott , virtualization@lists.linux-foundation.org, linux-fsdevel@vger.kernel.org Subject: [RFC PATCH v2 5/7] Documentation: Add three sysctls for smart idle poll Date: Tue, 29 Aug 2017 11:46:39 +0000 Message-Id: <1504007201-12904-6-git-send-email-yang.zhang.wz@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504007201-12904-1-git-send-email-yang.zhang.wz@gmail.com> References: <1504007201-12904-1-git-send-email-yang.zhang.wz@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To reduce the cost of poll, we introduce three sysctl to control the poll time. Signed-off-by: Yang Zhang Signed-off-by: Quan Xu Cc: Jonathan Corbet Cc: Jeremy Fitzhardinge Cc: Chris Wright Cc: Alok Kataria Cc: Rusty Russell Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x86@kernel.org Cc: "Luis R. Rodriguez" Cc: Kees Cook Cc: Mauro Carvalho Chehab Cc: Krzysztof Kozlowski Cc: Josh Poimboeuf Cc: Andrew Morton Cc: Petr Mladek Cc: Peter Zijlstra Cc: Jessica Yu Cc: Larry Finger Cc: zijun_hu Cc: Baoquan He Cc: Johannes Berg Cc: Ian Abbott Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: virtualization@lists.linux-foundation.org Cc: linux-fsdevel@vger.kernel.org --- Documentation/sysctl/kernel.txt | 25 +++++++++++++++++++++++++ arch/x86/kernel/paravirt.c | 4 ++++ include/linux/kernel.h | 6 ++++++ kernel/sysctl.c | 23 +++++++++++++++++++++++ 4 files changed, 58 insertions(+) diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt index bac23c1..67447b8 100644 --- a/Documentation/sysctl/kernel.txt +++ b/Documentation/sysctl/kernel.txt @@ -63,6 +63,9 @@ show up in /proc/sys/kernel: - perf_event_max_stack - perf_event_max_contexts_per_stack - pid_max +- poll_grow [ X86 only ] +- poll_shrink [ X86 only ] +- poll_threshold_ns [ X86 only ] - powersave-nap [ PPC only ] - printk - printk_delay @@ -702,6 +705,28 @@ kernel tries to allocate a number starting from this one. ============================================================== +poll_grow: (X86 only) + +This parameter is multiplied in the grow_poll_ns() to increase the poll time. +By default, the values is 2. + +============================================================== +poll_shrink: (X86 only) + +This parameter is divided in the shrink_poll_ns() to reduce the poll time. +By default, the values is 2. + +============================================================== +poll_threshold_ns: (X86 only) + +This parameter controls the max poll time before entering real idle path. +This parameter is expected to take effect only when running inside a VM. +It would make no sense to turn on it in bare mental. +By default, the values is 0 means don't poll. It is recommended to change +the value to non-zero if running latency-bound workloads inside VM. + +============================================================== + powersave-nap: (PPC only) If set, Linux-PPC will use the 'nap' mode of powersaving, diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index a11b2c2..0b92f8f 100644 --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c @@ -318,6 +318,10 @@ struct pv_idle_ops pv_idle_ops = { .update = paravirt_nop, }; +unsigned long poll_threshold_ns; +unsigned int poll_shrink = 2; +unsigned int poll_grow = 2; + __visible struct pv_irq_ops pv_irq_ops = { .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl), .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl), diff --git a/include/linux/kernel.h b/include/linux/kernel.h index bd6d96c..6cb2820 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -462,6 +462,12 @@ extern __scanf(2, 0) extern bool crash_kexec_post_notifiers; +#ifdef CONFIG_PARAVIRT +extern unsigned long poll_threshold_ns; +extern unsigned int poll_shrink; +extern unsigned int poll_grow; +#endif + /* * panic_cpu is used for synchronizing panic() and crash_kexec() execution. It * holds a CPU number which is executing panic() currently. A value of diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 6648fbb..9b86a8f 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -1229,6 +1229,29 @@ static int sysrq_sysctl_handler(struct ctl_table *table, int write, .extra2 = &one, }, #endif +#ifdef CONFIG_PARAVIRT + { + .procname = "halt_poll_threshold", + .data = &poll_threshold_ns, + .maxlen = sizeof(unsigned long), + .mode = 0644, + .proc_handler = proc_dointvec, + }, + { + .procname = "halt_poll_grow", + .data = &poll_grow, + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, + { + .procname = "halt_poll_shrink", + .data = &poll_shrink, + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, +#endif { } };