From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32A2521A43A for ; Fri, 24 Jan 2025 09:58:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737712719; cv=none; b=jMeeCnH4atMbhkDC25j9nYjdBZyjwG83ni+YsaIUtOC+V2siJYY23ytGF9B+U3xFJdsVtFYxOR+6Vs8YBMFZLLLnj3ASXGEXyxQo6YhAH5MTLqYxr53NKX8d8aIhary7fH4Dh8DDg6uQCDkTnIcYMG3+Xq68eB0hqot6oBAgNDQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737712719; c=relaxed/simple; bh=b0NM6/LjIOBz/UPiTAWXH24WsHcyH4sODiI1aMjHIqQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=eUnEvRHZe6B72kx58KI68B67pKArV0beHOUB6KFqlvPUuEeaftIBrumLrif0HEzIs2vT5vkMw/K9J4k2KejqoQGCBBGVwLiycBxB1aEVvO01xXC0lAplLunkvUMt5LXKbWFy4+x+Ne8k+XoDfarsWSaLfPtqn9ppIgjif7MdYg4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=NfN34gq6; arc=none smtp.client-ip=209.85.216.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="NfN34gq6" Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2efdaa02378so447707a91.1 for ; Fri, 24 Jan 2025 01:58:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1737712716; x=1738317516; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=QZxKjba6HTWFABaly4I6MxGfobohJauNd1R6JB0rLRg=; b=NfN34gq6ocg6H5q9aX72lfa55M6krjv3bcCtJBa/BzYL5Q7S2sd/EvJeJ2g3MdyrN9 3f/GCpRgykl8Gsv5e9fNaOXTCXzj4ohIfPnjt99WjMwOIdtaaM1iLVB+chQYYp4SSwDM k18uXqKlGKgR8R7wmununkeU+T5M60R2I58JCJ6AzQsc+JZC77ldrNzWBDNHRM7acJJ0 FmS5CjiZdpVtiO//cUJhF1sKducsiJTMf0k1toMHPTqNrXgIS4z6p9DYT7YwIX9n9ZHt D+tj7YuPGPUN4x2GO/bzrQTY7+U9EFaf2Idxp8wwltQmVVMgYyq0Tjz9gudpTceWoh/r rZ5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737712716; x=1738317516; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QZxKjba6HTWFABaly4I6MxGfobohJauNd1R6JB0rLRg=; b=VqMgdDh/mQf1/3j/QoREXx1CZQpMURu1HE9qztV/spxUJ2Qg8Z87huuzpxG5Tua7rM 4F8kVhE1dnWpjgnMhDBEWx5n9NKgeN8fePxGN0SLo/8L5ZS3I0yGUq+2/SwjzyMZngyV +8N3JxHm7hep9IoVbnNinJ6074CAFbmJYnVtg6vn2USn1bH8yRHqZqayfL894oYwxwEd F4KFMi5jCrSwY1XqhHMmIoe0w18ym9qpIaAGufZ4WnoCcGY3m9NBHZ40W2/P4QDvw3c2 BQRbpdykst2yfqIvM0qsX1E8jEVVPXoW2jxHTRc4xNgQEF0ARZIOIALYvwU5uTZkdCxh dcGQ== X-Forwarded-Encrypted: i=1; AJvYcCXrTMy36kqVXM95qS+xoF63bWGVzf3Lf7XjwzpXUSMVHcNBHDGSfhcvy9odElz5Z7taUSpqyYC7BsjHZfY=@vger.kernel.org X-Gm-Message-State: AOJu0Yxz2x9notefSOHJ6swBGpRxLKiDYzR49npJTb9wxXrGJ475q1nS TGw2tTYtrU6nBQQfdEKt2jfQ34jwNI3boy395Yv35t4zxVeGttqTQONiy3eBoz8= X-Gm-Gg: ASbGncuuYCy8GjXQ0x9/WzW/e88ucgzlyibRTmgBk1UiI0IvreIhSVvdaaIOCVduP7h qRAZHcEBbenX7qjFOSjjNC4F1IOK709ehyr3+brue16imAZ7XtsAVVIUpF1vq4hIXGKJaXSk/eJ y02hoEJrNI2PECwz+uNGS/O/vV1cgY8wsCfcDQniHm+tNUW1mPOV7QLwIIlu7EcPktO77fpG5o7 bmjUSf1/GivLChGlZPBcLZZ982vlcLybwZ54USVLvEvCqBzwyAQ4FS5d3cZh2wFW86PUwjo7Zoi y9c5H5DGVnkM/jjNlvGgI21BSPNndg== X-Google-Smtp-Source: AGHT+IHtYalRAVyxBUhTBsy5Jn95iocNFeyYPN3yZIod2dqOmdZ06kSOSS2mzh+YdMEduLvhnG7BLA== X-Received: by 2002:a17:90b:6c4:b0:2ee:cbc9:d50b with SMTP id 98e67ed59e1d1-2f782d35946mr16117328a91.4.1737712716429; Fri, 24 Jan 2025 01:58:36 -0800 (PST) Received: from [10.254.144.106] ([139.177.225.251]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f7ffac2807sm1246125a91.20.2025.01.24.01.58.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Jan 2025 01:58:35 -0800 (PST) Message-ID: Date: Fri, 24 Jan 2025 17:58:26 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/3] cgroup/rstat: Fix forceidle time in cpu.stat Content-Language: en-US To: =?UTF-8?Q?Michal_Koutn=C3=BD?= Cc: Tejun Heo , Johannes Weiner , Jonathan Corbet , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Thomas Gleixner , Yury Norov , Andrew Morton , Bitao Hu , Chen Ridong , "open list:CONTROL GROUP (CGROUP)" , "open list:DOCUMENTATION" , open list References: <20250123174713.25570-1-wuyun.abel@bytedance.com> <20250123174713.25570-2-wuyun.abel@bytedance.com> From: Abel Wu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 1/24/25 5:22 PM, Michal Koutný Wrote: > Hello. > > On Fri, Jan 24, 2025 at 01:47:01AM +0800, Abel Wu wrote: >> The commit b824766504e4 ("cgroup/rstat: add force idle show helper") >> retrieves forceidle_time outside cgroup_rstat_lock for non-root cgroups >> which can be potentially inconsistent with other stats. >> >> Rather than reverting that commit, fix it in a way that retains the >> effort of cleaning up the ifdef-messes. > > Sorry, I'm blind, where's the change moving wrt cgroup_rstat_lock? > (I only see unuse of root cgroup's bstat and a few renames). Hi Michal, The following hunk deleted the snapshot of cgrp->bstat.forceidle_sum: if (cgroup_parent(cgrp)) { cgroup_rstat_flush_hold(cgrp); usage = cgrp->bstat.cputime.sum_exec_runtime; cputime_adjust(&cgrp->bstat.cputime, &cgrp->prev_cputime, &utime, &stime); -#ifdef CONFIG_SCHED_CORE - forceidle_time = cgrp->bstat.forceidle_sum; -#endif cgroup_rstat_flush_release(cgrp); } else { and then read forceidle_sum from @cgrp directly outside of the lock, but its value can be changed in this window, so... -#ifdef CONFIG_SCHED_CORE - seq_printf(seq, "core_sched.force_idle_usec %llu\n", forceidle_time); -#endif + cgroup_force_idle_show(seq, &cgrp->bstat); } result in the inconsistence between forceidle and other cputimes. Best Regards, Abel