Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2224990pxm; Fri, 4 Mar 2022 11:47:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwWgBe35FbKY0vvl+MktuZq39zL+Zt/p4RB7mUOesIkZzel004kBOKliRQvJwJQNXxFrMzb X-Received: by 2002:a05:6a00:c90:b0:4bd:22a:bb1d with SMTP id a16-20020a056a000c9000b004bd022abb1dmr58305pfv.32.1646423226242; Fri, 04 Mar 2022 11:47:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646423226; cv=none; d=google.com; s=arc-20160816; b=X7/FwwjAZ7j2MMHXpzh+CjB7f0pxYtKBrBt6HtHjivCqd3x24FmzikszDqQhXHkSEg x8b+QbnQmYd4qsR1YnxUFoDN5pSdblDs/ow3gBNSLPxTowb5EhygvGDuHl3iEBZPJCj6 CScvnxY1Cp2EP3Z4ebRhXWen2UYmALbwycr6nB+CCQpyhaWAW5Q+hcf43e5yRx9GTaHh AVBR1LAfVMMJMYYkV4o2UNOXO9xnMriLkd4rsgjaInFYQMwduTwdqV1XJ0HeHs/Tjyp/ 5+knMGOKQ7COr5faeH+xUT6JAITCMf1T/8agvNpma6G51cKLAB6LHcHNtQxbimT4FUP3 KvUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=Ze2fqoG8Uv2ivOdemEby3h5mEqMYX8ZelC0Z+W02JsY=; b=nVW6LOtA0ZkBMq8gT2NKc/9OvaEh6wey8zCkpPeUAd3AfBAJN3a39SPCN1TFK8ochm crPpLS78Qm5hnwnQtDjEzb1p/SeY5OyfKTR8/RDwNM2Fy2JcZZm7OG/UcoGipKe2wDQk s/1hcojzOQ2nEUEWLy5dMzNodM3g4NRht5RGncdIQFn3ZlK6gueexfESyj5UsJ4moaeq n7KxeQl8kA6oBVl/AD/E18oIns23oPDJSuUcdHXmFWndnFSZXf0HcEkdVvrBnd54phKy Lm5me6+oRg1IVtpEt1Y8MkFPU1tMNzahrEHXl+NQOJxfYagY6MWiMUj6AZhlF1KbDA6C jgZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=MByDOnLK; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id c2-20020a655a82000000b003632fc0b6c0si5436135pgt.744.2022.03.04.11.47.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 11:47:06 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=MByDOnLK; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3C2827C789; Fri, 4 Mar 2022 11:18:18 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239920AbiCDOoC (ORCPT + 99 others); Fri, 4 Mar 2022 09:44:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239904AbiCDOoB (ORCPT ); Fri, 4 Mar 2022 09:44:01 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 818511BD072 for ; Fri, 4 Mar 2022 06:43:12 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id p3-20020a17090a680300b001bbfb9d760eso10771600pjj.2 for ; Fri, 04 Mar 2022 06:43:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=Ze2fqoG8Uv2ivOdemEby3h5mEqMYX8ZelC0Z+W02JsY=; b=MByDOnLKlFXdAZczHK4WVBzn4RAn6PAHsHIoSaVTs0Hd0A9DZT3CFOy2QmicB40p5j DyQT2LZiwFafH9eamIKEoh0PuIFAkMzhGsEHPz3VgijVEDjImTUWNn3mozIJp4QgnY27 276pkjtyHVm1SQY0FstynGu5/6sB0ML6eFEtcWccIgrlTJHhr8TTnrm4LfEwgtOXealL tD1WrPbWEc8eDFGMgCY2rjJHVFUyEXMnHWQuv9H1xvDQ4rCi08c2njHZ26qCI5CR6mCM +zHqtbNTXi6AzslQtMfQr4syff73Alj+suX1drdIzowGvnnE7J1T6oyNxdn0W2Uqs2O6 vPBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=Ze2fqoG8Uv2ivOdemEby3h5mEqMYX8ZelC0Z+W02JsY=; b=IFHsmeOBUql+LyEAy60bEJX0J+vdxp6RUwQKYfaScvqsvPc1coNpMNrSp2cy0PDf0W HokcRuN+lpYU7vm1iJC2mz6Ki+0BlM+uZ4N+OMql111w3u475mCUkqZakRSaVQWswJDy /DaxTT1iaE2S+UYTBnSDgSGTb4ughVtbMF8M8YK0Am2CJ9ldCat5UEqvq6163WPqIqo4 muFvQz+77Y/s3JQz6LMdJmIhmanom7L3S2r7SJd8cfgQkd6iTfRM71EfHr9q+88I1Iwb KPWlxEXol6L9Hyi5g7taqaqQekbdws3R79Rs8+o8FS4hTFjeHFpQGCIIrAueJm7LTDZe TSHA== X-Gm-Message-State: AOAM5318Y4TdQMH7e7FmgIVHBKiIH65HoSEN/63E+kmyIHQyScFRJtuV nBDecBctClgEVbJBYypCRU49cw== X-Received: by 2002:a17:90a:a887:b0:1bc:388a:329f with SMTP id h7-20020a17090aa88700b001bc388a329fmr11106568pjq.17.1646404991696; Fri, 04 Mar 2022 06:43:11 -0800 (PST) Received: from ?IPV6:2409:8a28:e6d:cc00:d089:89fd:5c33:f12? ([2409:8a28:e6d:cc00:d089:89fd:5c33:f12]) by smtp.gmail.com with ESMTPSA id s21-20020a056a00195500b004f65b15b3a0sm6169814pfk.8.2022.03.04.06.43.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Mar 2022 06:43:11 -0800 (PST) Message-ID: Date: Fri, 4 Mar 2022 22:43:01 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [External] Re: [PATCH] psi: remove CPU full metric at system level Content-Language: en-US To: Johannes Weiner Cc: corbet@lwn.net, mingo@redhat.com, peterz@infradead.org, surenb@google.com, ebiggers@google.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, songmuchun@bytedance.com, Martin Steigerwald References: <20220303055814.93057-1-zhouchengming@bytedance.com> From: Chengming Zhou In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/3/3 9:26 下午, Johannes Weiner wrote: > On Thu, Mar 03, 2022 at 01:58:14PM +0800, Chengming Zhou wrote: >> Martin find it confusing when look at the /proc/pressure/cpu output, >> and found no hint about that CPU "full" line in psi Documentation. >> >> % cat /proc/pressure/cpu >> some avg10=0.92 avg60=0.91 avg300=0.73 total=933490489 >> full avg10=0.22 avg60=0.23 avg300=0.16 total=358783277 >> >> The PSI_CPU_FULL state is introduced by commit e7fcd7622823 >> ("psi: Add PSI_CPU_FULL state"), which mainly for cgroup level, >> but also counted at the system level as a side effect. >> >> Naturally, the FULL state doesn't exist for the CPU resource at >> the system level. These "full" numbers can come from CPU idle >> schedule latency. For example, t1 is the time when task wakeup >> on an idle CPU, t2 is the time when CPU pick and switch to it. >> The delta of (t2 - t1) will be in CPU_FULL state. >> >> Another case all processes can be stalled is when all cgroups >> have been throttled at the same time, which unlikely to happen. >> >> Anyway, CPU_FULL metric is meaningless and confusing at the >> system level. So this patch removed CPU full metric at the >> system level, and removed it's monitor function too. The psi >> Documentation has also been updated accordingly. >> >> Fixes: e7fcd7622823 ("psi: Add PSI_CPU_FULL state") >> Reported-by: Martin Steigerwald >> Signed-off-by: Chengming Zhou >> --- >> Documentation/accounting/psi.rst | 18 +++++++++++++++--- >> kernel/sched/psi.c | 10 +++++++++- >> 2 files changed, 24 insertions(+), 4 deletions(-) >> >> diff --git a/Documentation/accounting/psi.rst b/Documentation/accounting/psi.rst >> index 860fe651d645..519652c06d7d 100644 >> --- a/Documentation/accounting/psi.rst >> +++ b/Documentation/accounting/psi.rst >> @@ -178,8 +178,20 @@ Cgroup2 interface >> In a system with a CONFIG_CGROUP=y kernel and the cgroup2 filesystem >> mounted, pressure stall information is also tracked for tasks grouped >> into cgroups. Each subdirectory in the cgroupfs mountpoint contains >> -cpu.pressure, memory.pressure, and io.pressure files; the format is >> -the same as the /proc/pressure/ files. >> +cpu.pressure, memory.pressure, and io.pressure files; the format of >> +memory.pressure and io.pressure is the same as the /proc/pressure/ files. >> + >> +But the format of cpu.pressure is as such:: >> + some avg10=0.00 avg60=0.00 avg300=0.00 total=0 >> + full avg10=0.00 avg60=0.00 avg300=0.00 total=0 > > It's the format of cpu.pressure, except when it's > /sys/fs/cgroup/cpu.pressure... I think this is getting maybe a tad too > difficult to write parsers for. Plus, we added the line over a year > ago so we might break somebody by removing it again. > > How about reporting zeroes at the system level? Ok, it's really better for userspace parsers, will change to this way and send later. Thanks. > > diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c > index e14358178849..86824de404bc 100644 > --- a/kernel/sched/psi.c > +++ b/kernel/sched/psi.c > @@ -1062,14 +1062,17 @@ int psi_show(struct seq_file *m, struct psi_group *group, enum psi_res res) > mutex_unlock(&group->avgs_lock); > > for (full = 0; full < 2; full++) { > - unsigned long avg[3]; > - u64 total; > + unsigned long avg[3] = { 0, }; > + u64 total = 0; > int w; > > - for (w = 0; w < 3; w++) > - avg[w] = group->avg[res * 2 + full][w]; > - total = div_u64(group->total[PSI_AVGS][res * 2 + full], > - NSEC_PER_USEC); > + /* CPU FULL is undefined at the system level */ > + if (!(group == &psi_system && res == PSI_CPU && full)) { > + for (w = 0; w < 3; w++) > + avg[w] = group->avg[res * 2 + full][w]; > + total = div_u64(group->total[PSI_AVGS][res * 2 + full], > + NSEC_PER_USEC); > + } > > seq_printf(m, "%s avg10=%lu.%02lu avg60=%lu.%02lu avg300=%lu.%02lu total=%llu\n", > full ? "full" : "some",