From patchwork Fri Jun 28 06:09:22 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: 13715497 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 595E3C2BBCA for ; Fri, 28 Jun 2024 06:09:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DAD2B6B0096; Fri, 28 Jun 2024 02:09:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D34536B0098; Fri, 28 Jun 2024 02:09:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B87E76B0099; Fri, 28 Jun 2024 02:09:45 -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 93C876B0096 for ; Fri, 28 Jun 2024 02:09:45 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 27805A4706 for ; Fri, 28 Jun 2024 06:09:45 +0000 (UTC) X-FDA: 82279271130.09.3222AB9 Received: from out-186.mta1.migadu.com (out-186.mta1.migadu.com [95.215.58.186]) by imf28.hostedemail.com (Postfix) with ESMTP id 8AC62C0005 for ; Fri, 28 Jun 2024 06:09:40 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=olAC4XjD; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf28.hostedemail.com: domain of horen.chuang@linux.dev designates 95.215.58.186 as permitted sender) smtp.mailfrom=horen.chuang@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719554966; a=rsa-sha256; cv=none; b=xfY46VyDO2Azxqc9TiX/IB2UvyKy0d+7y0pLRPsP9Bc6INJGneYYkHRpkOUbHmM7QDHtAg YxXO05fjAZuDfO3Rn8GukZN37n/YsTxo204BuC+Gy5Tfxjgd1emPLNOVlL0NeQZwJxR9qY tQqan4gHLMx9CuNKduyhGxjI7gj//3c= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=olAC4XjD; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf28.hostedemail.com: domain of horen.chuang@linux.dev designates 95.215.58.186 as permitted sender) smtp.mailfrom=horen.chuang@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719554966; 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=6gy0NOjp3fgzujNjn03YIvDzl9Fqj+1fNboTj9KDJII=; b=wDM3YL6qc+xGceodh52iD10j5FAw0Dw3dIobMzEKP2nFKAOKnYh0IdDnoPAZVEgM7BPEEm 3PCCAGLrR5+MUjPkDSOZlPKIcomAR8MgU/VRRE9WQWVeJuBQiI6SbmKubRhr7NZCIWL5dy /HQMPVFeWBzzMxNKyinv8GefAgOwbzI= X-Envelope-To: jonathan.cameron@huawei.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1719554978; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=6gy0NOjp3fgzujNjn03YIvDzl9Fqj+1fNboTj9KDJII=; b=olAC4XjDPP/fIYuqIYhACcF5/4Q/28Tl5xNDSEpQwyykCTBPOuIffDA6Vg7OoyDUv/ACQE t2gRmiHkZ3W6SiC5zFK41pzhkDaP67L2UU8+WDsLIugF6N50jPTwOkvMeketPUCelsYeYv +ej74ibV2rxmx1qy02CHp5rhyLw7Ap4= X-Envelope-To: ying.huang@intel.com X-Envelope-To: gourry.memverge@gmail.com X-Envelope-To: aneesh.kumar@linux.ibm.com X-Envelope-To: mhocko@suse.com X-Envelope-To: tj@kernel.org X-Envelope-To: john@jagalactic.com X-Envelope-To: emirakhur@micron.com X-Envelope-To: vtavarespetr@micron.com X-Envelope-To: ravis.opensrc@micron.com X-Envelope-To: apopple@nvidia.com X-Envelope-To: sthanneeru@micron.com X-Envelope-To: sj@kernel.org X-Envelope-To: rafael@kernel.org X-Envelope-To: lenb@kernel.org X-Envelope-To: akpm@linux-foundation.org X-Envelope-To: dave.jiang@intel.com X-Envelope-To: dan.j.williams@intel.com X-Envelope-To: jonathan.cameron@huawei.com X-Envelope-To: horen.chuang@linux.dev X-Envelope-To: linux-acpi@vger.kernel.org X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: linux-mm@kvack.org X-Envelope-To: horenc@vt.edu X-Envelope-To: horenchuang@bytedance.com X-Envelope-To: horenchuang@gmail.com X-Envelope-To: linux-cxl@vger.kernel.org X-Envelope-To: qemu-devel@nongnu.org X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: "Ho-Ren (Jack) Chuang" To: "Jonathan Cameron" , "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" , "SeongJae Park" , "Rafael J. Wysocki" , Len Brown , Andrew Morton , Dave Jiang , Dan Williams , Jonathan Cameron , "Ho-Ren (Jack) Chuang" , linux-acpi@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" , linux-cxl@vger.kernel.org, qemu-devel@nongnu.org Subject: [PATCH v2 0/1] memory tier: consolidate the initialization of memory tiers Date: Fri, 28 Jun 2024 06:09:22 +0000 Message-Id: <20240628060925.303309-1-horen.chuang@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 8AC62C0005 X-Stat-Signature: mkdx6cncpga68wye5grd5kfk78sn5iwd X-Rspam-User: X-HE-Tag: 1719554980-974618 X-HE-Meta: U2FsdGVkX19ka2rH9GD30xKImUzmExqliVLG0/g5zhnh9epmXJ6fqORjJic744EQBuSwtKkO70ZhLqFqtn93zsjsDOf7khlTv1s+XC1cHOPtlx8vF1ZPZbxsjPoTPYP0SMRhbV9Nd5l+zhkTLKKRGGor1Fmd118QQzmkGmF7fCeo3MB2RVaiT2ofLI+Tm1j3V6GqkgXtu8NkjkVq5gk23ftxy8Zt5TdEbPDLTxKEt5IajRBLvAUyhNB28t/2Ioz7FscVIE6fr8JudV9DZRK1rNpCVHIuH/IyYCV2MFZxp6phHsDFR8hh+0FiHK1eosUdUI7Dh7K7GV2GEBgQZfLz4BU0BIcCZIuXq+KupvU7OgE6c7jEHMSSQ2boxVU2EvJVK3vXoFHrIKI3QGZ1jDJasmdYmIZcEeRL60LHZnD3sHf78ibvphHhmpXr97TUUvskdrIMnDtwB4Wlr/6ecfS0mDjvvvnLDLKe+zlbbvyDhjQdO/X1VhZ38Fe+1VnkaDOeyvz1uTClstPQWXSVA9Ctcm4y54VzYYFjA3I4Ca5U4hbmwXcTuYu3j0HASzXnRdNZQFcp2+Y0P1Pn1cXx2RaemGawaseVCmGOVWZ2TZz1vRedSxCcpoH9t8SZwhjSkHQ1k1yhl+CuUIHAaViH8V50V/5wrl9VVmNpqC7iddyJEIJ2Enbljbu0rZkVXRPxi/6XTwdl7Htz17UZMyvZTNm+afBwanovcSO6EPj6FzyhLPUWkP3u4jA+0hVK3nvHZ3vbXiU5Y98c8dA0OJRGDiIZNQnAqJj/l3nQb1tyK2nOhUXHgTzFnfQvbhAeu6opb3U/pnXedlPuaEnjHd6xPfS3L+RlNQCwTjsohSCC+b30xRjLT+3mFORo4WWZz+tMba8nl5GetaRsp0BXMLXgIdXD1eV4go5OKg4AvvYxXfLjlueq7xicdf56qo0HDuvoIlqsBv+Quki/HHjvJHZefq5 7FX4CwS0 MOu33vsvURKgS30q3UCmlaJp5N/24bjGOwi52vNTxpSQ+6W8pcpPvE+Vx8fUiRuyjg3Nd1FIcBiBZ4xx2GdEwxvLpeY55QWIWjxMOnfNSaWmLkSMIqWEksFQVRGMCmUCknmFKGdUPsWRD6jIY/lck9ZGxYju4QehKU3w7Zp6NOwZqV3psIPcQLNDvPdgXJX94YqjjLELGseOgNr0HaCTmYD7o7USYh2NbBb6dBiHh+pesjBr3llDyU6SBFE9HGORgvSS5P9QuRFmrxVMjUzVFpS0HiL0MGcseZ2PtMHX/1yQk0cS19IM4260PklCPwODIJPmkhkGLVh1CwpI= 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: The current memory tier initialization process is distributed across two different functions, memory_tier_init() and memory_tier_late_init(). This design is hard to maintain. Thus, this patch is proposed to reduce the possible code paths by consolidating different initialization patches into one. The earlier discussion with Jonathan and Ying is listed here: https://lore.kernel.org/lkml/20240405150244.00004b49@Huawei.com/ If we want to put these two initializations together, they must be placed together in the later function. Because only at that time, the HMAT information will be ready, adist between nodes can be calculated, and memory tiering can be established based on the adist. So we position the initialization at memory_tier_init() to the memory_tier_late_init() call. Moreover, it's natural to keep memory_tier initialization in drivers at device_initcall() level. - v2: Thanks to Huang, Ying's and Andrew's comments * Add cover letter * Add Suggested-by: Jonathan Cameron * Add get/put_online_mems() protection in memory_tier_late_init() * If memtype is set, skip initializing its node * Remove redundant code/comments or rewrite code in a cleaner manner - v1: * https://lore.kernel.org/all/20240621044833.3953055-1-horen.chuang@linux.dev/ This patchset is based on commits cf93be18fa1b and a72a30af550c: [0/2] https://lkml.kernel.org/r/20240405000707.2670063-1-horenchuang@bytedance.com [1/2] https://lkml.kernel.org/r/20240405000707.2670063-2-horenchuang@bytedance.com [1/2] https://lkml.kernel.org/r/20240405000707.2670063-3-horenchuang@bytedance.com Ho-Ren (Jack) Chuang (1): memory tier: consolidate the initialization of memory tiers drivers/acpi/numa/hmat.c | 5 +-- include/linux/memory-tiers.h | 2 ++ mm/memory-tiers.c | 59 +++++++++++++++--------------------- 3 files changed, 28 insertions(+), 38 deletions(-)