Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1459595 > unrolled thread
| Started by | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| First post | 2016-08-10 21:10 +0200 |
| Last post | 2016-08-10 23:20 +0200 |
| Articles | 4 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH] ARM: cpuidle: declare cpuidle_ops __read_mostly Arnd Bergmann <arnd@arndb.de> - 2016-08-10 21:10 +0200
Re: [PATCH] ARM: cpuidle: declare cpuidle_ops __read_mostly Jisheng Zhang <jszhang@marvell.com> - 2016-08-10 22:30 +0200
Re: [PATCH] ARM: cpuidle: declare cpuidle_ops __read_mostly Jisheng Zhang <jszhang@marvell.com> - 2016-08-10 22:30 +0200
Re: [PATCH] ARM: cpuidle: declare cpuidle_ops __read_mostly Arnd Bergmann <arnd@arndb.de> - 2016-08-10 23:20 +0200
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2016-08-10 21:10 +0200 |
| Subject | Re: [PATCH] ARM: cpuidle: declare cpuidle_ops __read_mostly |
| Message-ID | <s4H35-I0-57@gated-at.bofh.it> |
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? Arnd
[toc] | [next] | [standalone]
| From | Jisheng Zhang <jszhang@marvell.com> |
|---|---|
| Date | 2016-08-10 22:30 +0200 |
| Message-ID | <s4Iiu-1wh-33@gated-at.bofh.it> |
| In reply to | #1459595 |
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? Thanks, Jisheng
[toc] | [prev] | [next] | [standalone]
| From | Jisheng Zhang <jszhang@marvell.com> |
|---|---|
| Date | 2016-08-10 22:30 +0200 |
| Message-ID | <s4Iiu-1wh-45@gated-at.bofh.it> |
| In reply to | #1459841 |
Dear Arnd, On Wed, 10 Aug 2016 12:47:21 +0200 Arnd Bergmann wrote: > 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. > Got it, thanks for the detailed explanations. And I think the answer to questions: http://lists.infradead.org/pipermail/linux-arm-kernel/2016-August/448057.html and http://lists.infradead.org/pipermail/linux-arm-kernel/2016-August/448059.html are both "yes" Thanks, Jisheng
[toc] | [prev] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2016-08-10 23:20 +0200 |
| Message-ID | <s4Iiu-1wh-47@gated-at.bofh.it> |
| In reply to | #1459841 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web