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 97535C433FE for ; Tue, 17 May 2022 18:13:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2406B6B0072; Tue, 17 May 2022 14:13:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1EF896B0073; Tue, 17 May 2022 14:13:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B8366B0074; Tue, 17 May 2022 14:13:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id F19D66B0072 for ; Tue, 17 May 2022 14:13:48 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id C9CB161A7B for ; Tue, 17 May 2022 18:13:48 +0000 (UTC) X-FDA: 79476033336.20.11CFB18 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by imf06.hostedemail.com (Postfix) with ESMTP id A59FC180050 for ; Tue, 17 May 2022 18:13:45 +0000 (UTC) Received: by mail-wm1-f51.google.com with SMTP id r6-20020a1c2b06000000b00396fee5ebc9so1706551wmr.1 for ; Tue, 17 May 2022 11:13:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SxdLGiW7G4yy4xMRD8hfhHfhbpz1FE3G/RxrHKIn0i4=; b=dlOjwguLoSABSlSgnpYbdu/+hz6xKKTWhzMk/C7LJGmIpRXsihQvKoARr8bmjTriEN CnZHHPI2C6oDaLfkZ/omNpk2kv0RAjqvQFOH1wjzYlmNblToLm7kwdYRSORYVgTzy0TX x43CqGlTOW1HisGyl/oCzP8SWveY/V6ov38GxWtdQ8CjCkCQMPiNjeBLGeHRIXMTCCNQ 5tFyi/hY0V1RA7m53sC3PKKtrvyTOju4KPAXPgE9CjhmIumupMoyfhcxAfdfeO8b1T18 J7mie+Ri7kqib9BUe8Ys0WGxdy5mjIjG5eEIc6KeN0U5Rz8uIL1LV+0NDyoqZqumhfU8 BdKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SxdLGiW7G4yy4xMRD8hfhHfhbpz1FE3G/RxrHKIn0i4=; b=M4xW0k266G5sqAPmXKt4z2rVp8egfMA4GXUUDJ8NN3+Le928s3q0irquiSx4UNTo6m FLFE5m+C/wD2vsTt1zSPN5cu2t+yrxyqjHPH0DtVpgC0BjmhFL3SnAbpFx2iu4BSLTFh twzgGEXjWxSp9KSgljUfdleO5oSfV4nFvyTRG7vlb0ni1FBb/1YXsGoKjSXr+sMbGI5T FS21Zj7R//ZegdmFpA0GEgj9dq+hsC/AsxtrfXJ0P/SzNqoFEpnMoqE4wqMZ4Yq8pPzt Z0dbVCym/8YfEIg6Gc2U7VDBE5wDKiqjDZG0RVYckygbEYkNdGd2wWOXNlVC2+d/UJ2J s6EQ== X-Gm-Message-State: AOAM531U+bMllcXUU7bbE7Lvms2CvY7pMu+KoGqOBngH27aYYHLaeHbA QmyFsAKWrbKxbyy1MT8+cWE5W0eV1n1zficUoc7tmA== X-Google-Smtp-Source: ABdhPJwoiJ5pxRwzxetMp75okFV9PBCgHVA8ptysLcZUPvY8nSQ/S2080HUHHLeS3rHYTa428cdTOMVUWbutGjM/LlI= X-Received: by 2002:a05:600c:1910:b0:394:8517:496e with SMTP id j16-20020a05600c191000b003948517496emr22699150wmq.24.1652811226699; Tue, 17 May 2022 11:13:46 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Yosry Ahmed Date: Tue, 17 May 2022 11:13:10 -0700 Message-ID: Subject: Re: [RFC] Add swappiness argument to memory.reclaim To: Roman Gushchin Cc: Johannes Weiner , Michal Hocko , Shakeel Butt , Andrew Morton , David Rientjes , cgroups@vger.kernel.org, Tejun Heo , Linux-MM , Yu Zhao , Wei Xu , Greg Thelen , Chen Wandun Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: A59FC180050 X-Stat-Signature: 78wyaij4cdxj6cdy734fkgoncwaf77b7 Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=dlOjwguL; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf06.hostedemail.com: domain of yosryahmed@google.com designates 209.85.128.51 as permitted sender) smtp.mailfrom=yosryahmed@google.com X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1652811225-250667 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: On Tue, May 17, 2022 at 9:05 AM Roman Gushchin wrote: > > On Mon, May 16, 2022 at 03:29:42PM -0700, Yosry Ahmed wrote: > > The discussions on the patch series [1] to add memory.reclaim has > > shown that it is desirable to add an argument to control the type of > > memory being reclaimed by invoked proactive reclaim using > > memory.reclaim. > > > > I am proposing adding a swappiness optional argument to the interface. > > If set, it overwrites vm.swappiness and per-memcg swappiness. This > > provides a way to enforce user policy on a stateless per-reclaim > > basis. We can make policy decisions to perform reclaim differently for > > tasks of different app classes based on their individual QoS needs. It > > also helps for use cases when particularly page cache is high and we > > want to mainly hit that without swapping out. > > > > The interface would be something like this (utilizing the nested-keyed > > interface we documented earlier): > > > > $ echo "200M swappiness=30" > memory.reclaim > > What are the anticipated use cases except swappiness == 0 and > swappiness == system_default? > > IMO it's better to allow specifying the type of memory to reclaim, > e.g. type="file"/"anon"/"slab", it's a way more clear what to expect. I imagined swappiness would give user space flexibility to reclaim a ratio of file vs. anon as it sees fit based on app class or userspace policy, but I agree that the guarantees of swappiness are weak and we might want an explicit argument that directly controls the return value of get_scan_count() or whether or not we call shrink_slab(). My fear is that this interface may be less flexible, for example if we only want to avoid reclaiming file pages, but we are fine with anon or slab. Maybe in the future we will have a new type of memory to reclaim, does it get implicitly reclaimed when other types are specified or not? Maybe we can use one argument per type instead? E.g. $ echo "200M file=no anon=yes slab=yes" > memory.reclaim The default value would be "yes" for all types unless stated otherwise. This is also leaves room for future extensions (maybe file=clean to reclaim clean file pages only?). Interested to hear your thoughts on this! > > E.g. what > $ echo "200M swappiness=1" > memory.reclaim > means if there is only 10M of pagecache? How much of anon memory will > be reclaimed? Good point. I agree that the type argument or per-type arguments have multiple advantages over swappiness. > > Thanks!