From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933486AbcHJVKI (ORCPT ); Wed, 10 Aug 2016 17:10:08 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:52965 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932295AbcHJVIk (ORCPT ); Wed, 10 Aug 2016 17:08:40 -0400 From: Arnd Bergmann To: Jisheng Zhang Cc: linux-arm-kernel@lists.infradead.org, linux@armlinux.org.uk, daniel.lezcano@linaro.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ARM: cpuidle: declare cpuidle_ops __read_mostly Date: Wed, 10 Aug 2016 12:47:21 +0200 Message-ID: <8191851.HcPOqTYLq8@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-31-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <20160810171926.44557e35@xhacker> References: <1470818997-808-1-git-send-email-jszhang@marvell.com> <2118361.tr3K3hSZxF@wuerfel> <20160810171926.44557e35@xhacker> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:HxddOGzlln4rr1Hq1rTO/IJL485OgPBcrvxdiJXub1o42SQ8g2N +gVEr5Yq+E1WtlfXMEGGMU1KaR3qpR53Ink+Q9UuSZKq3cculmBdmxBi30MhD7zOSq6OblG 6cEQz8Zu2jo/rMXc9Ox3u5ghkiTkWCRtZeCTW+Evj0SMLA/GKMJhNVhKcLTn9weCRlbfw2q pn2gL9ITLrpFFVKxGYx5g== X-UI-Out-Filterresults: notjunk:1;V01:K0:rLN0kU0rgnc=:emn6Cz3YbinSeDIS2Ej7Ad juVQbkQBYUsN5V1wi79f/cAI8f0JggDQbMlYGb2iaRKkjL58F9Q7faPA7r8TEIdux0xXedQiz Q1aSbiWdxihrWGYR2yhVEYjazZv94oH0qDxEjA4FWG/CJtOaUSXmk/f6GBNpjLRA7lwpxM4hv yHztzt29VFL2R+fBaM+aef/Xo2hBwa+bAVxjdffSiFMX+1O+bH7maslwImzEixSdCGhE91KBv MDZQAJL3EMmGyn6nhkHQPjnBdMp7Uke+EQWfCDONitBb+HgLytHinKo4Rdele+eNDIAqDgOQy 3CfhGjircgQFU1LHhEkLv/NvRb8wmTsSyyBc1oF8RHmCunFTO1W/oY+OJ5ZuEK7flr2OzsyWL 08k7My08RDkadYrdLQ5aYiOYBcV7n07ERT2x7ex4YqkLeolJBMfYUWSIoQxUawwg0r5o/spqN RT7qvHt+2afRDvOa8NWXxkOSOw8X99zXzyGSxgV+6Sz2txYfxvpPYdjV0e048GmprBYUGziQe 6vX3qdgQHps7Pce9ruTNQoB5yVFXuz9GQYWsGi+ii18VeVGmdz2YgINKXRh0Pp+jYMFIQ63yR 57tW+2EZLd19LbLa35/qQtKwjKApklZT68fpTA1CiG9DFxSwajQI9qnbc7y4OYzXj+QPLCJSh uwCv9nMJXKdB+mgmkneYCpFK30mp5FmlykrhcQU7oTtZhv6JirUMTMUOMMuVdTqQL/4zFWCNe xpcNS9l7DhzPUw7F Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday, August 10, 2016 5:19:26 PM CEST Jisheng Zhang wrote: > Dear Arnd, > > On Wed, 10 Aug 2016 10:57:57 +0200 Arnd Bergmann wrote: > > > On Wednesday, August 10, 2016 4:49:57 PM CEST Jisheng Zhang wrote: > > > diff --git a/arch/arm/kernel/cpuidle.c b/arch/arm/kernel/cpuidle.c > > > index 7dccc96..762e0929 100644 > > > --- a/arch/arm/kernel/cpuidle.c > > > +++ b/arch/arm/kernel/cpuidle.c > > > @@ -19,7 +19,7 @@ extern struct of_cpuidle_method __cpuidle_method_of_table[]; > > > static const struct of_cpuidle_method __cpuidle_method_of_table_sentinel > > > __used __section(__cpuidle_method_of_table_end); > > > > > > -static struct cpuidle_ops cpuidle_ops[NR_CPUS]; > > > +static struct cpuidle_ops cpuidle_ops[NR_CPUS] __read_mostly; > > > > Should this perhaps be percpu data instead? > > > > Per my understanding, percpu is used for those vars with normal read/write > frequency, while the cpuidle_ops is read mostly, so IMHO, __read_mostly > is suitable, what do you think? You are right, __read_mostly is better than the normal .data section here, but percpu is also better than .data because it saves a little memory on machines that have few present CPUs than CONFIG_NR_CPUS. So both have their advantages, we just need to pick a preference. Actually __ro_after_init would be even better than __read_mostly here I think, as this is only updated in an __init function. I guess using that would have the added security advantage of preventing an attacker from writing to the function pointers when they find a way to overflow an access in the percpu data section. Arnd