Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1598782pxj; Wed, 19 May 2021 09:26:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9493iRVbnYD9t2tqKbE+J4XmcG97ZrDLS+I2O7I93oY3jTUZ9UKRz8tfQw0SZJIkswMVu X-Received: by 2002:a17:906:456:: with SMTP id e22mr13323307eja.427.1621441596450; Wed, 19 May 2021 09:26:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621441596; cv=none; d=google.com; s=arc-20160816; b=Z+sjwZ8QcPp9Otm3GlhhJJi+jyObZUiJlf54u3vst4fwyZUJb3U6CUvFBFMjeh59C8 d5nAEm68vnKXfIXOu6io1hxqIwJvDly51MzrY07bLa2mpZWBPXdeNdWlgG+NzZ+rGZGF y+YFW96768phEZw4/uFFk1RRsWycpEkTNCaeDqznBjoJShDvQ4O8UWtpBKfkYd8CFobt SG3l1Ay/6Bztyjylb1AgPetT4jj+WjkPpCBzyMyO2lOdlUHP/2EzX+kjb7jxpJlfQi9/ RvTLMVEmQbCvCXvgjcNcP3tOeX+pNOPcC2eWh9JLgpNiUmPbhQ9OPqJswvh+pfOlTQmS ZS2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=HhLhYx8X/N3oHEcmVADa59F9cz2oSPkONiRH7L58LjU=; b=i38HtLHWWxEDBrQoQmbKfl7eClD9uz6sOUWyzmOf3TUjTPclmTsZsVbcMV0SuSVnqh tU5Zik9TYArWsmjM6SwSZu+IStpKPZOdBjT5kqFaq4YE3EefyqHNLHeDQxdsgJd9YtGy nxJ/jVciW3Ps4Y20LOtXlkUA3RxRXFb0wYaRBJlPBCRvoytYPJKA+HkTIyqHR+XCg+AT cbJP80kfnjwVV3+FvCcqZt5TbGptpeXz+Y9G4gOKBAcntU8OvP00QtpXJ2OfL0GVVp0Z 5bGR4lhZnbWOMCEnjd490ePJMK4jS7yGbzdQ33kjkdbOLu65Uiinom5Pm46c7GcpfMeu pRcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=NXOYIm7f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u22si147464eje.506.2021.05.19.09.26.13; Wed, 19 May 2021 09:26:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=NXOYIm7f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242329AbhERIZb (ORCPT + 99 others); Tue, 18 May 2021 04:25:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbhERIZa (ORCPT ); Tue, 18 May 2021 04:25:30 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF5E8C061573 for ; Tue, 18 May 2021 01:24:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=HhLhYx8X/N3oHEcmVADa59F9cz2oSPkONiRH7L58LjU=; b=NXOYIm7fkali+E3M/XMfELs0Zt 6HTYghYovNl/UXPGPIAGbwe5PBHrRu3PPeukI/ZD7hadke8eTzII1SDuJ22FHOSyWA0jg4DdMiYG5 rNasnYhSFoATqOXG51sWc3oK8KYcwbFyJ8pkwEg2w/bclbwmQYwa+mE4ratE3LUPBSQ40j8Upf+EE l42Fct3DOytK8hvMnvYPLZhbczmoH2lQibGknwk042O/Iq86yUEtezUWpmDJJLo9hBevjH+XXgJwl lp1crZxNn5rpebcs+gnD461oe6XKtGit81XEYJgYhJ1y5sJRFzxrPMktyY//AQslo9PaGiUNw3qlf N5YUmsqQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1liv0V-00DnYd-Vl; Tue, 18 May 2021 08:23:26 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id B777130022A; Tue, 18 May 2021 10:23:13 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 988E93138186A; Tue, 18 May 2021 10:23:13 +0200 (CEST) Date: Tue, 18 May 2021 10:23:13 +0200 From: Peter Zijlstra To: "hasegawa-hitomi@fujitsu.com" Cc: "'fweisbec@gmail.com'" , "'tglx@linutronix.de'" , "'mingo@kernel.org'" , "'juri.lelli@redhat.com'" , "'vincent.guittot@linaro.org'" , "'dietmar.eggemann@arm.com'" , "'rostedt@goodmis.org'" , "'bsegall@google.com'" , "'mgorman@suse.de'" , "'bristot@redhat.com'" , "'linux-kernel@vger.kernel.org'" Subject: Re: Utime and stime are less when getrusage (RUSAGE_THREAD) is executed on a tickless CPU. Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 18, 2021 at 07:59:06AM +0000, hasegawa-hitomi@fujitsu.com wrote: > Hi Ingo, Peter, Juri, and Vincent > > > > I found that when I run getrusage(RUSAGE_THREAD) on a tickless CPU, the utime and stime I get are less than the actual time, unlike when I run getrusage(RUSAGE_SELF) on a single thread. > > This problem seems to be caused by the fact that se.sum_exec_runtime is not updated just before getting the information from 'current'. > > In the current implementation, task_cputime_adjusted() calls task_cputime() to get the 'current' utime and stime, then calls cputime_adjust() >to adjust the sum of utime and stime to be equal to cputime.sum_exec_runtime. On a tickless CPU, sum_exec_runtime is not updated >periodically, so there seems to be a discrepancy with the actual time. > > Therefore, I think I should include a process to update se.sum_exec_runtime just before getting the information from 'current' (as in other >processes except RUSAGE_THREAD). I'm thinking of the following improvement. > > > > @@ void getrusage(struct task_struct *p, int who, struct rusage *r) > > if (who == RUSAGE_THREAD) { > > + task_sched_runtime(current); > > task_cputime_adjusted(current, &utime, &stime); > > > > Is there any possible problem with this? > > > Any comments? Your email is malformed.