From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750905AbdHRETu (ORCPT ); Fri, 18 Aug 2017 00:19:50 -0400 Received: from mail-pg0-f41.google.com ([74.125.83.41]:37391 "EHLO mail-pg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750718AbdHRETs (ORCPT ); Fri, 18 Aug 2017 00:19:48 -0400 Date: Fri, 18 Aug 2017 09:49:44 +0530 From: Viresh Kumar To: "Rafael J. Wysocki" Cc: Srinivas Pandruvada , Len Brown , Ingo Molnar , Peter Zijlstra , linux-pm@vger.kernel.org, Vincent Guittot , linux-kernel@vger.kernel.org Subject: Re: [PATCH] cpufreq: Don't send callback pointer to cpufreq_add_update_util_hook() Message-ID: <20170818041944.GH24299@vireshk-i7> References: <2692371.TLU4a4PDeX@aspire.rjw.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2692371.TLU4a4PDeX@aspire.rjw.lan> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17-08-17, 17:31, Rafael J. Wysocki wrote: > On Thursday, August 17, 2017 2:04:48 PM CEST Viresh Kumar wrote: > > The callers already have the structure (struct update_util_data) where > > the function pointer is saved by cpufreq_add_update_util_hook(). And its > > better if the callers fill it themselves, as they can do it from the > > governor->init() callback then, which is called only once per policy > > lifetime rather than doing it from governor->start which can get called > > multiple times. > > So what problem exactly is this addressing? Its not fixing any problem really, but is rather just a cleanup patch. I had a look at include/linux/sched/cpufreq.h and got confused for a moment: struct update_util_data { void (*func)(struct update_util_data *data, u64 time, unsigned int flags); }; void cpufreq_add_update_util_hook(int cpu, struct update_util_data *data, void (*func)(struct update_util_data *data, u64 time, unsigned int flags)); It wasn't quite straight-forward to understand why we needed to pass both "data" and "func", while "data" should already have "func" set within it. And then I realized that cpufreq_add_update_util_hook() is actually setting that field. Filling the pointer from the callers is probably better because: - It makes it more readable. - We have to pass one less argument and the function prototype becomes quite short. - The callers don't have to set the data->func pointer from the governor->start() callback now and can do it only once from governor->init(). ->start(), stop() callbacks can get called a lot, for example with CPU hotplug. But yeah, its all trivial stuff. No big problem solved. -- viresh