On Thu, 2016-04-07 at 20:28 +0300, Ebru Akagunduz wrote: > Currently khugepaged makes swapin readahead to improve > THP collapse rate. This patch checks vm statistics > to avoid workload of swapin, if unnecessary. So that > when system under pressure, khugepaged won't consume > resources to swapin and won't trigger direct reclaim > when swapin readahead. > > The patch was tested with a test program that allocates > 800MB of memory, writes to it, and then sleeps. The system > was forced to swap out all. Afterwards, the test program > touches the area by writing, it skips a page in each > 20 pages of the area. When waiting to swapin readahead > left part of the test, the memory forced to be busy > doing page reclaim. There was enough free memory during > test, khugepaged did not swapin readahead due to business. > > Test results: > >                         After swapped out > ------------------------------------------------------------------- >               | Anonymous | AnonHugePages | Swap      | Fraction  | > ------------------------------------------------------------------- > With patch    | 0 kB      |  0 kB         | 800000 kB |    %100   | > ------------------------------------------------------------------- > Without patch | 0 kB      |  0 kB         | 800000 kB |    %100   | > ------------------------------------------------------------------- > >                         After swapped in > ------------------------------------------------------------------- >               | Anonymous | AnonHugePages | Swap      | Fraction  | > ------------------------------------------------------------------- > With patch    | 384812 kB | 96256 kB      | 415188 kB |    %25    | > ------------------------------------------------------------------- > Without patch | 389728 kB | 194560 kB     | 410272 kB |    %49    | > ------------------------------------------------------------------- > > Signed-off-by: Ebru Akagunduz Acked-by: Rik van Riel -- All Rights Reversed.