Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1430660 > unrolled thread

Re: [PATCH v3 1/6] mm/page_alloc: recalculate some of zone threshold when on/offline memory

Started byVlastimil Babka <vbabka@suse.cz>
First post2016-06-24 15:30 +0200
Last post2016-06-28 10:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v3 1/6] mm/page_alloc: recalculate some of zone threshold  when on/offline memory Vlastimil Babka <vbabka@suse.cz> - 2016-06-24 15:30 +0200
    Re: [PATCH v3 1/6] mm/page_alloc: recalculate some of zone threshold  when on/offline memory Joonsoo Kim <iamjoonsoo.kim@lge.com> - 2016-06-28 10:20 +0200

#1430660 — Re: [PATCH v3 1/6] mm/page_alloc: recalculate some of zone threshold when on/offline memory

FromVlastimil Babka <vbabka@suse.cz>
Date2016-06-24 15:30 +0200
SubjectRe: [PATCH v3 1/6] mm/page_alloc: recalculate some of zone threshold when on/offline memory
Message-ID<rNzlf-9y-15@gated-at.bofh.it>
On 05/26/2016 08:22 AM, js1304@gmail.com wrote:
> From: Joonsoo Kim <iamjoonsoo.kim@lge.com>
>
> Some of zone threshold depends on number of managed pages in the zone.
> When memory is going on/offline, it can be changed and we need to
> adjust them.
>
> This patch add recalculation to appropriate places and clean-up
> related function for better maintanance.

Can you be more specific about the user visible effect? Presumably it's 
not affecting just ZONE_CMA?
I assume it's fixing the thresholds where only part of node is onlined 
or offlined? Or are they currently wrong even when whole node is 
onlined/offlined?

