Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2318320rdb; Thu, 21 Sep 2023 15:18:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEDoOsG49w+WaDCRwNJsMxT0j9adTHz5OOjkaRPfFMaPuE7EKdlS74i4bIv9yIz/HxR2Zuk X-Received: by 2002:a05:6a20:5494:b0:14d:d9f8:83f8 with SMTP id i20-20020a056a20549400b0014dd9f883f8mr7730452pzk.1.1695334714724; Thu, 21 Sep 2023 15:18:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695334714; cv=none; d=google.com; s=arc-20160816; b=BbPuYF8dhWtqxV8CIcKROo2UEBvjH1pGT/DC3w3tKJOZkWG3LIv4bqnN+vu3r71tna AIqKferJwGAbt36ZHKifa0f449V82kuLC00/5229lkDgxeVCs8lGdcuS48sZfONGOywm wwma8e+SxdI7Y81nmR5h3yTr3jlR8qAbs3zGFaBwYWJtKW58O+o8f9H6/hs48Pav+7r6 hBT6QSgSYbmqkBODxKA16soEQRbw6tbJbiQPlU9N1eU7BLJ9qgqbC6MIv4y2RTu8E+o5 LLpovnWzWNpKkvn4VLJiBUIcdhI1zGyC5+I6CGbURcxYgaqtOGYL3mboYkyaRKu6Webk GrsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=oOvdW4rjq4rF0bAG64OmSLZEwP/8xU8SDSkVWspDfzo=; fh=mtVr4Bu7MiKINjDS2Oamkdc5YaS/LSSkF2mW8aGq/wk=; b=OpoQ1ivC0GJO+y4Sy0uiawjD60WNYELqQpxHV3491BKufQIpdTUkhUQbN5NcAZpJgC 8abrOE59ZV4/0Oak6osJwAThf3QMtvG9WJu1LusZwoCtAt3NztjEldTnYk4V3fieINl9 /X8M+vUD7Pqz53Pwm/kE4lkQokTJrM/hPfb8qeXgWGbrlutXQUTtYm7CDmnx4B2JnXkn dvrw4l4Vqq/tL1Z1EPpffFY0K1/Fu6LtlP9461JLTvqHegILjWIdoCCFgAkbtdvkz3Ol 6ygZVsX2vpkJApCenSfNPRFhT+Zc6WFF3pCidn6TWHv857v7kizfEASS9vh/Mp3kZ6s/ TJXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id n11-20020a170902e54b00b001c5d1016b37si2480632plf.587.2023.09.21.15.18.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 15:18:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id C503E837CF03; Thu, 21 Sep 2023 15:13:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230072AbjIUWNX (ORCPT + 99 others); Thu, 21 Sep 2023 18:13:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233071AbjIUWNF (ORCPT ); Thu, 21 Sep 2023 18:13:05 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D9256658F; Thu, 21 Sep 2023 15:04:35 -0700 (PDT) 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 7FBADDA7; Thu, 21 Sep 2023 15:05:12 -0700 (PDT) Received: from [192.168.178.106] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 47E6C3F59C; Thu, 21 Sep 2023 15:04:34 -0700 (PDT) Message-ID: <0f486d81-ec0f-22f0-a7cd-942da3288d6e@arm.com> Date: Fri, 22 Sep 2023 00:04:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] cpufreq: Rebuild sched-domains when removing cpufreq driver Content-Language: en-US To: Shrikanth Hegde , Pierre Gondois Cc: vschneid@redhat.com, "Rafael J. Wysocki" , Viresh Kumar , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230918112937.493352-1-pierre.gondois@arm.com> <0b3c7c1b-9905-cded-dc86-17296a10152a@linux.vnet.ibm.com> From: Dietmar Eggemann In-Reply-To: <0b3c7c1b-9905-cded-dc86-17296a10152a@linux.vnet.ibm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,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 morse.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 (morse.vger.email [0.0.0.0]); Thu, 21 Sep 2023 15:13:25 -0700 (PDT) On 20/09/2023 07:29, Shrikanth Hegde wrote: > > On 9/19/23 1:19 PM, Pierre Gondois wrote: >> >> On 9/19/23 01:03, Dietmar Eggemann wrote: >>> On 18/09/2023 13:29, Pierre Gondois wrote: [...] >>> Rebuilding SDs when inserting the driver is already covered by >>> >>>    cpufreq_online() >>>      cpufreq_set_policy() >>>        sched_cpufreq_governor_change() >>>          if (old or new gov eq. schedutil) >>>            schedule_work(&rebuild_sd_work) >>> >>> So what's missing is only a sched_cpufreq_governor_change() call when >>> removing the driver, right? >> >> Yes exact, removing a cpufreq driver (e.g. `rmmod cppc_cpufreq.ko`) goes >> through: >> cpufreq_remove_dev() >> \-__cpufreq_offline() >> >> so the path you mentioned is not used in this case. But IMHO the name of sched_cpufreq_governor_change() is now misleading when called from the driver removal path. It's not the governor which has changed. We want to disable EAS when unloading the driver in (3): ... if (!arch_scale_freq_invariant()) { if (sched_debug()) { pr_warn("rd %*pbl: Disabling EAS: frequency-invariant load tracking not yet supported", cpumask_pr_args(cpu_map)); } goto free; } ... > One Doubt, while looking through code. Not well versed with this area. > > cpuhp_cpufreq_offline is being registered with CPU hotplug. That ends up > calling cpufreq_offline. This may cause non desired issues. > 1. rebuild of sched domains twice instead, once by CPU hotplug and once by this. That's possible when you CPU hp out the last CPU of a policy (or Perf Domain (PD). Otherwise `cpuhp_cpufreq_offline -> cpufreq_offline() -> __cpufreq_offline()` returns early in `if (!policy_is_inactive(policy))` condition. partition_sched_domains_locked() does: (1) detach_destroy_domains() (2) build_sched_domains() (3) build_perf_domains() But only the first workqueue event (from cpuset_hotplug_workfn or rebuild_sd_workfn) will rebuild Sched Domains and PDs (1)-(3), the second one will only build PDs (3) again. That's not nice but AFAICS it is not functional incorrect. > 2. offline/online of CPU (non-SMT) may not disabling EAS. Can't see this issue right now. When we offline the last CPU of a PD on a 2 PD system, EAS should be stopped since the root domain does not have any asymmetric CPU capacities left and when we online it again, EAS should be started (sched_energy_set()).