Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp697782iob; Fri, 13 May 2022 10:25:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJys/u7a3k3TcJQDizuAQgDJg+gwZwxxP0CNkBWw+x3t+K5MDJptsMrsDNTEcZTAI77lIObA X-Received: by 2002:a17:907:3da4:b0:6f4:ff2b:8299 with SMTP id he36-20020a1709073da400b006f4ff2b8299mr5443267ejc.109.1652462706515; Fri, 13 May 2022 10:25:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652462706; cv=none; d=google.com; s=arc-20160816; b=vXKTjBVt3y/h/LN7lqBc1nhEkw29sxjgF0u7uo4JV8h791uTH0lwRH/fbWY85U0qNJ 3GneFBDshelF6s9n51Fr5bZu9u1+wyNtmDpYEezxnzPeHymHTNU59W2IMYJBSplHE+Dg pIQitTfy0wt7ljX5SEnf5our4c/4c4kE9NUvis5UDXAV26lgQPVvF5qgRwF1PiXjBbxM +qBw4rh2ASSRouNoWwxIe4IQCh6717cyuHNuOdaR63EahKgws89GSpKF4s+iU5YPEDEZ R3bsh1QV1SOorwz9HfG1FQswCFD0DLAn9/wsMgMKhME/MuX7FvvHBUHEr2BTeiUrOwic XM/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:to:from:subject:message-id :dkim-signature; bh=uN1dFoGqeQkfr1RTFYHImnQxm52BXh3UCzqHDEgXNHQ=; b=K+hfSAaQ7mwx/WGUquUHG1x8N4klod9kJv9jYi0DjKjPssH1aG6CO+RxPZcrCDuTxi 5kO0FezfqyNlOUJ4gWcZp73OLPUytN8pVOVx8XgwkeMJO5rDLa8KM/cQGK0Du01YoQoR D/AdOlFn9fuJZ1qD192y6PAYyHKWxIvaDcDIi0JGmMkccRXESkz6kg8lV8IRmO/QJv3O VINyT5upifys+OaXnqr6uod3v+lzzPjC1YRE2Sl+s6lxUVxmeA2hoLxhhz3HjrCvZOYC Q4+rGVi03wn9jZIUh9misnvAomE640nGt2wr62owBUGn9hfUtvHkyAsTksxfcQ1V+TPr J2lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JhID5sbc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dp4-20020a170906c14400b006f3f6f1b7besi2920172ejc.640.2022.05.13.10.24.39; Fri, 13 May 2022 10:25:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JhID5sbc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376734AbiEMDZp (ORCPT + 99 others); Thu, 12 May 2022 23:25:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376596AbiEMDZn (ORCPT ); Thu, 12 May 2022 23:25:43 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5E9C1009 for ; Thu, 12 May 2022 20:25:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652412341; x=1683948341; h=message-id:subject:from:to:date:in-reply-to:references: mime-version:content-transfer-encoding; bh=6JbJ7g7D2Yn2WY7qd9fnqK8G+aJNQ1BIcCplhlKlw6I=; b=JhID5sbcsn3Fla1qE+f555PVnMbIaXCaokLl56bliE4uY4G7LAvICCTX 3AdtpWgI6HxCdpBH0zWYSjcvQtcG7eh2TIOGEK5ophymfqCxG9M/sf1un uqOw3r4GKulb1qhgOtJWF4FXyW+4m2fjDYwvCGrHG3vTGg6cC71niLOVF Z79lzFc4Qyy3l/j5vbCV0Y4fm8J28dpixKVUpAD9vuyOGNlyV9keafoO7 kfOuSHI7gFhIfg9hDjFQPUoxBxdoz7Rvah2I33Ozp5UhseLSCafuoom9N bsGGYVZlf/jmElifeeF9PX5hXAGjNA1yulUmWytjQk2T0W80vh+E5psvE A==; X-IronPort-AV: E=McAfee;i="6400,9594,10345"; a="330802694" X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="330802694" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2022 20:25:41 -0700 X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="566997853" Received: from jliu69-mobl.ccr.corp.intel.com ([10.254.212.158]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2022 20:25:36 -0700 Message-ID: <69f2d063a15f8c4afb4688af7b7890f32af55391.camel@intel.com> Subject: Re: RFC: Memory Tiering Kernel Interfaces (v2) From: "ying.huang@intel.com" To: Wei Xu , Andrew Morton , Greg Thelen , "Aneesh Kumar K.V" , Yang Shi , Linux Kernel Mailing List , Jagdish Gediya , Michal Hocko , Tim C Chen , Dave Hansen , Alistair Popple , Baolin Wang , Feng Tang , Jonathan Cameron , Davidlohr Bueso , Dan Williams , David Rientjes , Linux MM , Brice Goglin , Hesham Almatary Date: Fri, 13 May 2022 11:25:34 +0800 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2022-05-11 at 23:22 -0700, Wei Xu wrote: > > Memory Allocation for Demotion > ============================== > > To allocate a new page as the demotion target for a page, the kernel > calls the allocation function (__alloc_pages_nodemask) with the > source page node as the preferred node and the union of all lower > tier nodes as the allowed nodemask. The actual target node selection > then follows the allocation fallback order that the kernel has > already defined. > > The pseudo code looks like: > >     targets = NODE_MASK_NONE; >     src_nid = page_to_nid(page); >     src_tier = node_tier_map[src_nid]; >     for (i = src_tier + 1; i < MAX_MEMORY_TIERS; i++) >             nodes_or(targets, targets, memory_tiers[i]); >     new_page = __alloc_pages_nodemask(gfp, order, src_nid, targets); > > The memopolicy of cpuset, vma and owner task of the source page can > be set to refine the demotion target nodemask, e.g. to prevent > demotion or select a particular allowed node as the demotion target. Consider a system with 3 tiers, if we want to demote some pages from tier 0, the desired behavior is, - Allocate pages from tier 1 - If there's no enough free pages in tier 1, wakeup kswapd of tier 1 so demote some pages from tier 1 to tier 2 - If there's still no enough free pages in tier 1, allocate pages from tier 2. In this way, tier 0 will have the hottest pages, while tier 1 will have the coldest pages. With your proposed method, the demoting from tier 0 behavior is, - Allocate pages from tier 1 - If there's no enough free pages in tier 1, allocate pages in tier 2 The kswapd of tier 1 will not be waken up until there's no enough free pages in tier 2. In quite long time, there's no much hot/cold differentiation between tier 1 and tier 2. This isn't hard to be fixed, just call __alloc_pages_nodemask() for each tier one by one considering page allocation fallback order. Best Regards, Huang, Ying