Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp220131rdb; Fri, 6 Oct 2023 01:03:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH4RpVlsnnOMmdBWlz6Jxmws/UGY88RiffydmMuQbxGECzo3k9DhqHqnHd7IMoSD8uo60Ff X-Received: by 2002:a17:903:246:b0:1c0:b84d:3f73 with SMTP id j6-20020a170903024600b001c0b84d3f73mr8397625plh.53.1696579401986; Fri, 06 Oct 2023 01:03:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696579401; cv=none; d=google.com; s=arc-20160816; b=hw9pC6o7zlLMNUSlicEV4KUXYuk80ZRor91htKzawL0JChONX3SCKGRs4gV1wmzA6A TiKXtEs3rOAPJ38maLk+ZF9eDO9i6gbCw17EQjJAZL3X1IrJ/kn4OJYRpQD4LB6vaHTo 1q1plYhry8jfQ/xUbUa8c76NQG9UtKq22YJ1AZjz5OkxBTlS8WhvWI8EX3jxs8yGv760 jXH3pLRi3763AuPRaa3Z02TjfFhgSFK39jlLeVW9g3IF+VdsOD/Bsz5XVP1FIG0ONMG4 QmunbHThdWuEyPXagog3yK8NfoXnUMzvs9Hnf/kS68xlpyt/5KHfcbc6+3NCOuq5eGXY jh8g== 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=aaQy+ewPjLF+d68HiRHmjzRyfJT0It/mEfioXyKWnO4=; fh=Sntd+G0CthFoKfHeh5KAtcEJMuc35jsG6LFomUCRudQ=; b=Ppjy6lHQNah8cxxUeJP2wqYY5YOPv0nk5zqoHoPy6PMYidhUgTA49VPTq+qGj1UukG vqO4ouEfbgWUAuDUTJU5J+g7PDHyD2/e+hNHv4aeFgiW4Z2nSVjaGz2vM+lGTYeoDFUX glcj6fEp6Ze08OjKT658HjvKdPtFJg33U4W5AzvAbKcxGY9f/WcZYnscmtEEBAql7wuD UiL46XmGqbeWUxgT96Nw8H+mXYDngpGtUGk9UiEgOYWWdqjKvNxHR+oDbyfbNtQEnvDa uxUpOZZpaChJRjahaVdybrZXHgBO0M0Z17lNMwJZZdzGIINbjBCBqOaiLOSpouQvsBsp P0Ug== 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:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id km15-20020a17090327cf00b001bdd0d0530dsi3004524plb.129.2023.10.06.01.03.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 01:03:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 45E358035344; Fri, 6 Oct 2023 01:03:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230447AbjJFIDI (ORCPT + 99 others); Fri, 6 Oct 2023 04:03:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230361AbjJFIDH (ORCPT ); Fri, 6 Oct 2023 04:03:07 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 762DECA; Fri, 6 Oct 2023 01:03:05 -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 46EE7C15; Fri, 6 Oct 2023 01:03:43 -0700 (PDT) Received: from [10.57.94.224] (unknown [10.57.94.224]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 04E863F762; Fri, 6 Oct 2023 01:03:01 -0700 (PDT) Message-ID: Date: Fri, 6 Oct 2023 09:03:44 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH v4 09/18] PM: EM: Introduce runtime modifiable table Content-Language: en-US To: "Rafael J. Wysocki" Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, dietmar.eggemann@arm.com, rui.zhang@intel.com, amit.kucheria@verdurent.com, amit.kachhap@gmail.com, daniel.lezcano@linaro.org, viresh.kumar@linaro.org, len.brown@intel.com, pavel@ucw.cz, mhiramat@kernel.org, qyousef@layalina.io, wvw@google.com References: <20230925081139.1305766-1-lukasz.luba@arm.com> <20230925081139.1305766-10-lukasz.luba@arm.com> From: Lukasz Luba In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.0 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 agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 06 Oct 2023 01:03:19 -0700 (PDT) On 9/29/23 13:27, Rafael J. Wysocki wrote: > On Fri, Sep 29, 2023 at 11:15 AM Lukasz Luba wrote: >> >> [snip] >>>> em_debug_remove_pd(dev); >>>> >>>> + runtime_table = pd->runtime_table; >>>> + >>>> + rcu_assign_pointer(pd->runtime_table, NULL); >>>> + synchronize_rcu(); >>> >>> Is it really a good idea to call this under a mutex? >> >> This is the unregistration of the EM code path, so a thermal >> driver which gets some IRQs might not be aware that the EM >> is going to vanish. That's why those two code paths: update >> & unregister are protected with the same lock. >> >> This synchronize_rcu() won't be long, > > Are you sure? This potentially waits for all of the CPUs in the > system to go through a quiescent state which may take a while in > principle. > > In any case, though, this effectively makes everyone waiting for the > mutex also wait for the grace period to elapse and they may not care > about it. My apologies for the delay, I had to check this. Yes, should be possible and safe to not wait here as you described on this synchronize_rcu(). What I have drawn in other response to patch 11/18 [1] should still be true. Thanks, I will remove this sync call from here. > >> but makes sure that when we free(dev->em_pd) we don't leak runtime_table. >> >>> >>>> + >>>> kfree(pd->default_table->state); >>>> kfree(pd->default_table); >>>> kfree(dev->em_pd); >>>> + >>> >>> Unrelated change. >> >> ACK >> >>> >>>> dev->em_pd = NULL; >>>> mutex_unlock(&em_pd_mutex); >>>> } >>>> -- >>> >>> So this really adds a pointer to a table that can be dynamically >>> updated to struct em_perf_domain without any users so far. It is not >>> used anywhere as of this patch AFAICS, which is not what the changelog >>> is saying. >> >> Good catch. I will adjust the changlog in header and say: >> >> 'Add infrastructure and mechanisms for the new runtime table. >> The runtime modifiable EM data is used by the Energy Aware Scheduler >> (EAS)for the task placement. > > I would make it more clear that this is going to happen after some > other subsequent changes. > OK, I will add that information too. [1] https://lore.kernel.org/lkml/91d6e9be-d50c-d157-55a0-79134cbd01fb@arm.com/