x86: xen: remove the use of VLAIS
Subsystems (2)
PATCH 1/1 x86: xen: remove the use of VLAIS
Variable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
https://lkml.org/lkml/2013/9/23/500
Here, the VLAIS was used because the size of the bitmap returned from xen_mc_entry() depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we can define the variable length array (mask) to be a pointer, and calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely on num_possible_cpus() (thanks to a helpful checkpatch warning from an earlier version of this patch).
--- arch/x86/xen/mmu_pv.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
arch/x86/xen/mmu_pv.c +4 -6
@@ -1325,20 +1325,18 @@ static void xen_flush_tlb_others(const struct cpumask *cpus, {struct {struct mmuext_op op; -#ifdef CONFIG_SMP - DECLARE_BITMAP(mask, num_processors); -#else - DECLARE_BITMAP(mask, NR_CPUS); -#endif +unsigned long *mask; } *args;struct multicall_space mcs; +const size_t mc_entry_size =sizeof (args->op) + +sizeof (*args->mask) *BITS_TO_LONGS (num_possible_cpus ());trace_xen_mmu_flush_tlb_others (cpus, info->mm, info->start, info->end);if (cpumask_empty (cpus))return ;/* nothing to do */ - mcs =xen_mc_entry (sizeof (*args)); + mcs =xen_mc_entry (mc_entry_size); args = mcs.args; args->op.arg2.vcpumask =to_cpumask (args->mask);
Signature · 1 line
2.7.4
Juergen Gross
maintainerQuoted 5 lines · Nick Desaulniers
Variable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
Quoted 7 lines
Here, the VLAIS was used because the size of the bitmap returned from
xen_mc_entry()depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we can define the variable length array (mask) to be a pointer, and calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely onnum_possible_cpus()(thanks to a helpful checkpatch warning from an earlier version of this patch).
Using a pointer for mask seems to be wrong, as it is never initialized.
Why don't you just use:
DECLARE_BITMAP(mask, NR_CPUS);
and drop the #ifdef, while keeping the manual length calculation?
Juergen
Quoted 36 lines
Signed-off-by Nick Desaulniers <[email protected]>--- arch/x86/xen/mmu_pv.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)arch/x86/xen/mmu_pv.c +4
-6@@ -1325,20 +1325,18 @@ static void xen_flush_tlb_others(const struct cpumask *cpus, {struct {struct mmuext_op op; -#ifdef CONFIG_SMP - DECLARE_BITMAP(mask, num_processors); -#else - DECLARE_BITMAP(mask, NR_CPUS); -#endif +unsigned long *mask; } *args;struct multicall_space mcs; +const size_t mc_entry_size =sizeof (args->op) + +sizeof (*args->mask) *BITS_TO_LONGS (num_possible_cpus ());trace_xen_mmu_flush_tlb_others (cpus, info->mm, info->start, info->end);if (cpumask_empty (cpus))return ;/* nothing to do */ - mcs =xen_mc_entry (sizeof (*args)); + mcs =xen_mc_entry (mc_entry_size); args = mcs.args; args->op.arg2.vcpumask =to_cpumask (args->mask);
PATCH v2 1/1 x86: xen: remove the use of VLAIS
Variable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
https://lkml.org/lkml/2013/9/23/500
Here, the VLAIS was used because the size of the bitmap returned from xen_mc_entry() depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely on num_possible_cpus() (thanks to a helpful checkpatch warning from an earlier version of this patch).
---
Changes in v2:
* Change mask to us DECLARE_BITMAP instead of pointer, as suggested.
* Update commit message to remove mention of pointer.
* Update sizeof calculation to work with array rather than pointer.
arch/x86/xen/mmu_pv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
arch/x86/xen/mmu_pv.c +3 -5
@@ -1325,20 +1325,18 @@ static void xen_flush_tlb_others(const struct cpumask *cpus, {struct {struct mmuext_op op; -#ifdef CONFIG_SMP - DECLARE_BITMAP(mask, num_processors); -#else DECLARE_BITMAP(mask, NR_CPUS); -#endif } *args;struct multicall_space mcs; +const size_t mc_entry_size =sizeof (args->op) + +sizeof (args->mask[0 ]) *BITS_TO_LONGS (num_possible_cpus ());trace_xen_mmu_flush_tlb_others (cpus, info->mm, info->start, info->end);if (cpumask_empty (cpus))return ;/* nothing to do */ - mcs =xen_mc_entry (sizeof (*args)); + mcs =xen_mc_entry (mc_entry_size); args = mcs.args; args->op.arg2.vcpumask =to_cpumask (args->mask);
Signature · 1 line
2.7.4
Quoted 13 lines · Nick Desaulniers
Variable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
https://lkml.org/lkml/2013/9/23/500
Here, the VLAIS was used because the size of the bitmap returned from
xen_mc_entry()depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely onnum_possible_cpus()(thanks to a helpful checkpatch warning from an earlier version of this patch).
Quoted 2 lines
Suggested-by Juergen Gross <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>
Juergen
Quoted 13 lines · Nick Desaulniers
Variable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
https://lkml.org/lkml/2013/9/23/500
Here, the VLAIS was used because the size of the bitmap returned from
xen_mc_entry()depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely onnum_possible_cpus()(thanks to a helpful checkpatch warning from an earlier version of this patch).
Quoted 2 lines
Suggested-by Juergen Gross <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 13 lines · Nick Desaulniers
Variable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
https://lkml.org/lkml/2013/9/23/500
Here, the VLAIS was used because the size of the bitmap returned from
xen_mc_entry()depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely onnum_possible_cpus()(thanks to a helpful checkpatch warning from an earlier version of this patch).
Quoted 2 lines
Suggested-by Juergen Gross <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>
Applied to for-linus-4.15.
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 13 lines · Nick Desaulniers
Variable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
https://lkml.org/lkml/2013/9/23/500
Here, the VLAIS was used because the size of the bitmap returned from
xen_mc_entry()depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely onnum_possible_cpus()(thanks to a helpful checkpatch warning from an earlier version of this patch).
Quoted 2 lines
Suggested-by Juergen Gross <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>
Applied to for-linus-4.15.
-boris
Quoted 29 lines · Nick Desaulniers
Variable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
https://lkml.org/lkml/2013/9/23/500
Here, the VLAIS was used because the size of the bitmap returned from
xen_mc_entry()depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely onnum_possible_cpus()(thanks to a helpful checkpatch warning from an earlier version of this patch).Suggested-by Juergen Gross <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>---
Changes in v2:
* Change mask to usDECLARE_BITMAPinstead of pointer, as suggested.
* Update commit message to remove mention of pointer.
* Update sizeof calculation to work with array rather than pointer.arch/x86/xen/mmu_pv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)arch/x86/xen/mmu_pv.c +0
-0
arch/x86/xen/mmu_pv.c static void xen_flush_tlb_others(const struct cpumask *cpus, · line 1329
Quoted 9 lines
arch/x86/xen/mmu_pv.c +0
-4@@ -1325,20 +1325,18 @@ static void xen_flush_tlb_others(const struct cpumask *cpus, {struct {struct mmuext_op op; -#ifdef CONFIG_SMP - DECLARE_BITMAP(mask, num_processors); -#else DECLARE_BITMAP(mask, NR_CPUS); -#endif } *args;
Why is it OK for Xen to place this bitmap on-stack in the first place? That NR_CPUS thing can be fairly huge.
Boris Ostrovsky
reviewerQuoted 25 lines · Peter Zijlstra
Quoted 24 lines · Nick Desaulniers
Variable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
https://lkml.org/lkml/2013/9/23/500
Here, the VLAIS was used because the size of the bitmap returned from
xen_mc_entry()depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely onnum_possible_cpus()(thanks to a helpful checkpatch warning from an earlier version of this patch).Suggested-by Juergen Gross <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>---
Changes in v2:
* Change mask to usDECLARE_BITMAPinstead of pointer, as suggested.
* Update commit message to remove mention of pointer.
* Update sizeof calculation to work with array rather than pointer.arch/x86/xen/mmu_pv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
Quoted 16 lines
Quoted 5 lines
arch/x86/xen/mmu_pv.c +0
-0arch/x86/xen/mmu_pv.c static void xen_flush_tlb_others(const struct cpumask *cpus, · line 1329
Quoted 9 lines
arch/x86/xen/mmu_pv.c +0
-4@@ -1325,20 +1325,18 @@ static void xen_flush_tlb_others(const struct cpumask *cpus, {struct {struct mmuext_op op; -#ifdef CONFIG_SMP - DECLARE_BITMAP(mask, num_processors); -#else DECLARE_BITMAP(mask, NR_CPUS); -#endif } *args;Why is it OK for Xen to place this bitmap on-stack in the first place? That
NR_CPUSthing can be fairly huge.
Err... right. Now it's even worse than it was before, when the array was potentially smaller. I'll drop this.
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Boris Ostrovsky
reviewerQuoted 25 lines · Peter Zijlstra
Quoted 24 lines · Nick Desaulniers
Variable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
https://lkml.org/lkml/2013/9/23/500
Here, the VLAIS was used because the size of the bitmap returned from
xen_mc_entry()depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely onnum_possible_cpus()(thanks to a helpful checkpatch warning from an earlier version of this patch).Suggested-by Juergen Gross <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>---
Changes in v2:
* Change mask to usDECLARE_BITMAPinstead of pointer, as suggested.
* Update commit message to remove mention of pointer.
* Update sizeof calculation to work with array rather than pointer.arch/x86/xen/mmu_pv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
Quoted 16 lines
Quoted 5 lines
arch/x86/xen/mmu_pv.c +0
-0arch/x86/xen/mmu_pv.c static void xen_flush_tlb_others(const struct cpumask *cpus, · line 1329
Quoted 9 lines
arch/x86/xen/mmu_pv.c +0
-4@@ -1325,20 +1325,18 @@ static void xen_flush_tlb_others(const struct cpumask *cpus, {struct {struct mmuext_op op; -#ifdef CONFIG_SMP - DECLARE_BITMAP(mask, num_processors); -#else DECLARE_BITMAP(mask, NR_CPUS); -#endif } *args;Why is it OK for Xen to place this bitmap on-stack in the first place? That
NR_CPUSthing can be fairly huge.
Err... right. Now it's even worse than it was before, when the array was potentially smaller. I'll drop this.
-boris
Juergen Gross
maintainerQuoted 43 lines · Boris Ostrovsky
Quoted 25 lines · Peter Zijlstra
Quoted 24 lines · Nick Desaulniers
Variable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
https://lkml.org/lkml/2013/9/23/500
Here, the VLAIS was used because the size of the bitmap returned from
xen_mc_entry()depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely onnum_possible_cpus()(thanks to a helpful checkpatch warning from an earlier version of this patch).Suggested-by Juergen Gross <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>---
Changes in v2:
* Change mask to usDECLARE_BITMAPinstead of pointer, as suggested.
* Update commit message to remove mention of pointer.
* Update sizeof calculation to work with array rather than pointer.arch/x86/xen/mmu_pv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)Quoted 16 lines
Quoted 5 lines
arch/x86/xen/mmu_pv.c +0
-0arch/x86/xen/mmu_pv.c static void xen_flush_tlb_others(const struct cpumask *cpus, · line 1329
Quoted 9 lines
arch/x86/xen/mmu_pv.c +0
-4@@ -1325,20 +1325,18 @@ static void xen_flush_tlb_others(const struct cpumask *cpus, {struct {struct mmuext_op op; -#ifdef CONFIG_SMP - DECLARE_BITMAP(mask, num_processors); -#else DECLARE_BITMAP(mask, NR_CPUS); -#endif } *args;Why is it OK for Xen to place this bitmap on-stack in the first place? That
NR_CPUSthing can be fairly huge.
Quoted 2 lines
Err... right. Now it's even worse than it was before, when the array was potentially smaller. I'll drop this.
No, its only the pointer to the struct, not the struct itself.
Juergen
Boris Ostrovsky
reviewerQuoted 43 lines · Juergen Gross
Quoted 42 lines · Boris Ostrovsky
Quoted 41 lines · Peter Zijlstra
Quoted 29 lines · Nick Desaulniers
Variable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
https://lkml.org/lkml/2013/9/23/500
Here, the VLAIS was used because the size of the bitmap returned from
xen_mc_entry()depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely onnum_possible_cpus()(thanks to a helpful checkpatch warning from an earlier version of this patch).Suggested-by Juergen Gross <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>---
Changes in v2:
* Change mask to usDECLARE_BITMAPinstead of pointer, as suggested.
* Update commit message to remove mention of pointer.
* Update sizeof calculation to work with array rather than pointer.arch/x86/xen/mmu_pv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)arch/x86/xen/mmu_pv.c +0
-0arch/x86/xen/mmu_pv.c static void xen_flush_tlb_others(const struct cpumask *cpus, · line 1329
Quoted 9 lines
arch/x86/xen/mmu_pv.c +0
-4@@ -1325,20 +1325,18 @@ static void xen_flush_tlb_others(const struct cpumask *cpus, {struct {struct mmuext_op op; -#ifdef CONFIG_SMP - DECLARE_BITMAP(mask, num_processors); -#else DECLARE_BITMAP(mask, NR_CPUS); -#endif } *args;Why is it OK for Xen to place this bitmap on-stack in the first place? That
NR_CPUSthing can be fairly huge.
Quoted 4 lines
Quoted 2 lines
Err... right. Now it's even worse than it was before, when the array was potentially smaller. I'll drop this.
No, its only the pointer to the struct, not the struct itself.
It's the full array, isn't it?
#define DECLARE_BITMAP(name,bits) \
unsigned long name[BITS_TO_LONGS(bits)]
<pause>
OK, it *is* a pointer. Sigh...
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Boris Ostrovsky
reviewerQuoted 43 lines · Juergen Gross
Quoted 42 lines · Boris Ostrovsky
Quoted 41 lines · Peter Zijlstra
Quoted 29 lines · Nick Desaulniers
Variable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
https://lkml.org/lkml/2013/9/23/500
Here, the VLAIS was used because the size of the bitmap returned from
xen_mc_entry()depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely onnum_possible_cpus()(thanks to a helpful checkpatch warning from an earlier version of this patch).Suggested-by Juergen Gross <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>---
Changes in v2:
* Change mask to usDECLARE_BITMAPinstead of pointer, as suggested.
* Update commit message to remove mention of pointer.
* Update sizeof calculation to work with array rather than pointer.arch/x86/xen/mmu_pv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)arch/x86/xen/mmu_pv.c +0
-0arch/x86/xen/mmu_pv.c static void xen_flush_tlb_others(const struct cpumask *cpus, · line 1329
Quoted 9 lines
arch/x86/xen/mmu_pv.c +0
-4@@ -1325,20 +1325,18 @@ static void xen_flush_tlb_others(const struct cpumask *cpus, {struct {struct mmuext_op op; -#ifdef CONFIG_SMP - DECLARE_BITMAP(mask, num_processors); -#else DECLARE_BITMAP(mask, NR_CPUS); -#endif } *args;Why is it OK for Xen to place this bitmap on-stack in the first place? That
NR_CPUSthing can be fairly huge.
Quoted 4 lines
Quoted 2 lines
Err... right. Now it's even worse than it was before, when the array was potentially smaller. I'll drop this.
No, its only the pointer to the struct, not the struct itself.
It's the full array, isn't it?
#define DECLARE_BITMAP(name,bits) \
unsigned long name[BITS_TO_LONGS(bits)]
<pause>
OK, it *is* a pointer. Sigh...
-boris
Juergen Gross
maintainerQuoted 43 lines · Boris Ostrovsky
Quoted 25 lines · Peter Zijlstra
Quoted 24 lines · Nick Desaulniers
Variable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
https://lkml.org/lkml/2013/9/23/500
Here, the VLAIS was used because the size of the bitmap returned from
xen_mc_entry()depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely onnum_possible_cpus()(thanks to a helpful checkpatch warning from an earlier version of this patch).Suggested-by Juergen Gross <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>---
Changes in v2:
* Change mask to usDECLARE_BITMAPinstead of pointer, as suggested.
* Update commit message to remove mention of pointer.
* Update sizeof calculation to work with array rather than pointer.arch/x86/xen/mmu_pv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)Quoted 16 lines
Quoted 5 lines
arch/x86/xen/mmu_pv.c +0
-0arch/x86/xen/mmu_pv.c static void xen_flush_tlb_others(const struct cpumask *cpus, · line 1329
Quoted 9 lines
arch/x86/xen/mmu_pv.c +0
-4@@ -1325,20 +1325,18 @@ static void xen_flush_tlb_others(const struct cpumask *cpus, {struct {struct mmuext_op op; -#ifdef CONFIG_SMP - DECLARE_BITMAP(mask, num_processors); -#else DECLARE_BITMAP(mask, NR_CPUS); -#endif } *args;Why is it OK for Xen to place this bitmap on-stack in the first place? That
NR_CPUSthing can be fairly huge.
Quoted 2 lines
Err... right. Now it's even worse than it was before, when the array was potentially smaller. I'll drop this.
No, its only the pointer to the struct, not the struct itself.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Juergen Gross
maintainerQuoted 34 lines · Peter Zijlstra
Quoted 33 lines · Nick Desaulniers
Variable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
https://lkml.org/lkml/2013/9/23/500
Here, the VLAIS was used because the size of the bitmap returned from
xen_mc_entry()depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely onnum_possible_cpus()(thanks to a helpful checkpatch warning from an earlier version of this patch).Suggested-by Juergen Gross <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>---
Changes in v2:
* Change mask to usDECLARE_BITMAPinstead of pointer, as suggested.
* Update commit message to remove mention of pointer.
* Update sizeof calculation to work with array rather than pointer.arch/x86/xen/mmu_pv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)arch/x86/xen/mmu_pv.c +0
-1@@ -1325,20 +1325,18 @@ static void xen_flush_tlb_others(const struct cpumask *cpus, {struct {struct mmuext_op op; -#ifdef CONFIG_SMP
Quoted 8 lines
arch/x86/xen/mmu_pv.c static void xen_flush_tlb_others(const struct cpumask *cpus, · line 1329
Quoted 5 lines
arch/x86/xen/mmu_pv.c +0
-3-DECLARE_BITMAP (mask, num_processors); -#else DECLARE_BITMAP (mask,NR_CPUS ); -#endif } *args;Why is it OK for Xen to place this bitmap on-stack in the first place? That
NR_CPUSthing can be fairly huge.
This only a pointer to the bitmap.
Juergen
Quoted 44 lines · Juergen Gross
Quoted 34 lines · Peter Zijlstra
Quoted 33 lines · Nick Desaulniers
Variable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
https://lkml.org/lkml/2013/9/23/500
Here, the VLAIS was used because the size of the bitmap returned from
xen_mc_entry()depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely onnum_possible_cpus()(thanks to a helpful checkpatch warning from an earlier version of this patch).Suggested-by Juergen Gross <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>---
Changes in v2:
* Change mask to usDECLARE_BITMAPinstead of pointer, as suggested.
* Update commit message to remove mention of pointer.
* Update sizeof calculation to work with array rather than pointer.arch/x86/xen/mmu_pv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)arch/x86/xen/mmu_pv.c +0
-1@@ -1325,20 +1325,18 @@ static void xen_flush_tlb_others(const struct cpumask *cpus, {struct {struct mmuext_op op; -#ifdef CONFIG_SMP Quoted 8 lines
arch/x86/xen/mmu_pv.c static void xen_flush_tlb_others(const struct cpumask *cpus, · line 1329
Quoted 5 lines
arch/x86/xen/mmu_pv.c +0
-3-DECLARE_BITMAP (mask, num_processors); -#else DECLARE_BITMAP (mask,NR_CPUS ); -#endif } *args;Why is it OK for Xen to place this bitmap on-stack in the first place? That
NR_CPUSthing can be fairly huge.
Quoted 1 line
This only a pointer to the bitmap.
What's the maximum NR_CPUs for configs that can run this code, times 8?
Thanks,
Ingo
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 44 lines · Juergen Gross
Quoted 34 lines · Peter Zijlstra
Quoted 33 lines · Nick Desaulniers
Variable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
https://lkml.org/lkml/2013/9/23/500
Here, the VLAIS was used because the size of the bitmap returned from
xen_mc_entry()depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely onnum_possible_cpus()(thanks to a helpful checkpatch warning from an earlier version of this patch).Suggested-by Juergen Gross <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>---
Changes in v2:
* Change mask to usDECLARE_BITMAPinstead of pointer, as suggested.
* Update commit message to remove mention of pointer.
* Update sizeof calculation to work with array rather than pointer.arch/x86/xen/mmu_pv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)arch/x86/xen/mmu_pv.c +0
-1@@ -1325,20 +1325,18 @@ static void xen_flush_tlb_others(const struct cpumask *cpus, {struct {struct mmuext_op op; -#ifdef CONFIG_SMP Quoted 8 lines
arch/x86/xen/mmu_pv.c static void xen_flush_tlb_others(const struct cpumask *cpus, · line 1329
Quoted 5 lines
arch/x86/xen/mmu_pv.c +0
-3-DECLARE_BITMAP (mask, num_processors); -#else DECLARE_BITMAP (mask,NR_CPUS ); -#endif } *args;Why is it OK for Xen to place this bitmap on-stack in the first place? That
NR_CPUSthing can be fairly huge.
Quoted 1 line
This only a pointer to the bitmap.
What's the maximum NR_CPUs for configs that can run this code, times 8?
Thanks,
Ingo
Juergen Gross
maintainerQuoted 47 lines · Ingo Molnar
Quoted 44 lines · Juergen Gross
Quoted 42 lines · Peter Zijlstra
Quoted 29 lines · Nick Desaulniers
Variable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
https://lkml.org/lkml/2013/9/23/500
Here, the VLAIS was used because the size of the bitmap returned from
xen_mc_entry()depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely onnum_possible_cpus()(thanks to a helpful checkpatch warning from an earlier version of this patch).Suggested-by Juergen Gross <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>---
Changes in v2:
* Change mask to usDECLARE_BITMAPinstead of pointer, as suggested.
* Update commit message to remove mention of pointer.
* Update sizeof calculation to work with array rather than pointer.arch/x86/xen/mmu_pv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)arch/x86/xen/mmu_pv.c +0
-0arch/x86/xen/mmu_pv.c static void xen_flush_tlb_others(const struct cpumask *cpus, · line 1329
Quoted 9 lines
arch/x86/xen/mmu_pv.c +0
-4@@ -1325,20 +1325,18 @@ static void xen_flush_tlb_others(const struct cpumask *cpus, {struct {struct mmuext_op op; -#ifdef CONFIG_SMP - DECLARE_BITMAP(mask, num_processors); -#else DECLARE_BITMAP(mask, NR_CPUS); -#endif } *args;Why is it OK for Xen to place this bitmap on-stack in the first place? That
NR_CPUSthing can be fairly huge.
Quoted 3 lines
Quoted 1 line
This only a pointer to the bitmap.
What's the maximum
NR_CPUsfor configs that can run this code, times 8?
Why does this matter? args is a pointer only, so it occupies 8 bytes of the stack. The structure is only for type correctness.
Juergen
Juergen Gross
maintainerQuoted 47 lines · Ingo Molnar
Quoted 44 lines · Juergen Gross
Quoted 42 lines · Peter Zijlstra
Quoted 29 lines · Nick Desaulniers
Variable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
https://lkml.org/lkml/2013/9/23/500
Here, the VLAIS was used because the size of the bitmap returned from
xen_mc_entry()depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely onnum_possible_cpus()(thanks to a helpful checkpatch warning from an earlier version of this patch).Suggested-by Juergen Gross <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>---
Changes in v2:
* Change mask to usDECLARE_BITMAPinstead of pointer, as suggested.
* Update commit message to remove mention of pointer.
* Update sizeof calculation to work with array rather than pointer.arch/x86/xen/mmu_pv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)arch/x86/xen/mmu_pv.c +0
-0arch/x86/xen/mmu_pv.c static void xen_flush_tlb_others(const struct cpumask *cpus, · line 1329
Quoted 9 lines
arch/x86/xen/mmu_pv.c +0
-4@@ -1325,20 +1325,18 @@ static void xen_flush_tlb_others(const struct cpumask *cpus, {struct {struct mmuext_op op; -#ifdef CONFIG_SMP - DECLARE_BITMAP(mask, num_processors); -#else DECLARE_BITMAP(mask, NR_CPUS); -#endif } *args;Why is it OK for Xen to place this bitmap on-stack in the first place? That
NR_CPUSthing can be fairly huge.
Quoted 3 lines
Quoted 1 line
This only a pointer to the bitmap.
What's the maximum
NR_CPUsfor configs that can run this code, times 8?
Why does this matter? args is a pointer only, so it occupies 8 bytes of the stack. The structure is only for type correctness.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Juergen Gross
maintainerQuoted 34 lines · Peter Zijlstra
Quoted 33 lines · Nick Desaulniers
Variable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
https://lkml.org/lkml/2013/9/23/500
Here, the VLAIS was used because the size of the bitmap returned from
xen_mc_entry()depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely onnum_possible_cpus()(thanks to a helpful checkpatch warning from an earlier version of this patch).Suggested-by Juergen Gross <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>---
Changes in v2:
* Change mask to usDECLARE_BITMAPinstead of pointer, as suggested.
* Update commit message to remove mention of pointer.
* Update sizeof calculation to work with array rather than pointer.arch/x86/xen/mmu_pv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)arch/x86/xen/mmu_pv.c +0
-1@@ -1325,20 +1325,18 @@ static void xen_flush_tlb_others(const struct cpumask *cpus, {struct {struct mmuext_op op; -#ifdef CONFIG_SMP
Quoted 8 lines
arch/x86/xen/mmu_pv.c static void xen_flush_tlb_others(const struct cpumask *cpus, · line 1329
Quoted 5 lines
arch/x86/xen/mmu_pv.c +0
-3-DECLARE_BITMAP (mask, num_processors); -#else DECLARE_BITMAP (mask,NR_CPUS ); -#endif } *args;Why is it OK for Xen to place this bitmap on-stack in the first place? That
NR_CPUSthing can be fairly huge.
This only a pointer to the bitmap.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 29 lines · Nick Desaulniers
Variable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
https://lkml.org/lkml/2013/9/23/500
Here, the VLAIS was used because the size of the bitmap returned from
xen_mc_entry()depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely onnum_possible_cpus()(thanks to a helpful checkpatch warning from an earlier version of this patch).Suggested-by Juergen Gross <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>---
Changes in v2:
* Change mask to usDECLARE_BITMAPinstead of pointer, as suggested.
* Update commit message to remove mention of pointer.
* Update sizeof calculation to work with array rather than pointer.arch/x86/xen/mmu_pv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)arch/x86/xen/mmu_pv.c +0
-0
arch/x86/xen/mmu_pv.c static void xen_flush_tlb_others(const struct cpumask *cpus, · line 1329
Quoted 9 lines
arch/x86/xen/mmu_pv.c +0
-4@@ -1325,20 +1325,18 @@ static void xen_flush_tlb_others(const struct cpumask *cpus, {struct {struct mmuext_op op; -#ifdef CONFIG_SMP - DECLARE_BITMAP(mask, num_processors); -#else DECLARE_BITMAP(mask, NR_CPUS); -#endif } *args;
Why is it OK for Xen to place this bitmap on-stack in the first place? That NR_CPUS thing can be fairly huge.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 1/1 x86: xen: remove the use of VLAIS
In reply to Juergen GrossVariable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
https://lkml.org/lkml/2013/9/23/500
Here, the VLAIS was used because the size of the bitmap returned from xen_mc_entry() depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely on num_possible_cpus() (thanks to a helpful checkpatch warning from an earlier version of this patch).
---
Changes in v2:
* Change mask to us DECLARE_BITMAP instead of pointer, as suggested.
* Update commit message to remove mention of pointer.
* Update sizeof calculation to work with array rather than pointer.
arch/x86/xen/mmu_pv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
arch/x86/xen/mmu_pv.c +3 -5
@@ -1325,20 +1325,18 @@ static void xen_flush_tlb_others(const struct cpumask *cpus, {struct {struct mmuext_op op; -#ifdef CONFIG_SMP - DECLARE_BITMAP(mask, num_processors); -#else DECLARE_BITMAP(mask, NR_CPUS); -#endif } *args;struct multicall_space mcs; +const size_t mc_entry_size =sizeof (args->op) + +sizeof (args->mask[0 ]) *BITS_TO_LONGS (num_possible_cpus ());trace_xen_mmu_flush_tlb_others (cpus, info->mm, info->start, info->end);if (cpumask_empty (cpus))return ;/* nothing to do */ - mcs =xen_mc_entry (sizeof (*args)); + mcs =xen_mc_entry (mc_entry_size); args = mcs.args; args->op.arg2.vcpumask =to_cpumask (args->mask);
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Juergen Gross
maintainerQuoted 5 lines · Nick Desaulniers
Variable Length Arrays In Structs (VLAIS) is not supported by Clang, and frowned upon by others.
Quoted 7 lines
Here, the VLAIS was used because the size of the bitmap returned from
xen_mc_entry()depended on possibly (based on kernel configuration) runtime sized data. Rather than declaring args as a VLAIS then calling sizeof on *args, we can define the variable length array (mask) to be a pointer, and calculate the appropriate sizeof args manually. Further, we can get rid of the #ifdef's and rely onnum_possible_cpus()(thanks to a helpful checkpatch warning from an earlier version of this patch).
Using a pointer for mask seems to be wrong, as it is never initialized.
Why don't you just use:
DECLARE_BITMAP(mask, NR_CPUS);
and drop the #ifdef, while keeping the manual length calculation?
Juergen
Quoted 26 lines
Signed-off-by Nick Desaulniers <[email protected]>--- arch/x86/xen/mmu_pv.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)arch/x86/xen/mmu_pv.c +3
-5@@ -1325,20 +1325,18 @@ static void xen_flush_tlb_others(const struct cpumask *cpus, {struct {struct mmuext_op op; -#ifdef CONFIG_SMP - DECLARE_BITMAP(mask, num_processors); -#else - DECLARE_BITMAP(mask, NR_CPUS); -#endif +unsigned long *mask; } *args;struct multicall_space mcs; +const size_t mc_entry_size =sizeof (args->op) + +sizeof (*args->mask) *BITS_TO_LONGS (num_possible_cpus ());
arch/x86/xen/mmu_pv.c static void xen_flush_tlb_others(const struct cpumask *cpus, · line 1342
Quoted 10 lines
arch/x86/xen/mmu_pv.c +1
-1trace_xen_mmu_flush_tlb_others (cpus, info->mm, info->start, info->end);if (cpumask_empty (cpus))return ;/* nothing to do */ - mcs =xen_mc_entry (sizeof (*args)); + mcs =xen_mc_entry (mc_entry_size); args = mcs.args; args->op.arg2.vcpumask =to_cpumask (args->mask);
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel