From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) (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 552413E3146 for ; Mon, 13 Apr 2026 19:41:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776109304; cv=none; b=e19gHM575xCj9PnQUjXr2w/bFQSvoy129zET/7hh+W/VC9rZfu7nIlFjtzOkovEwv0F1y/kwuyOwYygdNaXlion4z+HYbRGZtgobtTpj3gK3xKm1+M1gJmbY+xD5dmWPbybhVmYNX4qGjwgffxL+peUnVkfuEWEHqtnDBHNy0q4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776109304; c=relaxed/simple; bh=6hRiNGqvtOWKux9ylwRAer4046Lz3jBPnR8zW37UMoA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OyN0rvyaL42ByoupZqxUqL1ZswXnYYUVz+vyRpeVojYiOhn2rB6SFqOBLQe741WOFTwC/5aAysmVvHqk6KljasVokXM6/Sat8xv8oOpoNZPoJwInLX2i9weLMhshwT0vSaQMqwa4Sz7krKFJbj6Z24TLH1eXbkoimqlb7/QEPts= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b=FRo9LgiE; arc=none smtp.client-ip=209.85.222.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b="FRo9LgiE" Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-8d933da14f0so526795085a.2 for ; Mon, 13 Apr 2026 12:41:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1776109302; x=1776714102; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ANyztBlS8ASp9MHR198GNmIsfqkyGsWGhTyu9QD8TKg=; b=FRo9LgiES7NQwMR9ULvyVcTSS3IjJAqLCF3Kp3xZyVjvoNFVwZoiNn4FWXvLif03UM iFdFl4XBFQHMbtQRyHas5Q3MS9qTIb+uwMhl2+xm1WCgkYynQhkNuDjUbrAtA3y+Rcr5 YvWxZlyrbgP5Dj7aS9U6c931SPItYy5qxXgf4xlgy9x2UzKnfeqvnl713wD9jWmSrIj+ gRMHZ6LGMO9l2iVKL++u3FuG7o6ZvMVdADsPBbWBFqiVlj1XAbAPLgfcriccqgjF/bIi WBiWzRtPeZKR4OiB46Wk6bfqWTrA6J/boX5wa2xnmJxzYocLwIADIpkRo5Tj3PxiKUQN /+oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776109302; x=1776714102; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ANyztBlS8ASp9MHR198GNmIsfqkyGsWGhTyu9QD8TKg=; b=SHa6RYQiagp2oq3aVhXGi03UQ7JQ4qIa+Rny8G6DBmTrdyD7nSokxW5njKRToUQVfZ Yrx3gaksAYSSbx5n6bE31h35EHD3OhRJTYAuYiOshzpcQIdCDEztn2idE/ovCDPRu1ER BGGK3mC8YKMLIdHgA3740fecrU4wOFUv8ohhcF3s1uJn7aikqDw8GK5cVKTmR+iBiIBH K6uzJrarBd+6FyU6zHwS/kztmprTJ0A9OMcaCIDlUrlb4+rVpi0uh3kXji5as93P9KDj gH7RFpNXj8X3Y8U7jr+0e0HUUtmipECNZVvMEV9Symj5O68EzpL0LuVtMUwtNKJGfmaY vEJg== X-Forwarded-Encrypted: i=1; AFNElJ8FK4F2pMRPEwnk+OO/xUP/vQAa74oahI6Q7L22NGRxhYPmGpQC3AhBwNaeXN1FcY6S63aj9xqPib2Nc9E=@vger.kernel.org X-Gm-Message-State: AOJu0Yw3ovFFQtPvgO/H4/7jFTJCziicEbJdSFFY48FZcsYybwkQh2cA eKEnB5hI6TDJs3i35zkxy6ajMumtRWFM1F7lxZJLQn9reL2vzZzfs/7wyaPTiU1XFu8= X-Gm-Gg: AeBDiet8TospnFi3htMsnWv9BIzlD1/zcDofUNGjnbEfgx5l5MvjoqmwTzKRP5rml93 Amx+7HHQyNfy5kvSnuusCoBIb+yhAOqN7p7ejSSr8BCDT46CeWwIg+5zLvDs0Xbxib/bAhnz3KY /emnE0G7JLySspB4Z8pqEGL3NqjB7KPvfjRbSqHPMELLYp7/9siPR7Kib0nwvyFcuzKhKEkLxza wLLTBu+eI5X6b8ALvJxdDdEEKxdUfiDKJqxBlDacxv7z/+LC3ZLqAPd3wL3L7LFGPfgYJ33sDHo LALGbRVf/4Lgg2SUW4MtjpNq+etDAZKitgUVjWJcfoLU2jffMg7qOcMd36TzqDYK7fTdCgz6+di y5dTvnc1xIzfhuC6CRZ4sWGobntINtfbWaZshIDuDIFXTKnaX8hBqhxhYVE9LwHfVV3zu16Rt0g Llz3YZ1Q4Xg7eME0xx1M4qZFUqliWI4Eq6qQx0gMURc+dT1Q2ddc+EKhZH6Ul53iUFab7yLM4Lm XsGg2+uleZbf24+nNzdzbjobMY4nRj/cA== X-Received: by 2002:a05:620a:440c:b0:8cd:8320:3359 with SMTP id af79cd13be357-8ddcd024831mr2080049985a.9.1776109302203; Mon, 13 Apr 2026 12:41:42 -0700 (PDT) Received: from gourry-fedora-PF4VCD3F (pool-71-191-243-150.washdc.fios.verizon.net. [71.191.243.150]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8ddb5f88c82sm901067685a.2.2026.04.13.12.41.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 12:41:41 -0700 (PDT) Date: Mon, 13 Apr 2026 15:41:39 -0400 From: Gregory Price To: "David Hildenbrand (Arm)" Cc: linux-mm@kvack.org, vishal.l.verma@intel.com, dave.jiang@intel.com, akpm@linux-foundation.org, osalvador@suse.de, dan.j.williams@intel.com, ljs@kernel.org, Liam.Howlett@oracle.com, vbabka@kernel.org, rppt@kernel.org, surenb@google.com, mhocko@suse.com, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH 1/8] mm/memory-tiers: consolidate memory type dedup into mt_get_memory_type() Message-ID: References: <20260321150404.3288786-1-gourry@gourry.net> <20260321150404.3288786-2-gourry@gourry.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Apr 13, 2026 at 05:06:35PM +0200, David Hildenbrand (Arm) wrote: > On 3/21/26 16:03, Gregory Price wrote: > > Replace per-driver memory type list infrastructure with a single > > mt_get_memory_type(adist) that deduplicates against the global > > default_memory_types list under memory_tier_lock. > > > > The per-driver lists (mutex + list_head + find/put wrappers) provided > > dedup within a single driver, but not across drivers or with the core. > > Since the number of distinct adist values is bounded and types on > > default_memory_types are never freed anyway, the per-driver cleanup > > on module unload was not useful. > > > > Add MEMTIER_DEFAULT_LOWTIER_ADISTANCE to replace the default DAX > > adistance, since it was really used as a standin for all kmem hotplugged > > memory. This at least makes the default tier relationship clearer to > > other drivers and they can see where to put their memory in relation to > > the default lower tier. > > Very confusing code. > > What's the purpose of kref_get/kref_put if "the types on > default_memory_types are never freed anyway" ? > Mostly trying to retain existing functionality rather than delete it. I think the entire memory_type() infrastructure in memory-tiers.c is generally very confusing and of dubious value - but i don't know who out there still depends on it. > IOW, couldn't init_node_memory_type()/clear_node_memory_type() just > consume the "adist", and lookup the memory type itself? > > All you'd need is some way in the driver to verify that there is a > memory type for the given adist, as some kind of prepare step. > > Alternatively, let init_node_memory_type() return an error to get a > clean interface? :) > tl;dr: yes all of this is true and I will rework it. ~Gregory