Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3035898ybi; Thu, 18 Jul 2019 19:43:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxItJiO0RRjFAH71Xkw/uUDmI/5IiA++u7MhnpbHlJhlO0FCYmxQy1h/4xaao8tYyGeD/J9 X-Received: by 2002:a17:90a:5887:: with SMTP id j7mr54228345pji.136.1563504239565; Thu, 18 Jul 2019 19:43:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563504239; cv=none; d=google.com; s=arc-20160816; b=MIYdgbHj6sYzHIk/oVVVymmdBVytAMw8Z3HsbsarEa4FC1q1v6QisLapGlCoPBay91 gwm3Km9LmyjlrGiWkOCnDCRzZlbbig+l0plhmq7mnrkp2UsTjF72NceojfKtMFRQW8e5 nCCv5p1qkJHpWqC0jUYKKEusa7FYly8FWmMQvVOg1rrrdCCXy2D+zpt6gcrgPhZNHjTr OP1/j98oFR37ziYUgvNXM7WuoTbWDMPhQoWfNYF21mtnBbcl8Rbt+lMXorxRtBJFWmXu X+4h9ketQkVhdv/hqEjGhPSDy5Jwqhw7sDtbtwuGAS6l+zhTOk80nDsbkPpcmnO/DRIo v2eQ== 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 :references:in-reply-to:message-id:date:subject:cc:from; bh=2EXfd43MIgh4rl7wkWwig6H2rOXtSIGdmj7iCkt/GYo=; b=pkjR92v3jIGxruZiO0x2SlpUqacXfOsYnofXukRHWt1DswHyQECQepVRKR35mKLKst h9zYGFaveu/rPM4Zz13/6wNn064fiEi0gSGMf5P1pokI4y3seA1VTpwzE1AMk4YLLGW7 Y+DNsqLv6JiWImZqpq6eSXrNVOjMORbyHUpkL90YHzxLbAZBPoDte5rLh8UlbNQ+wvj6 7NwxXz3AZILS5xE9IJ3zJZReYwgMfC6UdsJShSnaWRDauGoYVkhD8ZXyVwFFeNkomjqd 7J4iOnnmnF8M/3LWu2hV5MwRgSogtnw5DXF4mL0KMhchDOhiScbBtjspn6KN+UeUExKj tKag== 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 p22si1185876pli.255.2019.07.18.19.43.44; Thu, 18 Jul 2019 19:43:59 -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 S1726674AbfGSCm5 (ORCPT + 99 others); Thu, 18 Jul 2019 22:42:57 -0400 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:37160 "EHLO out30-56.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726015AbfGSCm5 (ORCPT ); Thu, 18 Jul 2019 22:42:57 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R711e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04391;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0TXFEz7S_1563504172; Received: from localhost(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0TXFEz7S_1563504172) by smtp.aliyun-inc.com(127.0.0.1); Fri, 19 Jul 2019 10:42:53 +0800 From: Alex Shi Cc: Alex Shi , Ingo Molnar , Peter Zijlstra , Frederic Weisbecker , Wanpeng Li , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] cputime: remove duplicate code in account_process_tick Date: Fri, 19 Jul 2019 10:42:42 +0800 Message-Id: <20190719024242.249429-2-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.856.g8858448bb In-Reply-To: <20190719024242.249429-1-alex.shi@linux.alibaba.com> References: <20190719024242.249429-1-alex.shi@linux.alibaba.com> 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 abb74cefa9c682fb (sched: Export ns irqtimes through /proc/stat) while account_process_tick still use jiffes. This divide isn't neccessary especially now both pathes 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 | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index 3aaf761ede81..6116f50e1f37 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,14 +389,13 @@ 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) { irqtime_account_process_tick(current, 0, 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, - int nr_ticks) { } #endif /* CONFIG_IRQ_TIME_ACCOUNTING */ /* @@ -472,30 +470,10 @@ 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; - if (vtime_accounting_cpu_enabled()) return; - if (sched_clock_irqtime) { - irqtime_account_process_tick(p, user_tick, 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 != this_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, 1); } /* -- 2.19.1.856.g8858448bb