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 X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6A48C433EF for ; Mon, 13 Sep 2021 01:12:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 55A046108C for ; Mon, 13 Sep 2021 01:12:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 55A046108C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id A6C146B0071; Sun, 12 Sep 2021 21:12:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A1B7C6B0072; Sun, 12 Sep 2021 21:12:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 90AC56B0073; Sun, 12 Sep 2021 21:12:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0215.hostedemail.com [216.40.44.215]) by kanga.kvack.org (Postfix) with ESMTP id 83FDC6B0071 for ; Sun, 12 Sep 2021 21:12:06 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 04E5E181AF5D3 for ; Mon, 13 Sep 2021 01:12:06 +0000 (UTC) X-FDA: 78580773852.30.53AD844 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) by imf27.hostedemail.com (Postfix) with ESMTP id A9194700009B for ; Mon, 13 Sep 2021 01:12:05 +0000 (UTC) Received: by mail-qk1-f180.google.com with SMTP id c10so8827980qko.11 for ; Sun, 12 Sep 2021 18:12:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=iEhRnE237B8QIVkmLvgcJTZVLxORa61csCgWecGhzwM=; b=ia70fbHiwFCeLKoe47VV4reDo/3CyaqW4Vi8QiBFK2RVC5YTWpoxw3gNPYe+9NgctY O+zdLj3x0PelNrAh2EBsWuuLDbopCa0djRVKOwFfksbRgKXFE1tdfRZre0wA0BXKRfks rrNMmNhQKKjmaNtccCfjOOcQERuQmb6pXCEzIqsjh+821MytWYU4pB8GlJ8kdQbXcofR tGuCLfPuP2qLbxWlh/+gPozXuOPNFEAy+kj5GcQvQLWhvjrxBimdpuu0i94o5dS8nQF7 61eIdV5KD1u5s14pHuW9pYdPO1u3RZRSu0lVFGrkqGQbjI/Ns/n3doX1sI0neeAOx/PX Zh5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=iEhRnE237B8QIVkmLvgcJTZVLxORa61csCgWecGhzwM=; b=PzW/J0vwMtOzj9fNjFheVNO0G+FcCZVeeL1SojWdTFtaBtCHcIbRb/rFmKUYaZGWQR Wki+4krwOajjlbVkPdjp6BooDLLGwS0elKC8PhCCvTn3SgRbPU4WzMn7b5MCtkY3qK4y fgCbLyaAhKsHGXLWaTLpv42iNtXkOK1E8sNUphzv0u3MMMwO8walhI3Nq1WzyVEBctZo ERtJvrKzK73wwoiwG+yo8czbYWpgfWPMyYJwEg+PfS81/DScMPiL/cJCWE8+YLe6Fi6J RIDo/ixrNVF/Ts5i7gxSBO3Y7cVyxJ6aLrKB5oBHkEVvDnRb1BgSAHBFNfSiuDGjoDCB EiBQ== X-Gm-Message-State: AOAM532AbXvQdIJaQ9fIarEanktoqzfVovK0gnOqc0+KApMlLdkV9M9w uH9lt4dsw+WH+3fULmixQxmpl7c/bGkLtqAGDA8= X-Google-Smtp-Source: ABdhPJwJuBjlIRnQWbvztYg/upXFj4Ihzvs9ktMMMSN0kTNh/YbFt0XlCcHCBmMbhs+IXwGfQ3EcxDbcJM3/R3IQXks= X-Received: by 2002:ae9:dd43:: with SMTP id r64mr7719816qkf.225.1631495525100; Sun, 12 Sep 2021 18:12:05 -0700 (PDT) MIME-Version: 1.0 References: <1631260486-6735-1-git-send-email-huangzhaoyang@gmail.com> In-Reply-To: From: Zhaoyang Huang Date: Mon, 13 Sep 2021 09:11:44 +0800 Message-ID: Subject: Re: [PATCH] psi : calc cfs task memstall time more precisely To: Johannes Weiner Cc: Zhaoyang Huang , "open list:MEMORY MANAGEMENT" , LKML , xuewen.yan@unisoc.com, Ke Wang Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: A9194700009B X-Stat-Signature: wtasmcdjhtpcghekfpfq37gqyn3ahc9t Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ia70fbHi; spf=pass (imf27.hostedemail.com: domain of huangzhaoyang@gmail.com designates 209.85.222.180 as permitted sender) smtp.mailfrom=huangzhaoyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1631495525-628353 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Sorry for the confusion. Actually, it is a new design which has taken previous advice into consideration. I agree that part of the off cpu time among the memstall time should be counted in, whereas, the preempted time by high priority tasks should NOT be, including RT,DEADLINE,IRQS time on cfs task. On Fri, Sep 10, 2021 at 9:16 PM Johannes Weiner wrote: > > Please don't send new revisions without replying to previous feedback. > > On Fri, Sep 10, 2021 at 03:54:46PM +0800, Huangzhaoyang wrote: > > From: Zhaoyang Huang > > > > cfs task's memstall time is counted as simple as exit - entry so far, which > > ignore the preempted time by rt, dl and irq time. Eliminating them by calc the > > time growth via the proportion of cfs_rq's utilization on the whole rq. > > > > eg. > > Here is the scenario which this commit want to fix, that is the rt and irq consume > > some utilization of the whole rq. This scenario could be typical in a core > > which is assigned to deal with all irqs. Furthermore, the rt task used to run on > > little core under EAS. > > > > Binder:305_3-314 [002] d..1 257.880195: psi_memtime_fixup: original:30616,adjusted:25951,se:89,cfs:353,rt:139,dl:0,irq:18 > > droid.phone-1525 [001] d..1 265.145492: psi_memtime_fixup: original:61616,adjusted:53492,se:55,cfs:225,rt:121,dl:0,irq:15 > > > > Signed-off-by: Zhaoyang Huang > > --- > > kernel/sched/psi.c | 20 +++++++++++++++++++- > > 1 file changed, 19 insertions(+), 1 deletion(-) > > > > diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c > > index cc25a3c..754a836 100644 > > --- a/kernel/sched/psi.c > > +++ b/kernel/sched/psi.c > > @@ -182,6 +182,8 @@ struct psi_group psi_system = { > > > > static void psi_avgs_work(struct work_struct *work); > > > > +static unsigned long psi_memtime_fixup(u32 growth); > > + > > static void group_init(struct psi_group *group) > > { > > int cpu; > > @@ -492,6 +494,21 @@ static u64 window_update(struct psi_window *win, u64 now, u64 value) > > return growth; > > } > > > > +static unsigned long psi_memtime_fixup(u32 growth) > > +{ > > + struct rq *rq = task_rq(current); > > + unsigned long growth_fixed = (unsigned long)growth; > > + > > + if (!(current->policy == SCHED_NORMAL || current->policy == SCHED_BATCH)) > > + return growth_fixed; > > + > > + if (current->in_memstall) > > + growth_fixed = div64_ul((1024 - rq->avg_rt.util_avg - rq->avg_dl.util_avg > > + - rq->avg_irq.util_avg + 1) * growth, 1024); > > + > > + return growth_fixed; > > +} > > + > > static void init_triggers(struct psi_group *group, u64 now) > > { > > struct psi_trigger *t; > > @@ -658,6 +675,7 @@ static void record_times(struct psi_group_cpu *groupc, u64 now) > > } > > > > if (groupc->state_mask & (1 << PSI_MEM_SOME)) { > > + delta = psi_memtime_fixup(delta); > > groupc->times[PSI_MEM_SOME] += delta; > > if (groupc->state_mask & (1 << PSI_MEM_FULL)) > > groupc->times[PSI_MEM_FULL] += delta; > > @@ -928,8 +946,8 @@ void psi_memstall_leave(unsigned long *flags) > > */ > > rq = this_rq_lock_irq(&rf); > > > > - current->in_memstall = 0; > > psi_task_change(current, TSK_MEMSTALL, 0); > > + current->in_memstall = 0; > > > > rq_unlock_irq(rq, &rf); > > } > > -- > > 1.9.1 > >