Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8851092ybl; Fri, 17 Jan 2020 02:11:39 -0800 (PST) X-Google-Smtp-Source: APXvYqxTLQ6//PxHuvJMltvRW344UTQJ2GgT1plohTGzd71CDve7l8WS1iBrhc09XAT7OvPHu9dw X-Received: by 2002:aca:b183:: with SMTP id a125mr2865534oif.83.1579255899736; Fri, 17 Jan 2020 02:11:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579255899; cv=none; d=google.com; s=arc-20160816; b=RrgH7E6RColK/UiIrlmxwhrpKZg9YJ//cR21E/VBAH5wrmKeG5cncqZrgGmH4k9tRx WdabC/R0ZcHiP2FAfbY97O0xSn+q+o8dRKaf0y49pMAfiNYNbLJNjcPq7pQJEFd7qaCH +VSDK8GRquTi2eNW+LnNkaRPBbFCP62XiWhXd0TgqVft6Y99TQrCx/syNepYiaWiImU5 yOS/LOyW/Isz8CE1Mjcj2J3xJuQPBmtvEx767YatwnGSg/c4rqbDnQb/oPlgQl7NAtuj Bl7F22sjCaspp9YCbgSC2mA2zfmJB1SPFJ5czeB6DXBBxf9rvhRITaCmJ8dfCCJTR4cz J4Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=qlVS5AYGGrhKrCmPYZdofMZ+FJr/7Pgl8Z9mJoigu8I=; b=xZqN+BtnJw77mw6x0DtEwlmI0s7P7bX3y3MWCE0W+ihAUksIVuqHSTz97wJksHgiqY ETFiOvsg4RLU4qdfyzxlE9fZfNbAd24WOgHigdehduJzhSl6J84B0MDHBN4GxcoUDaDe BG3YJU9uI0tf8nzZJVwTcB4VuC7mc7nhVunGdZCnq0hYEu+USzaKhBdcHEgKehVvCqhf +BoBKtq1OEGQZVRlutSjRZ/MhwaJ1/GZiN86pvbG4AWyZA11Apae3XhIiIHY8qiz/VFv nipSCBSEErFd8iq9Us1yAPjhMTenbICQbQ457oUY7HCPtbFQbLk2G1S0GRyFbllwVm5D C5Wg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j24si14735135otn.110.2020.01.17.02.11.28; Fri, 17 Jan 2020 02:11:39 -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; 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 S1729439AbgAQKKL (ORCPT + 99 others); Fri, 17 Jan 2020 05:10:11 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:55364 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727123AbgAQKIv (ORCPT ); Fri, 17 Jan 2020 05:08:51 -0500 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1isOYX-0005SH-42; Fri, 17 Jan 2020 11:08:45 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id DC8EF1C19CE; Fri, 17 Jan 2020 11:08:41 +0100 (CET) Date: Fri, 17 Jan 2020 10:08:41 -0000 From: "tip-bot2 for Alex Shi" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/cputime: move rq parameter in irqtime_account_process_tick Cc: Alex Shi , "Peter Zijlstra (Intel)" , x86 , LKML In-Reply-To: <1577959674-255537-1-git-send-email-alex.shi@linux.alibaba.com> References: <1577959674-255537-1-git-send-email-alex.shi@linux.alibaba.com> MIME-Version: 1.0 Message-ID: <157925572173.396.14623531131441259192.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: 9dec1b6949ae9509cdc3edb2d75fda39c9db9fa2 Gitweb: https://git.kernel.org/tip/9dec1b6949ae9509cdc3edb2d75fda39c9db9fa2 Author: Alex Shi AuthorDate: Thu, 02 Jan 2020 18:07:52 +08:00 Committer: Peter Zijlstra CommitterDate: Fri, 17 Jan 2020 10:19:21 +01:00 sched/cputime: move rq parameter in irqtime_account_process_tick Every time we call irqtime_account_process_tick() is in a interrupt, Every caller will get and assign a parameter rq = this_rq(), This is unnecessary and increase the code size a little bit. Move the rq getting action to irqtime_account_process_tick internally is better. base with this patch cputime.o 578792 bytes 577888 bytes Signed-off-by: Alex Shi Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/1577959674-255537-1-git-send-email-alex.shi@linux.alibaba.com --- kernel/sched/cputime.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index d43318a..cff3e65 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -355,7 +355,7 @@ void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times) * softirq as those do not count in task exec_runtime any more. */ static void irqtime_account_process_tick(struct task_struct *p, int user_tick, - struct rq *rq, int ticks) + int ticks) { u64 other, cputime = TICK_NSEC * ticks; @@ -381,7 +381,7 @@ static void irqtime_account_process_tick(struct task_struct *p, int user_tick, account_system_index_time(p, cputime, CPUTIME_SOFTIRQ); } else if (user_tick) { account_user_time(p, cputime); - } else if (p == rq->idle) { + } else if (p == this_rq()->idle) { account_idle_time(cputime); } else if (p->flags & PF_VCPU) { /* System time or guest time */ account_guest_time(p, cputime); @@ -392,14 +392,12 @@ static void irqtime_account_process_tick(struct task_struct *p, int user_tick, static void irqtime_account_idle_ticks(int ticks) { - struct rq *rq = this_rq(); - - irqtime_account_process_tick(current, 0, rq, 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, - struct rq *rq, int nr_ticks) { } + int nr_ticks) { } #endif /* CONFIG_IRQ_TIME_ACCOUNTING */ /* @@ -473,13 +471,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_enabled_this_cpu()) return; if (sched_clock_irqtime) { - irqtime_account_process_tick(p, user_tick, rq, 1); + irqtime_account_process_tick(p, user_tick, 1); return; } @@ -493,7 +490,7 @@ void account_process_tick(struct task_struct *p, int user_tick) if (user_tick) account_user_time(p, cputime); - else if ((p != rq->idle) || (irq_count() != HARDIRQ_OFFSET)) + else if ((p != this_rq()->idle) || (irq_count() != HARDIRQ_OFFSET)) account_system_time(p, HARDIRQ_OFFSET, cputime); else account_idle_time(cputime);