@@ -70,30 +70,33 @@ static long ratelimit_pages = 32;
70
70
/*
71
71
* Start background writeback (via writeback threads) at this percentage
72
72
*/
73
- int dirty_background_ratio = 10 ;
73
+ static int dirty_background_ratio = 10 ;
74
74
75
75
/*
76
76
* dirty_background_bytes starts at 0 (disabled) so that it is a function of
77
77
* dirty_background_ratio * the amount of dirtyable memory
78
78
*/
79
- unsigned long dirty_background_bytes ;
79
+ static unsigned long dirty_background_bytes ;
80
80
81
81
/*
82
82
* free highmem will not be subtracted from the total free memory
83
83
* for calculating free ratios if vm_highmem_is_dirtyable is true
84
84
*/
85
- int vm_highmem_is_dirtyable ;
85
+ static int vm_highmem_is_dirtyable ;
86
86
87
87
/*
88
88
* The generator of dirty data starts writeback at this percentage
89
89
*/
90
- int vm_dirty_ratio = 20 ;
90
+ static int vm_dirty_ratio = 20 ;
91
+
92
+ /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
93
+ static const unsigned long dirty_bytes_min = 2 * PAGE_SIZE ;
91
94
92
95
/*
93
96
* vm_dirty_bytes starts at 0 (disabled) so that it is a function of
94
97
* vm_dirty_ratio * the amount of dirtyable memory
95
98
*/
96
- unsigned long vm_dirty_bytes ;
99
+ static unsigned long vm_dirty_bytes ;
97
100
98
101
/*
99
102
* The interval between `kupdate'-style writebacks
@@ -491,7 +494,8 @@ bool node_dirty_ok(struct pglist_data *pgdat)
491
494
return nr_pages <= limit ;
492
495
}
493
496
494
- int dirty_background_ratio_handler (struct ctl_table * table , int write ,
497
+ #ifdef CONFIG_SYSCTL
498
+ static int dirty_background_ratio_handler (struct ctl_table * table , int write ,
495
499
void * buffer , size_t * lenp , loff_t * ppos )
496
500
{
497
501
int ret ;
@@ -502,7 +506,7 @@ int dirty_background_ratio_handler(struct ctl_table *table, int write,
502
506
return ret ;
503
507
}
504
508
505
- int dirty_background_bytes_handler (struct ctl_table * table , int write ,
509
+ static int dirty_background_bytes_handler (struct ctl_table * table , int write ,
506
510
void * buffer , size_t * lenp , loff_t * ppos )
507
511
{
508
512
int ret ;
@@ -513,7 +517,7 @@ int dirty_background_bytes_handler(struct ctl_table *table, int write,
513
517
return ret ;
514
518
}
515
519
516
- int dirty_ratio_handler (struct ctl_table * table , int write , void * buffer ,
520
+ static int dirty_ratio_handler (struct ctl_table * table , int write , void * buffer ,
517
521
size_t * lenp , loff_t * ppos )
518
522
{
519
523
int old_ratio = vm_dirty_ratio ;
@@ -527,7 +531,7 @@ int dirty_ratio_handler(struct ctl_table *table, int write, void *buffer,
527
531
return ret ;
528
532
}
529
533
530
- int dirty_bytes_handler (struct ctl_table * table , int write ,
534
+ static int dirty_bytes_handler (struct ctl_table * table , int write ,
531
535
void * buffer , size_t * lenp , loff_t * ppos )
532
536
{
533
537
unsigned long old_bytes = vm_dirty_bytes ;
@@ -540,6 +544,7 @@ int dirty_bytes_handler(struct ctl_table *table, int write,
540
544
}
541
545
return ret ;
542
546
}
547
+ #endif
543
548
544
549
static unsigned long wp_next_time (unsigned long cur_time )
545
550
{
@@ -1981,10 +1986,11 @@ bool wb_over_bg_thresh(struct bdi_writeback *wb)
1981
1986
return false;
1982
1987
}
1983
1988
1989
+ #ifdef CONFIG_SYSCTL
1984
1990
/*
1985
1991
* sysctl handler for /proc/sys/vm/dirty_writeback_centisecs
1986
1992
*/
1987
- int dirty_writeback_centisecs_handler (struct ctl_table * table , int write ,
1993
+ static int dirty_writeback_centisecs_handler (struct ctl_table * table , int write ,
1988
1994
void * buffer , size_t * length , loff_t * ppos )
1989
1995
{
1990
1996
unsigned int old_interval = dirty_writeback_interval ;
@@ -2005,6 +2011,7 @@ int dirty_writeback_centisecs_handler(struct ctl_table *table, int write,
2005
2011
2006
2012
return ret ;
2007
2013
}
2014
+ #endif
2008
2015
2009
2016
void laptop_mode_timer_fn (struct timer_list * t )
2010
2017
{
@@ -2069,6 +2076,79 @@ static int page_writeback_cpu_online(unsigned int cpu)
2069
2076
return 0 ;
2070
2077
}
2071
2078
2079
+ #ifdef CONFIG_SYSCTL
2080
+ static struct ctl_table vm_page_writeback_sysctls [] = {
2081
+ {
2082
+ .procname = "dirty_background_ratio" ,
2083
+ .data = & dirty_background_ratio ,
2084
+ .maxlen = sizeof (dirty_background_ratio ),
2085
+ .mode = 0644 ,
2086
+ .proc_handler = dirty_background_ratio_handler ,
2087
+ .extra1 = SYSCTL_ZERO ,
2088
+ .extra2 = SYSCTL_ONE_HUNDRED ,
2089
+ },
2090
+ {
2091
+ .procname = "dirty_background_bytes" ,
2092
+ .data = & dirty_background_bytes ,
2093
+ .maxlen = sizeof (dirty_background_bytes ),
2094
+ .mode = 0644 ,
2095
+ .proc_handler = dirty_background_bytes_handler ,
2096
+ .extra1 = SYSCTL_LONG_ONE ,
2097
+ },
2098
+ {
2099
+ .procname = "dirty_ratio" ,
2100
+ .data = & vm_dirty_ratio ,
2101
+ .maxlen = sizeof (vm_dirty_ratio ),
2102
+ .mode = 0644 ,
2103
+ .proc_handler = dirty_ratio_handler ,
2104
+ .extra1 = SYSCTL_ZERO ,
2105
+ .extra2 = SYSCTL_ONE_HUNDRED ,
2106
+ },
2107
+ {
2108
+ .procname = "dirty_bytes" ,
2109
+ .data = & vm_dirty_bytes ,
2110
+ .maxlen = sizeof (vm_dirty_bytes ),
2111
+ .mode = 0644 ,
2112
+ .proc_handler = dirty_bytes_handler ,
2113
+ .extra1 = (void * )& dirty_bytes_min ,
2114
+ },
2115
+ {
2116
+ .procname = "dirty_writeback_centisecs" ,
2117
+ .data = & dirty_writeback_interval ,
2118
+ .maxlen = sizeof (dirty_writeback_interval ),
2119
+ .mode = 0644 ,
2120
+ .proc_handler = dirty_writeback_centisecs_handler ,
2121
+ },
2122
+ {
2123
+ .procname = "dirty_expire_centisecs" ,
2124
+ .data = & dirty_expire_interval ,
2125
+ .maxlen = sizeof (dirty_expire_interval ),
2126
+ .mode = 0644 ,
2127
+ .proc_handler = proc_dointvec_minmax ,
2128
+ .extra1 = SYSCTL_ZERO ,
2129
+ },
2130
+ #ifdef CONFIG_HIGHMEM
2131
+ {
2132
+ .procname = "highmem_is_dirtyable" ,
2133
+ .data = & vm_highmem_is_dirtyable ,
2134
+ .maxlen = sizeof (vm_highmem_is_dirtyable ),
2135
+ .mode = 0644 ,
2136
+ .proc_handler = proc_dointvec_minmax ,
2137
+ .extra1 = SYSCTL_ZERO ,
2138
+ .extra2 = SYSCTL_ONE ,
2139
+ },
2140
+ #endif
2141
+ {
2142
+ .procname = "laptop_mode" ,
2143
+ .data = & laptop_mode ,
2144
+ .maxlen = sizeof (laptop_mode ),
2145
+ .mode = 0644 ,
2146
+ .proc_handler = proc_dointvec_jiffies ,
2147
+ },
2148
+ {}
2149
+ };
2150
+ #endif
2151
+
2072
2152
/*
2073
2153
* Called early on to tune the page writeback dirty limits.
2074
2154
*
@@ -2093,6 +2173,9 @@ void __init page_writeback_init(void)
2093
2173
page_writeback_cpu_online , NULL );
2094
2174
cpuhp_setup_state (CPUHP_MM_WRITEBACK_DEAD , "mm/writeback:dead" , NULL ,
2095
2175
page_writeback_cpu_online );
2176
+ #ifdef CONFIG_SYSCTL
2177
+ register_sysctl_init ("vm" , vm_page_writeback_sysctls );
2178
+ #endif
2096
2179
}
2097
2180
2098
2181
/**
0 commit comments