Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6768939ybi; Mon, 22 Jul 2019 01:17:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxYp1rv/h/l5bEQAwX1i36P8gXBFxuBYKgIRo8o12kHv7X3SlBpBerstBRHAy2p/PZ3cnlr X-Received: by 2002:a17:90a:9a83:: with SMTP id e3mr74369245pjp.105.1563783433969; Mon, 22 Jul 2019 01:17:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563783433; cv=none; d=google.com; s=arc-20160816; b=r9Xf/Ghpy/f1UCC22/Bu7VChcn8QQzXbqaMqcZRswvuFJue3ykqSoWo9dzWC+0FOQs oimh5pjYT4kjDc7+Y8gMeOuZMIy1PyvNJ5EiRdjy0rr2vKWRP5uulyGHpm7piTPz98ex 0rHO9Ox/4xB1z+HCFGyiAb/4cueH7y/Cv6l46JvZsV3xf+Wl2znVAZyOxD1UsrRKQjgP d82EgY0HSMqZmuMPzvz3d8d+2o3DlOhD7tzmvnsfHIrVWixCgTalhnEFN44OL+ZvkGbZ GIPRkVgzYGdo1YnS71aEpwcoaCko6ayQl+ukOQpEtdQvVCrrXPZA+0RwwmXt5SGvathc 45+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from; bh=AJT+Mz1VsaX5hXbRGt6rU81pqJMnN3gsElBkjckT6ns=; b=ie/ZkCjVGXHFGA+35ydauDuHmVKUph3FUM8rf8S2XVN+1r5DpJDL6/0uvlrWB6fyQ7 IJVqXSq1N6rS+TES7UNgyhqWQO0EvvsE0scCHtoFYQkVpkhbranWH+J5z4FDD+X7oUFW 7lq/vAzRFtuR/m5WsbQBcT0KVPc8XevFFFR3uC9K4aNwWX91vWRlPmTB8N3F08ux/hc7 yp1/eQhy68CPWw/1niscjflkeRO+LCMh8Y73u2ul7Ss3QRNxbFF92F9d6f12K7M6E5zQ /2y1RwkrvqXhxrRjecuMmRB3fvSVi3lJkc2tdItIBj5HXjrio1R48fDeZ8xj9uzC/fuV pbfA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i1si9846587pld.173.2019.07.22.01.16.57; Mon, 22 Jul 2019 01:17:13 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728023AbfGVHiz (ORCPT + 99 others); Mon, 22 Jul 2019 03:38:55 -0400 Received: from out30-42.freemail.mail.aliyun.com ([115.124.30.42]:48749 "EHLO out30-42.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727572AbfGVHiz (ORCPT ); Mon, 22 Jul 2019 03:38:55 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0TXUNmbb_1563781131; Received: from localhost(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0TXUNmbb_1563781131) by smtp.aliyun-inc.com(127.0.0.1); Mon, 22 Jul 2019 15:38:52 +0800 From: Alex Shi Cc: Alex Shi , Ingo Molnar , Peter Zijlstra , Frederic Weisbecker , Wanpeng Li , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH v3 1/2] cputime: remove duplicate code in account_process_tick Date: Mon, 22 Jul 2019 15:38:39 +0800 Message-Id: <20190722073840.32613-1-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.856.g8858448bb MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The irqtime_account_process_tick path was introduced for precise ns irq time account from commit abb74cefa9c6 ("sched: Export ns irqtimes through /proc/stat") while account_process_tick still use jiffes. This divide isn't necessary especially now both paths are ns precison. Move out the irqtime_account_process_tick func from IRQ_TIME_ACCOUNTING. So it do generally same things as account_process_tick whenever if IRQ_TIME_ACCOUNTING set or if sched_clock_irqtime enabled. Signed-off-by: Alex Shi Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Frederic Weisbecker Cc: Wanpeng Li Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org --- kernel/sched/cputime.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index 2305ce89a26c..5086b24d7bee 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -332,7 +332,6 @@ void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times) rcu_read_unlock(); } -#ifdef CONFIG_IRQ_TIME_ACCOUNTING /* * Account a tick to a process and cpustat * @p: the process that the CPU time gets accounted to @@ -390,6 +389,7 @@ static void irqtime_account_process_tick(struct task_struct *p, int user_tick, } } +#ifdef CONFIG_IRQ_TIME_ACCOUNTING static void irqtime_account_idle_ticks(int ticks) { struct rq *rq = this_rq(); @@ -398,8 +398,6 @@ static void irqtime_account_idle_ticks(int ticks) } #else /* CONFIG_IRQ_TIME_ACCOUNTING */ static inline void irqtime_account_idle_ticks(int ticks) { } -static inline void irqtime_account_process_tick(struct task_struct *p, int user_tick, - struct rq *rq, int nr_ticks) { } #endif /* CONFIG_IRQ_TIME_ACCOUNTING */ /* @@ -474,31 +472,12 @@ void thread_group_cputime_adjusted(struct task_struct *p, u64 *ut, u64 *st) */ void account_process_tick(struct task_struct *p, int user_tick) { - u64 cputime, steal; struct rq *rq = this_rq(); if (vtime_accounting_cpu_enabled()) return; - if (sched_clock_irqtime) { - irqtime_account_process_tick(p, user_tick, rq, 1); - return; - } - - cputime = TICK_NSEC; - steal = steal_account_process_time(ULONG_MAX); - - if (steal >= cputime) - return; - - cputime -= steal; - - if (user_tick) - account_user_time(p, cputime); - else if ((p != rq->idle) || (irq_count() != HARDIRQ_OFFSET)) - account_system_time(p, HARDIRQ_OFFSET, cputime); - else - account_idle_time(cputime); + irqtime_account_process_tick(p, user_tick, rq, 1); } /* -- 2.19.1.856.g8858448bb