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=ham 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 6E25BC433E4 for ; Wed, 20 May 2020 23:26:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 276E120897 for ; Wed, 20 May 2020 23:26:09 +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="qoEmy1tK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 276E120897 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 D79038000B; Wed, 20 May 2020 19:26:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D04EE8000A; Wed, 20 May 2020 19:26:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA30D8000B; Wed, 20 May 2020 19:26:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0020.hostedemail.com [216.40.44.20]) by kanga.kvack.org (Postfix) with ESMTP id 9C11B8000A for ; Wed, 20 May 2020 19:26:06 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 5F7A88245571 for ; Wed, 20 May 2020 23:26:06 +0000 (UTC) X-FDA: 76838682732.21.lift91_182c0d522e457 X-HE-Tag: lift91_182c0d522e457 X-Filterd-Recvd-Size: 6645 Received: from mail-qv1-f65.google.com (mail-qv1-f65.google.com [209.85.219.65]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Wed, 20 May 2020 23:26:05 +0000 (UTC) Received: by mail-qv1-f65.google.com with SMTP id er16so2273896qvb.0 for ; Wed, 20 May 2020 16:26:05 -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=AKHbKCUcHFNLRiN+4/B8hcf+bCyhRn4jQIo/5RZRxow=; b=qoEmy1tKSC0xVCapmBoUjzzu0j0Aj1hc9MAHx6UPt552xaOa7/mQRu++KzukzzNZfI cbpQWIDPyXI7+NHRVaY407+x+tWNgSW3vroKqtQezT1T1NMV23w7nWrp95GB9j0wemtV 5b2TEXx1rWN2NAUKHxy3gEEm1DZkJmUEDomarBU/lnllwWeeOXsqvu3SnmAlT7vRsF5u VcpvqECxLTn+kF4zAZbQDeANdJzm8nwOKue9fLo+hzoZQV/kKSQ4Prxh0UsIjICys1Hb Udy11DHrzA3j0Nw3cr5UJlj9H9X8ZYBYZ0US2EzRxw+sD3LKVmtrSMLqmU4mupf6yTUz Bh6A== 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=AKHbKCUcHFNLRiN+4/B8hcf+bCyhRn4jQIo/5RZRxow=; b=skPV8uy2R3rbeVwZit/Jn69i5b+2onhvpjtTajJI90v4eutvrpPGLnMF1teU6DxjW2 5hCj8h/19ieYbtvFBUpTroqlJj2/mtmunSTdkbpz6uRFcmFIuRxmZP9jNzhOXc0A49Tx umX4GidpA3fuDvZiGC8QXs4l9jWW6MJ9EXjr20MfGDLd4pFfKZ01Tyt6hsV9Xu9LgqJU 8+R/tUAe4dKHLQQsf9ir/Bgb75Ex3J7Cshjr7dJEy+6keviEvpbT8moV9uyb8eOg2VTf uz74mC1XjbIKUsRZEEc9r/qG+jZ4oS1XRFCmxJGmASy3lTIkv2vtLKsRuer8exSjV7bw dcAQ== X-Gm-Message-State: AOAM5300O14NodpzwaVb1Ofi+74TmahuV5kpCNS4hr7DPiusd3GLF5Oo oFTuQQ14L+LOwylZZgK/Z9DXoJsE2T8= X-Google-Smtp-Source: ABdhPJwp9ZX1EUTNRzadr7k2Tw2KHmAiDcrX312wi7ypQUlBcRghIKz1r+baKMwt5HCjHNgueyfdGw== X-Received: by 2002:ad4:4e6f:: with SMTP id ec15mr7582144qvb.88.1590017164865; Wed, 20 May 2020 16:26:04 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:4708]) by smtp.gmail.com with ESMTPSA id h15sm1879288qkh.18.2020.05.20.16.26.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2020 16:26:04 -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 03/14] mm: allow swappiness that prefers reclaiming anon over the file workingset Date: Wed, 20 May 2020 19:25:14 -0400 Message-Id: <20200520232525.798933-4-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: With the advent of fast random IO devices (SSDs, PMEM) and in-memory swap devices such as zswap, it's possible for swap to be much faster than filesystems, and for swapping to be preferable over thrashing filesystem caches. Allow setting swappiness - which defines the rough relative IO cost of cache misses between page cache and swap-backed pages - to reflect such situations by making the swap-preferred range configurable. v2: clarify how to calculate swappiness (Minchan Kim) Signed-off-by: Johannes Weiner --- Documentation/admin-guide/sysctl/vm.rst | 23 ++++++++++++++++++----- kernel/sysctl.c | 3 ++- mm/vmscan.c | 2 +- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Documentation/admin-guide/sysctl/vm.rst b/Documentation/admi= n-guide/sysctl/vm.rst index 0329a4d3fa9e..d46d5b7013c6 100644 --- a/Documentation/admin-guide/sysctl/vm.rst +++ b/Documentation/admin-guide/sysctl/vm.rst @@ -831,14 +831,27 @@ When page allocation performance is not a bottlenec= k and you want all swappiness =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 -This control is used to define how aggressive the kernel will swap -memory pages. Higher values will increase aggressiveness, lower values -decrease the amount of swap. A value of 0 instructs the kernel not to -initiate swap until the amount of free and file-backed pages is less -than the high water mark in a zone. +This control is used to define the rough relative IO cost of swapping +and filesystem paging, as a value between 0 and 200. At 100, the VM +assumes equal IO cost and will thus apply memory pressure to the page +cache and swap-backed pages equally; lower values signify more +expensive swap IO, higher values indicates cheaper. + +Keep in mind that filesystem IO patterns under memory pressure tend to +be more efficient than swap's random IO. An optimal value will require +experimentation and will also be workload-dependent. =20 The default value is 60. =20 +For in-memory swap, like zram or zswap, as well as hybrid setups that +have swap on faster devices than the filesystem, values beyond 100 can +be considered. For example, if the random IO against the swap device +is on average 2x faster than IO from the filesystem, swappiness should +be 133 (x + 2x =3D 200, 2x =3D 133.33). + +At 0, the kernel will not initiate swap until the amount of free and +file-backed pages is less than the high watermark in a zone. + =20 unprivileged_userfaultfd =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 8a176d8727a3..7f15d292e44c 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -131,6 +131,7 @@ static unsigned long zero_ul; static unsigned long one_ul =3D 1; static unsigned long long_max =3D LONG_MAX; static int one_hundred =3D 100; +static int two_hundred =3D 200; static int one_thousand =3D 1000; #ifdef CONFIG_PRINTK static int ten_thousand =3D 10000; @@ -1391,7 +1392,7 @@ static struct ctl_table vm_table[] =3D { .mode =3D 0644, .proc_handler =3D proc_dointvec_minmax, .extra1 =3D SYSCTL_ZERO, - .extra2 =3D &one_hundred, + .extra2 =3D &two_hundred, }, #ifdef CONFIG_HUGETLB_PAGE { diff --git a/mm/vmscan.c b/mm/vmscan.c index 70b0e2c6a4b9..43f88b1a4f14 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -161,7 +161,7 @@ struct scan_control { #endif =20 /* - * From 0 .. 100. Higher means more swappy. + * From 0 .. 200. Higher means more swappy. */ int vm_swappiness =3D 60; /* --=20 2.26.2