Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1340077rdb; Mon, 2 Oct 2023 06:50:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF06shtkXlgbAFrlVgnTKoks5Lb5JpQu4PzcUfVA2DJkSWz/ML28av8kgbIQKhuZQM3s91g X-Received: by 2002:a05:6e02:ee7:b0:34f:1e9c:45d5 with SMTP id j7-20020a056e020ee700b0034f1e9c45d5mr11016106ilk.32.1696254657705; Mon, 02 Oct 2023 06:50:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696254657; cv=none; d=google.com; s=arc-20160816; b=npH0nPWS3cDVvCEIrsZhJcTK11lA5N5MkwsiPbWwlLUxz16rSXV+mOk8lwdibOjYl5 Z3baBAHg5FB1U+g/lH06keZ9KQ6tboLpJkHa1ytbfxl+mJ16ANdE7X8HXHaVoqZyRps5 yxWcMg1qpf+n7UKDt16xORqGK4KKR32PNiD+W0lADNJTZ6TLINbw/OFEBCPQPdyr1n87 7znGhGsH2JGuZJtMA9x/emvtUVBaXjpdw//X7nknNjHA88bCpke09W7aY2LfWquJJ/yt Iw5n5T1hJiVwvUfiOrUtBr49kGrJo9EvYtgluzCUeJVyvMHcyHLYRDkmezCwvMMRJ1b6 SRcg== 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 :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=jHQyKpKlEblXMpS5MRtqNKnIl+bcExO8UfBE9Yxjizo=; fh=Sntd+G0CthFoKfHeh5KAtcEJMuc35jsG6LFomUCRudQ=; b=X/tIH4xwMFLdwpbfMyxLHQ9ToISd4fpS8sGil5Qu+StfJZtq/PJv+0Jmzg5WIe6z6A 6XQURiyvN+ia5mdtP1sFYxo2dZD7VQ3WrL3uGwIV6yczuIbCVZjOwjCVCpCjRUUKqOzE K5L6E3+44agB+b7/9TLTJyid0SUyQ00Fcz5ME5wjbh5xgm4xP1+SBlRM44g0Km9JbXZm P73IE96GJIur3wsPd1GvrpRJDc6bNw89QWs9Jf+JdjqiTI3VAcUjXznP1D3TPNqMlDbs Dl5KAMdodK+w06NdBs76icUAf29wN09AKg0HfTejrxXnbCWhOctwMNp2+wIGxlzn+ohX sg3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id b13-20020a63d80d000000b0056a36f9eb0esi15992884pgh.15.2023.10.02.06.50.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 06:50:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 70A9480C0A69; Mon, 2 Oct 2023 06:43:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237475AbjJBNna (ORCPT + 99 others); Mon, 2 Oct 2023 09:43:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237476AbjJBNn3 (ORCPT ); Mon, 2 Oct 2023 09:43:29 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 46CC4B0; Mon, 2 Oct 2023 06:43:26 -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 70AD2C15; Mon, 2 Oct 2023 06:44:04 -0700 (PDT) Received: from [10.57.93.204] (unknown [10.57.93.204]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CD7653F59C; Mon, 2 Oct 2023 06:43:23 -0700 (PDT) Message-ID: <57078a6b-83bc-d558-1071-be23d213a56f@arm.com> Date: Mon, 2 Oct 2023 14:44:05 +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 10/18] PM: EM: Add RCU mechanism which safely cleans the old data 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-11-lukasz.luba@arm.com> Content-Language: en-US From: Lukasz Luba In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 02 Oct 2023 06:43:48 -0700 (PDT) On 9/29/23 13:59, Rafael J. Wysocki wrote: > On Fri, Sep 29, 2023 at 11:36 AM Lukasz Luba wrote: [snip] >> We had a few internal reviews and there were voices where saying that >> it's better to have 2 identical tables: 'default_table' and >> 'runtime_table' to make sure it's visible everywhere when it's used. >> That made the need to actually have also the 'state' table inside. >> I don't see it as a big problem, though. > > What I'm trying to say is that you can allocate runtime_table along > with the table pointed to by its state field in one invocation of > kzalloc() (say). > > Having just one memory region to free eventually instead of two of > them would help to avoid some complexity, especially in the next > patch. I think, I know what you mean, basically: ------------------------------ struct em_perf_table { struct rcu_head rcu; struct em_perf_state state[]; } kzalloc(sizeof(struct em_perf_table) + N * sizeof(struct em_perf_state)) ------ IMO that should also be OK in the rest of places. I agree the alloc/free code would be smaller. Let me do that than. > >>> >>>> +} >>>> + >>>> +static void em_perf_runtime_table_set(struct device *dev, >>>> + struct em_perf_table *runtime_table) >>>> +{ >>>> + struct em_perf_domain *pd = dev->em_pd; >>>> + struct em_perf_table *tmp; >>>> + >>>> + tmp = pd->runtime_table; >>>> + >>>> + rcu_assign_pointer(pd->runtime_table, runtime_table); >>>> + >>>> + em_cpufreq_update_efficiencies(dev, runtime_table->state); >>>> + >>>> + /* Don't free default table since it's used by other frameworks. */ >>> >>> Apparently, some frameworks are only going to use the default table >>> while the runtime-updatable table will be used somewhere else at the >>> same time. >>> >>> I'm not really sure if this is a good idea. >> >> Runtime table is only for driving the task placement in the EAS. >> >> The thermal gov IPA won't make better decisions because it already >> has the mechanism to accumulate the error that it made. >> >> The same applies to DTPM, which works in a more 'configurable' way, >> rather that hard optimization mechanism (like EAS). > > My understanding of the above is that the other EM users don't really > care that much so they can get away with using the default table all > the time, but EAS needs more accuracy, so the table used by it needs > to be adjusted in certain situations. Yes > > Fair enough, I'm assuming that you've done some research around it. > Still, this is rather confusing. Yes, I have presented those ~2y ago in Android Gerrit world (got feedback from a few vendors) and in a few Linux conferences. For now we don't plan to have this feature for the thermal governor or something similar. > >>> >>>> + if (tmp != pd->default_table) >>>> + call_rcu(&tmp->rcu, em_destroy_rt_table_rcu); >> >> The em_destroy_rt_table_rcu() is used here ^^^^^^