Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp110294iof; Sun, 5 Jun 2022 22:41:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYaJ2RDale7Q785jN5csNfUYmIwikchbxHH/Urbw7rhUxUxD9afr1om3KPe7bE6FqfzqXe X-Received: by 2002:a62:ed0e:0:b0:4fa:11ed:2ad1 with SMTP id u14-20020a62ed0e000000b004fa11ed2ad1mr22826116pfh.34.1654494105621; Sun, 05 Jun 2022 22:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654494105; cv=none; d=google.com; s=arc-20160816; b=yGHhuyb4pTiPG8UyP4A7Om4KJ/haXqu3IaqSYjQAMbJi/KO6z7bl8Jh3q2neqNlsSS ZnC6nTHm2cWBkpvVAQF7AyMwXFbEoG8jPYEvaL7ElS7vJe52/7CsH02bF4MMMNIQ25hD TCtubj1XI1bnZAWV5aRy4xegbBuoHAqFwh6YNdgraGGSH9pYPNq7P0MpCIVJm6IJnTPk bwHT0YFABbZxtHCth01R9s1ThlZEr9ojJPmi+o+ga8luTIEJ8JajEzC46pKrFQ01bDz4 PTnnBvr04m/rTdTUrMGK61g/EyLTeWTpgYR0ZIGaQWZ4i08YUiGmVUf8JY+h0RS9PsPw qSTQ== 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:cc:to:from:subject :message-id:dkim-signature; bh=4wrOhRJOhP3XEDuN/8POglvBc8eTD9md6kz8sw0AHk8=; b=J8QGvVnk9wpffK4i5NI5FGhqpcKJ9tKJadwLoVvlxwWalHaq/4mPOTcTduWcJ1Epbm tKNVq0iXBrXe62q3c2P+SZSM9YiCWjTQ3+Vh6aJRtosCMf535AVLqPIzVcj/nMg3vZS0 C2cgTWEGgMCMyQgn+01HixODo5+yjhiw53CecBq+W8MCoGE7QyIB0RLd+BHgoWqADiC8 V+O37tmPRxKKmLwfmMeSHPSo0q/O7sObRM9LbO201KLqCTuLH0B/SAMr0ktPRKdWrjWn 26mvq1WZBCIpoPyHZyXhdVcu1avBj7QBTkoKwffv4i7HK8cnegdZPok6sxqN8Mvr4AP1 pLpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JytA87ZA; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d19-20020a170902aa9300b00163f3eaa7c7si18994202plr.1.2022.06.05.22.41.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 22:41:45 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JytA87ZA; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D3F8321D493; Sun, 5 Jun 2022 21:33:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352144AbiFFCtz (ORCPT + 99 others); Sun, 5 Jun 2022 22:49:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232695AbiFFCtx (ORCPT ); Sun, 5 Jun 2022 22:49:53 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D4D511452 for ; Sun, 5 Jun 2022 19:49:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654483792; x=1686019792; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=p29TgaZG9mtSmtjL1acqW5VnhwVAVC4lrQZFNN9yRKs=; b=JytA87ZAOYZL08CF3zwZXlXAikjOAlyQAk2lqP9yRXkiX0R3xKGhaWv6 3Z5lEHglHewncqP88zQOe5lmmAQL4XWiqHq/m8uTAkenJgqdk1XHxDxj5 qD0FTYAH/OnAm7aUCkPrOmxVR5mB34pJcdrjnplYnHbFXj0H1QrpPKHf3 VaHWmeH+JG4j+Av5mPQSwMPX5JwvfTSasEVNjJm4cHy4hN13frPMr3cp+ Fk+EjjoB7AbQkZsMvkue+vbOU/yuZ/2kEBAInVn4Hg0LANGicgpMIXs5z dmt5tClLqTzheI1OXcOAFx3ZQ+BMu/Czr3GQdWijw0ODa42gixEaUPlet g==; X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="276654410" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="276654410" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 19:49:52 -0700 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="635363523" Received: from xingguom-mobl.ccr.corp.intel.com ([10.254.213.116]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 19:49:47 -0700 Message-ID: Subject: Re: [RFC PATCH v4 1/7] mm/demotion: Add support for explicit memory tiers From: Ying Huang To: "Aneesh Kumar K.V" Cc: Greg Thelen , Yang Shi , Davidlohr Bueso , Tim C Chen , Brice Goglin , Michal Hocko , Linux Kernel Mailing List , Hesham Almatary , Dave Hansen , Jonathan Cameron , Alistair Popple , Dan Williams , Feng Tang , Jagdish Gediya , Baolin Wang , David Rientjes , linux-mm@kvack.org, akpm@linux-foundation.org Date: Mon, 06 Jun 2022 10:49:44 +0800 In-Reply-To: <352ae5f408b6d7d4d3d820d68e2f2c6b494e95e1.camel@intel.com> References: <20220527122528.129445-1-aneesh.kumar@linux.ibm.com> <20220527122528.129445-2-aneesh.kumar@linux.ibm.com> <352ae5f408b6d7d4d3d820d68e2f2c6b494e95e1.camel@intel.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Thu, 2022-06-02 at 14:07 +0800, Ying Huang wrote: > On Fri, 2022-05-27 at 17:55 +0530, Aneesh Kumar K.V wrote: > > From: Jagdish Gediya > > > > In the current kernel, memory tiers are defined implicitly via a > > demotion path relationship between NUMA nodes, which is created > > during the kernel initialization and updated when a NUMA node is > > hot-added or hot-removed. The current implementation puts all > > nodes with CPU into the top tier, and builds the tier hierarchy > > tier-by-tier by establishing the per-node demotion targets based > > on the distances between nodes. > > > > This current memory tier kernel interface needs to be improved for > > several important use cases, > > > > The current tier initialization code always initializes > > each memory-only NUMA node into a lower tier. But a memory-only > > NUMA node may have a high performance memory device (e.g. a DRAM > > device attached via CXL.mem or a DRAM-backed memory-only node on > > a virtual machine) and should be put into a higher tier. > > > > The current tier hierarchy always puts CPU nodes into the top > > tier. But on a system with HBM or GPU devices, the > > memory-only NUMA nodes mapping these devices should be in the > > top tier, and DRAM nodes with CPUs are better to be placed into the > > next lower tier. > > > > With current kernel higher tier node can only be demoted to selected nodes on the > > next lower tier as defined by the demotion path, not any other > > node from any lower tier. This strict, hard-coded demotion order > > does not work in all use cases (e.g. some use cases may want to > > allow cross-socket demotion to another node in the same demotion > > tier as a fallback when the preferred demotion node is out of > > space), This demotion order is also inconsistent with the page > > allocation fallback order when all the nodes in a higher tier are > > out of space: The page allocation can fall back to any node from > > any lower tier, whereas the demotion order doesn't allow that. > > > > The current kernel also don't provide any interfaces for the > > userspace to learn about the memory tier hierarchy in order to > > optimize its memory allocations. > > > > This patch series address the above by defining memory tiers explicitly. > > > > This patch adds below sysfs interface which is read-only and > > can be used to read nodes available in specific tier. > > > > /sys/devices/system/memtier/memtierN/nodelist > > > > Tier 0 is the highest tier, while tier MAX_MEMORY_TIERS - 1 is the > > lowest tier. The absolute value of a tier id number has no specific > > meaning. what matters is the relative order of the tier id numbers. > > > > All the tiered memory code is guarded by CONFIG_TIERED_MEMORY. > > Default number of memory tiers are MAX_MEMORY_TIERS(3). All the > > nodes are by default assigned to DEFAULT_MEMORY_TIER(1). > > > > Default memory tier can be read from, > > /sys/devices/system/memtier/default_tier > > > > Max memory tier can be read from, > > /sys/devices/system/memtier/max_tiers > > > > This patch implements the RFC spec sent by Wei Xu at [1]. > > > > [1] https://lore.kernel.org/linux-mm/CAAPL-u-DGLcKRVDnChN9ZhxPkfxQvz9Sb93kVoX_4J2oiJSkUw@mail.gmail.com/ > > > > Signed-off-by: Jagdish Gediya > > Signed-off-by: Aneesh Kumar K.V > > IMHO, we should change the kernel internal implementation firstly, then > implement the kerne/user space interface. That is, make memory tier > explicit inside kernel, then expose it to user space. Why ignore this comment for v5? If you don't agree, please respond me. Best Regards, Huang, Ying