diff mbox series

[1/3] mm/show_mem: simplify ifdef on si_meminfo_node()

Message ID 20240314005436.2962962-2-mcgrof@kernel.org (mailing list archive)
State New
Headers show
Series mm: random cleanups | expand

Commit Message

Luis Chamberlain March 14, 2024, 12:54 a.m. UTC
There is an ifdef where the same exact values are used at
the end, so remove the else and keep the same values for both
conditions.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 mm/show_mem.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Kefeng Wang March 14, 2024, 1:13 a.m. UTC | #1
On 2024/3/14 8:54, Luis Chamberlain wrote:
> There is an ifdef where the same exact values are used at
> the end, so remove the else and keep the same values for both
> conditions.
> 
> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
> ---
>   mm/show_mem.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/mm/show_mem.c b/mm/show_mem.c
> index 8dcfafbd283c..529d2f9b6410 100644
> --- a/mm/show_mem.c
> +++ b/mm/show_mem.c
> @@ -108,12 +108,9 @@ void si_meminfo_node(struct sysinfo *val, int nid)
>   			free_highpages += zone_page_state(zone, NR_FREE_PAGES);
>   		}
>   	}
> +#endif
>   	val->totalhigh = managed_highpages;
>   	val->freehigh = free_highpages;
> -#else
> -	val->totalhigh = managed_highpages;
> -	val->freehigh = free_highpages;
> -#endif
>   	val->mem_unit = PAGE_SIZE;
>   }
>   #endif

More cleanup?
diff --git a/mm/show_mem.c b/mm/show_mem.c
index 8dcfafbd283c..44dd6d6e9488 100644
--- a/mm/show_mem.c
+++ b/mm/show_mem.c
@@ -94,26 +94,21 @@ void si_meminfo_node(struct sysinfo *val, int nid)
         unsigned long free_highpages = 0;
         pg_data_t *pgdat = NODE_DATA(nid);

-       for (zone_type = 0; zone_type < MAX_NR_ZONES; zone_type++)
-               managed_pages += 
zone_managed_pages(&pgdat->node_zones[zone_type]);
-       val->totalram = managed_pages;
-       val->sharedram = node_page_state(pgdat, NR_SHMEM);
-       val->freeram = sum_zone_node_page_state(nid, NR_FREE_PAGES);
-#ifdef CONFIG_HIGHMEM
         for (zone_type = 0; zone_type < MAX_NR_ZONES; zone_type++) {
                 struct zone *zone = &pgdat->node_zones[zone_type];

+               managed_pages += zone_managed_pages(zone);
                 if (is_highmem(zone)) {
                         managed_highpages += zone_managed_pages(zone);
                         free_highpages += zone_page_state(zone, 
NR_FREE_PAGES);
                 }
         }
+
+       val->totalram = managed_pages;
+       val->sharedram = node_page_state(pgdat, NR_SHMEM);
+       val->freeram = sum_zone_node_page_state(nid, NR_FREE_PAGES);
         val->totalhigh = managed_highpages;
         val->freehigh = free_highpages;
-#else
-       val->totalhigh = managed_highpages;
-       val->freehigh = free_highpages;
-#endif
         val->mem_unit = PAGE_SIZE;
  }
diff mbox series

Patch

diff --git a/mm/show_mem.c b/mm/show_mem.c
index 8dcfafbd283c..529d2f9b6410 100644
--- a/mm/show_mem.c
+++ b/mm/show_mem.c
@@ -108,12 +108,9 @@  void si_meminfo_node(struct sysinfo *val, int nid)
 			free_highpages += zone_page_state(zone, NR_FREE_PAGES);
 		}
 	}
+#endif
 	val->totalhigh = managed_highpages;
 	val->freehigh = free_highpages;
-#else
-	val->totalhigh = managed_highpages;
-	val->freehigh = free_highpages;
-#endif
 	val->mem_unit = PAGE_SIZE;
 }
 #endif