Skip to contentSkip to conversation

clocksource: add __ro_after_init to cyclecounter

PATCH In review Bhumika Goyal 5 participants 10 messages Feb 11, 2017 – Feb 12, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clocksource: add __ro_after_init to cyclecounter

The object cyclecounter of type cyclecounter is not getting modified after getting initialized by arch_counter_register. Apart from initialization in arch_counter_register it is also passed as an argument to the function timecounter_init but this argument is of type const. Therefore, add __ro_after_init to its declaration.

---
 drivers/clocksource/arm_arch_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/arm_arch_timer.c +1 -1
index 4c8c3fb..a10506b 100644
@@ -580,7 +580,7 @@ static u64 arch_counter_read_cc(const struct cyclecounter *cc)
 	.flags	= CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
-static struct cyclecounter cyclecounter = {
+static struct cyclecounter cyclecounter __ro_after_init = {
 	.read	= arch_counter_read_cc,
 	.mask	= CLOCKSOURCE_MASK(56),
 };
Signature · 1 line
1.9.1
#1 lore raw
Quoted 6 lines · Bhumika Goyal

The object cyclecounter of type cyclecounter is not getting modified after getting initialized by arch_counter_register. Apart from initialization in arch_counter_register it is also passed as an argument to the function timecounter_init but this argument is of type const. Therefore, add __ro_after_init to its declaration.

I think adding __ro_after_init is fine if this struct is never modified after init. But the reference in the commit log to the constness of the timecounter_init() argument makes no sense: that only means timecounter_init() will not modify the object, which allows pointers to const objects to be passed to it as well. The opposite is not true, though: there is no requirement whatsoever that objects passed into const pointer arguments should be const themselves.

Quoted 26 lines
---
 drivers/clocksource/arm_arch_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/arm_arch_timer.c +1 -2
index 4c8c3fb..a10506b 100644
@@ -580,7 +580,7 @@ static u64 arch_counter_read_cc(const struct cyclecounter *cc)
        .flags  = CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
-static struct cyclecounter cyclecounter = {
+static struct cyclecounter cyclecounter __ro_after_init = {
        .read   = arch_counter_read_cc,
        .mask   = CLOCKSOURCE_MASK(56),
 };
--

1.9.1

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#7 lore raw
In reply to Bhumika Goyal

On Sun, 12 Feb 2017, Bhumika Goyal wrote:

Please be more careful with your subject line. The prefix for this is definitely not 'clocksource'. git log would have told you the proper one:

clocksource/drivers/arm_arch_timer

'clocksource' is the general subsystem and used for system wide changes or core changes, but not for a particular driver.

Quoted 5 lines

The object cyclecounter of type cyclecounter is not getting modified after getting initialized by arch_counter_register. Apart from initialization in arch_counter_register it is also passed as an argument to the function timecounter_init but this argument is of type const. Therefore, add __ro_after_init to its declaration.

Other than that this is fine. I'll fix it up when applying.

Thanks,

tglx

#2 lore raw
In reply to Ard Biesheuvel
Quoted 8 lines · Ard Biesheuvel
Quoted 6 lines · Bhumika Goyal

The object cyclecounter of type cyclecounter is not getting modified after getting initialized by arch_counter_register. Apart from initialization in arch_counter_register it is also passed as an argument to the function timecounter_init but this argument is of type const. Therefore, add __ro_after_init to its declaration.

Quoted 7 lines

I think adding __ro_after_init is fine if this struct is never modified after init. But the reference in the commit log to the constness of the timecounter_init() argument makes no sense: that only means timecounter_init() will not modify the object, which allows pointers to const objects to be passed to it as well. The opposite is not true, though: there is no requirement whatsoever that objects passed into const pointer arguments should be const themselves.

Indeed.

#3 lore raw
In reply to Ard Biesheuvel
Quoted 8 lines · Ard Biesheuvel
Quoted 6 lines · Bhumika Goyal

The object cyclecounter of type cyclecounter is not getting modified after getting initialized by arch_counter_register. Apart from initialization in arch_counter_register it is also passed as an argument to the function timecounter_init but this argument is of type const. Therefore, add __ro_after_init to its declaration.

Quoted 9 lines

I think adding __ro_after_init is fine if this struct is never modified after init. But the reference in the commit log to the constness of the timecounter_init() argument makes no sense: that only means timecounter_init() will not modify the object, which allows pointers to const objects to be passed to it as well. The opposite is not true, though: there is no requirement whatsoever that objects passed into const pointer arguments should be const themselves.

Yes, true. I will change the commit log and send a v2. Thanks for explaining.

Thanks,
Bhumika

Quoted 26 lines
Quoted 26 lines
---
 drivers/clocksource/arm_arch_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/arm_arch_timer.c +1 -2
index 4c8c3fb..a10506b 100644
@@ -580,7 +580,7 @@ static u64 arch_counter_read_cc(const struct cyclecounter *cc)
        .flags  = CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
-static struct cyclecounter cyclecounter = {
+static struct cyclecounter cyclecounter __ro_after_init = {
        .read   = arch_counter_read_cc,
        .mask   = CLOCKSOURCE_MASK(56),
 };
--

1.9.1

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#8 lore raw
In reply to Thomas Gleixner
Quoted 10 lines · Thomas Gleixner

On Sun, 12 Feb 2017, Bhumika Goyal wrote:

Please be more careful with your subject line. The prefix for this is definitely not 'clocksource'. git log would have told you the proper one:

clocksource/drivers/arm_arch_timer

'clocksource' is the general subsystem and used for system wide changes or core changes, but not for a particular driver.

I will be more careful about this in future.

Thanks,
Bhumika

Quoted 11 lines
Quoted 5 lines

The object cyclecounter of type cyclecounter is not getting modified after getting initialized by arch_counter_register. Apart from initialization in arch_counter_register it is also passed as an argument to the function timecounter_init but this argument is of type const. Therefore, add __ro_after_init to its declaration.

Other than that this is fine. I'll fix it up when applying.

Thanks,

tglx

#4 lore raw
In reply to Bhumika Goyal
Quoted 20 lines · Bhumika Goyal
Quoted 8 lines · Ard Biesheuvel
Quoted 6 lines · Bhumika Goyal

The object cyclecounter of type cyclecounter is not getting modified after getting initialized by arch_counter_register. Apart from initialization in arch_counter_register it is also passed as an argument to the function timecounter_init but this argument is of type const. Therefore, add __ro_after_init to its declaration.

Quoted 9 lines

I think adding __ro_after_init is fine if this struct is never modified after init. But the reference in the commit log to the constness of the timecounter_init() argument makes no sense: that only means timecounter_init() will not modify the object, which allows pointers to const objects to be passed to it as well. The opposite is not true, though: there is no requirement whatsoever that objects passed into const pointer arguments should be const themselves.

Quoted 1 line

Yes, true. I will change the commit log and send a v2. Thanks for explaining.

I've applied it already and fixed up the subject/changelog. You should have mail from tip-bot ...

#5 lore raw
Quoted 22 lines · Thomas Gleixner
Quoted 20 lines · Bhumika Goyal
Quoted 17 lines · Ard Biesheuvel
Quoted 6 lines · Bhumika Goyal

The object cyclecounter of type cyclecounter is not getting modified after getting initialized by arch_counter_register. Apart from initialization in arch_counter_register it is also passed as an argument to the function timecounter_init but this argument is of type const. Therefore, add __ro_after_init to its declaration.

I think adding __ro_after_init is fine if this struct is never modified after init. But the reference in the commit log to the constness of the timecounter_init() argument makes no sense: that only means timecounter_init() will not modify the object, which allows pointers to const objects to be passed to it as well. The opposite is not true, though: there is no requirement whatsoever that objects passed into const pointer arguments should be const themselves.

Quoted 4 lines
Quoted 1 line

Yes, true. I will change the commit log and send a v2. Thanks for explaining.

I've applied it already and fixed up the subject/changelog. You should have mail from tip-bot ...

Okay. Thanks. I thought the patch is not applied yet because I haven't received a mail from tip-bot yet.

Thanks,
Bhumika

#9 lore raw

[tip:timers/core] clocksource/drivers/arm_arch_timer:: Mark cyclecounter __ro_after_init

In reply to Bhumika Goyal
clocksource/drivers/arm_arch_timer:: Mark cyclecounter __ro_after_init
Commit-ID:  3d837bc01c2153565333b2ce71d613b6e7cc761c
Gitweb:     http://git.kernel.org/tip/3d837bc01c2153565333b2ce71d613b6e7cc761c
Author:     Bhumika Goyal <[email protected]>
AuthorDate: Sun, 12 Feb 2017 00:50:18 +0530
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Sat, 11 Feb 2017 21:39:04 +0100

clocksource/drivers/arm_arch_timer:: Mark cyclecounter __ro_after_init

The object cyclecounter of type cyclecounter is only modified during initialization in arch_counter_register. So it can be marked __ro_after_init.

---
 drivers/clocksource/arm_arch_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/arm_arch_timer.c +1 -1
index 7b06aef..93aa136 100644
@@ -646,7 +646,7 @@ static struct clocksource clocksource_counter = {
 	.flags	= CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
-static struct cyclecounter cyclecounter = {
+static struct cyclecounter cyclecounter __ro_after_init = {
 	.read	= arch_counter_read_cc,
 	.mask	= CLOCKSOURCE_MASK(56),
 };
#6 lore raw
In reply to Thomas Gleixner

On Sun, Feb 12, 2017 at 07:56:41PM +0100, Thomas Gleixner wrote:

[ ... ]

Quoted 2 lines

I've applied it already and fixed up the subject/changelog. You should have mail from tip-bot ...

For the record, I did not receive the mails from the tip-bot when the patches from the PR were applied.

-- Daniel

<http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog