From patchwork Wed May 20 23:25:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 11561701 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 90937739 for ; Wed, 20 May 2020 23:26:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5ED0520897 for ; Wed, 20 May 2020 23:26:10 +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 5ED0520897 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) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D04EE8000A; Wed, 20 May 2020 19:26:06 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org 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-Original-To: linux-mm@kvack.org 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-Spam-Summary: 2,0,0,ed9bcff5493f41c2,d41d8cd98f00b204,hannes@cmpxchg.org,,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1260:1311:1314:1345:1359:1437:1515:1535:1543:1711:1730:1747:1777:1792:1801:2196:2197:2199:2200:2393:2559:2562:2693:2740:3138:3139:3140:3141:3142:3355:3369:3865:3866:3867:3868:3870:3871:3872:3873:3874:4117:4250:4321:4385:4605:5007:6119:6261:6653:7875:7903:9707:10004:11026:11232:11473:11658:11914:12043:12291:12296:12297:12438:12517:12519:12555:12895:13146:13184:13229:13230:13255:13869:13894:14181:14394:14721:21080:21444:21451:21627:21740:21990:30005:30054,0,RBL:209.85.219.65:@cmpxchg.org:.lbl8.mailshell.net-62.2.0.100 66.100.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none 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 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/admin-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 bottleneck and you want all swappiness ========== -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. The default value is 60. +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 = 200, 2x = 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. + unprivileged_userfaultfd ======================== 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 = 1; static unsigned long long_max = LONG_MAX; static int one_hundred = 100; +static int two_hundred = 200; static int one_thousand = 1000; #ifdef CONFIG_PRINTK static int ten_thousand = 10000; @@ -1391,7 +1392,7 @@ static struct ctl_table vm_table[] = { .mode = 0644, .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, - .extra2 = &one_hundred, + .extra2 = &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 /* - * From 0 .. 100. Higher means more swappy. + * From 0 .. 200. Higher means more swappy. */ int vm_swappiness = 60; /*