From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92862C433DF for ; Wed, 20 May 2020 23:26:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4C72A20899 for ; Wed, 20 May 2020 23:26:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="hpPggKJV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C72A20899 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C6CFD80017; Wed, 20 May 2020 19:26:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA3F98000A; Wed, 20 May 2020 19:26:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F50B80017; Wed, 20 May 2020 19:26:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0193.hostedemail.com [216.40.44.193]) by kanga.kvack.org (Postfix) with ESMTP id 80E8F8000A for ; Wed, 20 May 2020 19:26:23 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 40F03181AC544 for ; Wed, 20 May 2020 23:26:23 +0000 (UTC) X-FDA: 76838683446.20.nerve99_1a9b961e1f912 X-HE-Tag: nerve99_1a9b961e1f912 X-Filterd-Recvd-Size: 5642 Received: from mail-qt1-f196.google.com (mail-qt1-f196.google.com [209.85.160.196]) by imf05.hostedemail.com (Postfix) with ESMTP for ; Wed, 20 May 2020 23:26:22 +0000 (UTC) Received: by mail-qt1-f196.google.com with SMTP id l1so4081464qtp.6 for ; Wed, 20 May 2020 16:26:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y1gbv98UFIo3SZ72LRLIih1+wdVTAGD1gNzI7HeJpHo=; b=hpPggKJV3g/zDlX6q+IhjzuaavboPvYaqmrBUzXq9ZuPMM5ClP8Bg1in2XIQ9orriE C3/fOi2brri7XodOhZcMTWfdRuq9LwXxZYJxLvZ+Ht5koUY1VFZ3AzkUVKxMwi330Gxv mVC7DJPtGzV5OUq+Xq06kmHZBrnWm4DjETEOTBOqK0WFjGIYMvQFk8Ghbw+2G5CELACD US/WZx6T8fOw2RdBM2kdBYcP8oaAV1GpYueK7oj7VZz/GEL1gJha+42iQCDigfZX9qPm nrC/AXRbipE8QvX3yfiJgY/Ye36g5GgmfjtVLl9gC1u+mb+PMdEBjUd6SFV5M19yghd4 Cjdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y1gbv98UFIo3SZ72LRLIih1+wdVTAGD1gNzI7HeJpHo=; b=c8z/GJJ9cNK6bMrpoq6f7ND5E5CwCYoUOh7cSGY3wR2+UaHoposhmXqFC0Bn6JH46N N8JeLAOZWlGVspSgmjg8GKoP/jhzhNmIW20jQ3qZCLFgRdjqa+zX22pA3ZFOvLCWVwXG n4GadfouhrUIk2oJXvuMplLQ2Vn0USZHVdswYYAzDStT8sYcQWnxedTVgEpZwX+BSJ/x LPmAynlbXWMfvqZVqUcLD8gZt86GchWCCHRb2r2EmIUA8VMNJr+IxKY2gk/TcKHDlEyl 5wb4waRrDJnSHCmhCWI+ZPIOjzzvtNxLNEKva8MmwwZN9Fm3BPpOPSIRtJKcNd9vyv9T STqQ== X-Gm-Message-State: AOAM532DsMDw7vwl3JiWX7NjQuUBz9wx1zQlZpeuEkoy+pxJ2S3/bmR5 Kd8I/PG+ag+KlU2t5rv48HjJJ2wucVE= X-Google-Smtp-Source: ABdhPJzwApchXPfv+uLAF0ZuP3Mw5WX1lotYMFwoUQTYCPT/AwiqdCElwWXi1OQ68cMyYPQz/b88jQ== X-Received: by 2002:ac8:2dbc:: with SMTP id p57mr7872466qta.280.1590017181716; Wed, 20 May 2020 16:26:21 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:4708]) by smtp.gmail.com with ESMTPSA id o3sm3597138qtt.56.2020.05.20.16.26.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2020 16:26:21 -0700 (PDT) From: Johannes Weiner To: linux-mm@kvack.org Cc: Rik van Riel , Minchan Kim , Michal Hocko , Andrew Morton , Joonsoo Kim , linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 14/14] mm: vmscan: limit the range of LRU type balancing Date: Wed, 20 May 2020 19:25:25 -0400 Message-Id: <20200520232525.798933-15-hannes@cmpxchg.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200520232525.798933-1-hannes@cmpxchg.org> References: <20200520232525.798933-1-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When LRU cost only shows up on one list, we abruptly stop scanning that list altogether. That's an extreme reaction: by the time the other list starts thrashing and the pendulum swings back, we may have no recent age information on the first list anymore, and we could have significant latencies until the scanner has caught up. Soften this change in the feedback system by ensuring that no list receives less than a third of overall pressure, and only distribute the other 66% according to LRU cost. This ensures that we maintain a minimum rate of aging on the entire workingset while it's being pressured, while still allowing a generous rate of convergence when the relative sizes of the lists need to adjust. Signed-off-by: Johannes Weiner --- mm/vmscan.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 5453b4ef2ea1..c628f9ab886b 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2237,12 +2237,11 @@ static void get_scan_count(struct lruvec *lruvec,= struct scan_control *sc, unsigned long *nr) { struct mem_cgroup *memcg =3D lruvec_memcg(lruvec); + unsigned long anon_cost, file_cost, total_cost; int swappiness =3D mem_cgroup_swappiness(memcg); u64 fraction[2]; u64 denominator =3D 0; /* gcc */ - unsigned long anon_prio, file_prio; enum scan_balance scan_balance; - unsigned long totalcost; unsigned long ap, fp; enum lru_list lru; =20 @@ -2301,17 +2300,22 @@ static void get_scan_count(struct lruvec *lruvec,= struct scan_control *sc, * the relative IO cost of bringing back a swapped out * anonymous page vs reloading a filesystem page (swappiness). * + * Although we limit that influence to ensure no list gets + * left behind completely: at least a third of the pressure is + * applied, before swappiness. + * * With swappiness at 100, anon and file have equal IO cost. */ - anon_prio =3D swappiness; - file_prio =3D 200 - anon_prio; + total_cost =3D sc->anon_cost + sc->file_cost; + anon_cost =3D total_cost + sc->anon_cost; + file_cost =3D total_cost + sc->file_cost; + total_cost =3D anon_cost + file_cost; =20 - totalcost =3D sc->anon_cost + sc->file_cost; - ap =3D anon_prio * (totalcost + 1); - ap /=3D sc->anon_cost + 1; + ap =3D swappiness * (total_cost + 1); + ap /=3D anon_cost + 1; =20 - fp =3D file_prio * (totalcost + 1); - fp /=3D sc->file_cost + 1; + fp =3D (200 - swappiness) * (total_cost + 1); + fp /=3D file_cost + 1; =20 fraction[0] =3D ap; fraction[1] =3D fp; --=20 2.26.2