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 B5AB2C433EF for ; Fri, 13 May 2022 03:25:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2CCB66B0073; Thu, 12 May 2022 23:25:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 27B456B0075; Thu, 12 May 2022 23:25:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 11C2E6B0078; Thu, 12 May 2022 23:25:50 -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 025526B0073 for ; Thu, 12 May 2022 23:25:49 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B5AFB21275 for ; Fri, 13 May 2022 03:25:49 +0000 (UTC) X-FDA: 79459280418.29.5C852B7 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf14.hostedemail.com (Postfix) with ESMTP id A1AC31000B0 for ; Fri, 13 May 2022 03:25:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652412346; x=1683948346; h=message-id:subject:from:to:date:in-reply-to:references: mime-version:content-transfer-encoding; bh=6JbJ7g7D2Yn2WY7qd9fnqK8G+aJNQ1BIcCplhlKlw6I=; b=KL3/wPAcEHKzR2YSR2JNz5iGqOJ7NTzD11tJN+uQHozkL4M9OXo0E9qO pBuaz8slcR43lOK3fIP4rcprxnzsEqbqI3xJW8BXWCzox3mYoNP7Uzmf1 K6V5U+0QhtfCV+BRj2jL2sFdMcc/YTMSLuiqNcJVlSRriWLts+Ewgt4oa QUKzGXmDS2ogvqVESciSQCFz1Kyn16wxDflG+hVskzyBRKh88tI5S6QAE zlgZRAUQ/zlkQHY3c9JKNTk9rUcBJS/Xdliyg/vf+0LnwFMcaWnSfpRU4 mxIIoJiuQRWXzp8u6aLzl2+NYPBHJ1HNNu04QqU82AtrMGqaGglcAftYH w==; X-IronPort-AV: E=McAfee;i="6400,9594,10345"; a="333236775" X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="333236775" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.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-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: A1AC31000B0 X-Stat-Signature: mmt16r6rpacsj1r8qq53td93wp6szaj4 X-Rspam-User: Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="KL3/wPAc"; spf=none (imf14.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.100) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-HE-Tag: 1652412344-564793 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 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