Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933360AbcLMOid (ORCPT ); Tue, 13 Dec 2016 09:38:33 -0500 Received: from mail-wj0-f194.google.com ([209.85.210.194]:33936 "EHLO mail-wj0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933325AbcLMOia (ORCPT ); Tue, 13 Dec 2016 09:38:30 -0500 Date: Tue, 13 Dec 2016 15:38:20 +0100 From: Frederic Weisbecker To: Martin Schwidefsky Cc: LKML , Tony Luck , Wanpeng Li , Peter Zijlstra , Michael Ellerman , Heiko Carstens , Benjamin Herrenschmidt , Thomas Gleixner , Paul Mackerras , Ingo Molnar , Fenghua Yu , Rik van Riel , Stanislaw Gruszka Subject: Re: [PATCH 09/10] s390/cputime: delayed accounting of system time Message-ID: <20161213143816.GA1272@lerouge> References: <1480991543-6557-1-git-send-email-fweisbec@gmail.com> <1480991543-6557-10-git-send-email-fweisbec@gmail.com> <20161210014804.GA3023@lerouge> <20161212112754.5ad104cf@mschwideX1> <20161212150228.GA17032@lerouge> <20161213121322.5fdbbb28@mschwideX1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161213121322.5fdbbb28@mschwideX1> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1325 Lines: 26 On Tue, Dec 13, 2016 at 12:13:22PM +0100, Martin Schwidefsky wrote: > On Mon, 12 Dec 2016 16:02:30 +0100 > Frederic Weisbecker wrote: > > > On Mon, Dec 12, 2016 at 11:27:54AM +0100, Martin Schwidefsky wrote: > > > 3) The call to vtime_flush in account_process_tick is done in irq context from > > > update_process_times. hardirq_offset==1 is also correct. > > > > Let's see this for example: > > > > + if ((tsk->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) > > + S390_lowcore.guest_timer += timer; > > > > If the tick is interrupting guest, we have accounted the guest time on tick IRQ entry. > > Now we are in the middle of the tick interrupt and since hardirq_offset is 1, we > > are taking the above path by accounting half of the tick-IRQ time as guest, which is wrong, > > it's actually IRQ time. > > Hmm, you got me there. The system time from irq_enter until account_process_tick > is reached is indeed IRQ time. It is not much but it is incorrect. The best fix > would be to rip out the accounting of the system time from account_process_tick > as irq_enter / irq_exit will do system time accounting anyway. To do that > do_account_vtime needs to be split, because for the task switch we need to > account the system time of the previous task. Exactly!