From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6A92C25B0E for ; Tue, 16 Aug 2022 11:30:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233952AbiHPLaw (ORCPT ); Tue, 16 Aug 2022 07:30:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234748AbiHPLaB (ORCPT ); Tue, 16 Aug 2022 07:30:01 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BD2F12080; Tue, 16 Aug 2022 03:47:39 -0700 (PDT) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4M6SRf31mKzXdRB; Tue, 16 Aug 2022 18:43:26 +0800 (CST) Received: from huawei.com (10.67.174.191) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 16 Aug 2022 18:47:37 +0800 From: Li Hua To: CC: , , , , , , , , , , , Subject: Re: [PATCH -next] sched/cputime: Fix the bug of reading time backward from /proc/stat Date: Wed, 17 Aug 2022 08:44:45 +0800 Message-ID: <20220817004445.43216-1-hucool.lihua@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.174.191] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It's unreadable, I'm sorry about that. The CPU statistics time read from /proc/stat should only be incremented. The bug I found is that the value read latest is smaller than the former. The root cause of the problem is that the "vtime->utime" and "delta" are temporarily added to the stack and show to the user. The value of 'vtime->utime + delta' depends on which task the CPU is executing. As bellow: show_stat -> kcpustat_cpu_fetch -> kcpustat_cpu_fetch_vtime -> cpustat[CPUTIME_USER] += vtime->utime + delta