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 63026CD1288 for ; Fri, 29 Mar 2024 00:48:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D365E6B0087; Thu, 28 Mar 2024 20:48:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CE6096B0089; Thu, 28 Mar 2024 20:48:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BAD2D6B008A; Thu, 28 Mar 2024 20:48:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 9DF106B0087 for ; Thu, 28 Mar 2024 20:48:21 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2B7C61205D6 for ; Fri, 29 Mar 2024 00:48:21 +0000 (UTC) X-FDA: 81948240402.12.10D904D Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) by imf04.hostedemail.com (Postfix) with ESMTP id 407DD4000E for ; Fri, 29 Mar 2024 00:48:19 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=OH1Z9cTR; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf04.hostedemail.com: domain of horenchuang@bytedance.com designates 209.85.167.175 as permitted sender) smtp.mailfrom=horenchuang@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711673299; a=rsa-sha256; cv=none; b=eMp/NpS12t+G38yDGejSbK/Xcr9zX5vJadsqRq5Qlmy3B/QNP52onU85Y9hthBjKEbe+fm 2mhC3S1sRRlCDwf/4ocrgthL4faSpxgsS2v4EEMCRVNllmCB1+/f313jksqqcX61xfqhhl 0pQKWEhpxlspwtp7TyvVsz38dwMUzpI= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=OH1Z9cTR; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf04.hostedemail.com: domain of horenchuang@bytedance.com designates 209.85.167.175 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=1711673299; 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=r556gW/Cfi0wJ9ucfJUvxgAelZ5AC4EcYQSPPpoFGLs=; b=m3mY0srQRVreeZeK/kfSyg12l75ti4ei32/tbakCRbLTbKUB+JsiAvrzLNZKLLBmW2kBJg Lsks8/UrQ3i91IoSPoJ63pn8tLepQZzMrgg86K+ki02UXupuNYpm22bEop/XQKRq4e150x 1l2svFW1XBCzza308KGMsHYYKddWX5Y= Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-3c3aa9ca414so1039381b6e.2 for ; Thu, 28 Mar 2024 17:48:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1711673298; x=1712278098; 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=r556gW/Cfi0wJ9ucfJUvxgAelZ5AC4EcYQSPPpoFGLs=; b=OH1Z9cTRLvBxKN3WuwoWK6NskqEwngJ4qvtbfu8BuaoqU7ogvpNYXhWeehhBcby1Gk C1h6YrJKbjGvs0rXQxLAiWA/I8fTX1sGDORfyi4JivW+npFFXuGFcI1+V4LsV4o/TTQK qlBGqdpsss8xO1fG46PXcAY6world1vN/syPEBLw99FMmdOiaq0/rTW0ZhrJ9fs3L6q/ wijKQvoBYKlWSyFpKidG5vlzxi/j/bRmzjTDZQw9na2S60j0YMvShtgyDuMANouvSeSg F2YrYb91f7GWfywI/v8uR9+Obc/Z43Mfwrl1bmreXeTO52bMggHMQHzF9J/fsm78JgKH bnlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711673298; x=1712278098; 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=r556gW/Cfi0wJ9ucfJUvxgAelZ5AC4EcYQSPPpoFGLs=; b=Qla47CqVB+53/RehDsw1q4zKD0VfXEXpl3komNHb621OV2Kxug6LNl5P0+7MOfQ6tm M9o/o7lnw4p75ci3yCpbu66tjsQJWdXN2Dv/vUHmWHMyzPhOR53fbUeUH9hLOx8kTWot jeJSu1J7EU7du27I02Elm7akECrb/1f4d50qqxdFTx87a1KosFrrRTeCPmz7ar/zLANZ zJN9ZFczFyl7CPxCE20ayKYYZ8Uh/4v76/TpFir3H7M9cc2zMFF8wuFQhW4PgWNUHE5a ip3YdvWEC6q7uT7/eQ/Qy918RXIjTZFCvzzxKk40UpBZFmNacyTuFRRHEbteH3q1vVLR UY3w== X-Forwarded-Encrypted: i=1; AJvYcCXu534TvTbTtpd5FU29qMTAReV8x8NID7/CbGbsuxACkPZvz3BwMaKTNZUEQ/f+BEEuWBxjCvgMqeZI8yB8hTlW3Hk= X-Gm-Message-State: AOJu0Yzaxkmo8Vnx+xHtqWXnSuTt4Qfed6y8vORWCG064ylQvEtJHttb 29X0jjtFOEiVMljgUd0maV+aJWwMx2XmfljMVVj1VCZWvOfnvo6MGfidskmUMyM= X-Google-Smtp-Source: AGHT+IEX7ShIC6O0vfmTE0ZHpiq/z8ldFe9ie+KXByR1IhyG1uQYPhwvYFTlSXbY2oXF2FX4Szjvow== X-Received: by 2002:a05:6808:3093:b0:3c3:ca2f:33ce with SMTP id bl19-20020a056808309300b003c3ca2f33cemr997529oib.52.1711673298139; Thu, 28 Mar 2024 17:48:18 -0700 (PDT) Received: from n231-228-171.byted.org ([130.44.212.125]) by smtp.gmail.com with ESMTPSA id v26-20020ac8749a000000b00430afbb6b50sm1102414qtq.51.2024.03.28.17.48.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 17:48:17 -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 v8 0/2] Improved Memory Tier Creation for CPUless NUMA Nodes Date: Fri, 29 Mar 2024 00:48:12 +0000 Message-Id: <20240329004815.195476-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: rspam06 X-Rspamd-Queue-Id: 407DD4000E X-Stat-Signature: m3t1bp5tn9a3bxmsz9djq45g3uwo5u1y X-HE-Tag: 1711673299-603819 X-HE-Meta: U2FsdGVkX19bsooPc0iF8zWSgCgybBdKTA8Z6pEu2Dg5r60M2RVabs0jKQcL/+Pt6hURhJUAdnfVnBQ379NwJXw+q0ajkeYpzlpvHSZAuZHQfMNMpG3q8cBBX8BPDughEYzz1jQJ5D/y4uaxtRxXvjBO87Y0FsDzheJNX0lD9C2nLHLbLsxZJqtQrtD6Q7jqaTndyezGt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KN1BvCQNcse8oiYhGceSrYN8VyJUOYsBZ5vMPRNM0KjzkPz3O+EDc4GPqUzeDRvulLUGfDh44czbD6jnNp2X3t56nSVYt/30QFPuaFrKGL+ch7XCrCvZVeNOrJA0XJK75z094rildqkpnhDTP6M03atbZZ7zVaiN9TD1KmJgGTqoentEh/HgBm9NtjRWfcBtDX/ThhvhzWIezhWfLvEJpvmN9JZNeYG4EYAl/TCU3NMjseeMhBzFLPGQIF7ick85BkovYbzykdPYpb4Ywjh8PuqR2i+CMG6stUSGG+lphk9O+h+VHJmfUXW3Z3MISbY03SsE9WyANh1MS1xlOTA= 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. -v8: * Fix email format -v7: * Add Reviewed-by: Huang, Ying -v6: Thanks to Ying's comments, * Move `default_dram_perf_lock` to the function's beginning for clarity * Fix double unlocking at v5 * https://lore.kernel.org/lkml/20240327072729.3381685-1-horenchuang@bytedance.com/T/#u -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` * https://lore.kernel.org/lkml/20240327041646.3258110-1-horenchuang@bytedance.com/T/#u -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 | 126 ++++++++++++++++++++++++++++++----- 3 files changed, 125 insertions(+), 34 deletions(-) -- Ho-Ren (Jack) Chuang