Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp317755imn; Thu, 4 Aug 2022 07:09:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR7KgO/m84usYoX7AxizGCP4ebqocnZlxEKfir+BM5aikh49kr0UKkKgapjhacX7e/KTEa51 X-Received: by 2002:a17:906:9bdd:b0:730:5b04:7298 with SMTP id de29-20020a1709069bdd00b007305b047298mr1666601ejc.180.1659622179206; Thu, 04 Aug 2022 07:09:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659622179; cv=none; d=google.com; s=arc-20160816; b=y2FrwdGoEy9sFj2HG6hDUC56oa0YseIK/PYp4B9lIpnUa4MnM1X147bDtITXXj2jMo WPQoh/FSmZw01Xk9Q5Nd9abkGyclVFd6nKAKL7wwJZD/kT59jTs7M80wXnSxBAU+djRB oWtxMJS9RdUmecvThankRHMmPXyHNBBxPVM7UDn1XbsmdsC0FTJhmcSp/fjiCYQJfaC/ S+0OR3Bv+qZur3Up4AztJ830mUH1qQR5+OXulHAR23ydgONTn9Z6WkURFmqVgMyp0Vx2 u7my66aG4qRwbdwlA/sbmcYCAPkkG750UOIp2jJjf/MEKdFUGYDi9k8lQzFFgxy9PldX wOfQ== 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=zD3BFnts15iHCWRPhU8Gog+NmQ8cf5xvVsVfiuX4De0=; b=dSde83rYA2C/IJW7cCpDDByQlG2L+cCetO+51/rf62qCpWFwS7HOZK2hmVNeNlyhnO v+K60bAc6XqqgVAieq66bdnzAvRRrz9Jpuad16bTbxDEllvYPeAwX1rnS/xvI06dJcaT o53zmSptemH9YwI6pcIv0gjtJhnpPNo3ZbgvCva4CTXvzEWOK3duyGSPViPL4djan46d Ee5xbESEuBIpVX/VLu4TceGvEw4IXgXkEaksnwhg8ReLKt1zc9SXMh3SI7Z0PRGh7RCV pQJJ8TiutbQ9O5Rsp9pdv72qBZLHQ37EVFt+FrkfYhyTe3i2xZSY9YfY0GCczuALPu9y 71xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=b4Os43C6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w8-20020a05640234c800b0043bb9f01aaesi1516324edc.335.2022.08.04.07.09.14; Thu, 04 Aug 2022 07:09:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=b4Os43C6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240002AbiHDNvs (ORCPT + 99 others); Thu, 4 Aug 2022 09:51:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240004AbiHDNvk (ORCPT ); Thu, 4 Aug 2022 09:51:40 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 301BA6423 for ; Thu, 4 Aug 2022 06:51:39 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id q7-20020a17090a7a8700b001f300db8677so5675267pjf.5 for ; Thu, 04 Aug 2022 06:51:39 -0700 (PDT) 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=zD3BFnts15iHCWRPhU8Gog+NmQ8cf5xvVsVfiuX4De0=; b=b4Os43C6zAFVcQDrf81Rv4I14peZHBpxPHbuzw/tn6Xt6vcEPzx/MDxvcsgBz/k3pF Ud8rYDGlvKEV5xE1EAgv/vECXgT+weHHFj4avDCpDfGGk+sO8n5NbivCvkI7W1sfveYO oS/F/KV7FWRRJ0hciFdksYAl/U8a1lBHE1NJuq1BN9ivJlmF0p6bCNALwXr44pQHbmgy o3y3sA2IpTktoadQBylIQavSHbDuu3ZbBrK304Dfjq70B4f4D5QlUj893p/iYWz9Pf0A pxq/q2tQVM+E91JOPQOoy7WwRQDTOJPMfnNjnqQuNyYuLzrvq0UBBf0x6V/TWeCVsRj6 S2Ig== 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=zD3BFnts15iHCWRPhU8Gog+NmQ8cf5xvVsVfiuX4De0=; b=6fThSTfEw0+xMnJLtsgQ8CNH9KTd4fK6oTkUTXpd/ymMYeQlAZ3gthQTwHad536dBS /3IxFzBKshuf9J7Je0+GhJEuiG6QtzB/jyw5zz/Fb7kE4ZDFniLpcuxjwVSFC06HRra0 ba2Y31tVMrwe8IrbRYyhtaoWESTGvIBLO220gdidlb/2exFNS7OSfJRKfakfUaRFNeun szN9lltcqcd2PqoCg3ATJACvtMgxaWdXMWXk9GJvcewTW1ONV0b/i3JMJ1av1ULANmNC UTIc61v0WOsQTASOK4E2HAcIwbirvgXVKPucZNxbTA0jPMLTp6JXryZJoRuZqLFpdH7d V+mQ== X-Gm-Message-State: ACgBeo2aBEt1cZogyhujRk6tYggdTXMmbkHw/8pAKJGwUTH9EahxDOJx GXCLT9zvK01MiJ5uBvI5eJ9riA== X-Received: by 2002:a17:90b:1e0f:b0:1f5:37f5:159c with SMTP id pg15-20020a17090b1e0f00b001f537f5159cmr2230830pjb.189.1659621098633; Thu, 04 Aug 2022 06:51:38 -0700 (PDT) Received: from [10.4.84.52] ([139.177.225.240]) by smtp.gmail.com with ESMTPSA id r7-20020a634407000000b0041c9a4001ebsm1154689pga.21.2022.08.04.06.51.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 04 Aug 2022 06:51:38 -0700 (PDT) Message-ID: Date: Thu, 4 Aug 2022 21:51:31 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.1.0 Subject: Re: [PATCH 8/9] sched/psi: add kernel cmdline parameter psi_inner_cgroup Content-Language: en-US To: Johannes Weiner , Tejun Heo Cc: surenb@google.com, mingo@redhat.com, peterz@infradead.org, corbet@lwn.net, akpm@linux-foundation.org, rdunlap@infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, songmuchun@bytedance.com, cgroups@vger.kernel.org References: <20220721040439.2651-1-zhouchengming@bytedance.com> <20220721040439.2651-9-zhouchengming@bytedance.com> <5a3410d6-428d-9ad1-3e5a-01ca805ceeeb@bytedance.com> From: Chengming Zhou In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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/8/4 03:22, Johannes Weiner wrote: > On Wed, Aug 03, 2022 at 07:58:27AM -1000, Tejun Heo wrote: >> Hello, >> >> On Wed, Aug 03, 2022 at 08:17:22PM +0800, Chengming Zhou wrote: >>>> Assuming the above isn't wrong, if we can figure out how we can re-enable >>>> it, which is more difficult as the counters need to be resynchronized with >>>> the current state, that'd be ideal. Then, we can just allow each cgroup to >>>> enable / disable PSI reporting dynamically as they see fit. >>> >>> This method is more fine-grained but more difficult like you said above. >>> I think it may meet most needs to disable PSI stats in intermediate cgroups? >> >> So, I'm not necessarily against implementing something easier but we at >> least wanna get the interface right, so that if we decide to do the full >> thing later we can easily expand on the existing interface. ie. let's please >> not be too hacky. I don't think it'd be that difficult to implement >> per-cgroup disable-only operation that we can later expand to allow >> re-enabling, right? > > It should be relatively straight-forward to disable and re-enable > state aggregation, time tracking, averaging on a per-cgroup level, if > we can live with losing history from while it was disabled. I.e. the > avgs will restart from 0, total= will have gaps - should be okay, IMO. > > Where it gets trickier is also stopping the tracking of task counts in > a cgroup. For re-enabling afterwards, we'd have to freeze scheduler > and cgroup state and find all tasks of interest across all CPUs for > the given cgroup to recreate the counts. I'm not quite sure whether > that's feasible, and if so, whether it's worth the savings. > > It might be good to benchmark the two disabling steps independently. > Maybe stopping aggregation while keeping task counts is good enough, > and we can commit to a disable/re-enable interface from the start. > > Or maybe it's all in the cachelines and iteration, and stopping the > aggregation while still writing task counts isn't saving much. In that > case we'd have to look closer at reconstructing task counts, to see if > later re-enabling is actually a practical option or whether a one-off > kill switch is more realistic. > > Chengming, can you experiment with disabling: record_times(), the > test_state() loop and state_mask construction, and the averaging > worker - while keeping the groupc->tasks updates? Hello, I did this experiment today with disabling record_times(), test_state() loop and averaging worker, while only keeping groupc->tasks[] updates, the results look promising. mmtests/config-scheduler-perfpipe on Intel Xeon Platinum with 3 levels of cgroup: perfpipe tip tip patched psi=off psi=on only groupc->tasks[] Min Time 7.99 ( 0.00%) 8.86 ( -10.95%) 8.31 ( -4.08%) 1st-qrtle Time 8.11 ( 0.00%) 8.94 ( -10.22%) 8.39 ( -3.46%) 2nd-qrtle Time 8.17 ( 0.00%) 9.02 ( -10.42%) 8.44 ( -3.37%) 3rd-qrtle Time 8.20 ( 0.00%) 9.08 ( -10.72%) 8.48 ( -3.43%) Max-1 Time 7.99 ( 0.00%) 8.86 ( -10.95%) 8.31 ( -4.08%) Max-5 Time 7.99 ( 0.00%) 8.86 ( -10.95%) 8.31 ( -4.08%) Max-10 Time 8.09 ( 0.00%) 8.89 ( -9.96%) 8.35 ( -3.22%) Max-90 Time 8.31 ( 0.00%) 9.13 ( -9.90%) 8.55 ( -2.95%) Max-95 Time 8.32 ( 0.00%) 9.14 ( -9.88%) 8.55 ( -2.81%) Max-99 Time 8.39 ( 0.00%) 9.26 ( -10.30%) 8.57 ( -2.09%) Max Time 8.56 ( 0.00%) 9.26 ( -8.23%) 8.72 ( -1.90%) Amean Time 8.19 ( 0.00%) 9.03 * -10.26%* 8.45 * -3.27%* Tejun suggested using a bitmap in task to remember whether the task is accounted at a given level or not, which I think also is a very good idea, but I haven't clearly figure out how to do it. The above performance test result looks good to me, so I think we can implement this per-cgroup "cgroup.psi" interface to disable/re-enable PSI stats from the start, and we can change to a better implementation if needed later? Thanks!