Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp5290268imm; Tue, 26 Jun 2018 08:50:49 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIldXh9syRyymWv4w9Ve4cIvxy1s8BJ6ha0QRgjktEBYzkDr5qJzn93YSsCYPP98RnBSOyq X-Received: by 2002:a63:ad46:: with SMTP id y6-v6mr1903918pgo.10.1530028249819; Tue, 26 Jun 2018 08:50:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530028249; cv=none; d=google.com; s=arc-20160816; b=WElCg10SGv/KZ3Bn3d3PPlGGpNAlgyl9LDd2Mjj1w85EhUFCi23riq96ZOqaAzJ32Q RcIw0wFXd8PQDOlXj0mohnnsYtKqKCCRVNL5V3u0ZKcjB8OxhsLc65p0CgTEvQJ33igl 0gjIRpXGiRTLUsxLoAVZEfg4p8j+qn3NpdAwFnW/BTLJym943nABpHKdW9FO0OpvfYbf vML7Z6g+/V4yhswaJhcRO8EWwHtGH/ZGomtZl8/6NgHNIYoWSMq+zzLDBO2Pg7a4juxW XSp/tt9bWCtKvptVoQO+MOebPDo1GFsgvIbTazwAHKc5LopSKt6gGBAbuiMO6DNNrZmj J1aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=g7l/Wpr4y387DyKpP5NSfi6g0+0kJ3joaNa4U7Xqwio=; b=0CqTp/ehMI0UPk6/ldBMbHMH0rbVeLLx6aX70XOk0lKTYnM/FgjUuRtovnrqvp45S5 EIwLX5h0+182ebhDAwXhSisGrf6C55yMA/U9vgT6dfwIz/PxpvtYe36PFd0bMBCtMzSA vuSd1CYrBKxbyF3r20Cc9V8rfcCV7kn0RKCbXhu6BmMjmcRZzwA0A++CzEYSyQcvMs+h LCY+b0DHrR98mW9yAhQj22JlDVc3H77gUBVqxS4KyRoa3TJ61QETNB+SnacTxatL3E7P vq3nNjtrQXWlJuRDB1Yn4rE8uVXq4uR8KoEBTbxe30iqHjTLV8zwJw5pLLEHPH5Tphyu RlhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=PpCGpnW1; 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 d7-v6si1430120pgc.445.2018.06.26.08.50.35; Tue, 26 Jun 2018 08:50:49 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=PpCGpnW1; 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 S1752243AbeFZPtR (ORCPT + 99 others); Tue, 26 Jun 2018 11:49:17 -0400 Received: from merlin.infradead.org ([205.233.59.134]:47780 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751576AbeFZPtQ (ORCPT ); Tue, 26 Jun 2018 11:49:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=g7l/Wpr4y387DyKpP5NSfi6g0+0kJ3joaNa4U7Xqwio=; b=PpCGpnW1VVxMEw8w91U7V0Oga cyAEqcDv+jFnRuaTMaBimK9A+jK16uYp8aKJ0mnBsBlLqzWyPyOxEM5J0cbeaUvydRRRed0kcdTid KPODOycUr6ZBt29gn8pKsQnNKthoHjkUuHFOUROyrtfxgpfX1wmxmPEUEX8WqKNrcbrvcuSRVhXL/ mvbPAMCK1ms4uRzKOG5b/a5f22E4LcrFcyXPRDK3j20udgETjQ6tCYmEnOvfVMnE6IE6LaEbXzXBr UoPzpM2PQL5F6Yn2lwNdmKAEqjK8nwiOz8PXA2zo7JDnyzZQQkw6su9Fdls0TBDDjl/iEZ5qqX6QW CpfSZlSWA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fXqDP-0002tH-7p; Tue, 26 Jun 2018 15:49:11 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 919502029F1DB; Tue, 26 Jun 2018 17:49:08 +0200 (CEST) Date: Tue, 26 Jun 2018 17:49:08 +0200 From: Peter Zijlstra To: Xunlei Pang Cc: Ingo Molnar , Frederic Weisbecker , Tejun Heo , linux-kernel@vger.kernel.org Subject: Re: [PATCH] sched/cputime: Ensure correct utime and stime proportion Message-ID: <20180626154908.GE2458@hirez.programming.kicks-ass.net> References: <20180622071542.61569-1-xlpang@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 26, 2018 at 08:19:49PM +0800, Xunlei Pang wrote: > On 6/22/18 3:15 PM, Xunlei Pang wrote: > > We use per-cgroup cpu usage statistics similar to "cgroup rstat", > > and encountered a problem that user and sys usages are wrongly > > split sometimes. > > > > Run tasks with some random run-sleep pattern for a long time, and > > when tick-based time and scheduler sum_exec_runtime hugely drifts > > apart(scheduler sum_exec_runtime is less than tick-based time), > > the current implementation of cputime_adjust() will produce less > > sys usage than the actual use after changing to run a different > > workload pattern with high sys. This is because total tick-based > > utime and stime are used to split the total sum_exec_runtime. > > > > Same problem exists on utime and stime from "/proc//stat". > > > > [Example] > > Run some random run-sleep patterns for minutes, then change to run > > high sys pattern, and watch. > > 1) standard "top"(which is the correct one): > > 4.6 us, 94.5 sy, 0.0 ni, 0.9 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st > > 2) our tool parsing utime and stime from "/proc//stat": > > 20.5 usr, 78.4 sys > > We can see "20.5 usr" displayed in 2) was incorrect, it recovers > > gradually with time: 9.7 usr, 89.5 sys > > > High sys probably means there's something abnormal on the kernel > path, it may hide issues, so we should make it fairly reliable. > It can easily hit this problem with our per-cgroup statistics. > > Hi Peter, any comment on this patch? Well, no, because the Changelog is incomprehensible and the patch doesn't really have useful comments, so I'll have to reverse engineer the entire thing, and I've just not had time for that.