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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F1DEC433F5 for ; Tue, 19 Apr 2022 18:46:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE9E46B0071; Tue, 19 Apr 2022 14:46:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B978C6B0073; Tue, 19 Apr 2022 14:46:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A38136B0074; Tue, 19 Apr 2022 14:46:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 9580C6B0071 for ; Tue, 19 Apr 2022 14:46:46 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 690CF60B99 for ; Tue, 19 Apr 2022 18:46:46 +0000 (UTC) X-FDA: 79374510012.10.342EBEE Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by imf18.hostedemail.com (Postfix) with ESMTP id 7DDBB1C000F for ; Tue, 19 Apr 2022 18:46:44 +0000 (UTC) Received: by mail-qk1-f172.google.com with SMTP id b189so14225314qkf.11 for ; Tue, 19 Apr 2022 11:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Bv5IZFxxycj4VF9FAHiGL9YNhUERdck5XbK5n8+IdIs=; b=bnX3/vIz1XDgHxx0IH8H6MmEN6xrCRGbplySBz2ObO5yuuHCOln2dH3v1bvlBAWjxj ewK4BB9rObmaEOfnXdxrW/RbUnbLQsTsKMRF672HDZ848QjMdKA35HksGdKs7IoCBXcR HqYT3Vh/zXrj/WZuC+fwqSPJYaaQHOSYHBcn78+DQA3KoYz75NYyhJMpFShN++PuDdlK O4BDcS5WEhwg4/eu47gx7ws2jZt2EO8n3H5v+UUVqwG7cA7G1vgWPViM2shgLH+i8DZh S2qjmU46Kla5OisiZaGHTgPBi3k5wYyP4/8CmB6M2aqqbzdmRkeCDVzfoTTl/ikEpk7X f+GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Bv5IZFxxycj4VF9FAHiGL9YNhUERdck5XbK5n8+IdIs=; b=aN8CNMxKsk/nZlyjM2++7u535seqtDv4qfBUjJW0SzFi7YFFkv1r493pI+7dp8SA++ /r8dGIiS/a3VwnmrVQXjUKxL00UtHPjNhac6OjUa7X6mDg8UU2hhppAnbwA7N56PvNrh 520QX6QV0EDryubZYfuBAvhQVTchgx9tlHfmBlLoPOrq49itURx7Ncd+wSS7ZFLwmr6l 71OEjk+Kgh9xOtsB6J+KRNXSAjUPFcI1EQd8qMel6/rYda6T0+ubmtU/vU74qOHU0oJ3 98xSdEIFFjcQRvGSjgz3Wa5pqISGpdCTVzoikTabHBRoaQZy6WCkc9Ao+JQELTmiufDg 2vUA== X-Gm-Message-State: AOAM530Ts9WHnRwOW5u8OwPHgO6RxZGwBGLMqy/RylFGV90XCr4OBFPG +oAifDPJPf58wejvnAydnkf6Og== X-Google-Smtp-Source: ABdhPJyvmV/AcmqMuj3TZiiT4bhBUz+woYja1eJmuuglieCujllahRMw2zgZZ72XgOkwu8uNXl27Vw== X-Received: by 2002:a05:620a:2902:b0:69e:b906:7078 with SMTP id m2-20020a05620a290200b0069eb9067078mr4659211qkp.717.1650394004432; Tue, 19 Apr 2022 11:46:44 -0700 (PDT) Received: from localhost (cpe-98-15-154-102.hvc.res.rr.com. [98.15.154.102]) by smtp.gmail.com with ESMTPSA id b13-20020ac85bcd000000b002e06856b04fsm502592qtb.51.2022.04.19.11.46.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 11:46:43 -0700 (PDT) Date: Tue, 19 Apr 2022 14:46:43 -0400 From: Johannes Weiner To: Nico Pache Cc: linux-mm@kvack.org, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, aquini@redhat.com, shakeelb@google.com, llong@redhat.com, mhocko@suse.com, hakavlad@inbox.lv Subject: Re: [PATCH v3] vm_swappiness=0 should still try to avoid swapping anon memory Message-ID: References: <20210809223740.59009-1-npache@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 7DDBB1C000F X-Stat-Signature: iaec8usrnwubcaep1rry7pgbqqda6q5f Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b="bnX3/vIz"; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf18.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.172 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org X-HE-Tag: 1650394004-403052 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: Hi Nico, On Tue, Apr 19, 2022 at 02:11:53PM -0400, Nico Pache wrote: > I think its is important to note the issue we are seeing has greatly improved > since the initial posting. However we have noticed that the issue is still > present (and significantly worse) when cgroupV1 is set. > > We were initially testing with CgroupV1 and later found that the issue was not > as bad in CgroupV2 (but was still an noticeable issue). This is also resulting > in the splitting of THPs in the host kernel. When swappiness is 0, cgroup limit reclaim has a fixed SCAN_FILE branch, so it shouldn't ever look at anon. I'm assuming you're getting global reclaim mixed in. Indeed, I think we can try harder not to swap for global reclaim if the user asks for that. Can you try the below patch? diff --git a/mm/vmscan.c b/mm/vmscan.c index ba19edbc2452..0aa929151386 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2729,11 +2729,9 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc, } /* - * Global reclaim will swap to prevent OOM even with no - * swappiness, but memcg users want to use this knob to - * disable swapping for individual groups completely when - * using the memory controller's swap limit feature would be - * too expensive. + * For cgroups, swappiness=0 means never swap. Historically, + * cgroup users have relied on this as it was cheaper than + * setting a swap limit of 0. */ if (cgroup_reclaim(sc) && !swappiness) { scan_balance = SCAN_FILE; @@ -2754,7 +2752,7 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc, * If the system is almost out of file pages, force-scan anon. */ if (sc->file_is_tiny) { - scan_balance = SCAN_ANON; + scan_balance = SCAN_EQUAL; goto out; } @@ -2767,6 +2765,12 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc, goto out; } + /* swappiness=0 means no swap until OOM is imminent */ + if (!swappiness && sc->priority) { + scan_balance = SCAN_FILE; + goto out; + } + scan_balance = SCAN_FRACT; /* * Calculate the pressure balance between anon and file pages.