From patchwork Thu Aug 1 14:32:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 11070865 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 C135017E0 for ; Thu, 1 Aug 2019 14:38:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2C1928515 for ; Thu, 1 Aug 2019 14:38:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6CEF28573; Thu, 1 Aug 2019 14:38:44 +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.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 5061328515 for ; Thu, 1 Aug 2019 14:38:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731556AbfHAOin (ORCPT ); Thu, 1 Aug 2019 10:38:43 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:36216 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731397AbfHAOiU (ORCPT ); Thu, 1 Aug 2019 10:38:20 -0400 Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1htCDU-0000lv-Qd; Thu, 01 Aug 2019 16:38:04 +0200 Message-Id: <20190801143250.370326052@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 01 Aug 2019 16:32:50 +0200 From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Peter Zijlstra , Ingo Molnar , Sebastian Siewior , Anna-Maria Gleixner , Steven Rostedt , Julia Cartwright , Paul McKenney , Frederic Weisbecker , Oleg Nesterov , kvm@vger.kernel.org, Radim Krcmar , Paolo Bonzini , John Stultz , Andy Lutomirski , "Paul E. McKenney" Subject: [patch 0/5] posix-cpu-timers: Move expiry into task work context Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Running posix cpu timers in hard interrupt context has a few downsides: - For PREEMPT_RT it cannot work as the expiry code needs to take sighand lock, which is a 'sleeping spinlock' in RT - For fine grained accounting it's just wrong to run this in context of the timer interrupt because that way a process specific cpu time is accounted to the timer interrupt. There is no real hard requirement to run the expiry code in hard interrupt context. The posix CPU timers are an approximation anyway, so having them expired and evaluated in task work context does not really make them worse. That unearthed the fact that KVM is missing to handle task work before entering a VM which is delaying pending task work until the vCPU thread goes all the way back to user space qemu. The series implements the necessary handling for x86/KVM and switches the posix cpu timer expiry into task work for X86. The posix timer modification is conditional on a selectable config switch as this requires that task work is handled in KVM. The available tests pass and no problematic difference has been observed. Thanks, tglx 8<-------------------- arch/x86/kvm/x86.c | 8 ++++- arch/x86/Kconfig | 1 include/linux/sched.h | 3 ++ include/linux/tracehook.h | 15 ++++++++++ kernel/task_work.c | 19 ++++++++++++ kernel/time/Kconfig | 5 +++ kernel/time/posix-cpu-timers.c | 61 ++++++++++++++++++++++++++++++----------- 7 files changed, 95 insertions(+), 17 deletions(-)