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 CDE35CD1288 for ; Fri, 29 Mar 2024 00:40:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 40A966B0088; Thu, 28 Mar 2024 20:40:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3931A6B0089; Thu, 28 Mar 2024 20:40:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F1516B008A; Thu, 28 Mar 2024 20:40:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id F0A436B0088 for ; Thu, 28 Mar 2024 20:40:41 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 66B23C0FB0 for ; Fri, 29 Mar 2024 00:40:41 +0000 (UTC) X-FDA: 81948221082.11.25CED72 Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) by imf05.hostedemail.com (Postfix) with ESMTP id C9CCA100014 for ; Fri, 29 Mar 2024 00:40:38 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b="O+Juuif/"; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf05.hostedemail.com: domain of horenchuang@bytedance.com designates 209.85.219.51 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=1711672839; 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=ATOisTRRjQB4sgxy7npSq+e14hDk0Gnp420OOaz5yog=; b=BXuDlteRNpfRhwqyFB3sl58HsquvNLC7yiyhViAS3095w59w6tbpkLVaKhXnL0GgWs9P2U vqlQ1sqtOzH6q3/6GeegH0jXhBLa2LwiXE/Y8w+JeKSVKY2g04XwaW1vqR1ZjF+VSdXYve lBBJtDj4vWVQVHByRvdnQXYpEPipYcg= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b="O+Juuif/"; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf05.hostedemail.com: domain of horenchuang@bytedance.com designates 209.85.219.51 as permitted sender) smtp.mailfrom=horenchuang@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711672839; a=rsa-sha256; cv=none; b=UXcPqNhEzpMms9+tpjpHd9kmd5J3gBZj2D5mGH8k/9CVKMrDPRQqXXTnfSc3/fHz4zQAAi YsxNMzQXxOVn3js81SMVZJFtlt9qbw5KOuRAFiwuhqYFgjryUHURfVrr5JHVttutLmD0UZ Ww/5e33tuGXJwXjwNzfP8VztSzjNX94= Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-69682bdf1d5so9178966d6.2 for ; Thu, 28 Mar 2024 17:40:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1711672837; x=1712277637; 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=ATOisTRRjQB4sgxy7npSq+e14hDk0Gnp420OOaz5yog=; b=O+Juuif/uCDoBYK8GqB8eJdh4ODHT8EmeTZRjqdDprWsGyYfTgcpowsReMzYimooE7 IhNjGlRoE/GJUgXTs3/jfIykahHfcgK7BocZxy7wX/p1IzD5ryt9h8qYl1io/WkTDOO2 jbqEfeWp1FgIfbXwXe8rUIS/KZQMsJIUy6G7aS/JytHD60XiqlzNHshjLm1Cr43Rry27 3/9VCwLYZLX/HPK0U50Y+oOBkJKUGw62/yPfqJ0SmHkbM9x02yQjc2iJIeMcqrXBeyF3 IYS9z4gvaPNnLg7fDmrlggZmFCUzP0zBLsgCgCQp64/PhX0L0KSQdP5/noVbLdlTdMQj FvZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711672837; x=1712277637; 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=ATOisTRRjQB4sgxy7npSq+e14hDk0Gnp420OOaz5yog=; b=Ue54XuZQ2cdp7rRNbqCjH/QgNl+XuD36+mqhRsYuiVHgQ+dWOCOrRSTdtXbiaLXR+q fwT+DVq0QmqtiZU3PVXXuRQPOpyar/Ox7lIf4Aph/TUMG9FKisMR0jWVneDQTMCZk1yC aHuMwSqSxIojq0yH8WD7m7ZLWFKQpPnx+Lao89xEOkEzPQMWgwBZJflVzjgmm4Sx4sL0 DVMl2yVl08ypJ2LTyDoME2xH0gBtmct5SlKmeJJSdu0wnfEUH/r+r6sCSIn6cwmifsxy Y822aKp3F3pQRfsAPSfDCM9ueUx5fthELjiQ2YWsnTMlixrGYX83HnLQbTxMZx0zl5oO uw9g== X-Forwarded-Encrypted: i=1; AJvYcCXiZLsnGxOhxhJDcaLqntztgF7e6l3FfnxlPSfTJqPUQHgFye0PoHvxI1eTtl4pSFmPK5B0AZytXT5Q83Oq9amtRWI= X-Gm-Message-State: AOJu0Yyk9rSOYzpauuHXEagf9FeClCkJIfaZlDgdfHNS+H7U3WkBj5z9 3qCy2MtpCDwXP74GWgH2H0kV/+8GIL+HIQBxcm/DEtuqSHBznLrj2JHKCxxflaY= X-Google-Smtp-Source: AGHT+IFGFZDh45AZa0PZbpCZ5KKj6jHei4/t/LDFVey2btcJI7NSFvNMp99+UdXTyXt83plS1QEmoA== X-Received: by 2002:a05:6214:bd4:b0:696:4084:d6f6 with SMTP id ff20-20020a0562140bd400b006964084d6f6mr965534qvb.8.1711672837688; Thu, 28 Mar 2024 17:40:37 -0700 (PDT) Received: from n231-228-171.byted.org ([147.160.184.85]) by smtp.gmail.com with ESMTPSA id gc15-20020a056214230f00b00690fc99a836sm1113530qvb.105.2024.03.28.17.40.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 17:40:37 -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 v7 0/2] Improved Memory Tier Creation for CPUless NUMA Nodes Date: Fri, 29 Mar 2024 00:40:33 +0000 Message-Id: <20240329004035.191601-1-horenchuang@bytedance.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: C9CCA100014 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 77gt5jxdd38r7cafrpyd3ipmea8x3o4n X-HE-Tag: 1711672838-840058 X-HE-Meta: U2FsdGVkX1/Ged9adZh5SM0yUXI4iZOgYuSxXRfWBYZiKinTbD7M8B2ObO5QnX/V1bkETMCwQSr7wzfldsvb6+LpEaM0SECdOEdF57PJp5YYaiPe9PuedN8VBpPRcWJHUueJsXWJlfeKkYpsFDyg+8yJurzxJVE53WzrJ7uIvBrEK7HxtCD8YA4KY/uJe0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HFjCdbJ353+Ok/sRrOVu+p0SZNQj90O+4dVQkgd89z3WpJOD6w/Ktl9noke7EihgfZz7FsVSvlyYgJ3ZqV8nCzKLvupzMjmf2UPo7e7fXkHYafTS9jYOoPYn66L4pqiLndEzPMRnlfxzKWCZK6VEimQyTV40Xm4El7MDW7Tsw9nSRgePJa3yYSi44TW9gxkZv5DcLs6ZI0gDS6aBHBUj4Q5c0Sob0HJvEHCspmA/0uBs4Usx5h4VVBW3JBpBaFzj3TA9m3623IA8ojU1uL7GO42tyscvjzMt9gToYQ9waYB5ehDXy1J+6Ql2YLMA== 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. -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