Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5395732rdb; Sat, 16 Sep 2023 15:35:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF1LpYMk1eV8ft7w6vp63vK1Nx2l714x5B6lpUHiQz8kH2F66odooMQz2S1Ijmye/g1eyR+ X-Received: by 2002:a17:90a:6e04:b0:268:1b60:5031 with SMTP id b4-20020a17090a6e0400b002681b605031mr4269732pjk.12.1694903716974; Sat, 16 Sep 2023 15:35:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694903716; cv=none; d=google.com; s=arc-20160816; b=BuFOspZp70wl/7R9tCcuuAYceDpE+nG4chwtSVHmwfROMUMCsYXQ/R+tlS0RcireRQ 6Po8kcEJzWvV12wDkAy4uAPTy9PhFyO1Fpon/1acOUDl1BGQp8+42DA+Qf64W8XgLA9f 8cTBsQQNYYzJg9AOZ9G2EzcG0F2mLN/79G1m8Kqrb+NutZj22NL3BWSc0foRWgfBiKIC txy/IioBYZZmAQQP6DBMeEErMYNwLuVgn66zmMjd5Kg+9mX7VPY9BKrWTH1xS4xRzJHk lC19Fnk5pNNcIDmz00NRO8EN8DlIY83aalbSmkLRSeAWGLtt9b2gASRYIIQGGEahP7SV 0g4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YemuLAkzZ3mwS+fKbYUx0+x9FMVINu37w9byNNYEGG4=; fh=rsWP5efm/MCkpaAvJLHch/VXRHcZ2mOg66v/XHlSLLo=; b=U800dXg3alWrfxodXnHgOE3/ZV3s3hsHpvHmV79Z2H91rZqVsqjfcaul1SQhgiadM/ aDvFs33QGqdENParMjSsh+LD+VN5In7abWNsRGZc8ciKfXVywR7kBShP+ELu7zDjD8Ne rBhZ7lu3SS+5wPtmLx1c/Y8lN1adiunlni/3W9oGwzNBntf851TUeM1eqANsX74sOrqG qMV8xdibxXbm4e1toRI7q9M01bzsZT2W33rqmRl2onax9TcroKbd6sxjkFzAP9oZX78B qHXmu8CB9EVnnhX3yLBJaoCEnZpBTE+hGijkbM5EM4fZAagsVmyuYt23JqHG0EulZU2J nLfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=SZmRlQSw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id az16-20020a17090b029000b0026f292ea34dsi7517650pjb.69.2023.09.16.15.35.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 15:35:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=SZmRlQSw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id C7FA58086825; Sat, 16 Sep 2023 12:26:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238414AbjIPTZi (ORCPT + 99 others); Sat, 16 Sep 2023 15:25:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236500AbjIPTZS (ORCPT ); Sat, 16 Sep 2023 15:25:18 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9114139 for ; Sat, 16 Sep 2023 12:25:12 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-31c5c06e8bbso3057882f8f.1 for ; Sat, 16 Sep 2023 12:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1694892311; x=1695497111; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=YemuLAkzZ3mwS+fKbYUx0+x9FMVINu37w9byNNYEGG4=; b=SZmRlQSw8lHgDamtJo31qQUNjwJXNnvvu+2ZwlyXUo1fneAwRHsaxxjuxAKvnZez1P IEGyDIpZD6MuzAXN75Xrxthk14Y/Y7MSvVGonhWOEtQtgyL4L07WuWJh0oLcPGNIuyCV PdosSY5owA4lo7lL7gS+OOuyrS3fv7ZyssPcVD9Dh6RVPb3YgeF4P7CpXhXjL219BK6L t587mm6XKGaY+xk8VE+/HvsJo1L4QRPSZg84pbK9PSLD+jtkoV3SXZapNdFULK8CZU4e X1V6ycKYscQ+gYMY50OZzlXFj0gAPxh3KV2n8lM0jF1phRMmOOS6V7tnlW+oNzH22ejo IRPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694892311; x=1695497111; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YemuLAkzZ3mwS+fKbYUx0+x9FMVINu37w9byNNYEGG4=; b=Mtp5gRDwzrSIYfkgDXZ/h90XmZXj33OofaO/SdSsgwYbXv8efpcOCJXbQwx1vZYpgD P7Z7KZzt1OwFuUF7wvldYGFpp9fvOIX/uV0LHKdq5WiHqmSznCEV/sQe7fCi7Z6dwugn oUwI8mffVyaNEoFMT/LnMV5AkKXQnCVaO5TB/oGLBwrcsOE2Onhs3sj912ZFBbiPK3tq MdWkUyJIA7k0UsPZ3ReQtKbUJNGXCEH2zh/oTP94VvpNhnDjBAuYG54tdFd4ghhQkUT/ NNHD74NAtNuZVFZ7phInuOilPhnLsGs+WhHbOyLPk/9gKApVVJtZScE/cDSPiUhaQ66k hgkw== X-Gm-Message-State: AOJu0YxdxgGQthQ31u3CGLO29FnlpNzrmV1Y9CWo1UEdMivBkDjZxqp6 IU6HRGFmZmxTehkfZDtxcJ/rHw== X-Received: by 2002:a05:6000:1549:b0:320:a4e:acf8 with SMTP id 9-20020a056000154900b003200a4eacf8mr303880wry.48.1694892311265; Sat, 16 Sep 2023 12:25:11 -0700 (PDT) Received: from airbuntu (host109-151-228-137.range109-151.btcentralplus.com. [109.151.228.137]) by smtp.gmail.com with ESMTPSA id n9-20020adfe789000000b003180fdf5589sm3500322wrm.6.2023.09.16.12.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 12:25:10 -0700 (PDT) Date: Sat, 16 Sep 2023 20:25:09 +0100 From: Qais Yousef To: Vincent Guittot Cc: "Rafael J. Wysocki" , Viresh Kumar , Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Dietmar Eggemann , Lukasz Luba Subject: Re: [PATCH 2/4] sched: cpufreq: Fix apply_dvfs_headroom() escaping uclamp constraints Message-ID: <20230916192509.bportepj7dbgp6ro@airbuntu> References: <20230820210640.585311-1-qyousef@layalina.io> <20230820210640.585311-3-qyousef@layalina.io> <20230829163740.uadhv2jfjuumqk3w@airbuntu> <20230907215555.exjxho34ntkjmn6r@airbuntu> <20230910174638.qe7jqq6mq36brh6o@airbuntu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sat, 16 Sep 2023 12:26:15 -0700 (PDT) On 09/12/23 18:03, Vincent Guittot wrote: > And it seems that what is done today doesn't work correctly for you. > Your proposal to include cpufreq headroom into the scheduler is not > correct IMO and it only applies for some cases. Then, the cpufreq > driver can have some really good reason to apply some headroom even > with an uclamp value but it can't make any decision. > > I think that we should use another way to fix your problem with how > uclamp than reordering how headroom is applied by cpufreq. Mixing > utilization and performance in one signal hide some differences that > cpufreq can make a good use of. > > As an example: > > cfs util = 650 > cfs uclamp = 800 > irq = 128 > > cfs with headroom 650*1.25=812 is clamped to 800 > > Final utilization will be : 800(1024-128)/1024+128*1.25=860 which is > above the target of 800. > > When we look at the detail, we have: > > cfs util once scaled to the full range is only 650(1024-128)/1024= 568 > > After applying irq (even with some headroom) 568+128*1.25 = 728 which > is below the uclamp of 800 so shouldn't we stay at 800 in this case ? Shouldn't it be (568+128)*1.25 = 870? Which is almost the 860 above. We calmped the 812 to 800, with rounding errors that almost accounts for the 10 points difference between 870 and 860.. I might have gotten the math wrong. But what I saw is that we have util = (X + Y + Z) * A and what I did util = AX + AY + AZ so maybe I missed something up, but I just did the multiplication with the headroom to each element individually rather than after the sum. So yeah, if I messed that part up, then that wasn't intentional and should be done differently. But I still can't see it. > > > > The main change being done here actually is to apply_dvfs_headroom() *before* > > doing uclamp_rq_util_with(). I am not sure how you see this mixing. > > Because dvfs_headroom is a cpufreq hints and you want to apply it > somewhere else. I am still not sure if you mean we are mixing up the code and we need better abstraction or something else. Beside the abstraction problem, which I agree with, I can't see what I am mixing up yet :( Sorry I think I need more helping hand to see it. > > Current code performs apply_dvfs_headroom() *after*; which what causes the CPU > > to run at a performance level higher than rq->uclamp[UCLAMP_MAX]. > > > > It doesn't matter how many tasks on the rq, if rq->uclamp[UCLAMP_MAX] is set to > > 800, then the CPU should not vote to max (assuminig all other pressures are 0). > > You can't remove the irq pressure from the picture. If > rq->uclamp[UCLAMP_MAX] is set to 800 means that cpu must not go above > 800, it should apply also after taking into account other inputs. At > least up to some level as described in my example above I was trying to simplify to understand what you mean as I don't think I see the problem you're highlighting still. Thanks! -- Qais Yousef