Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp287207ybl; Wed, 22 Jan 2020 21:40:17 -0800 (PST) X-Google-Smtp-Source: APXvYqzxnNRUuBgVLVPI5WFT0U7EFB2WGHO0MLh+aBDPp4aPl5bh7P7GFNItpH785DZCgV1XlJ1g X-Received: by 2002:a9d:21f4:: with SMTP id s107mr10499675otb.102.1579758017173; Wed, 22 Jan 2020 21:40:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579758017; cv=none; d=google.com; s=arc-20160816; b=F8msqr6EUMJIyXQEsFU/q/mNJAnn/IrLWJnrO5GNyFI608/Frj2c6HYZuDAisD89JO 5Xf+6iyXBKLlZaMWc/1F8QemyeLdKoJYcYsMDYHSHwcOxpL5L/WBMJaFteXtqDXYvqlW EwUKRYhYzCeCgytI0sm/l9RWIe/5SZ/y9Skf10N3VAZxNeWdt/xsLNrUcO7lNtG61tbX /77aU0817evDhE4Dz1tKMZ8PrXnH/LuZgXXyyG5Fq7sioRLuQYXC57LnylZUifL8EAnh EcloPryu33Aw/V8dFHw/RNX2voV72mP4X+a3IKbYExh2dHA6VsCszZB4CWD3WPH/qtTu rx0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=olcNFoFN1XXIUl/h/J5YSDSjEz+dlCu/0pWI28fy02Q=; b=FleZztzc2RW5wahcu9M9iBmXUTdmnp6NHlyoJdND/b9ExtVXhEQL06vgzsoZf9Wqe6 Br4PMsTbbE2OYJOqpPJG+a0EZqu1dP1mnTg3Ef3+gPzfHUG/5xIJgRBiO6ZqMF6U/0X3 RbhsE2dRGEwHwcMmFDSjQFTOhTdYqBI5lQpVyEZwSZ0Mi8Ny3rBt0EoYPav0go+M6SIb bjsYmcUWjLApqSf8JI4F5YTfMK4b4yLTwIwSXnT0w1z67Yf1W89U4+cT3zJu7ZBU9mTY gzCQ4vZ02G3GPrI8ChlaLrbl9UumXZwlNTlZ+fbZE6a01sXZ3q3u6yHlpsjSoEXZ27gh kIrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jUpnAm84; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a12si368998oie.87.2020.01.22.21.39.52; Wed, 22 Jan 2020 21:40:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jUpnAm84; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725955AbgAWFc4 (ORCPT + 99 others); Thu, 23 Jan 2020 00:32:56 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:36535 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725785AbgAWFc4 (ORCPT ); Thu, 23 Jan 2020 00:32:56 -0500 Received: by mail-pg1-f194.google.com with SMTP id k3so785871pgc.3 for ; Wed, 22 Jan 2020 21:32:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=olcNFoFN1XXIUl/h/J5YSDSjEz+dlCu/0pWI28fy02Q=; b=jUpnAm84r9pUqF9Xu8lwVDVPb4Q0SRJNzxeioAK4yHXPnfOFRa4nbDsIBTKpJcwpTw QDRaIHb/x/1Zyn4ln6/aVpRJkeEofXoM2wSl+O9ohWWiokIwMyN80801O1e0QUtEwe5K +Atis93gqDMRkvdkZual5xlzaxtqFqYsvFcieb9OJU/u0t17jjC+lX+8QlrR5bcYAZmL 2ESd1GLTk7Pe8jUBxGQXEDLgB153BNv63Kicx/zshBi27Q4b7QyYWxTtyYl5QqEbXxDZ uJ+F1NEM3dY+rCHfb/rTZYvfQ4lIMWr75mreOXm3PaYqdVmNfXQC6CweIH2AR5KYf9m4 1b6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=olcNFoFN1XXIUl/h/J5YSDSjEz+dlCu/0pWI28fy02Q=; b=PbDAZ45t/EpNcGnIFxcfpBw8FvyfveiLvMmNPLVAVAyrIQt4oqEn8KN7pIcBVgd7UH RchrfK/x157c8xEc5HNf4YYytos8HhfiyQRsXjW1fERa4CtFjRyWDjoMaJbb1ej6X2Ke rYqxODhQfBcSyP+kHTKvMBvykfyAlsfK3TnjExJyE/R2OqwNFuczgdfUFxxo0QfHH5h3 1IAzn/rDfUrkS7LDGpivXnURILpe6qgp68aTlkVEat0kP4xUBoS80ETDUg20ZWlXMqUh swbGSSnMiGVy1/XgWsfGi6w+4FuEH440MWPHBcE1p4QZqZN30tRXGC7DwoZSRE5qYjQc 7ngA== X-Gm-Message-State: APjAAAWy2MLQ342s/E9a/RZwCfG/t1cMluvePyF2vwCCQTnnsAKrrD24 vLgn36JSCB9JdUyZOVpN3cVyUOm4NPA= X-Received: by 2002:a63:447:: with SMTP id 68mr2206538pge.364.1579757574804; Wed, 22 Jan 2020 21:32:54 -0800 (PST) Received: from localhost ([122.167.18.14]) by smtp.gmail.com with ESMTPSA id j5sm772505pfn.180.2020.01.22.21.32.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jan 2020 21:32:53 -0800 (PST) Date: Thu, 23 Jan 2020 11:02:51 +0530 From: Viresh Kumar To: "Rafael J. Wysocki" Cc: Linux PM , LKML , Srinivas Pandruvada , Geert Uytterhoeven , kbuild test robot Subject: Re: [PATCH] cpufreq: Avoid creating excessively large stack frames Message-ID: <20200123053251.3j7muofewhfidplw@vireshk-i7> References: <2523300.pfpGjzY74h@kreacher> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2523300.pfpGjzY74h@kreacher> User-Agent: NeoMutt/20180716-391-311a52 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23-01-20, 00:16, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > In the process of modifying a cpufreq policy, the cpufreq core makes > a copy of it including all of the internals which is stored on the > CPU stack. Because struct cpufreq_policy is relatively large, this > may cause the size of the stack frame to exceed the 2 KB limit and > so the GCC complains when -Wframe-larger-than= is used. > > In fact, it is not necessary to copy the entire policy structure > in order to modify it, however. > > First, because cpufreq_set_policy() obtains the min and max policy > limits from frequency QoS now, it is not necessary to pass the limits > to it from the callers. The only things that need to be passed to it > from there are the new governor pointer or (if there is a built-in > governor in the driver) the "policy" value representing the governor > choice. They both can be passed as individual arguments, though, so > make cpufreq_set_policy() take them this way and rework its callers > accordingly. This avoids making copies of cpufreq policies in the > callers of cpufreq_set_policy(). > > Second, cpufreq_set_policy() still needs to pass the new policy > data to the ->verify() callback of the cpufreq driver whose task > is to sanitize the min and max policy limits. It still does not > need to make a full copy of struct cpufreq_policy for this purpose, > but it needs to pass a few items from it to the driver in case they > are needed (different drivers have different needs in that respect > and all of them have to be covered). For this reason, introduce > struct cpufreq_policy_data to hold copies of the members of > struct cpufreq_policy used by the existing ->verify() driver > callbacks and pass a pointer to a temporary structure of that > type to ->verify() (instead of passing a pointer to full struct > cpufreq_policy to it). > > While at it, notice that intel_pstate doesn't really need to verify > the "policy" value in struct cpufreq_policy, so drop that check from > it to avoid copying "policy" into struct cpufreq_policy_data (which > allows it to be slightly smaller). > > Also while at it fix up white space in a couple of places and make > cpufreq_set_policy() static (as it can be so). > > Fixes: 3000ce3c52f8 ("cpufreq: Use per-policy frequency QoS") > Link: https://lore.kernel.org/linux-pm/CAMuHMdX6-jb1W8uC2_237m8ctCpsnGp=JCxqt8pCWVqNXHmkVg@mail.gmail.com > Reported-by: kbuild test robot > Reported-by: Geert Uytterhoeven > Cc: 5.4+ # 5.4+ > Signed-off-by: Rafael J. Wysocki > --- > drivers/cpufreq/cppc_cpufreq.c | 2 > drivers/cpufreq/cpufreq-nforce2.c | 2 > drivers/cpufreq/cpufreq.c | 147 +++++++++++++++++-------------------- > drivers/cpufreq/freq_table.c | 4 - > drivers/cpufreq/gx-suspmod.c | 2 > drivers/cpufreq/intel_pstate.c | 38 ++++----- > drivers/cpufreq/longrun.c | 2 > drivers/cpufreq/pcc-cpufreq.c | 2 > drivers/cpufreq/sh-cpufreq.c | 2 > drivers/cpufreq/unicore2-cpufreq.c | 2 > include/linux/cpufreq.h | 32 +++++--- > 11 files changed, 119 insertions(+), 116 deletions(-) Acked-by: Viresh Kumar -- viresh