Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp83387pxh; Tue, 9 Nov 2021 21:41:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJzA6NB0RitdGyRNEVuUqH2K9B2X3NC53MPJHzyQv3wscp/MOGoKr8Z3WTCUsH1HKv8ObEFe X-Received: by 2002:a05:6402:5190:: with SMTP id q16mr18224273edd.123.1636522864589; Tue, 09 Nov 2021 21:41:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636522864; cv=none; d=google.com; s=arc-20160816; b=TCE4I0XHoDb57oUcZkKN5rg1/onRlXr6Uoh5YiF5ePIh575wKDsttFMnme7aV/MWT0 ya+0iLfIyIQNQRXGFEARoQJx00ZqCGCVSti9jwKR6teW99ElH3sGugvDEdZywlUnUc5f KAGaqMJ9yByQHN5d4/oZtR2zGsyFpcQ7aQ8ko2hJ07/AWaJkChnxplDl9m4HzCVXVbvy JJWfP+LcytmDy/NZX/raKtWbCORXGajG+Rlvn4hMH7wG5yKqwIkgVUG/3RbTzZUj+dhF 489gxP4YCjOyK4ZspgOgn2L8IN1p4nMZM7REGia6IsB6YQrKDVVD/snTd5dbhcZvLMGh 1G6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=+zcX1ef8v4+GqxdMyQ+IPlbHORR9ZeSP0Dh2u9Ax2y8=; b=y3AoodDpsgDSmEJxnADu4yEkN9A/juxqXNrtqFJNHxQdZljj73PbgJCjGPFIMzHyVz np6zBgwQTtYXds4MAzJunarYbedV/t5mftu3KKt1bepWLTFS0kQ3XSg1zcil1wztwnBy MIWhQRUYmf6IptazOl0hi4emdUnCTYCQNpUPOu04YQbdkXj7Rvma1PrvKduqz8yFVz2P kIn5BjXvCjjrfWvuQgzqS9TXTILgxOXq9cfVUiOHBRjqF9aHd/Nit/jDGmSo0BtvInPx g1Os6RuSlc1NvZoQoNWKmBJw7TSlENgT4IF4VZCydAW/h3BOQcSpi7nLdc3BNGvDnUPe EjAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FgO26LrT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o16si47590538edc.582.2021.11.09.21.40.40; Tue, 09 Nov 2021 21:41:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FgO26LrT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229903AbhKJFjt (ORCPT + 99 others); Wed, 10 Nov 2021 00:39:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229710AbhKJFjq (ORCPT ); Wed, 10 Nov 2021 00:39:46 -0500 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88195C061767 for ; Tue, 9 Nov 2021 21:36:59 -0800 (PST) Received: by mail-lf1-x12d.google.com with SMTP id y26so3117008lfa.11 for ; Tue, 09 Nov 2021 21:36:59 -0800 (PST) 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=+zcX1ef8v4+GqxdMyQ+IPlbHORR9ZeSP0Dh2u9Ax2y8=; b=FgO26LrTjzGM5BvVPfuHRSTAi5yDrSozFO4pxxHUmJ53mVGntZazCHpRVD+HkonMEj vBY9OU5mdGmEEksVtedcUpkHlrNgOSHnfy4K81OvC+WW5VS6F9xtKWVeL6737N+NpvXu yTmkVVPWCVsp200M4jwHQp9ooWSth1ncqFJu5HQeraGAiF0Hv8Ps9mTJGwRvGjf2IAOi 1F8sULnwbrCQapwRX/ne0E290otcQ/8z7zVxc14zUAr6rqp223fvnYaeuM3pWUlKN+Qz WNi9PFoI5Y9p3713rca3r0G0R498DsH/pprwYBpB35DRHJD6L71D2p6FSqwU8FJoGb/C zFlg== 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=+zcX1ef8v4+GqxdMyQ+IPlbHORR9ZeSP0Dh2u9Ax2y8=; b=Kk0AbK5kSfgDwhUTC56xPnYdQ1kJ7etj3PqxIUB9ubAeVj3kR7Qli/6DSIT/xSioXY rgDoTqbPVmf1MF0+bVGcFBKtiPJm3j9AJSQBxKFeY7PrsGVAAd2rnSBDZ08nY5Wqc6lm S+3ZE/Gc8ozF/LXKn/UwOhhliU5h2TlFOuZjn5UaTze8x9CvDkyPBrB0042Vs5X0qWzi C3IbuTghUV5/IwMhLgr49qNoJ3OPsryk3Zq2qSLJUuqe81G/qYxuzUOxmX4cLbYUVWvD Dp+hvDRINkkfv8jxKeWrBov+rLQwRz4DiQQB9vl2+eCFN/0lgNsE9vK/J0h+EsAL6vT+ rlWQ== X-Gm-Message-State: AOAM531vIVdttjxOlM4RaLOHEiDrjsjbUt2IYKeIpjHGELA20Py58oAo zYXU15gD55AI3EskkWe+jIdEAlGlaYUM5S4wvUejz83evnw= X-Received: by 2002:ac2:442e:: with SMTP id w14mr12548128lfl.577.1636522617826; Tue, 09 Nov 2021 21:36:57 -0800 (PST) MIME-Version: 1.0 References: <1634278612-17055-1-git-send-email-huangzhaoyang@gmail.com> <78b3f72b-3fe7-f2e0-0e6b-32f28b8ce777@arm.com> <85c81ab7-49ed-aba5-6221-ea6a8f37f8ad@arm.com> <05a2e61e-9c55-8f8d-5e72-9854613e53c9@arm.com> In-Reply-To: <05a2e61e-9c55-8f8d-5e72-9854613e53c9@arm.com> From: Xuewen Yan Date: Wed, 10 Nov 2021 13:36:45 +0800 Message-ID: Subject: Re: [Resend PATCH] psi : calc cfs task memstall time more precisely To: Dietmar Eggemann Cc: Zhaoyang Huang , Johannes Weiner , Andrew Morton , Michal Hocko , Vladimir Davydov , Zhaoyang Huang , "open list:MEMORY MANAGEMENT" , LKML , Peter Zijlstra , Vincent Guittot , xuewen.yan@unisoc.com, Ke Wang Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dietmar On Tue, Nov 9, 2021 at 5:43 PM Dietmar Eggemann wrote: > > On 08/11/2021 09:49, Xuewen Yan wrote: > > Hi Dietmar > > > > On Sat, Nov 6, 2021 at 1:20 AM Dietmar Eggemann > > wrote: > >> > >> On 05/11/2021 06:58, Zhaoyang Huang wrote: > >>>> I don't understand the EAS (probably asymmetric CPU capacity is meant > >>>> here) angle of the story. Pressure on CPU capacity which is usable for > >>>> CFS happens on SMP as well? > >>> Mentioning EAS here mainly about RT tasks preempting small CFS tasks > >>> (big CFS tasks could be scheduled to big core), which would introduce > >>> more proportion of preempted time within PSI_MEM_STALL than SMP does. > >> > >> What's your CPU layout? Do you have the little before the big CPUs? Like > >> Hikey 960? > > [...] > > >> And I guess rt class prefers lower CPU numbers hence you see this? > >> > > our CPU layout is: > > xuewen.yan:/ # cat /sys/devices/system/cpu/cpu*/cpu_capacity > > 544 > > 544 > > 544 > > 544 > > 544 > > 544 > > 1024 > > 1024 > > > > And in our platform, we use the kernel in mobile phones with Android. > > And we prefer power, so we prefer the RT class to run on little cores. > > Ah, OK, out-of-tree extensions. > > [...] > > >>>>>>>> + 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); > >>>>>>>> + > >>>> > >>>> We do this slightly different in scale_rt_capacity() [fair.c]: > >>>> > >>>> max = arch_scale_cpu_capacity(cpu_of(rq) /* instead of 1024 to support > >>>> asymmetric CPU capacity */ > >>> Is it possible that the SUM of rqs' util_avg large than > >>> arch_scale_cpu_capacity because of task migration things? > >> > >> I assume you meant if the rq (cpu_rq(CPUx)) util_avg sum (CFS, RT, DL, > >> IRQ and thermal part) can be larger than arch_scale_cpu_capacity(CPUx)? > >> > >> Yes it can. > >> > >> Have a lock at > >> > >> effective_cpu_util(..., max, ...) { > >> > >> if (foo >= max) > >> return max; > >> > >> } > >> > >> Even the CFS part (cpu_rq(CPUx)->cfs.avg.util_avg) can be larger than > >> the original cpu capacity (rq->cpu_capacity_orig). > >> > >> Have a look at cpu_util(). capacity_orig_of(CPUx) and > >> arch_scale_cpu_capacity(CPUx) both returning rq->cpu_capacity_orig. > >> > > > > Well, your means is we should not use the 1024 and should use the > > original cpu capacity? > > And maybe use the "sched_cpu_util()" is a good choice just like this: > > > > + if (current->in_memstall) > > + growth_fixed = div64_ul(cpu_util_cfs(rq) * growth, > > sched_cpu_util(rq->cpu, capacity_orig_of(rq->cpu))); > > Not sure about this. In case util_cfs=0 you would get scale=0. Yes , we should consider it. In addition, it also should be considered when util_cfs > capacity_orig because of the UTIL_EST...... > > IMHO, you need > > cap = rq->cpu_capacity > cap_orig = rq->cpu_capacity_orig > > scale = (cap * X) / cap_orig > > or if the update of these rq values happens to infrequently for you then > you have to calc the pressure evey time. Something like: > > pressure = cpu_util_rt(rq) + cpu_util_dl(rq) > > irq = cpu_util_irq(rq) > > if (irq >= cap_orig) > pressure = cap_orig > else > pressure = scale_irq_capacity(pressure, irq, cap_orig) > pressure += irq > > scale = ((cap_orig - pressure) * X) / cap_orig Why rescale the util there, the sched_cpu_util() would invoke the effective_cpu_util(), and I don't think it's necessary to rescale it. Thanks!