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=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 96171C433ED for ; Thu, 1 Apr 2021 20:06:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2FFAD61005 for ; Thu, 1 Apr 2021 20:06:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2FFAD61005 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A760E6B00B0; Thu, 1 Apr 2021 16:06:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A25C56B00B1; Thu, 1 Apr 2021 16:06:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 89E5D6B00B2; Thu, 1 Apr 2021 16:06:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0247.hostedemail.com [216.40.44.247]) by kanga.kvack.org (Postfix) with ESMTP id 63D536B00B0 for ; Thu, 1 Apr 2021 16:06:41 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 21AFF183B2F88 for ; Thu, 1 Apr 2021 20:06:41 +0000 (UTC) X-FDA: 77984881002.39.120B0E5 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) by imf21.hostedemail.com (Postfix) with ESMTP id 0C418E0001B4 for ; Thu, 1 Apr 2021 20:06:39 +0000 (UTC) Received: by mail-ej1-f48.google.com with SMTP id ce10so4635810ejb.6 for ; Thu, 01 Apr 2021 13:06:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/5FgskCBgp4mYNMsW4JO+VcIW0/eiYLcwbqkkWuoz1o=; b=VR9rdV+dZtbtNdZi+t7HB7jIHlB6jGzShQeEsDb84EsEBYYfW+qnmLVXvQQIZkSWD6 VPRTbyWKemmh/hOHgXnqqOAU+dDYdqCSxX2CkAIoDFnF2JT8XBseONmXJUC+pRx9u7kC Y4FbiTcJwwdpB9CRpfpmu9yhupsnCFxsZv1+jqmUF3vj176dGQp2o7gBfUUBFF5MOR8l Q0nKRp9ZFvYkIYzNp2Fdfovdd0ExxK6z+xmpRtrbFa7NCK4jA9V2U3QzdzFHrR7CoXQT bChDcJJADEh1onUweHesT6SnBjH4/TQwGpTVCANRt/D+5MualskepxrMn7vSj+cNn/pt NE+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/5FgskCBgp4mYNMsW4JO+VcIW0/eiYLcwbqkkWuoz1o=; b=Q++AF3+CxPRYK2ZpD3vqVVc63ee0hUKQJ8FxrO+h3e0rfwQ3TDVRwhR/3ESC2uirq5 9Ikhv38mD5A2JWBMWr2GGofmpzWYGWYWN2kUGolEgt4UGhQkeX6ZbVNAFap3OnmxgOzS GdkIAUDWCpTAcn/IP+fpQyzm8PfxodV0x494HR/nyJSLcE6MmGm4nGyvZRrTXkFRCcng 4vbDJR64SPPJGhJ6FYSOoYGiJVY37RYgyB8XuAhM2VaCMJZlo06Np3S/AwWYNb1qqUuN 1Z/kalbEMqjJk60jXT0V4PRQshzIjI5cZS6oz0CMze8IYGVhf6g5PadeR0Qh/Hkj9GKt 70wg== X-Gm-Message-State: AOAM532h7UC/Aa6VeVFelPULfq/PSduXlzsnXkYrTOMInf8fRgGAVtz4 cqU+Qmh1gTDxa232LOK/KEJAcEYuhojnFLwlRCI= X-Google-Smtp-Source: ABdhPJw1cweuziLtv/UH9L+Hjp146uOcfObrlPQGwV1dUwYQeFuQvXUBmPLl90qcZqsPi0V8EDbqD/v4uSTh3H+5Jfg= X-Received: by 2002:a17:906:4bce:: with SMTP id x14mr10681523ejv.383.1617307599465; Thu, 01 Apr 2021 13:06:39 -0700 (PDT) MIME-Version: 1.0 References: <20210401183216.443C4443@viggo.jf.intel.com> <20210401183235.BCC49E8B@viggo.jf.intel.com> In-Reply-To: <20210401183235.BCC49E8B@viggo.jf.intel.com> From: Yang Shi Date: Thu, 1 Apr 2021 13:06:27 -0700 Message-ID: Subject: Re: [PATCH 10/10] mm/migrate: new zone_reclaim_mode to enable reclaim migration To: Dave Hansen Cc: Linux MM , Linux Kernel Mailing List , weixugc@google.com, Yang Shi , David Rientjes , Huang Ying , Dan Williams , David Hildenbrand , Oscar Salvador Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: 85spgyths3bz9iyfqed68shid311pnhi X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 0C418E0001B4 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf21; identity=mailfrom; envelope-from=""; helo=mail-ej1-f48.google.com; client-ip=209.85.218.48 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617307599-821312 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 Thu, Apr 1, 2021 at 11:35 AM Dave Hansen wrote: > > > From: Dave Hansen > > Some method is obviously needed to enable reclaim-based migration. > > Just like traditional autonuma, there will be some workloads that > will benefit like workloads with more "static" configurations where > hot pages stay hot and cold pages stay cold. If pages come and go > from the hot and cold sets, the benefits of this approach will be > more limited. > > The benefits are truly workload-based and *not* hardware-based. > We do not believe that there is a viable threshold where certain > hardware configurations should have this mechanism enabled while > others do not. > > To be conservative, earlier work defaulted to disable reclaim- > based migration and did not include a mechanism to enable it. > This proposes extending the existing "zone_reclaim_mode" (now > now really node_reclaim_mode) as a method to enable it. > > We are open to any alternative that allows end users to enable > this mechanism or disable it it workload harm is detected (just > like traditional autonuma). > > Once this is enabled page demotion may move data to a NUMA node > that does not fall into the cpuset of the allocating process. > This could be construed to violate the guarantees of cpusets. > However, since this is an opt-in mechanism, the assumption is > that anyone enabling it is content to relax the guarantees. > > Signed-off-by: Dave Hansen > Cc: Wei Xu > Cc: Yang Shi > Cc: David Rientjes > Cc: Huang Ying > Cc: Dan Williams > Cc: David Hildenbrand > Cc: osalvador > > Changes since 20200122: > * Changelog material about relaxing cpuset constraints > > Changes since 20210304: > * Add Documentation/ material about relaxing cpuset constraints Reviewed-by: Yang Shi > --- > > b/Documentation/admin-guide/sysctl/vm.rst | 12 ++++++++++++ > b/include/linux/swap.h | 3 ++- > b/include/uapi/linux/mempolicy.h | 1 + > b/mm/vmscan.c | 6 ++++-- > 4 files changed, 19 insertions(+), 3 deletions(-) > > diff -puN Documentation/admin-guide/sysctl/vm.rst~RECLAIM_MIGRATE Documentation/admin-guide/sysctl/vm.rst > --- a/Documentation/admin-guide/sysctl/vm.rst~RECLAIM_MIGRATE 2021-03-31 15:17:40.324000190 -0700 > +++ b/Documentation/admin-guide/sysctl/vm.rst 2021-03-31 15:17:40.349000190 -0700 > @@ -976,6 +976,7 @@ This is value OR'ed together of > 1 Zone reclaim on > 2 Zone reclaim writes dirty pages out > 4 Zone reclaim swaps pages > +8 Zone reclaim migrates pages > = =================================== > > zone_reclaim_mode is disabled by default. For file servers or workloads > @@ -1000,3 +1001,14 @@ of other processes running on other node > Allowing regular swap effectively restricts allocations to the local > node unless explicitly overridden by memory policies or cpuset > configurations. > + > +Page migration during reclaim is intended for systems with tiered memory > +configurations. These systems have multiple types of memory with varied > +performance characteristics instead of plain NUMA systems where the same > +kind of memory is found at varied distances. Allowing page migration > +during reclaim enables these systems to migrate pages from fast tiers to > +slow tiers when the fast tier is under pressure. This migration is > +performed before swap. It may move data to a NUMA node that does not > +fall into the cpuset of the allocating process which might be construed > +to violate the guarantees of cpusets. This should not be enabled on > +systems which need strict cpuset location guarantees. > diff -puN include/linux/swap.h~RECLAIM_MIGRATE include/linux/swap.h > --- a/include/linux/swap.h~RECLAIM_MIGRATE 2021-03-31 15:17:40.331000190 -0700 > +++ b/include/linux/swap.h 2021-03-31 15:17:40.351000190 -0700 > @@ -382,7 +382,8 @@ extern int sysctl_min_slab_ratio; > static inline bool node_reclaim_enabled(void) > { > /* Is any node_reclaim_mode bit set? */ > - return node_reclaim_mode & (RECLAIM_ZONE|RECLAIM_WRITE|RECLAIM_UNMAP); > + return node_reclaim_mode & (RECLAIM_ZONE |RECLAIM_WRITE| > + RECLAIM_UNMAP|RECLAIM_MIGRATE); > } > > extern void check_move_unevictable_pages(struct pagevec *pvec); > diff -puN include/uapi/linux/mempolicy.h~RECLAIM_MIGRATE include/uapi/linux/mempolicy.h > --- a/include/uapi/linux/mempolicy.h~RECLAIM_MIGRATE 2021-03-31 15:17:40.337000190 -0700 > +++ b/include/uapi/linux/mempolicy.h 2021-03-31 15:17:40.352000190 -0700 > @@ -71,5 +71,6 @@ enum { > #define RECLAIM_ZONE (1<<0) /* Run shrink_inactive_list on the zone */ > #define RECLAIM_WRITE (1<<1) /* Writeout pages during reclaim */ > #define RECLAIM_UNMAP (1<<2) /* Unmap pages during reclaim */ > +#define RECLAIM_MIGRATE (1<<3) /* Migrate to other nodes during reclaim */ > > #endif /* _UAPI_LINUX_MEMPOLICY_H */ > diff -puN mm/vmscan.c~RECLAIM_MIGRATE mm/vmscan.c > --- a/mm/vmscan.c~RECLAIM_MIGRATE 2021-03-31 15:17:40.339000190 -0700 > +++ b/mm/vmscan.c 2021-03-31 15:17:40.357000190 -0700 > @@ -1074,6 +1074,9 @@ static bool migrate_demote_page_ok(struc > VM_BUG_ON_PAGE(PageHuge(page), page); > VM_BUG_ON_PAGE(PageLRU(page), page); > > + if (!(node_reclaim_mode & RECLAIM_MIGRATE)) > + return false; > + > /* It is pointless to do demotion in memcg reclaim */ > if (cgroup_reclaim(sc)) > return false; > @@ -1083,8 +1086,7 @@ static bool migrate_demote_page_ok(struc > if (PageTransHuge(page) && !thp_migration_supported()) > return false; > > - // FIXME: actually enable this later in the series > - return false; > + return true; > } > > /* Check if a page is dirty or under writeback */ > _ >