Improve sequential read throughput v2
Subsystems (10)
cover Improve sequential read throughput v2
Changelog since v1
o Rebase to v3.16-rc2
o Move CFQ patch to end of series where it can be rejected easier if necessary
o Introduce page-reclaim related patch related to kswapd/fairzone interactions
o Rework fast zone policy patch
IO performance since 3.0 has been a mixed bag. In many respects we are better and in some we are worse and one of those places is sequential read throughput. This is visible in a number of benchmarks but I looked at tiobench the closest. This is using ext3 on a mid-range desktop and comparing against 3.0.
3.16.0-rc2 3.16.0-rc2 3.0.0
vanilla cfq600 vanilla
Min SeqRead-MB/sec-1 120.96 ( 0.00%) 140.43 ( 16.10%) 134.04 ( 10.81%) Min SeqRead-MB/sec-2 100.73 ( 0.00%) 118.18 ( 17.32%) 120.76 ( 19.88%) Min SeqRead-MB/sec-4 96.05 ( 0.00%) 110.84 ( 15.40%) 114.49 ( 19.20%) Min SeqRead-MB/sec-8 82.46 ( 0.00%) 92.40 ( 12.05%) 98.04 ( 18.89%) Min SeqRead-MB/sec-16 66.37 ( 0.00%) 76.68 ( 15.53%) 79.49 ( 19.77%)
This series does not fully restore throughput performance to 3.0 levels but it brings it acceptably close. While throughput for higher numbers of threads is lower, it is known that it can be tuned by increasing target_latency or disabling low_latency giving higher overall throughput at the cost of latency and IO fairness.
This series in ordered in ascending-likelihood-to-cause-controversary so that a partial series can still potentially be merged even if parts of it are naked (e.g. CGQ). For reference, here is the series without the CFQ patch at the end.
3.16.0-rc2 3.16.0-rc2 3.0.0
vanilla lessdirty vanilla
Min SeqRead-MB/sec-1 120.96 ( 0.00%) 141.04 ( 16.60%) 134.04 ( 10.81%) Min SeqRead-MB/sec-2 100.73 ( 0.00%) 116.26 ( 15.42%) 120.76 ( 19.88%) Min SeqRead-MB/sec-4 96.05 ( 0.00%) 109.52 ( 14.02%) 114.49 ( 19.20%) Min SeqRead-MB/sec-8 82.46 ( 0.00%) 88.60 ( 7.45%) 98.04 ( 18.89%) Min SeqRead-MB/sec-16 66.37 ( 0.00%) 69.87 ( 5.27%) 79.49 ( 19.77%)
block/cfq-iosched.c | 2 +- include/linux/mmzone.h | 210 ++++++++++++++++++++++------------------- include/linux/writeback.h | 1 + include/trace/events/pagemap.h | 16 ++-- mm/internal.h | 1 + mm/mm_init.c | 5 +- mm/page-writeback.c | 15 +-- mm/page_alloc.c | 206 ++++++++++++++++++++++++++-------------- mm/swap.c | 4 +- mm/vmscan.c | 16 ++-- mm/vmstat.c | 4 +- 11 files changed, 285 insertions(+), 195 deletions(-)
Signature · 7 lines
1.8.4.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/6 mm: pagemap: Avoid unnecessary overhead when tracepoints are deactivated
The LRU insertion and activate tracepoints take PFN as a parameter forcing the overhead to the caller. Move the overhead to the tracepoint fast-assign method to ensure the cost is only incurred when the tracepoint is active.
--- include/trace/events/pagemap.h | 16 +++++++--------- mm/swap.c | 4 ++-- 2 files changed, 9 insertions(+), 11 deletions(-)
include/trace/events/pagemap.h +7 -9
@@ -28,12 +28,10 @@ TRACE_EVENT(mm_lru_insertion,TP_PROTO ( struct page *page, - unsigned long pfn, - int lru, - unsigned long flags + int lru ), -TP_ARGS (page, pfn, lru, flags), +TP_ARGS (page, lru),TP_STRUCT__entry ( __field(struct page *, page )
@@ -44,9 +42,9 @@ TRACE_EVENT(mm_lru_insertion,TP_fast_assign ( __entry->page = page; - __entry->pfn = pfn; + __entry->pfn =page_to_pfn (page); __entry->lru = lru; - __entry->flags = flags; + __entry->flags =trace_pagemap_flags (page); ),/* Flag format is based on page-types.c formatting for pagemap */
@@ -64,9 +62,9 @@ TRACE_EVENT(mm_lru_insertion, TRACE_EVENT(mm_lru_activate, - TP_PROTO(struct page *page, unsigned long pfn), + TP_PROTO(struct page *page), - TP_ARGS(page, pfn), + TP_ARGS(page), TP_STRUCT__entry( __field(struct page *, page )
@@ -75,7 +73,7 @@ TRACE_EVENT(mm_lru_activate,TP_fast_assign ( __entry->page = page; - __entry->pfn = pfn; + __entry->pfn =page_to_pfn (page); ),/* Flag format is based on page-types.c formatting for pagemap */
mm/swap.c +2 -2
@@ -501,7 +501,7 @@ static void __activate_page(struct page *page, struct lruvec *lruvec,SetPageActive (page); lru +=LRU_ACTIVE ;add_page_to_lru_list (page, lruvec, lru); -trace_mm_lru_activate (page,page_to_pfn (page)); +trace_mm_lru_activate (page);__count_vm_event (PGACTIVATE );update_page_reclaim_stat (lruvec, file,1 );
@@ -996,7 +996,7 @@ static void __pagevec_lru_add_fn(struct page *page, struct lruvec *lruvec,SetPageLRU (page);add_page_to_lru_list (page, lruvec, lru);update_page_reclaim_stat (lruvec, file, active); -trace_mm_lru_insertion (page,page_to_pfn (page), lru,trace_pagemap_flags (page)); +trace_mm_lru_insertion (page, lru); }/*
Signature · 7 lines
1.8.4.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/6 mm: Rearrange zone fields into read-only, page alloc, statistics and page reclaim lines
In reply to Mel GormanThe arrangement of struct zone has changed over time and now it has reached the point where there is some inappropriate sharing going on. On x86-64 for example
o The zone->node field is shared with the zone lock and zone->node is accessed frequently from the page allocator due to the fair zone allocation policy.
o span_seqlock is almost never used by shares a line with free_area
o Some zone statistics share a cache line with the LRU lock so reclaim-intensive and allocator-intensive workloads can bounce the cache line on a stat update
This patch rearranges struct zone to put read-only and read-mostly fields together and then splits the page allocator intensive fields, the zone statistics and the page reclaim intensive fields into their own cache lines. Note that arguably the biggest change is reducing the size of the lowmem_reserve type. It should still be large enough but by shrinking it the fields used by the page allocator fast path all fit in one cache line.
On the test configuration I used the overall size of struct zone shrunk by one cache line.
--- include/linux/mmzone.h | 201 +++++++++++++++++++++++++------------------------ mm/page_alloc.c | 13 ++-- mm/vmstat.c | 4 +- 3 files changed, 113 insertions(+), 105 deletions(-)
include/linux/mmzone.h +103 -98
@@ -324,19 +324,12 @@ enum zone_type { #ifndef __GENERATING_BOUNDS_H struct zone { - /* Fields commonly accessed by the page allocator */ + /* Read-mostly fields */ /* zone watermarks, access with *_wmark_pages(zone) macros */ unsigned long watermark[NR_WMARK]; /* - * When free pages are below this point, additional steps are taken - * when reading the number of free pages to avoid per-cpu counter - * drift allowing watermarks to be breached - */ - unsigned long percpu_drift_mark; - - /* * We don't know if the memory that we're going to allocate will be freeable * or/and it will be released eventually, so to avoid totally wasting several * GB of ram we must reserve some of the lower zone memory (otherwise we risk
@@ -344,41 +337,17 @@ struct zone {* on the higher zones). This array is recalculated at runtime if the * sysctl_lowmem_reserve_ratio sysctl changes. */ -unsigned long lowmem_reserve[MAX_NR_ZONES ]; - -/* -* This is a per-zone reserve of pages that should not be -* considered dirtyable memory. -*/ -unsigned long dirty_balance_reserve; +unsigned int lowmem_reserve[MAX_NR_ZONES ]; +struct per_cpu_pageset __percpu *pageset;#ifdef CONFIG_NUMA int node; -/* -* zone reclaim becomes active if more unmapped pages exist. -*/ -unsigned long min_unmapped_pages; -unsigned long min_slab_pages;#endif -struct per_cpu_pageset __percpu *pageset;/* -* free areas of different sizes +* The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on +* this zone's LRU. Maintained by the pageout code. */ -spinlock_t lock; -#if definedCONFIG_COMPACTION || definedCONFIG_CMA -/* Set to true when the PG_migrate_skip bits should be cleared */ -bool compact_blockskip_flush; - -/* pfn where compaction free scanner should start */ -unsigned long compact_cached_free_pfn; -/* pfn where async and sync compaction migration scanner should start */ -unsigned long compact_cached_migrate_pfn[2 ]; -#endif -#ifdef CONFIG_MEMORY_HOTPLUG -/* see spanned/present_pages for more description */ -seqlock_t span_seqlock; -#endif -struct free_area free_area[MAX_ORDER ]; +unsigned int inactive_ratio;#ifndef CONFIG_SPARSEMEM /*
@@ -388,74 +357,37 @@ struct zone {unsigned long *pageblock_flags;#endif /* CONFIG_SPARSEMEM */ -#ifdef CONFIG_COMPACTION /* -* On compaction failure, 1<<compact_defer_shift compactions -* are skipped before trying again. The number attempted since -* last failure is tracked with compact_considered. +* This is a per-zone reserve of pages that should not be +* considered dirtyable memory. */ -unsigned int compact_considered; -unsigned int compact_defer_shift; -int compact_order_failed; -#endif - -ZONE_PADDING (_pad1_) - -/* Fields commonly accessed by the page reclaim scanner */ - spinlock_t lru_lock; -struct lruvec lruvec; - -/* Evictions & activations on the inactive file list */ -atomic_long_t inactive_age; - -unsigned long pages_scanned;/* since last reclaim */ -unsigned long flags;/* zone flags, see below */ - -/* Zone statistics */ -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS ]; +unsigned long dirty_balance_reserve;/* -* The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on -* this zone's LRU. Maintained by the pageout code. +* When free pages are below this point, additional steps are taken +* when reading the number of free pages to avoid per-cpu counter +* drift allowing watermarks to be breached */ -unsigned int inactive_ratio; - - -ZONE_PADDING (_pad2_) -/* Rarely used or read-mostly fields */ +unsigned long percpu_drift_mark; +#ifdef CONFIG_NUMA /* -* wait_table -- the array holding the hash table -* wait_table_hash_nr_entries -- the size of the hash table array -* wait_table_bits -- wait_table_size == (1 << wait_table_bits) -* -* The purpose of all these is to keep track of the people -* waiting for a page to become available and make them -* runnable again when possible. The trouble is that this -* consumes a lot of space, especially when so few things -* wait on pages at a given time. So instead of using -* per-page waitqueues, we use a waitqueue hash table. -* -* The bucket discipline is to sleep on the same queue when -* colliding and wake all in that wait queue when removing. -* When something wakes, it must check to be sure its page is -* truly available, a la thundering herd. The cost of a -* collision is great, but given the expected load of the -* table, they should be so rare as to be outweighed by the -* benefits from the saved space. -* -* __wait_on_page_locked() and unlock_page() in mm/filemap.c, are the -* primary users of these fields, and in mm/page_alloc.c -* free_area_init_core() performs the initialization of them. +* zone reclaim becomes active if more unmapped pages exist. */ - wait_queue_head_t * wait_table; -unsigned long wait_table_hash_nr_entries; -unsigned long wait_table_bits; +unsigned long min_unmapped_pages; +unsigned long min_slab_pages; +#endif /* CONFIG_NUMA */ + +const char *name;/* -* Discontig memory support fields. +* Number of MIGRATE_RESEVE page block. To maintain for just +* optimization. Protected by zone->lock. */ +int nr_migrate_reserve_block; +struct pglist_data *zone_pgdat; +/* zone_start_pfn == zone_start_paddr >> PAGE_SHIFT */ unsigned long zone_start_pfn;
@@ -504,16 +436,89 @@ struct zone {unsigned long present_pages;unsigned long managed_pages; +#ifdef CONFIG_MEMORY_HOTPLUG +/* see spanned/present_pages for more description */ +seqlock_t span_seqlock; +#endif +/* -* Number of MIGRATE_RESEVE page block. To maintain for just -* optimization. Protected by zone->lock. +* wait_table -- the array holding the hash table +* wait_table_hash_nr_entries -- the size of the hash table array +* wait_table_bits -- wait_table_size == (1 << wait_table_bits) +* +* The purpose of all these is to keep track of the people +* waiting for a page to become available and make them +* runnable again when possible. The trouble is that this +* consumes a lot of space, especially when so few things +* wait on pages at a given time. So instead of using +* per-page waitqueues, we use a waitqueue hash table. +* +* The bucket discipline is to sleep on the same queue when +* colliding and wake all in that wait queue when removing. +* When something wakes, it must check to be sure its page is +* truly available, a la thundering herd. The cost of a +* collision is great, but given the expected load of the +* table, they should be so rare as to be outweighed by the +* benefits from the saved space. +* +* __wait_on_page_locked() and unlock_page() in mm/filemap.c, are the +* primary users of these fields, and in mm/page_alloc.c +* free_area_init_core() performs the initialization of them. */ -int nr_migrate_reserve_block; +wait_queue_head_t *wait_table; +unsigned long wait_table_hash_nr_entries; +unsigned long wait_table_bits; + +ZONE_PADDING (_pad1_) + +/* Write-intensive fields used from the page allocator */ + spinlock_t lock; + +/* free areas of different sizes */ +struct free_area free_area[MAX_ORDER ]; + +/* zone flags, see below */ +unsigned long flags; + +ZONE_PADDING (_pad2_) + +/* Write-intensive fields used by page reclaim */ + +/* Fields commonly accessed by the page reclaim scanner */ + spinlock_t lru_lock; +struct lruvec lruvec; + +/* Evictions & activations on the inactive file list */ +atomic_long_t inactive_age; + +unsigned long pages_scanned;/* since last reclaim */ + +#if definedCONFIG_COMPACTION || definedCONFIG_CMA +/* pfn where compaction free scanner should start */ +unsigned long compact_cached_free_pfn; +/* pfn where async and sync compaction migration scanner should start */ +unsigned long compact_cached_migrate_pfn[2 ]; +#endif +#ifdef CONFIG_COMPACTION /* -* rarely used fields: +* On compaction failure, 1<<compact_defer_shift compactions +* are skipped before trying again. The number attempted since +* last failure is tracked with compact_considered. */ -const char *name; +unsigned int compact_considered; +unsigned int compact_defer_shift; +int compact_order_failed; +#endif + +#if definedCONFIG_COMPACTION || definedCONFIG_CMA +/* Set to true when the PG_migrate_skip bits should be cleared */ +bool compact_blockskip_flush; +#endif + +ZONE_PADDING (_pad3_) +/* Zone statistics */ + atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS]; }____cacheline_internodealigned_in_smp ; typedef enum {
mm/page_alloc.c +8 -5
@@ -1699,7 +1699,6 @@ static bool __zone_watermark_ok(struct zone *z, unsigned int order, {/* free_pages my go negative - that's OK */ long min = mark; -long lowmem_reserve = z->lowmem_reserve[classzone_idx];int o;long free_cma =0 ;
@@ -1714,7 +1713,7 @@ static bool __zone_watermark_ok(struct zone *z, unsigned int order, free_cma =zone_page_state (z,NR_FREE_CMA_PAGES );#endif -if (free_pages - free_cma <= min + lowmem_reserve) +if (free_pages - free_cma <= min + z->lowmem_reserve[classzone_idx])return false;for (o =0 ; o < order; o++) {/* At the next order, this order's pages become unavailable */
@@ -3245,7 +3244,7 @@ void show_free_areas(unsigned int filter) );printk ("lowmem_reserve[]:" );for (i =0 ; i <MAX_NR_ZONES ; i++) -printk (" %lu" , zone->lowmem_reserve[i]); +printk (" %u" , zone->lowmem_reserve[i]);printk ("\n" ); }
@@ -5566,7 +5565,7 @@ static void calculate_totalreserve_pages(void)for_each_online_pgdat (pgdat) {for (i =0 ; i <MAX_NR_ZONES ; i++) {struct zone *zone = pgdat->node_zones + i; -unsigned long max =0 ; +unsigned int max =0 ;/* Find valid and maximum lowmem_reserve in the zone */ for (j = i; j <MAX_NR_ZONES ; j++) {
@@ -5617,6 +5616,7 @@ static void setup_per_zone_lowmem_reserve(void) idx = j;while (idx) {struct zone *lower_zone; +unsigned long reserve; idx--;
@@ -5624,8 +5624,11 @@ static void setup_per_zone_lowmem_reserve(void) sysctl_lowmem_reserve_ratio[idx] =1 ; lower_zone = pgdat->node_zones + idx; - lower_zone->lowmem_reserve[j] = managed_pages / + reserve = managed_pages / sysctl_lowmem_reserve_ratio[idx]; +if (WARN_ON (reserve >UINT_MAX )) + reserve =UINT_MAX ; + lower_zone->lowmem_reserve[j] = reserve; managed_pages += lower_zone->managed_pages; } }
mm/vmstat.c +2 -2
@@ -1077,10 +1077,10 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat, zone_page_state(zone, i));seq_printf (m, -"\n protection: (%lu" , +"\n protection: (%u" , zone->lowmem_reserve[0 ]);for (i =1 ; i <ARRAY_SIZE (zone->lowmem_reserve); i++) -seq_printf (m,", %lu" , zone->lowmem_reserve[i]); +seq_printf (m,", %u" , zone->lowmem_reserve[i]);seq_printf (m,")" "\n pagesets" );
Signature · 7 lines
1.8.4.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 3/6 mm: vmscan: Do not reclaim from lower zones if they are balanced
In reply to Mel GormanHistorically kswapd scanned from DMA->Movable in the opposite direction to the page allocator to avoid allocating behind kswapd direction of progress. The fair zone allocation policy altered this in a non-obvious manner.
Traditionally, the page allocator prefers to use the highest eligible zone until the watermark is depleted, woke kswapd and moved onto the next zone. kswapd scans zones in the opposite direction so the scanning lists on 64-bit look like this;
Page alloc Kswapd
---------- ------
Movable DMA
Normal DMA32
DMA32 Normal
DMA Movable
If kswapd scanned in the same direction as the page allocator then it is possible that kswapd would proportionally reclaim the lower zones that were never used as the page allocator was always allocating behind the reclaim. This would work as follows
pgalloc hits Normal low wmark
kswapd reclaims Normal kswapd reclaims DMA32
pgalloc hits Normal low wmark
kswapd reclaims Normal kswapd reclaims DMA32
The introduction of the fair zone allocation policy fundamentally altered this problem by interleaving between zones until the low watermark is reached. There are at least two issues with this
o The page allocator can allocate behind kswapds progress (scans/reclaims lower zone and fair zone allocation policy then uses those pages)
o When the low watermark of the high zone is reached there may recently allocated pages allocated from the lower zone but as kswapd scans dma->highmem to the highest zone needing balancing it'll reclaim the lower zone even if it was balanced.
The problem is fundamental to the fact we have per-zone LRU and allocation policies and ideally we would only have per-node allocation and LRU lists. This would avoid the need for the fair zone allocation policy but the low-memory-starvation issue would have to be addressed again from scratch.
This patch will only scan/reclaim from lower zones if they have not reached their watermark. This should not break the normal page aging as the proportional allocations due to the fair zone allocation policy should compensate.
tiobench was used to evaluate this because it includes a simple sequential reader which is the most obvious regression. It also has threaded readers that produce reasonably steady figures.
3.16.0-rc2 3.16.0-rc2 3.0.0
vanilla checklow-v2r14 vanilla
Min SeqRead-MB/sec-1 120.96 ( 0.00%) 140.63 ( 16.26%) 134.04 ( 10.81%) Min SeqRead-MB/sec-2 100.73 ( 0.00%) 117.95 ( 17.10%) 120.76 ( 19.88%) Min SeqRead-MB/sec-4 96.05 ( 0.00%) 109.54 ( 14.04%) 114.49 ( 19.20%) Min SeqRead-MB/sec-8 82.46 ( 0.00%) 88.22 ( 6.99%) 98.04 ( 18.89%) Min SeqRead-MB/sec-16 66.37 ( 0.00%) 69.14 ( 4.17%) 79.49 ( 19.77%) Mean RandWrite-MB/sec-16 1.34 ( 0.00%) 1.34 ( 0.00%) 1.34 ( 0.25%)
Note that this patch makes a large performance difference for lower numbers of threads and brings performance closer to 3.0 figures. It was also tested against xfs and there are similar gains although I don't have 3.0 figures to compare against. There are still regressions for higher number of threads but this is related to changes in the CFQ IO scheduler.
--- mm/vmscan.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
mm/vmscan.c +10 -6
@@ -3124,12 +3124,13 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order,/* * Now scan the zone in the dma->highmem direction, stopping -* at the last zone which needs scanning. -* -* We do this because the page allocator works in the opposite -* direction. This prevents the page allocator from allocating -* pages behind kswapd's direction of progress, which would -* cause too much scanning of the lower zones. +* at the last zone which needs scanning. We do this because +* the page allocators prefers to work in the opposite +* direction and we want to avoid the page allocator reclaiming +* behind kswapd's direction of progress. Due to the fair zone +* allocation policy interleaving allocations between zones +* we no longer proportionally scan the lower zones if the +* watermarks are ok. */ for (i =0 ; i <= end_zone; i++) {struct zone *zone = pgdat->node_zones + i;
@@ -3152,6 +3153,9 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order, &nr_soft_scanned); sc.nr_reclaimed += nr_soft_reclaimed; +if (zone_balanced (zone, order,0 ,0 )) +continue ; +/* * There should be no need to raise the scanning * priority if enough pages are already being scanned
Signature · 7 lines
1.8.4.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerRe: [PATCH 3/6] mm: vmscan: Do not reclaim from lower zones if they are balanced
Quoted 10 lines · On Wed, 25 Jun 2014 08:58:46 +0100 Mel Gorman <[email protected]> wrote:
Historically kswapd scanned from
DMA->Movablein the opposite direction to the page allocator to avoid allocating behind kswapd direction of progress. The fair zone allocation policy altered this in a non-obvious manner.Traditionally, the page allocator prefers to use the highest eligible zone until the watermark is depleted, woke kswapd and moved onto the next zone. kswapd scans zones in the opposite direction so the scanning lists on 64-bit look like this;
Quoted 8 lines
...
Note that this patch makes a large performance difference for lower numbers of threads and brings performance closer to 3.0 figures. It was also tested against xfs and there are similar gains although I don't have 3.0 figures to compare against. There are still regressions for higher number of threads but this is related to changes in the CFQ IO scheduler.
Why did this patch make a difference to sequential read performance? IOW, by what means was/is reclaim interfering with sequential reads?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 3/6] mm: vmscan: Do not reclaim from lower zones if they are balanced
Quoted 21 lines · Andrew Morton
Quoted 10 lines · On Wed, 25 Jun 2014 08:58:46 +0100 Mel Gorman <[email protected]> wrote:
Historically kswapd scanned from
DMA->Movablein the opposite direction to the page allocator to avoid allocating behind kswapd direction of progress. The fair zone allocation policy altered this in a non-obvious manner.Traditionally, the page allocator prefers to use the highest eligible zone until the watermark is depleted, woke kswapd and moved onto the next zone. kswapd scans zones in the opposite direction so the scanning lists on 64-bit look like this;
Quoted 8 lines
...
Note that this patch makes a large performance difference for lower numbers of threads and brings performance closer to 3.0 figures. It was also tested against xfs and there are similar gains although I don't have 3.0 figures to compare against. There are still regressions for higher number of threads but this is related to changes in the CFQ IO scheduler.
Quoted 3 lines
Why did this patch make a difference to sequential read performance? IOW, by what means was/is reclaim interfering with sequential reads?
The fair zone allocator is interleaving between Normal/DMA32. Kswapd is reclaiming from DMA->Highest where Highest is an unbalanced zone. Kswapd will reclaim from DMA32 even if it is balanced if Normal is below watermarks.
Let N = high_wmark(Normal) + high_wmark(DMA32)
Of the last N allocations, some percentage will be allocated from Normal and some from DMA32. The percentage depends on the ratio of the zone sizes and when their watermarks were hit. If Normal is unbalanced, DMA32 will be shrunk by kswapd. If DMA32 is unbalanced only DMA32 will be shrunk. This leads to a difference of ages between DMA32 and Normal. Relatively young pages are then continually rotated and reclaimed from DMA32 due to the higher zone being unbalanced.
A debugging patch showed that some PageReadahead pages are reaching the end of the LRU. The number is not very high but it's there. Monitoring of nr_free_pages on a per-zone basis show that there is constant reclaim of the lower zones even when the watermarks should be ok. The iostats showed that without the page there are more pages being read.
I believe the difference in sequential read performance is because relatively young pages recently readahead are being reclaimed from the lower zones.
Signature · 2 lines
Mel Gorman SUSE Labs
PATCH 4/6 mm: page_alloc: Reduce cost of the fair zone allocation policy
In reply to Mel GormanThe fair zone allocation policy round-robins allocations between zones within a node to avoid age inversion problems during reclaim. If the first allocation fails, the batch counts is reset and a second attempt made before entering the slow path.
One assumption made with this scheme is that batches expire at roughly the same time and the resets each time are justified. This assumption does not hold when zones reach their low watermark as the batches will be consumed at uneven rates. Allocation failure due to watermark depletion result in additional zonelist scans for the reset and another watermark check before hitting the slowpath.
This patch makes a number of changes that should reduce the overall cost
o Do not apply the fair zone policy to small zones such as DMA
o Abort the fair zone allocation policy once remote or small zones are encountered
o Use a simplier scan when resetting NR_ALLOC_BATCH
o Use a simple flag to identify depleted zones instead of accessing a potentially write-intensive cache line for counters
o Track zones who met the watermark but failed the NR_ALLOC_BATCH check to avoid doing a rescan of the zonelist when the counters are reset
On UMA machines, the effect is marginal. Even judging from system CPU usage it's small for the tiobench test
3.16.0-rc2 3.16.0-rc2
checklow fairzone
User 396.24 396.23
System 395.23 391.50Elapsed 5182.65 5165.49
And the number of pages allocated from each zone is comparable
3.16.0-rc2 3.16.0-rc2
checklow fairzoneDMA allocs 0 0
DMA32 allocs 7374217 7920241
Normal allocs 999277551 996568115
On NUMA machines, the scanning overhead is higher as zones are scanned that are ineligible for use by zone allocation policy. This patch fixes the zone-order zonelist policy and reduces the numbers of zones scanned by the allocator.
--- include/linux/mmzone.h | 7 ++ mm/mm_init.c | 5 +- mm/page_alloc.c | 179 ++++++++++++++++++++++++++++++++----------------- 3 files changed, 128 insertions(+), 63 deletions(-)
include/linux/mmzone.h +7 -0
@@ -534,6 +534,7 @@ typedef enum {ZONE_WRITEBACK ,/* reclaim scanning has recently found * many pages under writeback */ +ZONE_FAIR_DEPLETED ,/* fair zone policy batch depleted */ } zone_flags_t;static inline void zone_set_flag (struct zone *zone,zone_flags_t flag)
@@ -571,6 +572,11 @@ static inline int zone_is_reclaim_locked(const struct zone *zone)return test_bit (ZONE_RECLAIM_LOCKED , &zone->flags); } +static inline int zone_is_fair_depleted (const struct zone *zone) +{ +return test_bit (ZONE_FAIR_DEPLETED , &zone->flags); +} +static inline int zone_is_oom_locked (const struct zone *zone) {return test_bit (ZONE_OOM_LOCKED , &zone->flags);
@@ -694,6 +700,7 @@ struct zonelist_cache;struct zoneref {struct zone *zone;/* Pointer to actual zone */ int zone_idx;/* zone_idx(zoneref->zone) */ +bool fair_enabled;/* eligible for fair zone policy */ };/*
mm/mm_init.c +3 -2
@@ -54,8 +54,9 @@ void mminit_verify_zonelist(void)/* Iterate the zonelist */ for_each_zone_zonelist (zone, z, zonelist, zoneid) {#ifdef CONFIG_NUMA -printk (KERN_CONT "%d:%s " , - zone->node, zone->name); +printk (KERN_CONT "%d:%s%s " , + zone->node, zone->name, + z->fair_enabled ?"(F)" :"" );#else printk (KERN_CONT "0:%s " , zone->name);#endif /* CONFIG_NUMA */
mm/page_alloc.c +118 -61
307 lines not on this page · raw message
Signature · 7 lines
1.8.4.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 5/6 mm: page_alloc: Reduce cost of dirty zone balancing
In reply to Mel GormanWhen allocating a page cache page for writing the allocator makes an attempt to proportionally distribute dirty pages between populated zones. The call to zone_dirty_ok is more expensive than expected because of the number of vmstats it examines. This patch caches some of that information to reduce the cost. It means the proportional allocation is based on stale data but the heuristic should not need perfectly accurate information. As before, the benefit is marginal but cumulative and depends on the size of the machine. For a very small machine the effect is visible in system CPU time for a tiobench test but it'll vary between workloads.
3.16.0-rc2 3.16.0-rc2
fairzone lessdirty
User 393.76 389.03
System 391.50 388.64Elapsed 5182.86 5186.28
Even though the benefit is small it's generally worthwhile reducing overhead in the page allocator as it has a tendency to creep up over time.
--- include/linux/mmzone.h | 2 ++ include/linux/writeback.h | 1 + mm/internal.h | 1 + mm/page-writeback.c | 15 +++++++++------ mm/page_alloc.c | 16 ++++++++++++---- 5 files changed, 25 insertions(+), 10 deletions(-)
include/linux/mmzone.h +2 -0
@@ -480,6 +480,8 @@ struct zone {/* zone flags, see below */ unsigned long flags; +unsigned long dirty_limit_cached; +ZONE_PADDING (_pad2_)/* Write-intensive fields used by page reclaim */
include/linux/writeback.h +1 -0
@@ -121,6 +121,7 @@ static inline void laptop_sync_completion(void) { }#endif void throttle_vm_writeout (gfp_t gfp_mask);bool zone_dirty_ok (struct zone *zone); +unsigned long zone_dirty_limit (struct zone *zone);extern unsigned long global_dirty_limit;
mm/internal.h +1 -0
@@ -370,5 +370,6 @@ unsigned long reclaim_clean_pages_from_list(struct zone *zone,#define ALLOC_CPUSET 0x40/* check for correct cpuset */ #define ALLOC_CMA 0x80/* allow allocations from CMA areas */ #define ALLOC_FAIR 0x100/* fair zone allocation */ +#define ALLOC_DIRTY 0x200/* spread GFP_WRITE allocations */ #endif /* __MM_INTERNAL_H */
mm/page-writeback.c +9 -6
@@ -298,10 +298,9 @@ void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty)* Returns the maximum number of dirty pages allowed in a zone, based * on the zone's dirtyable memory. */ -static unsigned long zone_dirty_limit (struct zone *zone) +unsigned long zone_dirty_limit (struct zone *zone) {unsigned long zone_memory =zone_dirtyable_memory (zone); -struct task_struct *tsk = current;unsigned long dirty;if (vm_dirty_bytes)
@@ -310,9 +309,6 @@ static unsigned long zone_dirty_limit(struct zone *zone)else dirty = vm_dirty_ratio * zone_memory /100 ; -if (tsk->flags &PF_LESS_THROTTLE ||rt_task (tsk)) - dirty += dirty /4 ; -return dirty; }
@@ -325,7 +321,14 @@ static unsigned long zone_dirty_limit(struct zone *zone)*/ bool zone_dirty_ok (struct zone *zone) { -unsigned long limit =zone_dirty_limit (zone); +unsigned long limit = zone->dirty_limit_cached; +struct task_struct *tsk = current; + +if (tsk->flags &PF_LESS_THROTTLE ||rt_task (tsk)) { + limit =zone_dirty_limit (zone); + zone->dirty_limit_cached = limit; + limit += limit /4 ; + }return zone_page_state (zone,NR_FILE_DIRTY ) + zone_page_state(zone, NR_UNSTABLE_NFS) +
mm/page_alloc.c +12 -4
@@ -1942,9 +1942,7 @@ get_page_from_freelist(gfp_t gfp_mask, nodemask_t *nodemask, unsigned int order,nodemask_t *allowednodes =NULL ;/* zonelist_cache approximation */ int zlc_active =0 ;/* set if using zonelist_cache */ int did_zlc_setup =0 ;/* just call zlc_setup() one time */ -bool consider_zone_dirty = (alloc_flags &ALLOC_WMARK_LOW ) && - (gfp_mask & __GFP_WRITE); -int nr_fair_skipped =0 ; +int nr_fair_skipped =0 , nr_fail_dirty =0 ;struct zone *fair_zone =NULL ;bool zonelist_rescan;
@@ -2007,8 +2005,11 @@ zonelist_scan:* will require awareness of zones in the * dirty-throttling and the flusher threads. */ -if (consider_zone_dirty && !zone_dirty_ok (zone)) +if ((alloc_flags &ALLOC_DIRTY ) && !zone_dirty_ok (zone)) { + nr_fail_dirty++; + zone->dirty_limit_cached =zone_dirty_limit (zone);continue ; + } mark = zone->watermark[alloc_flags &ALLOC_WMARK_MASK ]; if (!zone_watermark_ok(zone, order, mark,
@@ -2134,6 +2135,11 @@ this_zone_full: zonelist_rescan = true; } +if ((alloc_flags &ALLOC_DIRTY ) && nr_fail_dirty) { + alloc_flags &= ~ALLOC_DIRTY ; + zonelist_rescan = true; + } +if (zonelist_rescan) goto zonelist_scan;
@@ -2791,6 +2797,8 @@ retry_cpuset:if (preferred_zoneref->fair_enabled) alloc_flags |=ALLOC_FAIR ; +if (gfp_mask & __GFP_WRITE) + alloc_flags |=ALLOC_DIRTY ;#ifdef CONFIG_CMA if (allocflags_to_migratetype (gfp_mask) ==MIGRATE_MOVABLE ) alloc_flags |=ALLOC_CMA ;
Signature · 7 lines
1.8.4.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerRe: [PATCH 5/6] mm: page_alloc: Reduce cost of dirty zone balancing
mm/page-writeback.c static unsigned long zone_dirty_limit(struct zone *zone) · line 331
Quoted 13 lines · On Wed, 25 Jun 2014 08:58:48 +0100 Mel Gorman <[email protected]> wrote:
mm/page-writeback.c +8
-1@@ -325,7 +321,14 @@ static unsigned long zone_dirty_limit(struct zone *zone)*/ bool zone_dirty_ok (struct zone *zone) { -unsigned long limit =zone_dirty_limit (zone); +unsigned long limit = zone->dirty_limit_cached; +struct task_struct *tsk = current; + +if (tsk->flags &PF_LESS_THROTTLE ||rt_task (tsk)) { + limit =zone_dirty_limit (zone); + zone->dirty_limit_cached = limit; + limit += limit /4 ; + }
Could we get a comment in here explaining what we're doing and why PF_LESS_THROTTLE and rt_task control whether we do it?
Re: [PATCH 5/6] mm: page_alloc: Reduce cost of dirty zone balancing
Quoted 19 lines · Andrew Morton
mm/page-writeback.c static unsigned long zone_dirty_limit(struct zone *zone) · line 331
Quoted 13 lines · On Wed, 25 Jun 2014 08:58:48 +0100 Mel Gorman <[email protected]> wrote:
mm/page-writeback.c +8
-1@@ -325,7 +321,14 @@ static unsigned long zone_dirty_limit(struct zone *zone)*/ bool zone_dirty_ok (struct zone *zone) { -unsigned long limit =zone_dirty_limit (zone); +unsigned long limit = zone->dirty_limit_cached; +struct task_struct *tsk = current; + +if (tsk->flags &PF_LESS_THROTTLE ||rt_task (tsk)) { + limit =zone_dirty_limit (zone); + zone->dirty_limit_cached = limit; + limit += limit /4 ; + }Could we get a comment in here explaining what we're doing and why
PF_LESS_THROTTLEandrt_taskcontrol whether we do it?
/*
* The dirty limits are lifted by 1/4 for PF_LESS_THROTTLE (ie. nfsd)
* and real-time tasks to prioritise their allocations.
* PF_LESS_THROTTLE tasks may be cleaning memory and rt tasks may be
* blocking tasks that can clean pages.
*/
That's fairly weak though. It would also seem reasonable to just delete this check and allow PF_LESS_THROTTLE and rt_tasks to fall into the slow path if dirty pages are already fairly distributed between zones. Johannes, any objection to that limit raising logic being deleted?
Signature · 2 lines
Mel Gorman SUSE Labs
Johannes Weiner
maintainerRe: [PATCH 5/6] mm: page_alloc: Reduce cost of dirty zone balancing
Quoted 28 lines · Mel Gorman
Quoted 19 lines · Andrew Morton
mm/page-writeback.c static unsigned long zone_dirty_limit(struct zone *zone) · line 331
Quoted 13 lines · On Wed, 25 Jun 2014 08:58:48 +0100 Mel Gorman <[email protected]> wrote:
mm/page-writeback.c +8
-1@@ -325,7 +321,14 @@ static unsigned long zone_dirty_limit(struct zone *zone)*/ bool zone_dirty_ok (struct zone *zone) { -unsigned long limit =zone_dirty_limit (zone); +unsigned long limit = zone->dirty_limit_cached; +struct task_struct *tsk = current; + +if (tsk->flags &PF_LESS_THROTTLE ||rt_task (tsk)) { + limit =zone_dirty_limit (zone); + zone->dirty_limit_cached = limit; + limit += limit /4 ; + }Could we get a comment in here explaining what we're doing and why
PF_LESS_THROTTLEandrt_taskcontrol whether we do it?/*
* The dirty limits are lifted by 1/4 forPF_LESS_THROTTLE(ie. nfsd)
* and real-time tasks to prioritise their allocations.
*PF_LESS_THROTTLEtasks may be cleaning memory and rt tasks may be
* blocking tasks that can clean pages.
*/
Quoted 4 lines
That's fairly weak though. It would also seem reasonable to just delete this check and allow
PF_LESS_THROTTLEandrt_tasksto fall into the slow path if dirty pages are already fairly distributed between zones. Johannes, any objection to that limit raising logic being deleted?
I copied that over from global_dirty_limits() such that the big picture and the per-zone picture have the same view - otherwise these tasks fall back to first fit zone allocations before global limits start throttling dirtiers and waking up the flushers. This increases the probability of reclaim running into dirty pages.
Would you remove it from global_dirty_limits() as well?
On that note, I don't really understand why global_dirty_limits() raises the *background* limit for less-throttle/rt tasks, shouldn't it only raise the dirty limit? Sure, the throttle point is somewhere between the two limits, but we don't really want to defer waking up the flushers for them.
Re: [PATCH 5/6] mm: page_alloc: Reduce cost of dirty zone balancing
Quoted 40 lines · Johannes Weiner
Quoted 28 lines · Mel Gorman
Quoted 19 lines · Andrew Morton
mm/page-writeback.c static unsigned long zone_dirty_limit(struct zone *zone) · line 331
Quoted 13 lines · On Wed, 25 Jun 2014 08:58:48 +0100 Mel Gorman <[email protected]> wrote:
mm/page-writeback.c +8
-1@@ -325,7 +321,14 @@ static unsigned long zone_dirty_limit(struct zone *zone)*/ bool zone_dirty_ok (struct zone *zone) { -unsigned long limit =zone_dirty_limit (zone); +unsigned long limit = zone->dirty_limit_cached; +struct task_struct *tsk = current; + +if (tsk->flags &PF_LESS_THROTTLE ||rt_task (tsk)) { + limit =zone_dirty_limit (zone); + zone->dirty_limit_cached = limit; + limit += limit /4 ; + }Could we get a comment in here explaining what we're doing and why
PF_LESS_THROTTLEandrt_taskcontrol whether we do it?/*
* The dirty limits are lifted by 1/4 forPF_LESS_THROTTLE(ie. nfsd)
* and real-time tasks to prioritise their allocations.
*PF_LESS_THROTTLEtasks may be cleaning memory and rt tasks may be
* blocking tasks that can clean pages.
*/Quoted 4 lines
That's fairly weak though. It would also seem reasonable to just delete this check and allow
PF_LESS_THROTTLEandrt_tasksto fall into the slow path if dirty pages are already fairly distributed between zones. Johannes, any objection to that limit raising logic being deleted?I copied that over from
global_dirty_limits()such that the big picture and the per-zone picture have the same view - otherwise these tasks fall back to first fit zone allocations before global limits start throttling dirtiers and waking up the flushers. This increases the probability of reclaim running into dirty pages.
Quoted 7 lines
Would you remove it from
global_dirty_limits()as well?On that note, I don't really understand why
global_dirty_limits()raises the *background* limit for less-throttle/rt tasks, shouldn't it only raise the dirty limit? Sure, the throttle point is somewhere between the two limits, but we don't really want to defer waking up the flushers for them.
All of which is fair enough and is something that should be examined on a rainy day (shouldn't take too long in Ireland). I'm not going to touch it within this series though. It's outside the scope of what I'm trying to do here -- restore performance of tiobench and bonnie++ to as close to 3.0 levels as possible. The series is tripping up enough on the fair zone and CFQ aspects as it is without increasing the scope :(
Signature · 2 lines
Mel Gorman SUSE Labs
Johannes Weiner
maintainerRe: [PATCH 5/6] mm: page_alloc: Reduce cost of dirty zone balancing
Quoted 49 lines · Mel Gorman
Quoted 40 lines · Johannes Weiner
Quoted 28 lines · Mel Gorman
Quoted 19 lines · Andrew Morton
mm/page-writeback.c static unsigned long zone_dirty_limit(struct zone *zone) · line 331
Quoted 13 lines · On Wed, 25 Jun 2014 08:58:48 +0100 Mel Gorman <[email protected]> wrote:
mm/page-writeback.c +8
-1@@ -325,7 +321,14 @@ static unsigned long zone_dirty_limit(struct zone *zone)*/ bool zone_dirty_ok (struct zone *zone) { -unsigned long limit =zone_dirty_limit (zone); +unsigned long limit = zone->dirty_limit_cached; +struct task_struct *tsk = current; + +if (tsk->flags &PF_LESS_THROTTLE ||rt_task (tsk)) { + limit =zone_dirty_limit (zone); + zone->dirty_limit_cached = limit; + limit += limit /4 ; + }Could we get a comment in here explaining what we're doing and why
PF_LESS_THROTTLEandrt_taskcontrol whether we do it?/*
* The dirty limits are lifted by 1/4 forPF_LESS_THROTTLE(ie. nfsd)
* and real-time tasks to prioritise their allocations.
*PF_LESS_THROTTLEtasks may be cleaning memory and rt tasks may be
* blocking tasks that can clean pages.
*/Quoted 4 lines
That's fairly weak though. It would also seem reasonable to just delete this check and allow
PF_LESS_THROTTLEandrt_tasksto fall into the slow path if dirty pages are already fairly distributed between zones. Johannes, any objection to that limit raising logic being deleted?I copied that over from
global_dirty_limits()such that the big picture and the per-zone picture have the same view - otherwise these tasks fall back to first fit zone allocations before global limits start throttling dirtiers and waking up the flushers. This increases the probability of reclaim running into dirty pages.Quoted 7 lines
Would you remove it from
global_dirty_limits()as well?On that note, I don't really understand why
global_dirty_limits()raises the *background* limit for less-throttle/rt tasks, shouldn't it only raise the dirty limit? Sure, the throttle point is somewhere between the two limits, but we don't really want to defer waking up the flushers for them.
Quoted 6 lines
All of which is fair enough and is something that should be examined on a rainy day (shouldn't take too long in Ireland). I'm not going to touch it within this series though. It's outside the scope of what I'm trying to do here -- restore performance of tiobench and bonnie++ to as close to 3.0 levels as possible. The series is tripping up enough on the fair zone and CFQ aspects as it is without increasing the scope :(
You asked to remove it, I'm just asking follow-up questions ;-)
I agree that this is out-of-scope for your patches and it probably should be left alone for now. However, I do like your comment and wouldn't mind including it in this change.
Would everybody be okay with that?
PATCH 6/6 cfq: Increase default value of target_latency
In reply to Mel GormanThe existing CFQ default target_latency results in very poor performance for larger numbers of threads doing sequential reads. While this can be easily described as a tuning problem for users, it is one that is tricky to detect. This patch updates the default to benefit smaller machines. Dave Chinner points out that it is dangerous to assume that people know how to tune their IO scheduler. Jeff Moyer asked what workloads even care about threaded readers but it's reasonable to assume file, media, database and multi-user servers all experience large sequential readers from multiple sources at the same time.
It's a bit depressing to note how much slower this relatively simple case is in comparison to 3.0. The following is from tiobench on a mid-range desktop using ext3 as the test filesystem although it's known other filesystems experience similar trouble.
3.16.0-rc2 3.16.0-rc2 3.0.0
lessdirty cfq600 vanilla
Min SeqRead-MB/sec-1 140.79 ( 0.00%) 140.43 ( -0.26%) 134.04 ( -4.79%) Min SeqRead-MB/sec-2 118.08 ( 0.00%) 118.18 ( 0.08%) 120.76 ( 2.27%) Min SeqRead-MB/sec-4 108.47 ( 0.00%) 110.84 ( 2.18%) 114.49 ( 5.55%) Min SeqRead-MB/sec-8 87.20 ( 0.00%) 92.40 ( 5.96%) 98.04 ( 12.43%) Min SeqRead-MB/sec-16 68.98 ( 0.00%) 76.68 ( 11.16%) 79.49 ( 15.24%)
The full series including this patch brings performance within an acceptable distance of 3.0.0-vanilla considering that read latencies and fairness are generally better now at the cost of overall throughput.
Here is the very high-level view of the iostats
3.16.0-rc2 3.16.0-rc2 3.0.0
lessdirty cfq600 vanilla
Mean sda-avgqusz 935.48 957.28 1000.70 Mean sda-avgrqsz 575.27 579.85 600.71
Mean sda-await 4405.00 4471.12 4887.67
Mean sda-r_await 82.43 87.95 108.53
Mean sda-w_await 13272.23 10783.67 11599.83
Mean sda-rrqm 14.12 10.14 19.68
Mean sda-wrqm 1631.24 1744.00 11999.46 Max sda-avgqusz 2179.79 2238.95 2626.78 Max sda-avgrqsz 1021.03 1021.97 1024.00 Max sda-await 15007.79 13600.51 24971.00 Max sda-r_await 897.78 893.09 5308.00 Max sda-w_await 207814.40 179483.79 177698.47 Max sda-rrqm 68.40 45.60 73.30 Max sda-wrqm 19544.00 19619.20 58058.40
await figures are generally ok. Average wait times are still acceptable and the worst-case read wait times are ok. Queue sizes and request sizes generally look ok. It's worth noting that the iostats are generally *far* better than 3.0.
--- block/cfq-iosched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/cfq-iosched.c +1 -1
@@ -32,7 +32,7 @@ static int cfq_slice_async = HZ / 25;static const int cfq_slice_async_rq =2 ;static int cfq_slice_idle =HZ /125 ;static int cfq_group_idle =HZ /125 ; -static const int cfq_target_latency =HZ *3 /10 ;/* 300 ms */ +static const int cfq_target_latency =HZ *6 /10 ;/* 600 ms */ static const int cfq_hist_divisor =4 ;/*
Signature · 7 lines
1.8.4.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 6/6] cfq: Increase default value of target_latency
Quoted 9 lines · Mel Gorman
The existing CFQ default
target_latencyresults in very poor performance for larger numbers of threads doing sequential reads. While this can be easily described as a tuning problem for users, it is one that is tricky to detect. This patch updates the default to benefit smaller machines. Dave Chinner points out that it is dangerous to assume that people know how to tune their IO scheduler. Jeff Moyer asked what workloads even care about threaded readers but it's reasonable to assume file, media, database and multi-user servers all experience large sequential readers from multiple sources at the same time.
Right, and I guess I hadn't considered that case as I thought folks used more than one spinning disk for such workloads.
My main reservation about this change is that you've only provided numbers for one benchmark. To bump the default target_latency, ideally we'd know how it affects other workloads. However, I'm having a hard time justifying putting any time into this for a couple of reasons:
1) blk-mq pretty much does away with the i/o scheduler, and that is the future
2) there is work in progress to convert cfq into bfq, and that will essentially make any effort put into this irrelevant (so it might be interesting to test your workload with bfq)
Cheers,
Jeff
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 6/6] cfq: Increase default value of target_latency
Quoted 12 lines · Jeff Moyer
Quoted 9 lines · Mel Gorman
The existing CFQ default
target_latencyresults in very poor performance for larger numbers of threads doing sequential reads. While this can be easily described as a tuning problem for users, it is one that is tricky to detect. This patch updates the default to benefit smaller machines. Dave Chinner points out that it is dangerous to assume that people know how to tune their IO scheduler. Jeff Moyer asked what workloads even care about threaded readers but it's reasonable to assume file, media, database and multi-user servers all experience large sequential readers from multiple sources at the same time.
Quoted 3 lines
Right, and I guess I hadn't considered that case as I thought folks used more than one spinning disk for such workloads.
They probably are but by and large my IO testing is based on simple storage. The reasoning is that if we get the simple case wrong then we probably are getting the complex case wrong too or at least not performing as well as we should. I also don't use SSD on my own machines for the same reason.
Quoted 2 lines
My main reservation about this change is that you've only provided numbers for one benchmark.
The other obvious one to run would be pgbench workloads but it's a rathole of arguing whether the configuration is valid and whether it's inappropriate to test on simple storage. The tiobench tests alone take a long time to complete -- 1.5 hours on a simple machine, 7 hours on a low-end NUMA machine.
Quoted 9 lines
To bump the default
target_latency, ideally
we'd know how it affects other workloads. However, I'm having a hard time justifying putting any time into this for a couple of reasons:
1) blk-mq pretty much does away with the i/o scheduler, and that is the future
2) there is work in progress to convert cfq into bfq, and that will essentially make any effort put into this irrelevant (so it might be interesting to test your workload with bfq)
Ok, you've convinced me and I'll drop this patch. For anyone based on kernels from around this time they can tune CFQ or buy a better disk. Hopefully they will find this via Google.
There are multiple process sequential read regressions that are getting progressively worse since 3.0 that are partially explained by changes to CFQ. You may have experienced this if you are using a kernel somewhere between 3.3 and 3.15. It's not really a bug in CFQ but a difference in objectives. CFQ in later kernels is more fair to threads and this partially sacrifices overall throughput for lower latency experienced by each of the processes. If you see that the problem goes away using a different IO scheduler but need to use CFQ for whatever reason then tune target_latency to higher values. 600 appears to work reasonable well for a single disk but you may need higher. Keep an eye on IO fairness if that is something that your workload is sensitive to it. Your other option is to disable low_latency in CFQ. As always, check what the most recent kernel is particularly if there have been interesting things happening in either the blk-mq or with the bfq IO scheduler.
Signature · 2 lines
Mel Gorman SUSE Labs
Re: [PATCH 6/6] cfq: Increase default value of target_latency
Quoted 10 lines · Mel Gorman
Quoted 3 lines · Jeff Moyer
Right, and I guess I hadn't considered that case as I thought folks used more than one spinning disk for such workloads.
They probably are but by and large my IO testing is based on simple storage. The reasoning is that if we get the simple case wrong then we probably are getting the complex case wrong too or at least not performing as well as we should. I also don't use SSD on my own machines for the same reason.
A single disk is actually the hard case in this instance, but I understand what you're saying. ;-)
Quoted 7 lines
Quoted 2 lines
My main reservation about this change is that you've only provided numbers for one benchmark.
The other obvious one to run would be pgbench workloads but it's a rathole of arguing whether the configuration is valid and whether it's inappropriate to test on simple storage. The tiobench tests alone take a long time to complete -- 1.5 hours on a simple machine, 7 hours on a low-end NUMA machine.
And we should probably run our standard set of I/O exercisers at the very least. But, like I said, it seems like wasted effort.
Quoted 10 lines
Quoted 9 lines
To bump the default
target_latency, ideally
we'd know how it affects other workloads. However, I'm having a hard time justifying putting any time into this for a couple of reasons:
1) blk-mq pretty much does away with the i/o scheduler, and that is the future
2) there is work in progress to convert cfq into bfq, and that will essentially make any effort put into this irrelevant (so it might be interesting to test your workload with bfq)
Quoted 3 lines
Ok, you've convinced me and I'll drop this patch. For anyone based on kernels from around this time they can tune CFQ or buy a better disk. Hopefully they will find this via Google.
Funny, I wasn't weighing in against your patch. I was merely indicating that I personally wasn't going to invest the time to validate it. But, if you're ok with dropping it, that's obviously fine with me.
Cheers,
Jeff
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 6/6] cfq: Increase default value of target_latency
Quoted 19 lines · Jeff Moyer
Quoted 10 lines · Mel Gorman
Quoted 3 lines · Jeff Moyer
Right, and I guess I hadn't considered that case as I thought folks used more than one spinning disk for such workloads.
They probably are but by and large my IO testing is based on simple storage. The reasoning is that if we get the simple case wrong then we probably are getting the complex case wrong too or at least not performing as well as we should. I also don't use SSD on my own machines for the same reason.
A single disk is actually the hard case in this instance, but I understand what you're saying. ;-)
Quoted 3 lines
Quoted 2 lines
My main reservation about this change is that you've only provided numbers for one benchmark.
Quoted 8 lines
Quoted 4 lines
The other obvious one to run would be pgbench workloads but it's a rathole of arguing whether the configuration is valid and whether it's inappropriate to test on simple storage. The tiobench tests alone take a long time to complete -- 1.5 hours on a simple machine, 7 hours on a low-end NUMA machine.
And we should probably run our standard set of I/O exercisers at the very least. But, like I said, it seems like wasted effort.
Out of curiousity, what do you consider to be the standard set of I/O exercisers? I have a whole battery of them that are run against major releases to track performance over time -- tiobench (it's stupid, but too many people use it), fsmark used in various configurations (single/multi threaded, zero-sized and large files), postmark (file sizes fairly small, working set 2xRAM), bonnie++ (2xRAM), ffsb used in a mail server configuration (taken from btrfs tests), dbench3 (checking in-memory updates, not a realistic IO benchmark), dbench4 (bit more realistic although high thread counts it gets silly and overall it's not a stable predictor of performance), sysbench in various configurations, pgbench used in limited configurations, stutter which tends to hit the worse-case interactivity issues experienced on desktops and kernel builds are the main ones. It takes days to churn through the full set of tests which is why I don't do it for a patch series. I selected tiobench this time because it was the most reliable test to cover both single and multiple-sources-of-IO cases. If I merge a major change I'll usually then watch the next major release and double check that nothing else broke.
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
To bump the default
target_latency, ideally
we'd know how it affects other workloads. However, I'm having a hard time justifying putting any time into this for a couple of reasons:
1) blk-mq pretty much does away with the i/o scheduler, and that is the future
2) there is work in progress to convert cfq into bfq, and that will essentially make any effort put into this irrelevant (so it might be interesting to test your workload with bfq)
Quoted 8 lines
Quoted 3 lines
Ok, you've convinced me and I'll drop this patch. For anyone based on kernels from around this time they can tune CFQ or buy a better disk. Hopefully they will find this via Google.
Funny, I wasn't weighing in against your patch. I was merely indicating that I personally wasn't going to invest the time to validate it. But, if you're ok with dropping it, that's obviously fine with me.
I fear the writing is on the wall that it'll never pass the "have you tested every workload" test and no matter what a counter-example will be found where it's the wrong setting. If CFQ is going to be irrelevant soon it's just not worth wasting the electricity against a mainline kernel.
I'm still interested in what you consider your standard set of IO exercisers though because I can slot any missing parts into the tests that run for every mainline release.
The main one I'm missing is the postgres folks fsync benchmark. I wrote the automation months ago but never activated it because there are enough known problems already.
Thanks.
Signature · 2 lines
Mel Gorman SUSE Labs
Re: [PATCH 6/6] cfq: Increase default value of target_latency
Quoted 6 lines · Mel Gorman
Quoted 3 lines
And we should probably run our standard set of I/O exercisers at the very least. But, like I said, it seems like wasted effort.
Out of curiousity, what do you consider to be the standard set of I/O exercisers?
Yes, that was vague, sorry. I was referring to any io generator that will perform sequential and random I/O (writes, re-writes, reads, random writes, random reads, strided reads, backwards reads, etc). We use iozone internally, testing both buffered and direct I/O, varying file and record sizes and across multiple file systems. Data sets that fall inside of the page cache tend to have a high standard deviation, so, as an I/O guy, I ignore those. ;-)
Cheers,
Jeff
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>