(Sorry but I can't really orient myself in the maze of memory hotplug :(

Thanks,
Vlastimil

> Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> ---
>  mm/page_alloc.c | 36 +++++++++++++++++++++++++++++-------
>  1 file changed, 29 insertions(+), 7 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index d27e8b9..90e5a82 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -4874,6 +4874,8 @@ int local_memory_node(int node)
>  }
>  #endif
>
> +static void setup_min_unmapped_ratio(struct zone *zone);
> +static void setup_min_slab_ratio(struct zone *zone);
>  #else	/* CONFIG_NUMA */
>
>  static void set_zonelist_order(void)
> @@ -5988,9 +5990,8 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat)
>  		zone->managed_pages = is_highmem_idx(j) ? realsize : freesize;
>  #ifdef CONFIG_NUMA
>  		zone->node = nid;
> -		zone->min_unmapped_pages = (freesize*sysctl_min_unmapped_ratio)
> -						/ 100;
> -		zone->min_slab_pages = (freesize * sysctl_min_slab_ratio) / 100;
> +		setup_min_unmapped_ratio(zone);
> +		setup_min_slab_ratio(zone);
>  #endif
>  		zone->name = zone_names[j];
>  		spin_lock_init(&zone->lock);
> @@ -6896,6 +6897,7 @@ int __meminit init_per_zone_wmark_min(void)
>  {
>  	unsigned long lowmem_kbytes;
>  	int new_min_free_kbytes;
> +	struct zone *zone;
>
>  	lowmem_kbytes = nr_free_buffer_pages() * (PAGE_SIZE >> 10);
>  	new_min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
> @@ -6913,6 +6915,14 @@ int __meminit init_per_zone_wmark_min(void)
>  	setup_per_zone_wmarks();
>  	refresh_zone_stat_thresholds();
>  	setup_per_zone_lowmem_reserve();
> +
> +	for_each_zone(zone) {
> +#ifdef CONFIG_NUMA
> +		setup_min_unmapped_ratio(zone);
> +		setup_min_slab_ratio(zone);
> +#endif
> +	}
> +
>  	return 0;
>  }
>  core_initcall(init_per_zone_wmark_min)
> @@ -6954,6 +6964,12 @@ int watermark_scale_factor_sysctl_handler(struct ctl_table *table, int write,
>  }
>
>  #ifdef CONFIG_NUMA
> +static void setup_min_unmapped_ratio(struct zone *zone)
> +{
> +	zone->min_unmapped_pages = (zone->managed_pages *
> +			sysctl_min_unmapped_ratio) / 100;
> +}
> +
>  int sysctl_min_unmapped_ratio_sysctl_handler(struct ctl_table *table, int write,
>  	void __user *buffer, size_t *length, loff_t *ppos)
>  {
> @@ -6965,11 +6981,17 @@ int sysctl_min_unmapped_ratio_sysctl_handler(struct ctl_table *table, int write,
>  		return rc;
>
>  	for_each_zone(zone)
> -		zone->min_unmapped_pages = (zone->managed_pages *
> -				sysctl_min_unmapped_ratio) / 100;
> +		setup_min_unmapped_ratio(zone);
> +
>  	return 0;
>  }
>
> +static void setup_min_slab_ratio(struct zone *zone)
> +{
> +	zone->min_slab_pages = (zone->managed_pages *
> +			sysctl_min_slab_ratio) / 100;
> +}
> +
>  int sysctl_min_slab_ratio_sysctl_handler(struct ctl_table *table, int write,
>  	void __user *buffer, size_t *length, loff_t *ppos)
>  {
> @@ -6981,8 +7003,8 @@ int sysctl_min_slab_ratio_sysctl_handler(struct ctl_table *table, int write,
>  		return rc;
>
>  	for_each_zone(zone)
> -		zone->min_slab_pages = (zone->managed_pages *
> -				sysctl_min_slab_ratio) / 100;
> +		setup_min_slab_ratio(zone);
> +
>  	return 0;
>  }
>  #endif
>

[toc] | [next] | [standalone]


#1432622

FromJoonsoo Kim <iamjoonsoo.kim@lge.com>
Date2016-06-28 10:20 +0200
Message-ID<rOWpr-4kK-27@gated-at.bofh.it>
In reply to#1430660
On Fri, Jun 24, 2016 at 03:20:43PM +0200, Vlastimil Babka wrote:
> On 05/26/2016 08:22 AM, js1304@gmail.com wrote:
> >From: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> >
> >Some of zone threshold depends on number of managed pages in the zone.
> >When memory is going on/offline, it can be changed and we need to
> >adjust them.
> >
> >This patch add recalculation to appropriate places and clean-up
> >related function for better maintanance.
> 
> Can you be more specific about the user visible effect? Presumably
> it's not affecting just ZONE_CMA?

Yes, it's also affecting memory hotplug.

> I assume it's fixing the thresholds where only part of node is
> onlined or offlined? Or are they currently wrong even when whole
> node is onlined/offlined?

When memory hotplug happens, managed_pages changes and we need to
recalculate everything based on managed_pages. min_slab_pages and
min_unmapped_pages are missed so this patch does it, too.

Thanks.

> 
> (Sorry but I can't really orient myself in the maze of memory hotplug :(
> 
> Thanks,
> Vlastimil
> 
> >Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> >---
> > mm/page_alloc.c | 36 +++++++++++++++++++++++++++++-------
> > 1 file changed, 29 insertions(+), 7 deletions(-)
> >
> >diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> >index d27e8b9..90e5a82 100644
> >--- a/mm/page_alloc.c
> >+++ b/mm/page_alloc.c
> >@@ -4874,6 +4874,8 @@ int local_memory_node(int node)
> > }
> > #endif
> >
> >+static void setup_min_unmapped_ratio(struct zone *zone);
> >+static void setup_min_slab_ratio(struct zone *zone);
> > #else	/* CONFIG_NUMA */
> >
> > static void set_zonelist_order(void)
> >@@ -5988,9 +5990,8 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat)
> > 		zone->managed_pages = is_highmem_idx(j) ? realsize : freesize;
> > #ifdef CONFIG_NUMA
> > 		zone->node = nid;
> >-		zone->min_unmapped_pages = (freesize*sysctl_min_unmapped_ratio)
> >-						/ 100;
> >-		zone->min_slab_pages = (freesize * sysctl_min_slab_ratio) / 100;
> >+		setup_min_unmapped_ratio(zone);
> >+		setup_min_slab_ratio(zone);
> > #endif
> > 		zone->name = zone_names[j];
> > 		spin_lock_init(&zone->lock);
> >@@ -6896,6 +6897,7 @@ int __meminit init_per_zone_wmark_min(void)
> > {
> > 	unsigned long lowmem_kbytes;
> > 	int new_min_free_kbytes;
> >+	struct zone *zone;
> >
> > 	lowmem_kbytes = nr_free_buffer_pages() * (PAGE_SIZE >> 10);
> > 	new_min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
> >@@ -6913,6 +6915,14 @@ int __meminit init_per_zone_wmark_min(void)
> > 	setup_per_zone_wmarks();
> > 	refresh_zone_stat_thresholds();
> > 	setup_per_zone_lowmem_reserve();
> >+
> >+	for_each_zone(zone) {
> >+#ifdef CONFIG_NUMA
> >+		setup_min_unmapped_ratio(zone);
> >+		setup_min_slab_ratio(zone);
> >+#endif
> >+	}
> >+
> > 	return 0;
> > }
> > core_initcall(init_per_zone_wmark_min)
> >@@ -6954,6 +6964,12 @@ int watermark_scale_factor_sysctl_handler(struct ctl_table *table, int write,
> > }
> >
> > #ifdef CONFIG_NUMA
> >+static void setup_min_unmapped_ratio(struct zone *zone)
> >+{
> >+	zone->min_unmapped_pages = (zone->managed_pages *
> >+			sysctl_min_unmapped_ratio) / 100;
> >+}
> >+
> > int sysctl_min_unmapped_ratio_sysctl_handler(struct ctl_table *table, int write,
> > 	void __user *buffer, size_t *length, loff_t *ppos)
> > {
> >@@ -6965,11 +6981,17 @@ int sysctl_min_unmapped_ratio_sysctl_handler(struct ctl_table *table, int write,
> > 		return rc;
> >
> > 	for_each_zone(zone)
> >-		zone->min_unmapped_pages = (zone->managed_pages *
> >-				sysctl_min_unmapped_ratio) / 100;
> >+		setup_min_unmapped_ratio(zone);
> >+
> > 	return 0;
> > }
> >
> >+static void setup_min_slab_ratio(struct zone *zone)
> >+{
> >+	zone->min_slab_pages = (zone->managed_pages *
> >+			sysctl_min_slab_ratio) / 100;
> >+}
> >+
> > int sysctl_min_slab_ratio_sysctl_handler(struct ctl_table *table, int write,
> > 	void __user *buffer, size_t *length, loff_t *ppos)
> > {
> >@@ -6981,8 +7003,8 @@ int sysctl_min_slab_ratio_sysctl_handler(struct ctl_table *table, int write,
> > 		return rc;
> >
> > 	for_each_zone(zone)
> >-		zone->min_slab_pages = (zone->managed_pages *
> >-				sysctl_min_slab_ratio) / 100;
> >+		setup_min_slab_ratio(zone);
> >+
> > 	return 0;
> > }
> > #endif
> >
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web