ARM: VDSO: put read only/mostly objects into proper sections
PATCH 1/1 ARM: VDSO: put read only/mostly objects into proper sections
vdso_data_mapping is never modified, so mark it as const.
vdso_data_page and vdso_text_mapping are initialized by vdso_init(), thereafter are mostly read during vdso special mapping handling.
The fact that they are mostly read and not written to makes them candidates for __read_mostly declarations.
--- arch/arm/kernel/vdso.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/kernel/vdso.c +3 -3
@@ -47,13 +47,13 @@ unsigned int vdso_total_pages __read_mostly; static union vdso_data_store vdso_data_store __page_aligned_data;static struct vdso_data *vdso_data = &vdso_data_store.data; -static struct page *vdso_data_page; -static struct vm_special_mapping vdso_data_mapping = { +static struct page *vdso_data_page__read_mostly ; +static const struct vm_special_mapping vdso_data_mapping = { .name ="[vvar]" , .pages = &vdso_data_page, }; -static struct vm_special_mapping vdso_text_mapping = { +static struct vm_special_mapping vdso_text_mapping__read_mostly = { .name ="[vdso]" , };
Signature · 1 line
2.8.1
+ Kees
Quoted 7 lines · On Wed, 10 Aug 2016 17:09:47 +0800 wrote:
vdso_data_mappingis never modified, so mark it as const.
vdso_data_pageandvdso_text_mappingare initialized byvdso_init(), thereafter are mostly read during vdso special mapping handling.The fact that they are mostly read and not written to makes them candidates for
__read_mostlydeclarations.
Inspired by Kees's "arm: apply more __ro_after_init", is it better to mark these vars as __ro_after_init?
Thanks,
Jisheng
Quoted 27 lines
Signed-off-by Jisheng Zhang <[email protected]>--- arch/arm/kernel/vdso.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)arch/arm/kernel/vdso.c +3
-3@@ -47,13 +47,13 @@ unsigned int vdso_total_pages __read_mostly; static union vdso_data_store vdso_data_store __page_aligned_data;static struct vdso_data *vdso_data = &vdso_data_store.data; -static struct page *vdso_data_page; -static struct vm_special_mapping vdso_data_mapping = { +static struct page *vdso_data_page__read_mostly ; +static const struct vm_special_mapping vdso_data_mapping = { .name ="[vvar]" , .pages = &vdso_data_page, }; -static struct vm_special_mapping vdso_text_mapping = { +static struct vm_special_mapping vdso_text_mapping__read_mostly = { .name ="[vdso]" , };
Quoted 6 lines · Jisheng Zhang
+ Kees
Quoted 2 lines · On Wed, 10 Aug 2016 17:09:47 +0800 wrote:
vdso_data_mappingis never modified, so mark it as const.
Quoted 8 lines
Quoted 5 lines
vdso_data_pageandvdso_text_mappingare initialized byvdso_init(), thereafter are mostly read during vdso special mapping handling.The fact that they are mostly read and not written to makes them candidates for
__read_mostlydeclarations.Inspired by Kees's "arm: apply more
__ro_after_init", is it better to mark these vars as__ro_after_init?
Yeah, if they're not written outside of __init, please do. It would be a nice complement to commit 11bf9b865898 ("ARM/vdso: Mark the vDSO code read-only after init").
-Kees
Quoted 32 lines
Thanks,
JishengQuoted 27 lines
Signed-off-by Jisheng Zhang <[email protected]>--- arch/arm/kernel/vdso.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)arch/arm/kernel/vdso.c +3
-3@@ -47,13 +47,13 @@ unsigned int vdso_total_pages __read_mostly; static union vdso_data_store vdso_data_store __page_aligned_data;static struct vdso_data *vdso_data = &vdso_data_store.data; -static struct page *vdso_data_page; -static struct vm_special_mapping vdso_data_mapping = { +static struct page *vdso_data_page__read_mostly ; +static const struct vm_special_mapping vdso_data_mapping = { .name ="[vvar]" , .pages = &vdso_data_page, }; -static struct vm_special_mapping vdso_text_mapping = { +static struct vm_special_mapping vdso_text_mapping__read_mostly = { .name ="[vdso]" , };
Signature · 2 lines
Kees Cook Nexus Security
Quoted 13 lines · Kees Cook
Quoted 12 lines · Jisheng Zhang
+ Kees
Quoted 7 lines · On Wed, 10 Aug 2016 17:09:47 +0800 wrote:
vdso_data_mappingis never modified, so mark it as const.
vdso_data_pageandvdso_text_mappingare initialized byvdso_init(), thereafter are mostly read during vdso special mapping handling.The fact that they are mostly read and not written to makes them candidates for
__read_mostlydeclarations.
Quoted 6 lines
Quoted 2 lines
Inspired by Kees's "arm: apply more
__ro_after_init", is it better to mark these vars as__ro_after_init?Yeah, if they're not written outside of
__init, please do. It would be a nice complement to commit11bf9b865898("ARM/vdso: Mark the vDSO code read-only after init").
I agree.