Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3538914rwb; Sat, 3 Dec 2022 06:34:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf7a9Ansbag/cqDydP30fTx5q6TpxgeJODEm6/8nNUFCANBO5q9sV81SDy5IfaELhq0C+Coo X-Received: by 2002:a17:902:ce82:b0:186:ed91:5086 with SMTP id f2-20020a170902ce8200b00186ed915086mr57406323plg.59.1670078061456; Sat, 03 Dec 2022 06:34:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670078061; cv=none; d=google.com; s=arc-20160816; b=a4P5pjADjNJ6M/hhMqncoTZj3nM8g5BgUCE0Bmb67l71iM0zdi0PaOPycnisgqwJ74 edvC3KtY/xscsUtFk2mmJgrh0xrEfvcavkcHVwcw8FU2OC47jr9H0m+cs9thTeRx398M R6jA45dkL8pLgQLmQYZ6XrlkYlnqzCYfyx9nxRIR6LEmFVNW+UGWvgRvzYUa3xcCogIy biFqsh7atDDZnPvNLR0ZcQ5kS8dFrTOPHKHu1NksHWm2+kNvngt1PDjt+6jvHDU2g4x7 41DomHgF9mt/ejM2TgarUWdv98PACoaJrfyVseL2FfOIXbEJY2U1cn2AtmW+KIvGF+20 JW3A== 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=8QjdvcBfpY62HjxgDg6d8xd9Ur3ryWmHVOJJHV4pl8o=; b=h1yf2khaEjVSCm0TY6d1LyuZ2gIL49Jzn2aZ+ZARhMKt6Lz9DliPXl0go3HmAb5U+Z Pxx+nkLvaS8hqQOV8f4/3dp1kYGqGrH5s+DYzoH+hNnyEATpr6y4bROars5DQ/9MVULI pVGCzW7IFtO+j+auYTa4eiAAZnhbNvNwEN/rxwsPrmsHXAni4Fea28x4xX42BT6a9TG7 pxXUoB97gH+7S+sZFGUDQcVfZ4ongisSwnvSi0/Snky2QQgbtAmGbzpu8CQvgCe2hJwm BrtdpYUjKQryxkqxIYz7kN3wCne/3Fv6uYqh59ZUOI8LxDPYZ+7ec3FxUqK3GFvjg0CY JbQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@layalina-io.20210112.gappssmtp.com header.s=20210112 header.b=i+YT32mw; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cp17-20020a056a00349100b00574b46d3b26si9877104pfb.334.2022.12.03.06.34.09; Sat, 03 Dec 2022 06:34:21 -0800 (PST) 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=@layalina-io.20210112.gappssmtp.com header.s=20210112 header.b=i+YT32mw; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229739AbiLCOcX (ORCPT + 83 others); Sat, 3 Dec 2022 09:32:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229698AbiLCOcV (ORCPT ); Sat, 3 Dec 2022 09:32:21 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B06920F69 for ; Sat, 3 Dec 2022 06:32:20 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id h10so2571829wrx.3 for ; Sat, 03 Dec 2022 06:32:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20210112.gappssmtp.com; s=20210112; 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=8QjdvcBfpY62HjxgDg6d8xd9Ur3ryWmHVOJJHV4pl8o=; b=i+YT32mwJOa7srtTEon4jLCGGthL7khqDRCB8hLwQKxDeqrwVBVqNpIFtF2q9DQUT7 d+dTN8UhbnJrjIAP4DD4mHBadMnss56aJM+4KpRbtUvOsTjtNp573o7Lmf91gp6NG4Yw Nwqu5+eAKl2EbUBs3BbURkpcX9895p5zPUhAQFQyQa7+UOLh7mGk7b0NZ1c+TynzTGr0 Bpz+qNlkhJWABWkwYcmcYM7Dimau0tgVa08RLmDYe3AWrBFtWNoOYyoi+SQMk8a8X+Yc +JKh9NMjWiJRinJxfH8GMen1SHxdk8t2/BSboLJe5QCaFdQM/PUaL4kwHEIdFgNa92Tk eT5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=8QjdvcBfpY62HjxgDg6d8xd9Ur3ryWmHVOJJHV4pl8o=; b=jCRnuoNVHFCuO+iXuRXN31LcDQWRJSKapBtNkrW2ip2JrINSRdFAPHEoWjp5RP+Oy+ j8HqfGxmMagzQt6H9Kwj7WX+q8DEZTYdXVLuqFSOGcXzF1u8pCVRO+Xh7n3VCFM9ggAz Zih/31//E6mAP3ut+y8Pru3+dypgXI2usfG1jgSDABbxULV+Y3kJwWNbHOWlCiGq5YlG t2EU9yVgNXPCxPNGlpbgt6/LfajWImZTFXO9kwuoX4UG++Lk4jbr5BgqwbpsU3t1a2/2 wMUmGeNyKVK3WNvTkzHWY9hOD7dWaTEt+bAJaKdz4O9810LC6g8ndaua4Xvdr5j0/76+ ydTw== X-Gm-Message-State: ANoB5plsxsuAjA70OyICiXpPAwK/ZG9LF3uHo6FxlBBisZ8XJy79Iuzb 7qq7rz/3ht+BSUM3xvDfLZhi3w== X-Received: by 2002:adf:ba87:0:b0:241:c471:72b4 with SMTP id p7-20020adfba87000000b00241c47172b4mr37412701wrg.238.1670077938687; Sat, 03 Dec 2022 06:32:18 -0800 (PST) Received: from airbuntu (host86-130-134-87.range86-130.btcentralplus.com. [86.130.134.87]) by smtp.gmail.com with ESMTPSA id c14-20020a05600c0a4e00b003cffd3c3d6csm11668898wmq.12.2022.12.03.06.32.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Dec 2022 06:32:18 -0800 (PST) Date: Sat, 3 Dec 2022 14:32:16 +0000 From: Qais Yousef To: "Rafael J. Wysocki" Cc: Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann , Viresh Kumar , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Lukasz Luba , Wei Wang , Xuewen Yan , Hank , Jonathan JMChen Subject: Re: [RFC PATCH 3/3] sched/fair: Traverse cpufreq policies to detect capacity inversion Message-ID: <20221203143216.oezd2u6dpxodpuc3@airbuntu> References: <20221127141742.1644023-1-qyousef@layalina.io> <20221127141742.1644023-4-qyousef@layalina.io> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 11/30/22 19:27, Rafael J. Wysocki wrote: > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > index 7c0dd57e562a..4bbbca85134b 100644 > > --- a/kernel/sched/fair.c > > +++ b/kernel/sched/fair.c > > @@ -8856,23 +8856,20 @@ static void update_cpu_capacity(struct sched_domain *sd, int cpu) > > * * Thermal pressure will impact all cpus in this perf domain > > * equally. > > */ > > - if (sched_energy_enabled()) { > > + if (static_branch_unlikely(&sched_asym_cpucapacity)) { > > unsigned long inv_cap = capacity_orig - thermal_load_avg(rq); > > - struct perf_domain *pd = rcu_dereference(rq->rd->pd); > > + struct cpufreq_policy *policy, __maybe_unused *policy_n; > > > > rq->cpu_capacity_inverted = 0; > > > > - SCHED_WARN_ON(!rcu_read_lock_held()); > > - > > - for (; pd; pd = pd->next) { > > - struct cpumask *pd_span = perf_domain_span(pd); > > + for_each_active_policy_safe(policy, policy_n) { > > 1. Is the "safe" part sufficient for protection against concurrent > deletion and freeing of list entries? cpufreq driver removal can do > that AFAICS. The freeing part is not safe probably. I need to research this more. Do you have issues against the exportation of this traversal in principle? Switching them to be RCU protected could be the best safe option, anything against that too? I might not end up needing that. I need to dig more. > 2. For a casual reader of this code it may not be clear why cpufreq > policies matter here. I'm looking for a way to traverse the list of capacities of the system and know their related CPUs. AFAICT this information already exists in the performance domains and cpufreq_policy. Performance domains are conditional to energy model and schedutil. So trying to switch to cpufreq_policy. Assuming this question wasn't a request to add a comment :-) Thanks! -- Qais Yousef