diff mbox series

[v2,2/3] mm/vmstat: skip NR_TLB_REMOTE_FLUSH* properly

Message ID 20181001143138.95119-2-jannh@google.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/3] mm/vmstat: fix outdated vmstat_text | expand

Commit Message

Jann Horn Oct. 1, 2018, 2:31 p.m. UTC
commit 5dd0b16cdaff ("mm/vmstat: Make NR_TLB_REMOTE_FLUSH_RECEIVED
available even on UP") made the availability of the NR_TLB_REMOTE_FLUSH*
counters inside the kernel unconditional to reduce #ifdef soup, but
(either to avoid showing dummy zero counters to userspace, or because that
code was missed) didn't update the vmstat_array, meaning that all following
counters would be shown with incorrect values.

This only affects kernel builds with
CONFIG_VM_EVENT_COUNTERS=y && CONFIG_DEBUG_TLBFLUSH=y && CONFIG_SMP=n.

Fixes: 5dd0b16cdaff ("mm/vmstat: Make NR_TLB_REMOTE_FLUSH_RECEIVED available even on UP")
Cc: stable@vger.kernel.org
Signed-off-by: Jann Horn <jannh@google.com>
---
 mm/vmstat.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Kees Cook Oct. 1, 2018, 3:57 p.m. UTC | #1
On Mon, Oct 1, 2018 at 7:31 AM, Jann Horn <jannh@google.com> wrote:
> commit 5dd0b16cdaff ("mm/vmstat: Make NR_TLB_REMOTE_FLUSH_RECEIVED
> available even on UP") made the availability of the NR_TLB_REMOTE_FLUSH*
> counters inside the kernel unconditional to reduce #ifdef soup, but
> (either to avoid showing dummy zero counters to userspace, or because that
> code was missed) didn't update the vmstat_array, meaning that all following
> counters would be shown with incorrect values.
>
> This only affects kernel builds with
> CONFIG_VM_EVENT_COUNTERS=y && CONFIG_DEBUG_TLBFLUSH=y && CONFIG_SMP=n.
>
> Fixes: 5dd0b16cdaff ("mm/vmstat: Make NR_TLB_REMOTE_FLUSH_RECEIVED available even on UP")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jann Horn <jannh@google.com>

Reviewed-by: Kees Cook <keescook@chromium.org>

-Kees

> ---
>  mm/vmstat.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/mm/vmstat.c b/mm/vmstat.c
> index 4cea7b8f519d..7878da76abf2 100644
> --- a/mm/vmstat.c
> +++ b/mm/vmstat.c
> @@ -1275,6 +1275,9 @@ const char * const vmstat_text[] = {
>  #ifdef CONFIG_SMP
>         "nr_tlb_remote_flush",
>         "nr_tlb_remote_flush_received",
> +#else
> +       "", /* nr_tlb_remote_flush */
> +       "", /* nr_tlb_remote_flush_received */
>  #endif /* CONFIG_SMP */
>         "nr_tlb_local_flush_all",
>         "nr_tlb_local_flush_one",
> --
> 2.19.0.605.g01d371f741-goog
>
Michal Hocko Oct. 4, 2018, 7:22 a.m. UTC | #2
On Mon 01-10-18 16:31:37, Jann Horn wrote:
> commit 5dd0b16cdaff ("mm/vmstat: Make NR_TLB_REMOTE_FLUSH_RECEIVED
> available even on UP") made the availability of the NR_TLB_REMOTE_FLUSH*
> counters inside the kernel unconditional to reduce #ifdef soup, but
> (either to avoid showing dummy zero counters to userspace, or because that
> code was missed) didn't update the vmstat_array, meaning that all following
> counters would be shown with incorrect values.
> 
> This only affects kernel builds with
> CONFIG_VM_EVENT_COUNTERS=y && CONFIG_DEBUG_TLBFLUSH=y && CONFIG_SMP=n.
> 
> Fixes: 5dd0b16cdaff ("mm/vmstat: Make NR_TLB_REMOTE_FLUSH_RECEIVED available even on UP")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jann Horn <jannh@google.com>

Acked-by: Michal Hocko <mhocko@suse.com>

> ---
>  mm/vmstat.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/mm/vmstat.c b/mm/vmstat.c
> index 4cea7b8f519d..7878da76abf2 100644
> --- a/mm/vmstat.c
> +++ b/mm/vmstat.c
> @@ -1275,6 +1275,9 @@ const char * const vmstat_text[] = {
>  #ifdef CONFIG_SMP
>  	"nr_tlb_remote_flush",
>  	"nr_tlb_remote_flush_received",
> +#else
> +	"", /* nr_tlb_remote_flush */
> +	"", /* nr_tlb_remote_flush_received */
>  #endif /* CONFIG_SMP */
>  	"nr_tlb_local_flush_all",
>  	"nr_tlb_local_flush_one",
> -- 
> 2.19.0.605.g01d371f741-goog
diff mbox series

Patch

diff --git a/mm/vmstat.c b/mm/vmstat.c
index 4cea7b8f519d..7878da76abf2 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1275,6 +1275,9 @@  const char * const vmstat_text[] = {
 #ifdef CONFIG_SMP
 	"nr_tlb_remote_flush",
 	"nr_tlb_remote_flush_received",
+#else
+	"", /* nr_tlb_remote_flush */
+	"", /* nr_tlb_remote_flush_received */
 #endif /* CONFIG_SMP */
 	"nr_tlb_local_flush_all",
 	"nr_tlb_local_flush_one",