From patchwork Tue Aug 29 11:46:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Zhang X-Patchwork-Id: 9927193 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 1ECF06022E for ; Tue, 29 Aug 2017 11:48:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A4D128874 for ; Tue, 29 Aug 2017 11:48:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1ACB288B6; Tue, 29 Aug 2017 11:48:07 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable 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 8383428874 for ; Tue, 29 Aug 2017 11:48:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752557AbdH2Lrz (ORCPT ); Tue, 29 Aug 2017 07:47:55 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:33981 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753501AbdH2Lr2 (ORCPT ); Tue, 29 Aug 2017 07:47:28 -0400 Received: by mail-pg0-f65.google.com with SMTP id 63so2553074pgc.1; Tue, 29 Aug 2017 04:47:28 -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=JwVMFdtNia3Q2XMJe/uI3trq1910K7osuzZoLMhz/8Q=; b=eruI/oBKw4biPD10yQ7G3wEqfikreEkVq6tsGsZQoWDVrWVbFrUrEqWUaCpkBCHZeq SxjzpEhZkI6W0yrR4rdSJicgLYv7rcZpiz9zDNpdoVAEpEvff+w7aE3a8C0tP2qpxpee a6/7grCZiPCMAuQSNflZWY16LZ8bhxUaDu3EhOcLkWSnWm0iqbAupWJgjxl7WPyKbLIZ F131CDp5JhJFQ9b+L63m9M6A6i26O+jbvlmOMcIjDSFlWPD2TvEQPpOfFqq6577soMSW B9qn7QtI3YJS+EuyQNOoAqhItsdABZw1NtcqSwq49n+/nZf/iT01LDmFX7fm3LTdvCrz wv1Q== 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=JwVMFdtNia3Q2XMJe/uI3trq1910K7osuzZoLMhz/8Q=; b=ZqXd88OQLIPA1v+dY6aI2IL0Pl+rvU6OM47/fVI4rs8MLAzn2MYYB/ZzkAlmH5gJKb vg1wiT36Ju3gP35vILLt6aVvNB8dVlTuJowondYLY8RwODKhi9cXpJzCFotU+AVp9l5Q Arcwb8H8ClBFretYpmPQIvW7begUl0PnNEwvvJXbCaeEiMuGsKvc/qMVBoiw4zFnDA22 pFs+xRNfv67XkDRVZJuZNYHgdVzFNuLd66kIKJ8rA3o4hKh3mN8dq7erGzgJdZdaeKG8 Mt3pctJF3y8PqtwsoER6tSf4SyTvzL0c/q4mlrKIuPDZEWdCW2hEMUycBRbtS75I5/3Z 8R/g== X-Gm-Message-State: AHYfb5g6UjN4r6m7e0W1YOjhi2eCHIb3awjhvhqBriSeSB0kih9AvCHd d05Isnhdmawni2A/hpE= X-Received: by 10.98.91.199 with SMTP id p190mr4981pfb.235.1504007247674; Tue, 29 Aug 2017 04:47:27 -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.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Aug 2017 04:47:27 -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 , Ingo Molnar Subject: [RFC PATCH v2 7/7] sched/idle: update poll time when wakeup from idle Date: Tue, 29 Aug 2017 11:46:41 +0000 Message-Id: <1504007201-12904-8-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 In ttwu_do_wakeup, it will update avg_idle when wakeup from idle. Here we just reuse this logic to update the poll time. It may be a little late to update the poll in ttwu_do_wakeup, but the test result shows no obvious performance gap compare with updating poll in irq handler. one problem is that idle_stamp only used when using CFS scheduler. But it is ok since it is the default policy for scheduler and only consider it should enough. Signed-off-by: Yang Zhang Signed-off-by: Quan Xu Cc: Ingo Molnar Cc: Peter Zijlstra Cc: linux-kernel@vger.kernel.org --- include/linux/sched/idle.h | 4 ++++ kernel/sched/core.c | 4 ++++ kernel/sched/idle.c | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/include/linux/sched/idle.h b/include/linux/sched/idle.h index 5ca63eb..6e0554d 100644 --- a/include/linux/sched/idle.h +++ b/include/linux/sched/idle.h @@ -12,6 +12,10 @@ enum cpu_idle_type { extern void wake_up_if_idle(int cpu); +#if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT) +extern void update_poll_duration(unsigned long idle_duration); +#endif + /* * Idle thread specific functions to determine the need_resched * polling state. diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 0869b20..25be9a3 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1678,6 +1678,10 @@ static void ttwu_do_wakeup(struct rq *rq, struct task_struct *p, int wake_flags, if (rq->avg_idle > max) rq->avg_idle = max; +#if defined(CONFIG_PARAVIRT) + update_poll_duration(rq->avg_idle); +#endif + rq->idle_stamp = 0; } #endif diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index b374744..7eb8559 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -101,6 +101,13 @@ void __cpuidle default_idle_call(void) } } +#if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT) +void update_poll_duration(unsigned long idle_duration) +{ + paravirt_idle_update_poll_duration(idle_duration); +} +#endif + static int call_cpuidle(struct cpuidle_driver *drv, struct cpuidle_device *dev, int next_state) {