Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4289644rwd; Tue, 30 May 2023 03:20:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7iFWJh4ZIV7xVdo4ATNtFrniK9e4KIZ6CXks1j/qg9bi4aPY3rmOPcgju0OrPWEceZkBHV X-Received: by 2002:a17:902:724c:b0:1af:b9ed:1677 with SMTP id c12-20020a170902724c00b001afb9ed1677mr1707412pll.2.1685442040511; Tue, 30 May 2023 03:20:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685442040; cv=none; d=google.com; s=arc-20160816; b=CCceq/XcvnfmJS760IqAmdfYWxOSpHKi9UW+2SZjXwtuUCLDx2Xd6fPNw5NkIVdyK1 DyX7Ll7YwNScI0iD7VtK6zkdjOxxOGq9m04yFNME/8MVCpfGvCvhDOnV402Nted/TSIC lcGsaF2EKvHM8kbq5yB6nHMhlBcbjjBjX/WJdpS81pj6xg9CdUi0AmD6miFAcXlPSZxL YGuSz73AFZE4cATxYVY5xx4f+0nadUtFIniKJhhHqggX21Y1xwafUgiHTIK/GvL7t2BJ PlrymaGXjH5b7MxLVQdjMVg7/928giK0HEXmB0UncWS5RvXkLoLelJ56YX5i6+TK8SNK ScAw== 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=U9nVxJa7jmxwArTKBjPOtpkuBf01G13kQGfjclJcg9Q=; b=Y8TLF7DjsS5H9yH9AsJz68v1E6NwRAcdPaA///LlVH6mxXwyLd73n+A/NBOeV4Sn83 mbCtofUZbLgU4oTOeclGpNBQqRtsoidiieeXXVuMJrKifU8PTHXYHsu2Dr45YchJdN+I Qy0Xanb3dPjYMCOYj1Y1bU+E1d4r2XSNQUW2bAhdwUYfybYztCOsp9y0j+Ppyjc1jvfV 27um6o/vv1U+NOO+Y9kbWTWul82lF3RwDz2GA5AS1KPlfQpTp/kx/FIrTQQ9Rr3mh9mC rbV5T7LPy3KcQwLN3J4NgigsJGdQXopjTPANECvBNdGuWlcNruXXyfhY75BPScgPZd+J RZIw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y21-20020a1709027c9500b001b02d0941dfsi5412813pll.354.2023.05.30.03.20.25; Tue, 30 May 2023 03:20:40 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231303AbjE3KCS (ORCPT + 99 others); Tue, 30 May 2023 06:02:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230231AbjE3KCR (ORCPT ); Tue, 30 May 2023 06:02:17 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8F03293; Tue, 30 May 2023 03:02:15 -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 9C44EAB6; Tue, 30 May 2023 03:03:00 -0700 (PDT) Received: from [192.168.178.6] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1AC5F3F67D; Tue, 30 May 2023 03:02:12 -0700 (PDT) Message-ID: Date: Tue, 30 May 2023 12:02:11 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v2 09/17] PM: EM: Add RCU mechanism which safely cleans the old data Content-Language: en-US To: Lukasz Luba , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rafael@kernel.org Cc: 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, Pierre.Gondois@arm.com, ionela.voinescu@arm.com, rostedt@goodmis.org, mhiramat@kernel.org References: <20230512095743.3393563-1-lukasz.luba@arm.com> <20230512095743.3393563-10-lukasz.luba@arm.com> From: Dietmar Eggemann In-Reply-To: <20230512095743.3393563-10-lukasz.luba@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 12/05/2023 11:57, Lukasz Luba wrote: > The EM is going to support runtime modifications of the power data. > In order to achieve that prepare the internal mechanism. This patch > introduces RCU safe mechanism to clean up the old allocated EM data. s/In order to achieve that prepare the internal mechanism. This patch introduces/Introduce ... much shorter, same information. [...] > +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); > + > + if (trace_em_perf_state_enabled()) { > + unsigned long freq, power, cost, flags; > + int i; > + > + for (i = 0; i < pd->nr_perf_states; i++) { > + freq = runtime_table->state[i].frequency; > + power = runtime_table->state[i].power; > + cost = runtime_table->state[i].cost; > + flags = runtime_table->state[i].flags; > + > + trace_em_perf_state(dev_name(dev), pd->nr_perf_states, > + i, freq, power, cost, flags); > + } > + } > + > + /* > + * Check if the 'state' array is not actually the one from setup. > + * If it is then don't free it. > + */ > + if (tmp->state == pd->table) It's unfortunate that you have the refactoring in 13/17 which would lead to: if (pd->runtime_table>state == pd->default_table->state) ^^^^^^^^^^^^^ ^^^^^^^^^^^^^ so people would immediately grasp one of the core concepts of the design: non-modifiable default_table and modifiable runtime_table. I still belief that it would be the better idea to do the refactoring first. [...]