Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1743724imj; Fri, 8 Feb 2019 06:41:24 -0800 (PST) X-Google-Smtp-Source: AHgI3IYnyYja6kNsJXv+p+lj1MzB1aFLGdT9YoPnRa9yVZp11X1HXlenNoMugihZDNaOWqLAqfSR X-Received: by 2002:a17:902:d83:: with SMTP id 3mr22716761plv.43.1549636884851; Fri, 08 Feb 2019 06:41:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549636884; cv=none; d=google.com; s=arc-20160816; b=TOdKlQ6lh/H9KtYCDVvUwonepvWPRmQUocyOI+UZLbMqCz624YfwAxc5FwXmJKDMqH 0bkjNs58w4S40eMz8N71zIE7P/zHjMbRApg6pxSY874oaCqjb9/9GjhWJNE5BVLxJLq+ KnxK/GdNA8UCktzkUQeHKMK7dyQeX4YKv6kYn4V0VdHu6llWzCea0PhZoccBOmrU2zdG 6fDOezEBss4dUbXyiu6wBjf7c44KR1MST6HSFnaiLtJOFBRNyOMvWEA2kgYqm/FzmefC Zc4fQHHXJg8LMUtdEvnckmiqgox8W+wP5BKvy33Z/CXA4Wssz3eLayWzTrvX7XmKABfk Xglg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:message-id :dkim-signature; bh=5GG72cfsOyRs1FMwnBMqAfDwn15LcXCsOplueh6doO0=; b=Qdgy026zn+bdB04mlEwX0NhKoU5XNJLt02uN6ISYmVabRVlEgKotnJhRjHZB+mZc4C TPN8tDh3KTqlGqvVW5z8E8cK8PBQqmzIa/jc+D2KdgyGB2mycPlTNsR/kMaR6ZSFtbWP SkgU5/K9GyDvXhnFLOvzPBiLrfC+YMbOoQv+q2sN+JQ3EFTJ1lJuPsUX705XIAw09BVL qRUWC/0MGKYl5oC/dOLaNi1/EWb7FJ1nV1rlOOQWGMVnpvOiBL+wm2nC8qnpDV6a8Jb9 CWficHrxYpg8Z/W3zg9REKkPlP8hCtlBRpBqFVopLNkqyC8Gim5o9S1umIEdUot9WOuV 4Lwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=O40UEtSQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l16si1613452pfb.68.2019.02.08.06.41.08; Fri, 08 Feb 2019 06:41:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=O40UEtSQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727619AbfBHOkt (ORCPT + 99 others); Fri, 8 Feb 2019 09:40:49 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:19628 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726568AbfBHOkt (ORCPT ); Fri, 8 Feb 2019 09:40:49 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 43wyXY6gw7z9vBwc; Fri, 8 Feb 2019 15:40:45 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=O40UEtSQ; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id zYTMgxMD0fV5; Fri, 8 Feb 2019 15:40:45 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 43wyXY5PXkz9vBwZ; Fri, 8 Feb 2019 15:40:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1549636845; bh=5GG72cfsOyRs1FMwnBMqAfDwn15LcXCsOplueh6doO0=; h=From:Subject:To:Cc:Date:From; b=O40UEtSQxXdfDb/419Re+wWnkIIt+yZhnDbLDDNb+AktAn0M8c+EZhMz44A9SPEx8 DK2jD4twcM9JkfHglLX+MThSGZxrk3Tg84BzSvr1ikAfnrITj2QJCO19Ec21WRzBcN dhupWUw05SB2gjleGFvIcmOH7kvp0Y/UNFFhEIjE= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 3B10F8B8DA; Fri, 8 Feb 2019 15:40:47 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id ejnY7pB_f5qS; Fri, 8 Feb 2019 15:40:47 +0100 (CET) Received: from po16846vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.231.2]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 05AF48B756; Fri, 8 Feb 2019 15:40:47 +0100 (CET) Received: by po16846vm.idsi0.si.c-s.fr (Postfix, from userid 0) id CB010656D3; Fri, 8 Feb 2019 14:40:46 +0000 (UTC) Message-Id: From: Christophe Leroy Subject: [RFC PATCH v1] powerpc/accounting: do not account system time on transition to user. To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Nicholas Piggin Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Fri, 8 Feb 2019 14:40:46 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Time spent in kernel mode don't need to be accounted on transition to user space. As far as the time spent in user is known, it is possible to calculate the time spent in kernel by substracting the time spent in user. To do so, this patch modifies vtime_delta() to substract the time spent in user since the last call to vtime_delta(). This patch gives a 2% improvment of null_syscall() selftest on a 83xx. Signed-off-by: Christophe Leroy --- But surprisingly, this patch degrades the null_syscall selftest by 20% on the 8xx. Any idea of the reason ? arch/powerpc/include/asm/accounting.h | 1 + arch/powerpc/include/asm/ppc_asm.h | 8 +------- arch/powerpc/kernel/asm-offsets.c | 8 ++------ arch/powerpc/kernel/time.c | 4 +++- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/include/asm/accounting.h b/arch/powerpc/include/asm/accounting.h index c607c5d835cc..2f1ff5f9fd7a 100644 --- a/arch/powerpc/include/asm/accounting.h +++ b/arch/powerpc/include/asm/accounting.h @@ -27,6 +27,7 @@ struct cpu_accounting_data { /* Internal counters */ unsigned long starttime; /* TB value snapshot */ unsigned long starttime_user; /* TB value on exit to usermode */ + unsigned long utime_asm; #ifdef CONFIG_ARCH_HAS_SCALED_CPUTIME unsigned long startspurr; /* SPURR value snapshot */ unsigned long utime_sspurr; /* ->user_time when ->startspurr set */ diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h index e0637730a8e7..be17d570d484 100644 --- a/arch/powerpc/include/asm/ppc_asm.h +++ b/arch/powerpc/include/asm/ppc_asm.h @@ -28,9 +28,8 @@ #define ACCOUNT_STOLEN_TIME #else #define ACCOUNT_CPU_USER_ENTRY(ptr, ra, rb) \ - MFTB(ra); /* get timebase */ \ PPC_LL rb, ACCOUNT_STARTTIME_USER(ptr); \ - PPC_STL ra, ACCOUNT_STARTTIME(ptr); \ + MFTB(ra); /* get timebase */ \ subf rb,rb,ra; /* subtract start value */ \ PPC_LL ra, ACCOUNT_USER_TIME(ptr); \ add ra,ra,rb; /* add on to user time */ \ @@ -38,12 +37,7 @@ #define ACCOUNT_CPU_USER_EXIT(ptr, ra, rb) \ MFTB(ra); /* get timebase */ \ - PPC_LL rb, ACCOUNT_STARTTIME(ptr); \ PPC_STL ra, ACCOUNT_STARTTIME_USER(ptr); \ - subf rb,rb,ra; /* subtract start value */ \ - PPC_LL ra, ACCOUNT_SYSTEM_TIME(ptr); \ - add ra,ra,rb; /* add on to system time */ \ - PPC_STL ra, ACCOUNT_SYSTEM_TIME(ptr) #ifdef CONFIG_PPC_SPLPAR #define ACCOUNT_STOLEN_TIME \ diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c index 7a1b93c5af63..f2ba7735f56f 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c @@ -260,19 +260,15 @@ int main(void) OFFSET(PACAHWCPUID, paca_struct, hw_cpu_id); OFFSET(PACAKEXECSTATE, paca_struct, kexec_state); OFFSET(PACA_DSCR_DEFAULT, paca_struct, dscr_default); - OFFSET(ACCOUNT_STARTTIME, paca_struct, accounting.starttime); OFFSET(ACCOUNT_STARTTIME_USER, paca_struct, accounting.starttime_user); - OFFSET(ACCOUNT_USER_TIME, paca_struct, accounting.utime); - OFFSET(ACCOUNT_SYSTEM_TIME, paca_struct, accounting.stime); + OFFSET(ACCOUNT_USER_TIME, paca_struct, accounting.utime_asm); OFFSET(PACA_TRAP_SAVE, paca_struct, trap_save); OFFSET(PACA_NAPSTATELOST, paca_struct, nap_state_lost); OFFSET(PACA_SPRG_VDSO, paca_struct, sprg_vdso); #else /* CONFIG_PPC64 */ #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE - OFFSET(ACCOUNT_STARTTIME, thread_info, accounting.starttime); OFFSET(ACCOUNT_STARTTIME_USER, thread_info, accounting.starttime_user); - OFFSET(ACCOUNT_USER_TIME, thread_info, accounting.utime); - OFFSET(ACCOUNT_SYSTEM_TIME, thread_info, accounting.stime); + OFFSET(ACCOUNT_USER_TIME, thread_info, accounting.utime_asm); #endif #endif /* CONFIG_PPC64 */ diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index bc0503ef9c9c..79420643b45f 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c @@ -331,8 +331,10 @@ static unsigned long vtime_delta(struct task_struct *tsk, WARN_ON_ONCE(!irqs_disabled()); now = mftb(); - stime = now - acct->starttime; + stime = now - acct->starttime - acct->utime_asm; acct->starttime = now; + acct->utime += acct->utime_asm; + acct->utime_asm = 0; *stime_scaled = vtime_delta_scaled(acct, now, stime); -- 2.13.3