Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp582871pxh; Tue, 9 Nov 2021 15:39:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJx8whtF3mzI5+IVp6LSZg0ZpJjkeeRVdZxOT9JoNNJbEQ2lJ3NJd9TGBUUvoWwkf8Ko7mo0 X-Received: by 2002:a05:6e02:b2a:: with SMTP id e10mr7833793ilu.186.1636501189232; Tue, 09 Nov 2021 15:39:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636501189; cv=none; d=google.com; s=arc-20160816; b=wUPPosC2psSN8oQOW2bAyePr2Th1Mixf5AFljtHr/B6LQ+EbVif2gtCol1kCa/WqNd guO8aSpdVW+/+X7OadxuJxlFfehFY8FXIazt9+4xUFlBv7iW9wpdgumaSvQKzJpGiW9b IltwORcUesm5oTT7+3l4YMwoR1UAx++2fWDoopyyu6hcT9kXzvRIV/SZ1n6Bau1WrtdO bi5IlOybOUOf5l5ItSj6LFeRAnu4lgAtW1LzjC4CYNrPsMr0ZxON+4EIJVfmKZSq0LSu bkGhlzS3KckN6h/u6Km0vH1Br5caPa6B3vbJ83j6f5C7PewsyiC57hqMgVt09BGz99ro HAVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=Gb5FcNRRX7tzq7jTRNnrg7FBS3w9AekabfwGs+6fwVQ=; b=DgDsLS2fo2nxVmIIZYictpm1ndCuPAEAJHahLkwTol6xTCAc57D+592OrZ56I5klIn tV73o2SP/TgMu6c8zg7KJp1jYzE0H14CYA4nRm/sXTi5yW3DFyYB1bIu3PPQwLBin9ay CcUVnulO+WWA+9JWOmgfPxErU4CoJB4hSeXIRyjQc6QZqMUsYsXsnC5iXjYswzOXUub/ E9fkeRWvQnpVVjcfWst8l54QJmhlLwtTiVF9JAZsTGYmVcH2UfdGxpbaue4Pt6M4aYiX V+H39T6M3e5TkqeNICCzQPsDu7KeWnrrbdjhXbUFpNvyiMhvA+l38VzIZKzb1THGDSOn o7yQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f25si4234285iox.8.2021.11.09.15.39.37; Tue, 09 Nov 2021 15:39:49 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242371AbhKIMcZ (ORCPT + 97 others); Tue, 9 Nov 2021 07:32:25 -0500 Received: from foss.arm.com ([217.140.110.172]:33146 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231250AbhKIMcZ (ORCPT ); Tue, 9 Nov 2021 07:32:25 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 188BDED1; Tue, 9 Nov 2021 04:29:39 -0800 (PST) Received: from [192.168.178.6] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 26B0F3F7F5; Tue, 9 Nov 2021 04:29:37 -0800 (PST) Subject: Re: [Resend PATCH] psi : calc cfs task memstall time more precisely To: Zhaoyang Huang , Xuewen Yan Cc: 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 References: <1634278612-17055-1-git-send-email-huangzhaoyang@gmail.com> <78b3f72b-3fe7-f2e0-0e6b-32f28b8ce777@arm.com> <85c81ab7-49ed-aba5-6221-ea6a8f37f8ad@arm.com> From: Dietmar Eggemann Message-ID: <25828616-1976-6e24-cd7d-a95b789f1bc0@arm.com> Date: Tue, 9 Nov 2021 13:29:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/11/2021 10:20, Zhaoyang Huang wrote: > On Mon, Nov 8, 2021 at 4:49 PM 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: [...] >>>>> This will let the idle task (swapper) pass. Is this indented? Or do you >>>>> want to only let CFS tasks (including SCHED_IDLE) pass? >>>> idle tasks will NOT call psi_memstall_xxx. We just want CFS tasks to >>>> scale the STALL time. >>> >>> Not sure I get this. >>> >>> __schedule() -> psi_sched_switch() -> psi_task_change() -> >>> psi_group_change() -> record_times() -> psi_memtime_fixup() >>> >>> is something else than calling psi_memstall_enter() or _leave()? >>> >>> IMHO, at least record_times() can be called with current equal >>> swapper/X. Or is it that PSI_MEM_SOME is never set for the idle task in >>> this callstack? I don't know the PSI internals. > According to my understanding, PSI_MEM_SOME represents the CORE's > state within which there is at least one task trapped in memstall > path(only counted in by calling PSI_MEMSTALL_ENTER). record_times is > responsible for collecting the delta time of the CORE since it start. > What we are doing is to make the delta time more precise. So idle task > is irrelevant for these. Coming back to the original snippet of the patch. static unsigned long psi_memtime_fixup(u32 growth) { if (!(current->policy == SCHED_NORMAL || current->policy == SCHED_BATCH)) return growth_fixed; With this condition: (1) you're not bailing when current is the idle task. It has policy equal 0 (SCHED_NORMAL) (2) But you're bailing for a SCHED_IDLE (CFS) task. I'm not sure that this is indented here? Since you want to do the scaling later based on whats left for CFS tasks from the CPU capacity my hunch is that you want to rather do: if (current->sched_class != &fair_sched_class) return growth_fixed; What's the possible sched classes of current in psi_memtime_fixup?