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 EA8FAC47DD9 for ; Wed, 27 Mar 2024 04:16:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3170F6B007B; Wed, 27 Mar 2024 00:16:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A10A6B0082; Wed, 27 Mar 2024 00:16:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 11B096B0083; Wed, 27 Mar 2024 00:16:54 -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 F241F6B007B for ; Wed, 27 Mar 2024 00:16:53 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id BE340407F6 for ; Wed, 27 Mar 2024 04:16:53 +0000 (UTC) X-FDA: 81941508306.17.2D65854 Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) by imf05.hostedemail.com (Postfix) with ESMTP id 43517100014 for ; Wed, 27 Mar 2024 04:16:51 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b="d/fLrDUW"; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf05.hostedemail.com: domain of horenchuang@bytedance.com designates 209.85.160.173 as permitted sender) smtp.mailfrom=horenchuang@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711513012; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=wMdVp0KhU9BZV6tV0/g9FLJmEvDvjHVVK/qsvqbWJ7I=; b=KoxzWRH0h0ycsI8FDLYQWVCblA+2UTlvSUSZCbSiP53A8GuGKF7H0talT3vTMdnDSHkY1m ZrI9Pvt3LlmmHTWTxWSUQlPHYXK+X5ffG+X6Wh9lZvsG6ZmCOftO1VhYi8BeLauqasJ68z FiJW/WsdmFSbcFdzm80IkXEUD6oV/Zc= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b="d/fLrDUW"; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf05.hostedemail.com: domain of horenchuang@bytedance.com designates 209.85.160.173 as permitted sender) smtp.mailfrom=horenchuang@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711513012; a=rsa-sha256; cv=none; b=fJZuioEukFE2rK8Yc/YErh/H9Uav26894cIsrPn1Z3+qJYEFe1b90wexlrAKuDw7tDwG9h DQmgSmz2clLqbNbzeV9mPdtRn1Esy82ZoGytT6vye6+ZMHLQ5rGNw1vDfZspLmAJnjH651 bTDRM8ibzAkCZSmMyWcCgY4js5XwldU= Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-430c63d4da9so44654321cf.0 for ; Tue, 26 Mar 2024 21:16:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1711513010; x=1712117810; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=wMdVp0KhU9BZV6tV0/g9FLJmEvDvjHVVK/qsvqbWJ7I=; b=d/fLrDUW04SeUawkr54qApZYfN4xZEcsXW2aVaFO2UAp4lUeIYRiYyks+dYrzPf+nO 4AbcRjzHj2PQoZvYJZ2vH/ctao3b+cqvDGatkLj7BWwQFZatNs0vvxHSKh723X6gnQ9e OJAja71X0NmYfG4HTuSrgXMbmE56OxVo4/Uk2Rb+WyPr4d77Ys6NfNLC9bF0WkpAp4+Q 2RQLG9j2KJ4PKv9hpATHAsKwCkBkBHQ7cu10u8hQa/eRw7UmY0bVIrvqVoZ637oVpg9u sLhAMM6Dod2/A3yRaCnBooW4ZqYaugueDEp/F6yGf4CCe4IMZ31ETlCMEepGgMh1S1dq 63Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711513010; x=1712117810; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wMdVp0KhU9BZV6tV0/g9FLJmEvDvjHVVK/qsvqbWJ7I=; b=OrXQ3cnxR+HIVuoDQAHem5g+POVphscaa4g/8vAwnuTqZcGICSnPwB4Q/X0uHqEbVD RdTqhXQyJqbulN5UtY1m+ccQoiRW3hxPYDP1XBVLiP25WfegH4bAdl4EIr/4JboiUwQz QErf2oxFttAQSmuhis4OXbJOslYTlcBiq7scO3iNe1VCozAtTCfxY7a1rPw9w0uXmtqt QJYqcoxGm2rMalKFvCYcGtqRZbSAtXm7PLDhzgwG3RZkePnvu7Jw2yVdW77VfvAQ+Gfn l7WMsTd6PgVslzh0VyeoyuJPev3OzPGy0hJs9n1+RnxBBXtNGOdHYTkm0pVQEhYjhpF8 zi5w== X-Forwarded-Encrypted: i=1; AJvYcCXJm9j0boMo6jNth6YN4mu3j+7Lit1QIcJ/aqaIIzA52TZGKqgdAdPBf1yOfkuq7C7YFXpdjV5x62OcBWQxQlvYKJ8= X-Gm-Message-State: AOJu0YxN/ONdgvNFAdkccUtsDTUI0XFkE5lrn+d9hfVFyjLhKdqb+NOp MAcgBDjxPt4z2O15B0847LpXNQfNIHVIdWwz2Hwlc4AlfAtrdTRB0FLkxtPlJL4= X-Google-Smtp-Source: AGHT+IFPKIzBXhDWX0vwwecPPOx0TLesoDld5lggWtVvDT+Jl49ZpjG37mTEKqJH3a4f9GmGUE7nhA== X-Received: by 2002:a05:622a:407:b0:430:f228:5f87 with SMTP id n7-20020a05622a040700b00430f2285f87mr3797120qtx.31.1711513010098; Tue, 26 Mar 2024 21:16:50 -0700 (PDT) Received: from n231-228-171.byted.org ([147.160.184.93]) by smtp.gmail.com with ESMTPSA id hb11-20020a05622a2b4b00b0043123c8b6a6sm4370696qtb.4.2024.03.26.21.16.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 21:16:49 -0700 (PDT) From: "Ho-Ren (Jack) Chuang" To: "Huang, Ying" , "Gregory Price" , aneesh.kumar@linux.ibm.com, mhocko@suse.com, tj@kernel.org, john@jagalactic.com, "Eishan Mirakhur" , "Vinicius Tavares Petrucci" , "Ravis OpenSrc" , "Alistair Popple" , "Srinivasulu Thanneeru" , Dan Williams , Vishal Verma , Dave Jiang , Andrew Morton , nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: "Ho-Ren (Jack) Chuang" , "Ho-Ren (Jack) Chuang" , "Ho-Ren (Jack) Chuang" , qemu-devel@nongnu.org Subject: [PATCH v5 0/2] Improved Memory Tier Creation for CPUless NUMA Nodes Date: Wed, 27 Mar 2024 04:16:44 +0000 Message-Id: <20240327041646.3258110-1-horenchuang@bytedance.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 43517100014 X-Stat-Signature: bacz37j3hmdsjb9geg7ozme1ircyi6gb X-HE-Tag: 1711513011-532238 X-HE-Meta: U2FsdGVkX19ScBbdzIfo35pmFDnyb9pVod6HHuDg2bF6D+14b4xFrWDE3E0A6TF+X2BpwBN6gClm9w0q+FwLCCZKgfWEnAu0X1qz+1rhTMvMGf5c3pCZnYECCCuiUMi6hMIKJZALAC1Ru0jma6wi5MuYwmkA0SfJaJVqxWNX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cqzgKn2sozFutaZLeh6iLi8W6WmZHnXRwcjWFCbW1OA60uogyjR568jDeXQ4cR3si3XRQyFQfr12rq1yzhr+LhhV4+c5xCpQ8FubFC6IDaKaKNjFm9UhvbOBd1+BOuAM0I4eepkgqorbwxFTPX1XvGlJtLtTBPDeSkHnS8V4WCnNjVPkMoMUISDPE1J4noGYbyG2BBYa607t77klsc4/SfkGV/9JhKionYO8TEi8MbN8hlNnsboKWMfgMq5GShbwpJhA6eKNrssN8aKm9rWVn6tekxiC6ieYE17DC7QljzQcUFEVW7t+YlZ 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: List-Subscribe: List-Unsubscribe: When a memory device, such as CXL1.1 type3 memory, is emulated as normal memory (E820_TYPE_RAM), the memory device is indistinguishable from normal DRAM in terms of memory tiering with the current implementation. The current memory tiering assigns all detected normal memory nodes to the same DRAM tier. This results in normal memory devices with different attributions being unable to be assigned to the correct memory tier, leading to the inability to migrate pages between different types of memory. https://lore.kernel.org/linux-mm/PH0PR08MB7955E9F08CCB64F23963B5C3A860A@PH0PR08MB7955.namprd08.prod.outlook.com/T/ This patchset automatically resolves the issues. It delays the initialization of memory tiers for CPUless NUMA nodes until they obtain HMAT information and after all devices are initialized at boot time, eliminating the need for user intervention. If no HMAT is specified, it falls back to using `default_dram_type`. Example usecase: We have CXL memory on the host, and we create VMs with a new system memory device backed by host CXL memory. We inject CXL memory performance attributes through QEMU, and the guest now sees memory nodes with performance attributes in HMAT. With this change, we enable the guest kernel to construct the correct memory tiering for the memory nodes. -v5: Thanks to Ying's comments, * Add comments about what is protected by `default_dram_perf_lock` * Fix an uninitialized pointer mtype * Slightly shorten the time holding `default_dram_perf_lock` * Fix a deadlock bug in `mt_perf_to_adistance` -v4: Thanks to Ying's comments, * Remove redundant code * Reorganize patches accordingly * https://lore.kernel.org/lkml/20240322070356.315922-1-horenchuang@bytedance.com/T/#u -v3: Thanks to Ying's comments, * Make the newly added code independent of HMAT * Upgrade set_node_memory_tier to support more cases * Put all non-driver-initialized memory types into default_memory_types instead of using hmat_memory_types * find_alloc_memory_type -> mt_find_alloc_memory_type * https://lore.kernel.org/lkml/20240320061041.3246828-1-horenchuang@bytedance.com/T/#u -v2: Thanks to Ying's comments, * Rewrite cover letter & patch description * Rename functions, don't use _hmat * Abstract common functions into find_alloc_memory_type() * Use the expected way to use set_node_memory_tier instead of modifying it * https://lore.kernel.org/lkml/20240312061729.1997111-1-horenchuang@bytedance.com/T/#u -v1: * https://lore.kernel.org/lkml/20240301082248.3456086-1-horenchuang@bytedance.com/T/#u Ho-Ren (Jack) Chuang (2): memory tier: dax/kmem: introduce an abstract layer for finding, allocating, and putting memory types memory tier: create CPUless memory tiers after obtaining HMAT info drivers/dax/kmem.c | 20 +----- include/linux/memory-tiers.h | 13 ++++ mm/memory-tiers.c | 117 +++++++++++++++++++++++++++++++---- 3 files changed, 119 insertions(+), 31 deletions(-) -- Ho-Ren (Jack) Chuang