Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2023143ybl; Thu, 9 Jan 2020 05:41:26 -0800 (PST) X-Google-Smtp-Source: APXvYqxHskpBeyXUvFyOjQt/oZFSsLzOKoPbYM7h3LfXeaomaLovJ1SvrJX9g+sjol0ZaIBzpBUn X-Received: by 2002:a9d:5c10:: with SMTP id o16mr8791280otk.286.1578577286037; Thu, 09 Jan 2020 05:41:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578577286; cv=none; d=google.com; s=arc-20160816; b=NQvTjxcvW/B1A5j6BD/giqPTaaGPevrDIVzXH0mmRF2AUSzi361iRP+RsryFXDENyK cWXtKBSAXSwLNh4sHk8QWmQd52nIaNX3kioeBGof58XPctB+CGSztj4Tuo7nDs7qeNza D/DZENZhd8JKRMZowVLhGze6Q0fgmrjvCOuAva56Nyf+ztelyGNv/chtaWlg0lcFIi2o c1YJpIznZkkCCDoEwwF7fHnMmHv/G4HuVN30zWqxS5qs9l83LOzYA7UQZi1eOxFKIze7 e5Ik0MqKhwP1tMsLH0V+e/MIk6GBp2mHL3M6cGks3+WOXkiL8+j+u7XQsS99L3Z6q2og XcwA== 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:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=A0fUlBaM6603S0dIcpBfGR9uz7BZjcaJC3c6gj6G38A=; b=YlnvK0MMf4G/mRR+xObnWZlHiLiAl8mi2HxsvLbjVoDm+GLDdWDmglIMcayPpc2uXJ fu40ommaIqrpD6zGt5RaIcgFxAfYiSylJV9XXBaaM6f/iVtN5iFMBq+a43iGY/L4M96f bUj/xMspjRT/Pql/e8C9H70mMxvAlKJ0nHSygqTecBVbenGiJlC2wLxFNgtItClWkC93 0pQdMwxso5fwBkxiH1M+uK4vePJdrgbtl0W8SGSRjTfng8pg4X8H4w/NYsuR9Kb7JuMe vDH9N/S/kFGlGbXwe1qx6Hx4sgZWsvC18XrkpyAntJnOHcRuFzi8P8CglWaBrOI3w42U AooQ== 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 e1si4219099otj.276.2020.01.09.05.41.13; Thu, 09 Jan 2020 05:41:26 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731156AbgAINb6 (ORCPT + 99 others); Thu, 9 Jan 2020 08:31:58 -0500 Received: from out30-43.freemail.mail.aliyun.com ([115.124.30.43]:44213 "EHLO out30-43.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730471AbgAINb6 (ORCPT ); Thu, 9 Jan 2020 08:31:58 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R311e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04420;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0TnFa0Xr_1578576712; Received: from IT-FVFX43SYHV2H.local(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0TnFa0Xr_1578576712) by smtp.aliyun-inc.com(127.0.0.1); Thu, 09 Jan 2020 21:31:52 +0800 Subject: Re: [PATCH 2/3] sched/cputime: code cleanup in irqtime_account_process_tick To: Peter Zijlstra , Frederic Weisbecker Cc: Ingo Molnar , Frederic Weisbecker , Wanpeng Li , Anna-Maria Gleixner , Thomas Gleixner , linux-kernel@vger.kernel.org References: <1577959674-255537-1-git-send-email-alex.shi@linux.alibaba.com> <1577959674-255537-2-git-send-email-alex.shi@linux.alibaba.com> <20200106155350.GB26097@lenoir> <20200107091315.GS2844@hirez.programming.kicks-ass.net> From: Alex Shi Message-ID: <835fd412-544a-1bdd-e75f-f557e299a50a@linux.alibaba.com> Date: Thu, 9 Jan 2020 21:30:40 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: <20200107091315.GS2844@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >> I fear we can't really play the exact same game as account_process_tick() here. >> Since this is irqtime precise accounting, we have already computed the >> irqtime delta in account_other_time() (or we will at some point in the future) >> and substracted it from the ticks to account. This means that the remaining cputime >> to account has to be either utime/stime/gtime/idle-time but not interrupt time, or >> we may account interrupt time twice. And account_system_time() tries to account >> irq time, for example if we interrupt a softirq. > > OK, I've dropped 2 and 3. Thanks Frederic! > Hi Frederic & Peter, Thanks a lot for the comments and review! It's my fault to mess up the account_system_time details. And seems there is no easy way to replace irqtime_account_process_tick or account_process_tick with each other. but on the other side, the account_idle_ticks could be replaced by irqtime_account_process_tick, or at least to remove irqtime_account_idle_ticks function. Any comments? Thanks Alex --- From 7073e60babc3b42a987b4e89f380956887734233 Mon Sep 17 00:00:00 2001 From: Alex Shi Date: Thu, 9 Jan 2020 20:32:55 +0800 Subject: [PATCH] sched/cputime: remove irqtime_account_idle_ticks irqtime_account_idle_ticks and irqtime_account_process_tick use in same condition. We don't bother to name and use a irqtime_account_idle_ticks for only one calling. Remove the function to simply code and reduce a bit object size of kernel. And further more, we could replace account_idle_ticks by irqtime_account_process_tick too. But feed and check 'current' looks weird. So this is ok. Signed-off-by: Alex Shi Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Peter Zijlstra Cc: linux-kernel@vger.kernel.org --- kernel/sched/cputime.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index cff3e656566d..17640d145e44 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -390,12 +390,7 @@ static void irqtime_account_process_tick(struct task_struct *p, int user_tick, } } -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 */ @@ -505,7 +500,7 @@ void account_idle_ticks(unsigned long ticks) u64 cputime, steal; if (sched_clock_irqtime) { - irqtime_account_idle_ticks(ticks); + irqtime_account_process_tick(current, 0, ticks); return; } -- 1.8.3.1