From patchwork Wed Mar 20 06:10:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ho-Ren (Jack) Chuang" X-Patchwork-Id: 13597336 Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CC9F182D2 for ; Wed, 20 Mar 2024 06:10:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710915049; cv=none; b=qK0uGgW5eE7zkZvPITxY5eVZJ3diUCEwIM7kRxEwE8yRN5eb2jymMCs9w7OMRzw8k8moloQpri9k6ie9SatGcZnYawzz5QQuxa/0xUzj1qcXGczAJDKsIWonLUDD5Yfwk97nryzBNvq9675l2c4FXvoHKzm+ysTa4+KXY/eoYqo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710915049; c=relaxed/simple; bh=VUlBmGcp8svVRc+YgVvPOifmDRnW+ZmwDpx4QVsS7Fo=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ixnmOEBbm1lbDrhYJ16Wz/JfLlEP3SRiaWrV9wJocypgLw/gAmPV7Uf2EIIjDi0Nb2c0D7X7Fjyfg1BZWf/Am7hAhzgYDugCQuVOTemrz+7aFlQthMpzBv7xgvs1MRG1Jd4zdyMS4J2FUao9Te4Cg4Fatq6oPlaGRuYfCc54quY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=S5gwNjv7; arc=none smtp.client-ip=209.85.222.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="S5gwNjv7" Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-78a26aaefc8so2589285a.1 for ; Tue, 19 Mar 2024 23:10:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1710915045; x=1711519845; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=xCZgkB2SZu0i/tSjRR46WOtj0M+sNHf+HRU976J1PX4=; b=S5gwNjv7rJIYJ3VDBg8xMHkiad+9TbnYc5zUrCVGF2afOYKUuIMjRE8vzYClS4ysW5 +b2QkaiTRJ6KG18uQWLd+JF/3W2QPfuxMHdJTYNB2oaTw3W3AUBCsEWFnqO/Q9VC6DZR c8iSWGRKI54FH292DuskKmh/VfEtLJcOMUwhIMi/Yw1LQp3n/DVvisPEoXvDQEHq7PDd xyWOJ3QHa6NYD4cIBWu3Dqg832XyD5RQC9ftUAjV6cZwHRbzvX7rvag+RB0yZYR+kKHg IfzBRfhZR4m0olbg1N3Jr98DErl2l25xNE0VrLAUwD7jQdlYgEKIsKumvc+lgwDXT9+j OXIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710915045; x=1711519845; 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=xCZgkB2SZu0i/tSjRR46WOtj0M+sNHf+HRU976J1PX4=; b=t6yxkE3/WWGJer9I8hWShayNSBkmaAVmKaSJEQ2vqLCYbZnKUAAefY8wNbeNhmu7un g9/+KMfweItoVVbNtCgOVeKb+BcF6GStRvFG4f9aJBsI/UxYkx3CUamFilOgCCS4iYQ5 Lm4HkIXRBytlu4BOUFM6Lq8PapP58Y+ep5dqjIVtoK6XdpIfqGbSFkEoBYqAnBsRmtCR vAEJSO8+VoYTzuArGG8RumkK4nUpOWhFbtmvAOcJ6imrhoQM/Aw4Xl3zQ1vRM7+d97TG XUPurPsU49sQ5HyzVS9iYyVZkvE+FQfOTJzw/upqOfwR5FqN+KFdUav+U9vAZd6IeScj OaaA== X-Forwarded-Encrypted: i=1; AJvYcCV39BK+SYSSZxPr9hT0vkOwhAILdMBNqItIT8qN+VD3NXiR4ph6sxTGUZb8wk2EmuDr8mrHoJrHA87kl0BLS5YGmR2MsnuVb03f X-Gm-Message-State: AOJu0YxgMKc8daz16qxSaja4NAqhXeyc9BC+vT/IDLVjv9tNOgri+xCo zat2DlUjmwvpWBxyHwc4m93+zr0pN62BxcRD+Qm2dBYLYRD0x52t0mlM5Hc53Mo= X-Google-Smtp-Source: AGHT+IFa111kisVq1eXAsilnKhEWjB1FxneYVefed7MzhMngJVWVGZbwSa2ElD7e4aapqGZS/vkJjQ== X-Received: by 2002:a05:620a:5d8b:b0:78a:1c41:ac4e with SMTP id xx11-20020a05620a5d8b00b0078a1c41ac4emr2285040qkn.5.1710915045498; Tue, 19 Mar 2024 23:10:45 -0700 (PDT) Received: from n231-228-171.byted.org ([130.44.215.123]) by smtp.gmail.com with ESMTPSA id r15-20020a05620a03cf00b0078a042376absm2295914qkm.22.2024.03.19.23.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 23:10:45 -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 v3 0/2] Improved Memory Tier Creation for CPUless NUMA Nodes Date: Wed, 20 Mar 2024 06:10:38 +0000 Message-Id: <20240320061041.3246828-1-horenchuang@bytedance.com> X-Mailer: git-send-email 2.20.1 Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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. -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 -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: create CPUless memory tiers after obtaining HMAT info memory tier: dax/kmem: abstract memory types put drivers/dax/kmem.c | 20 +------ include/linux/memory-tiers.h | 13 +++++ mm/memory-tiers.c | 106 ++++++++++++++++++++++++++++++++--- 3 files changed, 114 insertions(+), 25 deletions(-)