From patchwork Thu May 28 01:46:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 6495771 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1B150C0020 for ; Thu, 28 May 2015 01:50:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2C12F2070A for ; Thu, 28 May 2015 01:50:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2359820726 for ; Thu, 28 May 2015 01:50:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752656AbbE1Bue (ORCPT ); Wed, 27 May 2015 21:50:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41553 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752008AbbE1BuZ (ORCPT ); Wed, 27 May 2015 21:50:25 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id A5323BACC8 for ; Thu, 28 May 2015 01:50:25 +0000 (UTC) Received: from amt.cnet (vpn1-5-142.gru2.redhat.com [10.97.5.142]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4S1oOcc003164; Wed, 27 May 2015 21:50:25 -0400 Received: from amt.cnet (localhost [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 037F5102634; Wed, 27 May 2015 22:50:06 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.7/8.14.7/Submit) id t4S1o50r027133; Wed, 27 May 2015 22:50:05 -0300 Message-Id: <20150528014929.457223842@redhat.com> User-Agent: quilt/0.60-1 Date: Wed, 27 May 2015 22:46:59 -0300 From: Marcelo Tosatti To: Paolo Bonzini Cc: Luiz Capitulino , kvm@vger.kernel.org, Marcelo Tosatti Subject: [patch 2/3] x86: kvmclock: set scheduler clock stable References: <20150528014657.367253422@redhat.com> Content-Disposition: inline; filename=02-guest-patch X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Luiz Capitulino If you try to enable NOHZ_FULL on a guest today, you'll get the following error when the guest tries to deactivate the scheduler tick: WARNING: CPU: 3 PID: 2182 at kernel/time/tick-sched.c:192 can_stop_full_tick+0xb9/0x290() NO_HZ FULL will not work with unstable sched clock CPU: 3 PID: 2182 Comm: kworker/3:1 Not tainted 4.0.0-10545-gb9bb6fb #204 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 Workqueue: events flush_to_ldisc ffffffff8162a0c7 ffff88011f583e88 ffffffff814e6ba0 0000000000000002 ffff88011f583ed8 ffff88011f583ec8 ffffffff8104d095 ffff88011f583eb8 0000000000000000 0000000000000003 0000000000000001 0000000000000001 Call Trace: [] dump_stack+0x4f/0x7b [] warn_slowpath_common+0x85/0xc0 [] warn_slowpath_fmt+0x46/0x50 [] can_stop_full_tick+0xb9/0x290 [] tick_nohz_irq_exit+0x8d/0xb0 [] irq_exit+0xc5/0x130 [] smp_apic_timer_interrupt+0x4a/0x60 [] apic_timer_interrupt+0x6e/0x80 [] ? _raw_spin_unlock_irqrestore+0x31/0x60 [] __wake_up+0x48/0x60 [] n_tty_receive_buf_common+0x49c/0xba0 [] ? tty_ldisc_ref+0x1f/0x70 [] n_tty_receive_buf2+0x14/0x20 [] flush_to_ldisc+0xe0/0x120 [] process_one_work+0x1d5/0x540 [] ? process_one_work+0x151/0x540 [] worker_thread+0x121/0x470 [] ? process_one_work+0x540/0x540 [] kthread+0xef/0x110 [] ? __kthread_parkme+0xa0/0xa0 [] ret_from_fork+0x42/0x70 [] ? __kthread_parkme+0xa0/0xa0 ---[ end trace 06e3507544a38866 ]--- However, it turns out that kvmclock does provide a stable sched_clock callback. So, let the scheduler know this which in turn makes NOHZ_FULL work in the guest. Signed-off-by: Marcelo Tosatti Signed-off-by: Luiz Capitulino --- arch/x86/kernel/kvmclock.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: kvm/arch/x86/kernel/kvmclock.c =================================================================== --- kvm.orig/arch/x86/kernel/kvmclock.c 2015-05-27 18:00:53.616391551 -0300 +++ kvm/arch/x86/kernel/kvmclock.c 2015-05-27 22:43:14.474432962 -0300 @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -217,8 +218,10 @@ void __init kvmclock_init(void) { + struct pvclock_vcpu_time_info *vcpu_time; unsigned long mem; - int size; + int size, cpu; + u8 flags; size = PAGE_ALIGN(sizeof(struct pvclock_vsyscall_time_info)*NR_CPUS); @@ -263,8 +266,18 @@ clocksource_register_hz(&kvm_clock, NSEC_PER_SEC); pv_info.name = "KVM"; + flags = PVCLOCK_COUNTS_FROM_ZERO; if (kvm_para_has_feature(KVM_FEATURE_CLOCKSOURCE_STABLE_BIT)) - pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT); + flags |= PVCLOCK_TSC_STABLE_BIT; + + pvclock_set_flags(flags); + + cpu = get_cpu(); + vcpu_time = &hv_clock[cpu].pvti; + flags = pvclock_read_flags(vcpu_time); + if (flags & PVCLOCK_COUNTS_FROM_ZERO) + set_sched_clock_stable(); + put_cpu(); } int __init kvm_setup_vsyscall_timeinfo(void)