lkml.org 
[lkml]   [2015]   [Nov]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH] mm: vmscan: Obey indeed proportional scanning for kswapd and memcg
    Date
    Commit e82e0561dae9f3ae5 ("mm: vmscan: obey proportional scanning
    requirements for kswapd") intended to preserve the proportional scanning
    and reclaim what was requested by get_scan_count() for kswapd and memcg
    by stopping reclaiming one type(anon or file) LRU and reducing the other's
    amount of scanning proportional to the original scan target.

    So the way to determine which LRU should be stopped reclaiming should be
    comparing scanned/unscanned percentages to the original scan target of two
    lru types instead of absolute values what implemented currently, because
    larger absolute value doesn't mean larger percentage, there shall be
    chance that larger absolute value with smaller percentage, for instance:

    target_file = 1000
    target_anon = 500
    nr_file = 500
    nr_anon = 400

    in this case, because nr_file > nr_anon, according to current implement,
    we will stop scanning anon lru and shrink file lru. This breaks
    proportional scanning intent and makes more unproportional.

    This patch changes to compare percentage to the original scan target to
    determine which lru should be shrunk.

    Signed-off-by: Yaowei Bai <baiyaowei@cmss.chinamobile.com>
    ---
    mm/vmscan.c | 16 +++++++++-------
    1 file changed, 9 insertions(+), 7 deletions(-)

    diff --git a/mm/vmscan.c b/mm/vmscan.c
    index 2aec424..09a37436 100644
    --- a/mm/vmscan.c
    +++ b/mm/vmscan.c
    @@ -2216,6 +2216,7 @@ static void shrink_lruvec(struct lruvec *lruvec, int swappiness,
    while (nr[LRU_INACTIVE_ANON] || nr[LRU_ACTIVE_FILE] ||
    nr[LRU_INACTIVE_FILE]) {
    unsigned long nr_anon, nr_file, percentage;
    + unsigned long percentage_anon, percentage_file;
    unsigned long nr_scanned;

    for_each_evictable_lru(lru) {
    @@ -2250,16 +2251,17 @@ static void shrink_lruvec(struct lruvec *lruvec, int swappiness,
    if (!nr_file || !nr_anon)
    break;

    - if (nr_file > nr_anon) {
    - unsigned long scan_target = targets[LRU_INACTIVE_ANON] +
    - targets[LRU_ACTIVE_ANON] + 1;
    + percentage_anon = nr_anon * 100 / (targets[LRU_INACTIVE_ANON] +
    + targets[LRU_ACTIVE_ANON] + 1);
    + percentage_file = nr_file * 100 / (targets[LRU_INACTIVE_FILE] +
    + targets[LRU_ACTIVE_FILE] + 1);
    +
    + if (percentage_file > percentage_anon) {
    lru = LRU_BASE;
    - percentage = nr_anon * 100 / scan_target;
    + percentage = percentage_anon;
    } else {
    - unsigned long scan_target = targets[LRU_INACTIVE_FILE] +
    - targets[LRU_ACTIVE_FILE] + 1;
    lru = LRU_FILE;
    - percentage = nr_file * 100 / scan_target;
    + percentage = percentage_file;
    }

    /* Stop scanning the smaller of the LRU */
    --
    1.9.1




    \
     
     \ /
      Last update: 2015-11-25 06:01    [W:3.354 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site