Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm/block/fs: remove laptop_mode

Laptop mode was introduced to save battery, by delaying and consolidating
writes and thereby maximize the time rotating hard drives wouldn't have to
spin.

Luckily, rotating hard drives, with their high spin-up times and power
draw, are a thing of the past for battery-powered devices. Reclaim has
also since changed to not write single filesystem pages anymore, and
regular filesystem writeback is lumpy by design.

The juice doesn't appear worth the squeeze anymore. The footprint of the
feature is small, but nevertheless it's a complicating factor in mm,
block, filesystems. Developers don't think about it, and it likely hasn't
been tested with new reclaim and writeback changes in years.

Let's sunset it. Keep the sysctl with a deprecation warning around for a
few more cycles, but remove all functionality behind it.

[akpm@linux-foundation.org: fix Documentation/admin-guide/laptops/index.rst]
Link: https://lkml.kernel.org/r/20251216185201.GH905277@cmpxchg.org
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Suggested-by: Christoph Hellwig <hch@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Jens Axboe <axboe@kernel.dk>
Reviewed-by: Shakeel Butt <shakeel.butt@linux.dev>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Deepanshu Kartikey <kartikey406@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Johannes Weiner and committed by
Andrew Morton
64dd89ae 657a81fe

+25 -888
-1
Documentation/admin-guide/laptops/index.rst
··· 10 10 alienware-wmi 11 11 asus-laptop 12 12 disk-shock-protection 13 - laptop-mode 14 13 lg-laptop 15 14 samsung-galaxybook 16 15 sony-laptop
-770
Documentation/admin-guide/laptops/laptop-mode.rst
··· 1 - =============================================== 2 - How to conserve battery power using laptop-mode 3 - =============================================== 4 - 5 - Document Author: Bart Samwel (bart@samwel.tk) 6 - 7 - Date created: January 2, 2004 8 - 9 - Last modified: December 06, 2004 10 - 11 - Introduction 12 - ------------ 13 - 14 - Laptop mode is used to minimize the time that the hard disk needs to be spun up, 15 - to conserve battery power on laptops. It has been reported to cause significant 16 - power savings. 17 - 18 - .. Contents 19 - 20 - * Introduction 21 - * Installation 22 - * Caveats 23 - * The Details 24 - * Tips & Tricks 25 - * Control script 26 - * ACPI integration 27 - * Monitoring tool 28 - 29 - 30 - Installation 31 - ------------ 32 - 33 - To use laptop mode, you don't need to set any kernel configuration options 34 - or anything. Simply install all the files included in this document, and 35 - laptop mode will automatically be started when you're on battery. For 36 - your convenience, a tarball containing an installer can be downloaded at: 37 - 38 - http://www.samwel.tk/laptop_mode/laptop_mode/ 39 - 40 - To configure laptop mode, you need to edit the configuration file, which is 41 - located in /etc/default/laptop-mode on Debian-based systems, or in 42 - /etc/sysconfig/laptop-mode on other systems. 43 - 44 - Unfortunately, automatic enabling of laptop mode does not work for 45 - laptops that don't have ACPI. On those laptops, you need to start laptop 46 - mode manually. To start laptop mode, run "laptop_mode start", and to 47 - stop it, run "laptop_mode stop". (Note: The laptop mode tools package now 48 - has experimental support for APM, you might want to try that first.) 49 - 50 - 51 - Caveats 52 - ------- 53 - 54 - * The downside of laptop mode is that you have a chance of losing up to 10 55 - minutes of work. If you cannot afford this, don't use it! The supplied ACPI 56 - scripts automatically turn off laptop mode when the battery almost runs out, 57 - so that you won't lose any data at the end of your battery life. 58 - 59 - * Most desktop hard drives have a very limited lifetime measured in spindown 60 - cycles, typically about 50.000 times (it's usually listed on the spec sheet). 61 - Check your drive's rating, and don't wear down your drive's lifetime if you 62 - don't need to. 63 - 64 - * If you mount some of your ext3 filesystems with the -n option, then 65 - the control script will not be able to remount them correctly. You must set 66 - DO_REMOUNTS=0 in the control script, otherwise it will remount them with the 67 - wrong options -- or it will fail because it cannot write to /etc/mtab. 68 - 69 - * If you have your filesystems listed as type "auto" in fstab, like I did, then 70 - the control script will not recognize them as filesystems that need remounting. 71 - You must list the filesystems with their true type instead. 72 - 73 - * It has been reported that some versions of the mutt mail client use file access 74 - times to determine whether a folder contains new mail. If you use mutt and 75 - experience this, you must disable the noatime remounting by setting the option 76 - DO_REMOUNT_NOATIME to 0 in the configuration file. 77 - 78 - 79 - The Details 80 - ----------- 81 - 82 - Laptop mode is controlled by the knob /proc/sys/vm/laptop_mode. This knob is 83 - present for all kernels that have the laptop mode patch, regardless of any 84 - configuration options. When the knob is set, any physical disk I/O (that might 85 - have caused the hard disk to spin up) causes Linux to flush all dirty blocks. The 86 - result of this is that after a disk has spun down, it will not be spun up 87 - anymore to write dirty blocks, because those blocks had already been written 88 - immediately after the most recent read operation. The value of the laptop_mode 89 - knob determines the time between the occurrence of disk I/O and when the flush 90 - is triggered. A sensible value for the knob is 5 seconds. Setting the knob to 91 - 0 disables laptop mode. 92 - 93 - To increase the effectiveness of the laptop_mode strategy, the laptop_mode 94 - control script increases dirty_expire_centisecs and dirty_writeback_centisecs in 95 - /proc/sys/vm to about 10 minutes (by default), which means that pages that are 96 - dirtied are not forced to be written to disk as often. The control script also 97 - changes the dirty background ratio, so that background writeback of dirty pages 98 - is not done anymore. Combined with a higher commit value (also 10 minutes) for 99 - ext3 filesystem (also done automatically by the control script), 100 - this results in concentration of disk activity in a small time interval which 101 - occurs only once every 10 minutes, or whenever the disk is forced to spin up by 102 - a cache miss. The disk can then be spun down in the periods of inactivity. 103 - 104 - 105 - Configuration 106 - ------------- 107 - 108 - The laptop mode configuration file is located in /etc/default/laptop-mode on 109 - Debian-based systems, or in /etc/sysconfig/laptop-mode on other systems. It 110 - contains the following options: 111 - 112 - MAX_AGE: 113 - 114 - Maximum time, in seconds, of hard drive spindown time that you are 115 - comfortable with. Worst case, it's possible that you could lose this 116 - amount of work if your battery fails while you're in laptop mode. 117 - 118 - MINIMUM_BATTERY_MINUTES: 119 - 120 - Automatically disable laptop mode if the remaining number of minutes of 121 - battery power is less than this value. Default is 10 minutes. 122 - 123 - AC_HD/BATT_HD: 124 - 125 - The idle timeout that should be set on your hard drive when laptop mode 126 - is active (BATT_HD) and when it is not active (AC_HD). The defaults are 127 - 20 seconds (value 4) for BATT_HD and 2 hours (value 244) for AC_HD. The 128 - possible values are those listed in the manual page for "hdparm" for the 129 - "-S" option. 130 - 131 - HD: 132 - 133 - The devices for which the spindown timeout should be adjusted by laptop mode. 134 - Default is /dev/hda. If you specify multiple devices, separate them by a space. 135 - 136 - READAHEAD: 137 - 138 - Disk readahead, in 512-byte sectors, while laptop mode is active. A large 139 - readahead can prevent disk accesses for things like executable pages (which are 140 - loaded on demand while the application executes) and sequentially accessed data 141 - (MP3s). 142 - 143 - DO_REMOUNTS: 144 - 145 - The control script automatically remounts any mounted journaled filesystems 146 - with appropriate commit interval options. When this option is set to 0, this 147 - feature is disabled. 148 - 149 - DO_REMOUNT_NOATIME: 150 - 151 - When remounting, should the filesystems be remounted with the noatime option? 152 - Normally, this is set to "1" (enabled), but there may be programs that require 153 - access time recording. 154 - 155 - DIRTY_RATIO: 156 - 157 - The percentage of memory that is allowed to contain "dirty" or unsaved data 158 - before a writeback is forced, while laptop mode is active. Corresponds to 159 - the /proc/sys/vm/dirty_ratio sysctl. 160 - 161 - DIRTY_BACKGROUND_RATIO: 162 - 163 - The percentage of memory that is allowed to contain "dirty" or unsaved data 164 - after a forced writeback is done due to an exceeding of DIRTY_RATIO. Set 165 - this nice and low. This corresponds to the /proc/sys/vm/dirty_background_ratio 166 - sysctl. 167 - 168 - Note that the behaviour of dirty_background_ratio is quite different 169 - when laptop mode is active and when it isn't. When laptop mode is inactive, 170 - dirty_background_ratio is the threshold percentage at which background writeouts 171 - start taking place. When laptop mode is active, however, background writeouts 172 - are disabled, and the dirty_background_ratio only determines how much writeback 173 - is done when dirty_ratio is reached. 174 - 175 - DO_CPU: 176 - 177 - Enable CPU frequency scaling when in laptop mode. (Requires CPUFreq to be setup. 178 - See Documentation/admin-guide/pm/cpufreq.rst for more info. Disabled by default.) 179 - 180 - CPU_MAXFREQ: 181 - 182 - When on battery, what is the maximum CPU speed that the system should use? Legal 183 - values are "slowest" for the slowest speed that your CPU is able to operate at, 184 - or a value listed in /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies. 185 - 186 - 187 - Tips & Tricks 188 - ------------- 189 - 190 - * Bartek Kania reports getting up to 50 minutes of extra battery life (on top 191 - of his regular 3 to 3.5 hours) using a spindown time of 5 seconds (BATT_HD=1). 192 - 193 - * You can spin down the disk while playing MP3, by setting disk readahead 194 - to 8MB (READAHEAD=16384). Effectively, the disk will read a complete MP3 at 195 - once, and will then spin down while the MP3 is playing. (Thanks to Bartek 196 - Kania.) 197 - 198 - * Drew Scott Daniels observed: "I don't know why, but when I decrease the number 199 - of colours that my display uses it consumes less battery power. I've seen 200 - this on powerbooks too. I hope that this is a piece of information that 201 - might be useful to the Laptop Mode patch or its users." 202 - 203 - * In syslog.conf, you can prefix entries with a dash `-` to omit syncing the 204 - file after every logging. When you're using laptop-mode and your disk doesn't 205 - spin down, this is a likely culprit. 206 - 207 - * Richard Atterer observed that laptop mode does not work well with noflushd 208 - (http://noflushd.sourceforge.net/), it seems that noflushd prevents laptop-mode 209 - from doing its thing. 210 - 211 - * If you're worried about your data, you might want to consider using a USB 212 - memory stick or something like that as a "working area". (Be aware though 213 - that flash memory can only handle a limited number of writes, and overuse 214 - may wear out your memory stick pretty quickly. Do _not_ use journalling 215 - filesystems on flash memory sticks.) 216 - 217 - 218 - Configuration file for control and ACPI battery scripts 219 - ------------------------------------------------------- 220 - 221 - This allows the tunables to be changed for the scripts via an external 222 - configuration file 223 - 224 - It should be installed as /etc/default/laptop-mode on Debian, and as 225 - /etc/sysconfig/laptop-mode on Red Hat, SUSE, Mandrake, and other work-alikes. 226 - 227 - Config file:: 228 - 229 - # Maximum time, in seconds, of hard drive spindown time that you are 230 - # comfortable with. Worst case, it's possible that you could lose this 231 - # amount of work if your battery fails you while in laptop mode. 232 - #MAX_AGE=600 233 - 234 - # Automatically disable laptop mode when the number of minutes of battery 235 - # that you have left goes below this threshold. 236 - MINIMUM_BATTERY_MINUTES=10 237 - 238 - # Read-ahead, in 512-byte sectors. You can spin down the disk while playing MP3/OGG 239 - # by setting the disk readahead to 8MB (READAHEAD=16384). Effectively, the disk 240 - # will read a complete MP3 at once, and will then spin down while the MP3/OGG is 241 - # playing. 242 - #READAHEAD=4096 243 - 244 - # Shall we remount journaled fs. with appropriate commit interval? (1=yes) 245 - #DO_REMOUNTS=1 246 - 247 - # And shall we add the "noatime" option to that as well? (1=yes) 248 - #DO_REMOUNT_NOATIME=1 249 - 250 - # Dirty synchronous ratio. At this percentage of dirty pages the process 251 - # which 252 - # calls write() does its own writeback 253 - #DIRTY_RATIO=40 254 - 255 - # 256 - # Allowed dirty background ratio, in percent. Once DIRTY_RATIO has been 257 - # exceeded, the kernel will wake flusher threads which will then reduce the 258 - # amount of dirty memory to dirty_background_ratio. Set this nice and low, 259 - # so once some writeout has commenced, we do a lot of it. 260 - # 261 - #DIRTY_BACKGROUND_RATIO=5 262 - 263 - # kernel default dirty buffer age 264 - #DEF_AGE=30 265 - #DEF_UPDATE=5 266 - #DEF_DIRTY_BACKGROUND_RATIO=10 267 - #DEF_DIRTY_RATIO=40 268 - #DEF_XFS_AGE_BUFFER=15 269 - #DEF_XFS_SYNC_INTERVAL=30 270 - #DEF_XFS_BUFD_INTERVAL=1 271 - 272 - # This must be adjusted manually to the value of HZ in the running kernel 273 - # on 2.4, until the XFS people change their 2.4 external interfaces to work in 274 - # centisecs. This can be automated, but it's a work in progress that still 275 - # needs# some fixes. On 2.6 kernels, XFS uses USER_HZ instead of HZ for 276 - # external interfaces, and that is currently always set to 100. So you don't 277 - # need to change this on 2.6. 278 - #XFS_HZ=100 279 - 280 - # Should the maximum CPU frequency be adjusted down while on battery? 281 - # Requires CPUFreq to be setup. 282 - # See Documentation/admin-guide/pm/cpufreq.rst for more info 283 - #DO_CPU=0 284 - 285 - # When on battery what is the maximum CPU speed that the system should 286 - # use? Legal values are "slowest" for the slowest speed that your 287 - # CPU is able to operate at, or a value listed in: 288 - # /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies 289 - # Only applicable if DO_CPU=1. 290 - #CPU_MAXFREQ=slowest 291 - 292 - # Idle timeout for your hard drive (man hdparm for valid values, -S option) 293 - # Default is 2 hours on AC (AC_HD=244) and 20 seconds for battery (BATT_HD=4). 294 - #AC_HD=244 295 - #BATT_HD=4 296 - 297 - # The drives for which to adjust the idle timeout. Separate them by a space, 298 - # e.g. HD="/dev/hda /dev/hdb". 299 - #HD="/dev/hda" 300 - 301 - # Set the spindown timeout on a hard drive? 302 - #DO_HD=1 303 - 304 - 305 - Control script 306 - -------------- 307 - 308 - Please note that this control script works for the Linux 2.4 and 2.6 series (thanks 309 - to Kiko Piris). 310 - 311 - Control script:: 312 - 313 - #!/bin/bash 314 - 315 - # start or stop laptop_mode, best run by a power management daemon when 316 - # ac gets connected/disconnected from a laptop 317 - # 318 - # install as /sbin/laptop_mode 319 - # 320 - # Contributors to this script: Kiko Piris 321 - # Bart Samwel 322 - # Micha Feigin 323 - # Andrew Morton 324 - # Herve Eychenne 325 - # Dax Kelson 326 - # 327 - # Original Linux 2.4 version by: Jens Axboe 328 - 329 - ############################################################################# 330 - 331 - # Source config 332 - if [ -f /etc/default/laptop-mode ] ; then 333 - # Debian 334 - . /etc/default/laptop-mode 335 - elif [ -f /etc/sysconfig/laptop-mode ] ; then 336 - # Others 337 - . /etc/sysconfig/laptop-mode 338 - fi 339 - 340 - # Don't raise an error if the config file is incomplete 341 - # set defaults instead: 342 - 343 - # Maximum time, in seconds, of hard drive spindown time that you are 344 - # comfortable with. Worst case, it's possible that you could lose this 345 - # amount of work if your battery fails you while in laptop mode. 346 - MAX_AGE=${MAX_AGE:-'600'} 347 - 348 - # Read-ahead, in kilobytes 349 - READAHEAD=${READAHEAD:-'4096'} 350 - 351 - # Shall we remount journaled fs. with appropriate commit interval? (1=yes) 352 - DO_REMOUNTS=${DO_REMOUNTS:-'1'} 353 - 354 - # And shall we add the "noatime" option to that as well? (1=yes) 355 - DO_REMOUNT_NOATIME=${DO_REMOUNT_NOATIME:-'1'} 356 - 357 - # Shall we adjust the idle timeout on a hard drive? 358 - DO_HD=${DO_HD:-'1'} 359 - 360 - # Adjust idle timeout on which hard drive? 361 - HD="${HD:-'/dev/hda'}" 362 - 363 - # spindown time for HD (hdparm -S values) 364 - AC_HD=${AC_HD:-'244'} 365 - BATT_HD=${BATT_HD:-'4'} 366 - 367 - # Dirty synchronous ratio. At this percentage of dirty pages the process which 368 - # calls write() does its own writeback 369 - DIRTY_RATIO=${DIRTY_RATIO:-'40'} 370 - 371 - # cpu frequency scaling 372 - # See Documentation/admin-guide/pm/cpufreq.rst for more info 373 - DO_CPU=${CPU_MANAGE:-'0'} 374 - CPU_MAXFREQ=${CPU_MAXFREQ:-'slowest'} 375 - 376 - # 377 - # Allowed dirty background ratio, in percent. Once DIRTY_RATIO has been 378 - # exceeded, the kernel will wake flusher threads which will then reduce the 379 - # amount of dirty memory to dirty_background_ratio. Set this nice and low, 380 - # so once some writeout has commenced, we do a lot of it. 381 - # 382 - DIRTY_BACKGROUND_RATIO=${DIRTY_BACKGROUND_RATIO:-'5'} 383 - 384 - # kernel default dirty buffer age 385 - DEF_AGE=${DEF_AGE:-'30'} 386 - DEF_UPDATE=${DEF_UPDATE:-'5'} 387 - DEF_DIRTY_BACKGROUND_RATIO=${DEF_DIRTY_BACKGROUND_RATIO:-'10'} 388 - DEF_DIRTY_RATIO=${DEF_DIRTY_RATIO:-'40'} 389 - DEF_XFS_AGE_BUFFER=${DEF_XFS_AGE_BUFFER:-'15'} 390 - DEF_XFS_SYNC_INTERVAL=${DEF_XFS_SYNC_INTERVAL:-'30'} 391 - DEF_XFS_BUFD_INTERVAL=${DEF_XFS_BUFD_INTERVAL:-'1'} 392 - 393 - # This must be adjusted manually to the value of HZ in the running kernel 394 - # on 2.4, until the XFS people change their 2.4 external interfaces to work in 395 - # centisecs. This can be automated, but it's a work in progress that still needs 396 - # some fixes. On 2.6 kernels, XFS uses USER_HZ instead of HZ for external 397 - # interfaces, and that is currently always set to 100. So you don't need to 398 - # change this on 2.6. 399 - XFS_HZ=${XFS_HZ:-'100'} 400 - 401 - ############################################################################# 402 - 403 - KLEVEL="$(uname -r | 404 - { 405 - IFS='.' read a b c 406 - echo $a.$b 407 - } 408 - )" 409 - case "$KLEVEL" in 410 - "2.4"|"2.6") 411 - ;; 412 - *) 413 - echo "Unhandled kernel version: $KLEVEL ('uname -r' = '$(uname -r)')" >&2 414 - exit 1 415 - ;; 416 - esac 417 - 418 - if [ ! -e /proc/sys/vm/laptop_mode ] ; then 419 - echo "Kernel is not patched with laptop_mode patch." >&2 420 - exit 1 421 - fi 422 - 423 - if [ ! -w /proc/sys/vm/laptop_mode ] ; then 424 - echo "You do not have enough privileges to enable laptop_mode." >&2 425 - exit 1 426 - fi 427 - 428 - # Remove an option (the first parameter) of the form option=<number> from 429 - # a mount options string (the rest of the parameters). 430 - parse_mount_opts () { 431 - OPT="$1" 432 - shift 433 - echo ",$*," | sed \ 434 - -e 's/,'"$OPT"'=[0-9]*,/,/g' \ 435 - -e 's/,,*/,/g' \ 436 - -e 's/^,//' \ 437 - -e 's/,$//' 438 - } 439 - 440 - # Remove an option (the first parameter) without any arguments from 441 - # a mount option string (the rest of the parameters). 442 - parse_nonumber_mount_opts () { 443 - OPT="$1" 444 - shift 445 - echo ",$*," | sed \ 446 - -e 's/,'"$OPT"',/,/g' \ 447 - -e 's/,,*/,/g' \ 448 - -e 's/^,//' \ 449 - -e 's/,$//' 450 - } 451 - 452 - # Find out the state of a yes/no option (e.g. "atime"/"noatime") in 453 - # fstab for a given filesystem, and use this state to replace the 454 - # value of the option in another mount options string. The device 455 - # is the first argument, the option name the second, and the default 456 - # value the third. The remainder is the mount options string. 457 - # 458 - # Example: 459 - # parse_yesno_opts_wfstab /dev/hda1 atime atime defaults,noatime 460 - # 461 - # If fstab contains, say, "rw" for this filesystem, then the result 462 - # will be "defaults,atime". 463 - parse_yesno_opts_wfstab () { 464 - L_DEV="$1" 465 - OPT="$2" 466 - DEF_OPT="$3" 467 - shift 3 468 - L_OPTS="$*" 469 - PARSEDOPTS1="$(parse_nonumber_mount_opts $OPT $L_OPTS)" 470 - PARSEDOPTS1="$(parse_nonumber_mount_opts no$OPT $PARSEDOPTS1)" 471 - # Watch for a default atime in fstab 472 - FSTAB_OPTS="$(awk '$1 == "'$L_DEV'" { print $4 }' /etc/fstab)" 473 - if echo "$FSTAB_OPTS" | grep "$OPT" > /dev/null ; then 474 - # option specified in fstab: extract the value and use it 475 - if echo "$FSTAB_OPTS" | grep "no$OPT" > /dev/null ; then 476 - echo "$PARSEDOPTS1,no$OPT" 477 - else 478 - # no$OPT not found -- so we must have $OPT. 479 - echo "$PARSEDOPTS1,$OPT" 480 - fi 481 - else 482 - # option not specified in fstab -- choose the default. 483 - echo "$PARSEDOPTS1,$DEF_OPT" 484 - fi 485 - } 486 - 487 - # Find out the state of a numbered option (e.g. "commit=NNN") in 488 - # fstab for a given filesystem, and use this state to replace the 489 - # value of the option in another mount options string. The device 490 - # is the first argument, and the option name the second. The 491 - # remainder is the mount options string in which the replacement 492 - # must be done. 493 - # 494 - # Example: 495 - # parse_mount_opts_wfstab /dev/hda1 commit defaults,commit=7 496 - # 497 - # If fstab contains, say, "commit=3,rw" for this filesystem, then the 498 - # result will be "rw,commit=3". 499 - parse_mount_opts_wfstab () { 500 - L_DEV="$1" 501 - OPT="$2" 502 - shift 2 503 - L_OPTS="$*" 504 - PARSEDOPTS1="$(parse_mount_opts $OPT $L_OPTS)" 505 - # Watch for a default commit in fstab 506 - FSTAB_OPTS="$(awk '$1 == "'$L_DEV'" { print $4 }' /etc/fstab)" 507 - if echo "$FSTAB_OPTS" | grep "$OPT=" > /dev/null ; then 508 - # option specified in fstab: extract the value, and use it 509 - echo -n "$PARSEDOPTS1,$OPT=" 510 - echo ",$FSTAB_OPTS," | sed \ 511 - -e 's/.*,'"$OPT"'=//' \ 512 - -e 's/,.*//' 513 - else 514 - # option not specified in fstab: set it to 0 515 - echo "$PARSEDOPTS1,$OPT=0" 516 - fi 517 - } 518 - 519 - deduce_fstype () { 520 - MP="$1" 521 - # My root filesystem unfortunately has 522 - # type "unknown" in /etc/mtab. If we encounter 523 - # "unknown", we try to get the type from fstab. 524 - cat /etc/fstab | 525 - grep -v '^#' | 526 - while read FSTAB_DEV FSTAB_MP FSTAB_FST FSTAB_OPTS FSTAB_DUMP FSTAB_DUMP ; do 527 - if [ "$FSTAB_MP" = "$MP" ]; then 528 - echo $FSTAB_FST 529 - exit 0 530 - fi 531 - done 532 - } 533 - 534 - if [ $DO_REMOUNT_NOATIME -eq 1 ] ; then 535 - NOATIME_OPT=",noatime" 536 - fi 537 - 538 - case "$1" in 539 - start) 540 - AGE=$((100*$MAX_AGE)) 541 - XFS_AGE=$(($XFS_HZ*$MAX_AGE)) 542 - echo -n "Starting laptop_mode" 543 - 544 - if [ -d /proc/sys/vm/pagebuf ] ; then 545 - # (For 2.4 and early 2.6.) 546 - # This only needs to be set, not reset -- it is only used when 547 - # laptop mode is enabled. 548 - echo $XFS_AGE > /proc/sys/vm/pagebuf/lm_flush_age 549 - echo $XFS_AGE > /proc/sys/fs/xfs/lm_sync_interval 550 - elif [ -f /proc/sys/fs/xfs/lm_age_buffer ] ; then 551 - # (A couple of early 2.6 laptop mode patches had these.) 552 - # The same goes for these. 553 - echo $XFS_AGE > /proc/sys/fs/xfs/lm_age_buffer 554 - echo $XFS_AGE > /proc/sys/fs/xfs/lm_sync_interval 555 - elif [ -f /proc/sys/fs/xfs/age_buffer ] ; then 556 - # (2.6.6) 557 - # But not for these -- they are also used in normal 558 - # operation. 559 - echo $XFS_AGE > /proc/sys/fs/xfs/age_buffer 560 - echo $XFS_AGE > /proc/sys/fs/xfs/sync_interval 561 - elif [ -f /proc/sys/fs/xfs/age_buffer_centisecs ] ; then 562 - # (2.6.7 upwards) 563 - # And not for these either. These are in centisecs, 564 - # not USER_HZ, so we have to use $AGE, not $XFS_AGE. 565 - echo $AGE > /proc/sys/fs/xfs/age_buffer_centisecs 566 - echo $AGE > /proc/sys/fs/xfs/xfssyncd_centisecs 567 - echo 3000 > /proc/sys/fs/xfs/xfsbufd_centisecs 568 - fi 569 - 570 - case "$KLEVEL" in 571 - "2.4") 572 - echo 1 > /proc/sys/vm/laptop_mode 573 - echo "30 500 0 0 $AGE $AGE 60 20 0" > /proc/sys/vm/bdflush 574 - ;; 575 - "2.6") 576 - echo 5 > /proc/sys/vm/laptop_mode 577 - echo "$AGE" > /proc/sys/vm/dirty_writeback_centisecs 578 - echo "$AGE" > /proc/sys/vm/dirty_expire_centisecs 579 - echo "$DIRTY_RATIO" > /proc/sys/vm/dirty_ratio 580 - echo "$DIRTY_BACKGROUND_RATIO" > /proc/sys/vm/dirty_background_ratio 581 - ;; 582 - esac 583 - if [ $DO_REMOUNTS -eq 1 ]; then 584 - cat /etc/mtab | while read DEV MP FST OPTS DUMP PASS ; do 585 - PARSEDOPTS="$(parse_mount_opts "$OPTS")" 586 - if [ "$FST" = 'unknown' ]; then 587 - FST=$(deduce_fstype $MP) 588 - fi 589 - case "$FST" in 590 - "ext3") 591 - PARSEDOPTS="$(parse_mount_opts commit "$OPTS")" 592 - mount $DEV -t $FST $MP -o remount,$PARSEDOPTS,commit=$MAX_AGE$NOATIME_OPT 593 - ;; 594 - "xfs") 595 - mount $DEV -t $FST $MP -o remount,$OPTS$NOATIME_OPT 596 - ;; 597 - esac 598 - if [ -b $DEV ] ; then 599 - blockdev --setra $(($READAHEAD * 2)) $DEV 600 - fi 601 - done 602 - fi 603 - if [ $DO_HD -eq 1 ] ; then 604 - for THISHD in $HD ; do 605 - /sbin/hdparm -S $BATT_HD $THISHD > /dev/null 2>&1 606 - /sbin/hdparm -B 1 $THISHD > /dev/null 2>&1 607 - done 608 - fi 609 - if [ $DO_CPU -eq 1 -a -e /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq ]; then 610 - if [ $CPU_MAXFREQ = 'slowest' ]; then 611 - CPU_MAXFREQ=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq` 612 - fi 613 - echo $CPU_MAXFREQ > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq 614 - fi 615 - echo "." 616 - ;; 617 - stop) 618 - U_AGE=$((100*$DEF_UPDATE)) 619 - B_AGE=$((100*$DEF_AGE)) 620 - echo -n "Stopping laptop_mode" 621 - echo 0 > /proc/sys/vm/laptop_mode 622 - if [ -f /proc/sys/fs/xfs/age_buffer -a ! -f /proc/sys/fs/xfs/lm_age_buffer ] ; then 623 - # These need to be restored, if there are no lm_*. 624 - echo $(($XFS_HZ*$DEF_XFS_AGE_BUFFER)) > /proc/sys/fs/xfs/age_buffer 625 - echo $(($XFS_HZ*$DEF_XFS_SYNC_INTERVAL)) > /proc/sys/fs/xfs/sync_interval 626 - elif [ -f /proc/sys/fs/xfs/age_buffer_centisecs ] ; then 627 - # These need to be restored as well. 628 - echo $((100*$DEF_XFS_AGE_BUFFER)) > /proc/sys/fs/xfs/age_buffer_centisecs 629 - echo $((100*$DEF_XFS_SYNC_INTERVAL)) > /proc/sys/fs/xfs/xfssyncd_centisecs 630 - echo $((100*$DEF_XFS_BUFD_INTERVAL)) > /proc/sys/fs/xfs/xfsbufd_centisecs 631 - fi 632 - case "$KLEVEL" in 633 - "2.4") 634 - echo "30 500 0 0 $U_AGE $B_AGE 60 20 0" > /proc/sys/vm/bdflush 635 - ;; 636 - "2.6") 637 - echo "$U_AGE" > /proc/sys/vm/dirty_writeback_centisecs 638 - echo "$B_AGE" > /proc/sys/vm/dirty_expire_centisecs 639 - echo "$DEF_DIRTY_RATIO" > /proc/sys/vm/dirty_ratio 640 - echo "$DEF_DIRTY_BACKGROUND_RATIO" > /proc/sys/vm/dirty_background_ratio 641 - ;; 642 - esac 643 - if [ $DO_REMOUNTS -eq 1 ] ; then 644 - cat /etc/mtab | while read DEV MP FST OPTS DUMP PASS ; do 645 - # Reset commit and atime options to defaults. 646 - if [ "$FST" = 'unknown' ]; then 647 - FST=$(deduce_fstype $MP) 648 - fi 649 - case "$FST" in 650 - "ext3") 651 - PARSEDOPTS="$(parse_mount_opts_wfstab $DEV commit $OPTS)" 652 - PARSEDOPTS="$(parse_yesno_opts_wfstab $DEV atime atime $PARSEDOPTS)" 653 - mount $DEV -t $FST $MP -o remount,$PARSEDOPTS 654 - ;; 655 - "xfs") 656 - PARSEDOPTS="$(parse_yesno_opts_wfstab $DEV atime atime $OPTS)" 657 - mount $DEV -t $FST $MP -o remount,$PARSEDOPTS 658 - ;; 659 - esac 660 - if [ -b $DEV ] ; then 661 - blockdev --setra 256 $DEV 662 - fi 663 - done 664 - fi 665 - if [ $DO_HD -eq 1 ] ; then 666 - for THISHD in $HD ; do 667 - /sbin/hdparm -S $AC_HD $THISHD > /dev/null 2>&1 668 - /sbin/hdparm -B 255 $THISHD > /dev/null 2>&1 669 - done 670 - fi 671 - if [ $DO_CPU -eq 1 -a -e /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq ]; then 672 - echo `cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq` > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq 673 - fi 674 - echo "." 675 - ;; 676 - *) 677 - echo "Usage: $0 {start|stop}" 2>&1 678 - exit 1 679 - ;; 680 - 681 - esac 682 - 683 - exit 0 684 - 685 - 686 - ACPI integration 687 - ---------------- 688 - 689 - Dax Kelson submitted this so that the ACPI acpid daemon will 690 - kick off the laptop_mode script and run hdparm. The part that 691 - automatically disables laptop mode when the battery is low was 692 - written by Jan Topinski. 693 - 694 - /etc/acpi/events/ac_adapter:: 695 - 696 - event=ac_adapter 697 - action=/etc/acpi/actions/ac.sh %e 698 - 699 - /etc/acpi/events/battery:: 700 - 701 - event=battery.* 702 - action=/etc/acpi/actions/battery.sh %e 703 - 704 - /etc/acpi/actions/ac.sh:: 705 - 706 - #!/bin/bash 707 - 708 - # ac on/offline event handler 709 - 710 - status=`awk '/^state: / { print $2 }' /proc/acpi/ac_adapter/$2/state` 711 - 712 - case $status in 713 - "on-line") 714 - /sbin/laptop_mode stop 715 - exit 0 716 - ;; 717 - "off-line") 718 - /sbin/laptop_mode start 719 - exit 0 720 - ;; 721 - esac 722 - 723 - 724 - /etc/acpi/actions/battery.sh:: 725 - 726 - #! /bin/bash 727 - 728 - # Automatically disable laptop mode when the battery almost runs out. 729 - 730 - BATT_INFO=/proc/acpi/battery/$2/state 731 - 732 - if [[ -f /proc/sys/vm/laptop_mode ]] 733 - then 734 - LM=`cat /proc/sys/vm/laptop_mode` 735 - if [[ $LM -gt 0 ]] 736 - then 737 - if [[ -f $BATT_INFO ]] 738 - then 739 - # Source the config file only now that we know we need 740 - if [ -f /etc/default/laptop-mode ] ; then 741 - # Debian 742 - . /etc/default/laptop-mode 743 - elif [ -f /etc/sysconfig/laptop-mode ] ; then 744 - # Others 745 - . /etc/sysconfig/laptop-mode 746 - fi 747 - MINIMUM_BATTERY_MINUTES=${MINIMUM_BATTERY_MINUTES:-'10'} 748 - 749 - ACTION="`cat $BATT_INFO | grep charging | cut -c 26-`" 750 - if [[ ACTION -eq "discharging" ]] 751 - then 752 - PRESENT_RATE=`cat $BATT_INFO | grep "present rate:" | sed "s/.* \([0-9][0-9]* \).*/\1/" ` 753 - REMAINING=`cat $BATT_INFO | grep "remaining capacity:" | sed "s/.* \([0-9][0-9]* \).*/\1/" ` 754 - fi 755 - if (($REMAINING * 60 / $PRESENT_RATE < $MINIMUM_BATTERY_MINUTES)) 756 - then 757 - /sbin/laptop_mode stop 758 - fi 759 - else 760 - logger -p daemon.warning "You are using laptop mode and your battery interface $BATT_INFO is missing. This may lead to loss of data when the battery runs out. Check kernel ACPI support and /proc/acpi/battery folder, and edit /etc/acpi/battery.sh to set BATT_INFO to the correct path." 761 - fi 762 - fi 763 - fi 764 - 765 - 766 - Monitoring tool 767 - --------------- 768 - 769 - Bartek Kania submitted this, it can be used to measure how much time your disk 770 - spends spun up/down. See tools/laptop/dslm/dslm.c
-8
Documentation/admin-guide/sysctl/vm.rst
··· 41 41 - extfrag_threshold 42 42 - highmem_is_dirtyable 43 43 - hugetlb_shm_group 44 - - laptop_mode 45 44 - legacy_va_layout 46 45 - lowmem_reserve_ratio 47 46 - max_map_count ··· 360 361 361 362 hugetlb_shm_group contains group id that is allowed to create SysV 362 363 shared memory segment using hugetlb page. 363 - 364 - 365 - laptop_mode 366 - =========== 367 - 368 - laptop_mode is a knob that controls "laptop mode". All the things that are 369 - controlled by this knob are discussed in Documentation/admin-guide/laptops/laptop-mode.rst. 370 364 371 365 372 366 legacy_va_layout
-3
block/blk-mq.c
··· 811 811 812 812 blk_mq_finish_request(rq); 813 813 814 - if (unlikely(laptop_mode && !blk_rq_is_passthrough(rq))) 815 - laptop_io_completion(q->disk->bdi); 816 - 817 814 rq_qos_done(q, rq); 818 815 819 816 WRITE_ONCE(rq->state, MQ_RQ_IDLE);
+1 -2
fs/ext4/inode.c
··· 3305 3305 /* 3306 3306 * We do something simple for now. The filemap_flush() will 3307 3307 * also start triggering a write of the data blocks, which is 3308 - * not strictly speaking necessary (and for users of 3309 - * laptop_mode, not even desirable). However, to do otherwise 3308 + * not strictly speaking necessary. However, to do otherwise 3310 3309 * would require replicating code paths in: 3311 3310 * 3312 3311 * ext4_writepages() ->
-2
fs/sync.c
··· 104 104 iterate_supers(sync_fs_one_sb, &wait); 105 105 sync_bdevs(false); 106 106 sync_bdevs(true); 107 - if (unlikely(laptop_mode)) 108 - laptop_sync_completion(); 109 107 } 110 108 111 109 SYSCALL_DEFINE0(sync)
-9
fs/xfs/xfs_super.c
··· 845 845 if (error) 846 846 return error; 847 847 848 - if (laptop_mode) { 849 - /* 850 - * The disk must be active because we're syncing. 851 - * We schedule log work now (now that the disk is 852 - * active) instead of later (when it might not be). 853 - */ 854 - flush_delayed_work(&mp->m_log->l_work); 855 - } 856 - 857 848 /* 858 849 * If we are called with page faults frozen out, it means we are about 859 850 * to freeze the transaction subsystem. Take the opportunity to shut
-3
include/linux/backing-dev-defs.h
··· 46 46 WB_REASON_VMSCAN, 47 47 WB_REASON_SYNC, 48 48 WB_REASON_PERIODIC, 49 - WB_REASON_LAPTOP_TIMER, 50 49 WB_REASON_FS_FREE_SPACE, 51 50 /* 52 51 * There is no bdi forker thread any more and works are done ··· 202 203 struct device *dev; 203 204 char dev_name[64]; 204 205 struct device *owner; 205 - 206 - struct timer_list laptop_mode_wb_timer; 207 206 208 207 #ifdef CONFIG_DEBUG_FS 209 208 struct dentry *debug_dir;
-4
include/linux/writeback.h
··· 328 328 bool dirty_exceeded; 329 329 }; 330 330 331 - void laptop_io_completion(struct backing_dev_info *info); 332 - void laptop_sync_completion(void); 333 - void laptop_mode_timer_fn(struct timer_list *t); 334 331 bool node_dirty_ok(struct pglist_data *pgdat); 335 332 int wb_domain_init(struct wb_domain *dom, gfp_t gfp); 336 333 #ifdef CONFIG_CGROUP_WRITEBACK ··· 339 342 /* These are exported to sysctl. */ 340 343 extern unsigned int dirty_writeback_interval; 341 344 extern unsigned int dirty_expire_interval; 342 - extern int laptop_mode; 343 345 344 346 void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty); 345 347 unsigned long wb_calc_thresh(struct bdi_writeback *wb, unsigned long thresh);
-1
include/trace/events/writeback.h
··· 42 42 EM( WB_REASON_VMSCAN, "vmscan") \ 43 43 EM( WB_REASON_SYNC, "sync") \ 44 44 EM( WB_REASON_PERIODIC, "periodic") \ 45 - EM( WB_REASON_LAPTOP_TIMER, "laptop_timer") \ 46 45 EM( WB_REASON_FS_FREE_SPACE, "fs_free_space") \ 47 46 EM( WB_REASON_FORKER_THREAD, "forker_thread") \ 48 47 EMe(WB_REASON_FOREIGN_FLUSH, "foreign_flush")
+1 -1
include/uapi/linux/sysctl.h
··· 183 183 VM_LOWMEM_RESERVE_RATIO=20,/* reservation ratio for lower memory zones */ 184 184 VM_MIN_FREE_KBYTES=21, /* Minimum free kilobytes to maintain */ 185 185 VM_MAX_MAP_COUNT=22, /* int: Maximum number of mmaps/address-space */ 186 - VM_LAPTOP_MODE=23, /* vm laptop mode */ 186 + 187 187 VM_BLOCK_DUMP=24, /* block dump mode */ 188 188 VM_HUGETLB_GROUP=25, /* permitted hugetlb group */ 189 189 VM_VFS_CACHE_PRESSURE=26, /* dcache/icache reclaim pressure */
-3
mm/backing-dev.c
··· 1034 1034 bdi->capabilities = BDI_CAP_WRITEBACK; 1035 1035 bdi->ra_pages = VM_READAHEAD_PAGES; 1036 1036 bdi->io_pages = VM_READAHEAD_PAGES; 1037 - timer_setup(&bdi->laptop_mode_wb_timer, laptop_mode_timer_fn, 0); 1038 1037 return bdi; 1039 1038 } 1040 1039 EXPORT_SYMBOL(bdi_alloc); ··· 1155 1156 1156 1157 void bdi_unregister(struct backing_dev_info *bdi) 1157 1158 { 1158 - timer_delete_sync(&bdi->laptop_mode_wb_timer); 1159 - 1160 1159 /* make sure nobody finds us on the bdi_list anymore */ 1161 1160 bdi_remove_from_list(bdi); 1162 1161 wb_shutdown(&bdi->wb);
+15 -59
mm/page-writeback.c
··· 109 109 */ 110 110 unsigned int dirty_expire_interval = 30 * 100; /* centiseconds */ 111 111 112 - /* 113 - * Flag that puts the machine in "laptop mode". Doubles as a timeout in jiffies: 114 - * a full sync is triggered after this time elapses without any disk activity. 115 - */ 116 - int laptop_mode; 117 - 118 - EXPORT_SYMBOL(laptop_mode); 119 - 120 112 /* End of sysctl-exported parameters */ 121 113 122 114 struct wb_domain global_wb_domain; ··· 1835 1843 balance_domain_limits(mdtc, strictlimit); 1836 1844 } 1837 1845 1838 - /* 1839 - * In laptop mode, we wait until hitting the higher threshold 1840 - * before starting background writeout, and then write out all 1841 - * the way down to the lower threshold. So slow writers cause 1842 - * minimal disk activity. 1843 - * 1844 - * In normal mode, we start background writeout at the lower 1845 - * background_thresh, to keep the amount of dirty memory low. 1846 - */ 1847 - if (!laptop_mode && nr_dirty > gdtc->bg_thresh && 1848 - !writeback_in_progress(wb)) 1846 + if (nr_dirty > gdtc->bg_thresh && !writeback_in_progress(wb)) 1849 1847 wb_start_background_writeback(wb); 1850 1848 1851 1849 /* ··· 1857 1875 current->nr_dirtied_pause = min(intv, m_intv); 1858 1876 break; 1859 1877 } 1860 - 1861 - /* Start writeback even when in laptop mode */ 1862 - if (unlikely(!writeback_in_progress(wb))) 1863 - wb_start_background_writeback(wb); 1864 1878 1865 1879 mem_cgroup_flush_foreign(wb); 1866 1880 ··· 2176 2198 } 2177 2199 #endif 2178 2200 2179 - void laptop_mode_timer_fn(struct timer_list *t) 2180 - { 2181 - struct backing_dev_info *backing_dev_info = 2182 - timer_container_of(backing_dev_info, t, laptop_mode_wb_timer); 2183 - 2184 - wakeup_flusher_threads_bdi(backing_dev_info, WB_REASON_LAPTOP_TIMER); 2185 - } 2186 - 2187 - /* 2188 - * We've spun up the disk and we're in laptop mode: schedule writeback 2189 - * of all dirty data a few seconds from now. If the flush is already scheduled 2190 - * then push it back - the user is still using the disk. 2191 - */ 2192 - void laptop_io_completion(struct backing_dev_info *info) 2193 - { 2194 - mod_timer(&info->laptop_mode_wb_timer, jiffies + laptop_mode); 2195 - } 2196 - 2197 - /* 2198 - * We're in laptop mode and we've just synced. The sync's writes will have 2199 - * caused another writeback to be scheduled by laptop_io_completion. 2200 - * Nothing needs to be written back anymore, so we unschedule the writeback. 2201 - */ 2202 - void laptop_sync_completion(void) 2203 - { 2204 - struct backing_dev_info *bdi; 2205 - 2206 - rcu_read_lock(); 2207 - 2208 - list_for_each_entry_rcu(bdi, &bdi_list, bdi_list) 2209 - timer_delete(&bdi->laptop_mode_wb_timer); 2210 - 2211 - rcu_read_unlock(); 2212 - } 2213 - 2214 2201 /* 2215 2202 * If ratelimit_pages is too high then we can get into dirty-data overload 2216 2203 * if a large number of processes all perform writes at the same time. ··· 2205 2262 } 2206 2263 2207 2264 #ifdef CONFIG_SYSCTL 2265 + 2266 + static int laptop_mode; 2267 + static int laptop_mode_handler(const struct ctl_table *table, int write, 2268 + void *buffer, size_t *lenp, loff_t *ppos) 2269 + { 2270 + int ret = proc_dointvec_jiffies(table, write, buffer, lenp, ppos); 2271 + 2272 + if (!ret && write) 2273 + pr_warn("%s: vm.laptop_mode is deprecated. Ignoring setting.\n", 2274 + current->comm); 2275 + 2276 + return ret; 2277 + } 2208 2278 2209 2279 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ 2210 2280 static const unsigned long dirty_bytes_min = 2 * PAGE_SIZE; ··· 2288 2332 .data = &laptop_mode, 2289 2333 .maxlen = sizeof(laptop_mode), 2290 2334 .mode = 0644, 2291 - .proc_handler = proc_dointvec_jiffies, 2335 + .proc_handler = laptop_mode_handler, 2292 2336 }, 2293 2337 }; 2294 2338 #endif
+8 -22
mm/vmscan.c
··· 104 104 unsigned int force_deactivate:1; 105 105 unsigned int skipped_deactivate:1; 106 106 107 - /* Writepage batching in laptop mode; RECLAIM_WRITE */ 107 + /* zone_reclaim_mode, boost reclaim */ 108 108 unsigned int may_writepage:1; 109 109 110 - /* Can mapped folios be reclaimed? */ 110 + /* zone_reclaim_mode */ 111 111 unsigned int may_unmap:1; 112 112 113 - /* Can folios be swapped as part of reclaim? */ 113 + /* zome_reclaim_mode, boost reclaim, cgroup restrictions */ 114 114 unsigned int may_swap:1; 115 115 116 116 /* Not allow cache_trim_mode to be turned on as part of reclaim? */ ··· 6365 6365 6366 6366 if (sc->compaction_ready) 6367 6367 break; 6368 - 6369 - /* 6370 - * If we're getting trouble reclaiming, start doing 6371 - * writepage even in laptop mode. 6372 - */ 6373 - if (sc->priority < DEF_PRIORITY - 2) 6374 - sc->may_writepage = 1; 6375 6368 } while (--sc->priority >= 0); 6376 6369 6377 6370 last_pgdat = NULL; ··· 6573 6580 .order = order, 6574 6581 .nodemask = nodemask, 6575 6582 .priority = DEF_PRIORITY, 6576 - .may_writepage = !laptop_mode, 6583 + .may_writepage = 1, 6577 6584 .may_unmap = 1, 6578 6585 .may_swap = 1, 6579 6586 }; ··· 6617 6624 struct scan_control sc = { 6618 6625 .nr_to_reclaim = SWAP_CLUSTER_MAX, 6619 6626 .target_mem_cgroup = memcg, 6620 - .may_writepage = !laptop_mode, 6627 + .may_writepage = 1, 6621 6628 .may_unmap = 1, 6622 6629 .reclaim_idx = MAX_NR_ZONES - 1, 6623 6630 .may_swap = !noswap, ··· 6663 6670 .reclaim_idx = MAX_NR_ZONES - 1, 6664 6671 .target_mem_cgroup = memcg, 6665 6672 .priority = DEF_PRIORITY, 6666 - .may_writepage = !laptop_mode, 6673 + .may_writepage = 1, 6667 6674 .may_unmap = 1, 6668 6675 .may_swap = !!(reclaim_options & MEMCG_RECLAIM_MAY_SWAP), 6669 6676 .proactive = !!(reclaim_options & MEMCG_RECLAIM_PROACTIVE), ··· 7044 7051 * from reclaim context. If no pages are reclaimed, the 7045 7052 * reclaim will be aborted. 7046 7053 */ 7047 - sc.may_writepage = !laptop_mode && !nr_boost_reclaim; 7054 + sc.may_writepage = !nr_boost_reclaim; 7048 7055 sc.may_swap = !nr_boost_reclaim; 7049 7056 7050 7057 /* ··· 7053 7060 * regardless of classzone as this is about consistent aging. 7054 7061 */ 7055 7062 kswapd_age_node(pgdat, &sc); 7056 - 7057 - /* 7058 - * If we're getting trouble reclaiming, start doing writepage 7059 - * even in laptop mode. 7060 - */ 7061 - if (sc.priority < DEF_PRIORITY - 2) 7062 - sc.may_writepage = 1; 7063 7063 7064 7064 /* Call soft limit reclaim before calling shrink_node. */ 7065 7065 sc.nr_scanned = 0; ··· 7785 7799 .reclaim_idx = gfp_zone(gfp_mask), 7786 7800 .proactive_swappiness = swappiness == -1 ? NULL : &swappiness, 7787 7801 .priority = DEF_PRIORITY, 7788 - .may_writepage = !laptop_mode, 7802 + .may_writepage = 1, 7789 7803 .nr_to_reclaim = max(batch_size, SWAP_CLUSTER_MAX), 7790 7804 .may_unmap = 1, 7791 7805 .may_swap = 1,