@@ -122,9 +122,7 @@ EXPORT_SYMBOL(laptop_mode);
122
122
123
123
/* End of sysctl-exported parameters */
124
124
125
- unsigned long global_dirty_limit ;
126
-
127
- static struct wb_domain global_wb_domain ;
125
+ struct wb_domain global_wb_domain ;
128
126
129
127
/*
130
128
* Length of period for aging writeout fractions of bdis. This is an
@@ -470,9 +468,15 @@ static void writeout_period(unsigned long t)
470
468
int wb_domain_init (struct wb_domain * dom , gfp_t gfp )
471
469
{
472
470
memset (dom , 0 , sizeof (* dom ));
471
+
472
+ spin_lock_init (& dom -> lock );
473
+
473
474
init_timer_deferrable (& dom -> period_timer );
474
475
dom -> period_timer .function = writeout_period ;
475
476
dom -> period_timer .data = (unsigned long )dom ;
477
+
478
+ dom -> dirty_limit_tstamp = jiffies ;
479
+
476
480
return fprop_global_init (& dom -> completions , gfp );
477
481
}
478
482
@@ -532,7 +536,9 @@ static unsigned long dirty_freerun_ceiling(unsigned long thresh,
532
536
533
537
static unsigned long hard_dirty_limit (unsigned long thresh )
534
538
{
535
- return max (thresh , global_dirty_limit );
539
+ struct wb_domain * dom = & global_wb_domain ;
540
+
541
+ return max (thresh , dom -> dirty_limit );
536
542
}
537
543
538
544
/**
@@ -916,17 +922,10 @@ static void wb_update_write_bandwidth(struct bdi_writeback *wb,
916
922
wb -> avg_write_bandwidth = avg ;
917
923
}
918
924
919
- /*
920
- * The global dirtyable memory and dirty threshold could be suddenly knocked
921
- * down by a large amount (eg. on the startup of KVM in a swapless system).
922
- * This may throw the system into deep dirty exceeded state and throttle
923
- * heavy/light dirtiers alike. To retain good responsiveness, maintain
924
- * global_dirty_limit for tracking slowly down to the knocked down dirty
925
- * threshold.
926
- */
927
925
static void update_dirty_limit (unsigned long thresh , unsigned long dirty )
928
926
{
929
- unsigned long limit = global_dirty_limit ;
927
+ struct wb_domain * dom = & global_wb_domain ;
928
+ unsigned long limit = dom -> dirty_limit ;
930
929
931
930
/*
932
931
* Follow up in one step.
@@ -939,7 +938,7 @@ static void update_dirty_limit(unsigned long thresh, unsigned long dirty)
939
938
/*
940
939
* Follow down slowly. Use the higher one as the target, because thresh
941
940
* may drop below dirty. This is exactly the reason to introduce
942
- * global_dirty_limit which is guaranteed to lie above the dirty pages.
941
+ * dom->dirty_limit which is guaranteed to lie above the dirty pages.
943
942
*/
944
943
thresh = max (thresh , dirty );
945
944
if (limit > thresh ) {
@@ -948,28 +947,27 @@ static void update_dirty_limit(unsigned long thresh, unsigned long dirty)
948
947
}
949
948
return ;
950
949
update :
951
- global_dirty_limit = limit ;
950
+ dom -> dirty_limit = limit ;
952
951
}
953
952
954
953
static void global_update_bandwidth (unsigned long thresh ,
955
954
unsigned long dirty ,
956
955
unsigned long now )
957
956
{
958
- static DEFINE_SPINLOCK (dirty_lock );
959
- static unsigned long update_time = INITIAL_JIFFIES ;
957
+ struct wb_domain * dom = & global_wb_domain ;
960
958
961
959
/*
962
960
* check locklessly first to optimize away locking for the most time
963
961
*/
964
- if (time_before (now , update_time + BANDWIDTH_INTERVAL ))
962
+ if (time_before (now , dom -> dirty_limit_tstamp + BANDWIDTH_INTERVAL ))
965
963
return ;
966
964
967
- spin_lock (& dirty_lock );
968
- if (time_after_eq (now , update_time + BANDWIDTH_INTERVAL )) {
965
+ spin_lock (& dom -> lock );
966
+ if (time_after_eq (now , dom -> dirty_limit_tstamp + BANDWIDTH_INTERVAL )) {
969
967
update_dirty_limit (thresh , dirty );
970
- update_time = now ;
968
+ dom -> dirty_limit_tstamp = now ;
971
969
}
972
- spin_unlock (& dirty_lock );
970
+ spin_unlock (& dom -> lock );
973
971
}
974
972
975
973
/*
@@ -1761,10 +1759,12 @@ void laptop_sync_completion(void)
1761
1759
1762
1760
void writeback_set_ratelimit (void )
1763
1761
{
1762
+ struct wb_domain * dom = & global_wb_domain ;
1764
1763
unsigned long background_thresh ;
1765
1764
unsigned long dirty_thresh ;
1765
+
1766
1766
global_dirty_limits (& background_thresh , & dirty_thresh );
1767
- global_dirty_limit = dirty_thresh ;
1767
+ dom -> dirty_limit = dirty_thresh ;
1768
1768
ratelimit_pages = dirty_thresh / (num_online_cpus () * 32 );
1769
1769
if (ratelimit_pages < 16 )
1770
1770
ratelimit_pages = 16 ;
0 commit comments