From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (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 E70BD377000 for ; Fri, 24 Apr 2026 13:21:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777036907; cv=none; b=dNG5ILIlR88krzGkbjQxiMEBKT/sgFO2sPZ7DP1VG6A22TGZxaDJLeXNDoRXauPMFhHFxFFAIhfqAyPW26b5i65IKLJ7v80ryDG2KriDkwcaSrKQI9Prcy+VPnmVY3hLWppcya9z4rK+0D+hguFZ4FHoLFoLzQjZ4+PQ3SB0CW4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777036907; c=relaxed/simple; bh=nj4nsijnX3b2kVa52lWxQ62x4QVPFtT0LCDre32ADPw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JgKndC3TyZxyBs0ucYwmaP6t68YuK74TLGqHom23J/RPQYnXKlMqtPvb4fJpBznrqiC3xbwKeEhwQaGMhEYDb30sxtEFsYlzLsPymDVO1Gww6q30kTIJ5wqH9obJYIR/VExMvftpTcFgrCLmp+HjBSsVRJJip4c2JMec45cs6uk= 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=j4ws1rRS; arc=none smtp.client-ip=209.85.222.176 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="j4ws1rRS" Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-8d65f4073bfso1079633885a.3 for ; Fri, 24 Apr 2026 06:21:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1777036905; x=1777641705; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=16wGkXPwfaEulioMF0Lhct1ImQNDyT+VaYWOkGB68v0=; b=j4ws1rRSr1IPTs5lMbw/38Kv6MW+K+47495GgMFhMJSLIiNrPZlH4gjeCjIZ3jxxPE WRZ/PIB9p0x/6BF2gPx9rs9v2F90c0YHLRSSCTqd3P9nDZZidPbNCup+DP/APJBpMBAg AMyBhOFIHxlQjE2M7f0sfOdlYOMp1aOzrM4VjlV9ZAN0Nm37Ah4yAVIuwu+TP3EDYIT0 wE+di+VMBzDqx5t8DjFjrBorI7tx9ybQAUso27wdbHSjp+G8P9pmLJNnPb0siAwXfYTp 0Dq4oTvFPmDST68WdzDEgfnDFlQRizFjmCNmZ+UQFj2Hl9Q3X1qADBW2Rpp0qv819oZD uGIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777036905; x=1777641705; h=in-reply-to:content-transfer-encoding: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=16wGkXPwfaEulioMF0Lhct1ImQNDyT+VaYWOkGB68v0=; b=rKIpYkWST17TOTaynjOMfHH/D8/Jldz6zkPJRm0LcfGeLl0jKyeCOFzaL5Mk78BPTC hl0tq0QJX+RoNkZFKuy6u8DE1ApofVtQreK1LU/mDz8s18ppWakzrnpx7n0+Xs/09gjj nAF/JW3cFXd3MYPErWXAtbfhIgi4unbMs7nrRFRi6mDTuKYxUgVyD3tHLCPWAj0qeMno x2094Qqd1xIYehgsgrAMZr/JvW7vd8s2vYlctKX7bnHC0hgp5a4dYJjqL5qsKDpPTNuy /FxlssWho7cVU1uMflFV6nJsortk54NwXQhUDRU7Ql+QB4HKi3EejkytMmJYiF39LcC2 OFSg== X-Forwarded-Encrypted: i=1; AFNElJ9SB3YOCSWY+9xuJsP84NNcrnPLHl9BcO9NC+wL7FgJGxkivXkprvstJKKkcsLcUik+CMOfo40NC1ul9AU=@vger.kernel.org X-Gm-Message-State: AOJu0YxfQWtDlyZ5XqfK7JGvkn08eyU2cj3iHnFIdEIzY8VktN4yifWs 2TgmKmClGCUaogoRW78ec8K2B20ad6FvdnueAoDXm/+9oCK7Qwv43sN23e9G5zfULJo= X-Gm-Gg: AeBDievaAsFxqWgu1YTatckGPTj9cIG9uisGJJKCSyFTnWJ3yliam0GQslSk+IBsHgL A2xBuhkRJINnvF2m6EwNWj7awNgJNOXPx7vE00gJTY43tl1cXc8BRlKbNSXRFUYXB4z/1L7cTD7 eHuWend7/tUrTDbcLvhD/bi43ECTRa8HDmIaHU2Yyuk2QyOCHhzbYMLePyj/CsS3wxmoVXHAago m9B7hnn2Bir8fflU9V7vZB8fOEtafMptHu4Fs5dRAGh6isn9trnfU4zALNXPCSmBZJQ38AB1WST O+CWGjg6bCZLBHyxE/ZiScRMFW4WraXumHaskXBCX94Aq9coT5PQbhNzPFEVokRs9iGnKbAejZy +UgtWUFEvFgR/mwqtd9qBcMOtbNV2cOdXo7KoGl9ZEFx4c6l2tRRhsoOGRYVNmDg0dXl4nbmx2r GUwVWSjaVvlkD1le6PFRbTExVCDXG0vQZGJTNqKCD1JKi/T3zOolida0Nwc7uOg/EYb5WnKod3O GRuqgZRworAsFypAw== X-Received: by 2002:a05:620a:e98:b0:8eb:49b5:bdb1 with SMTP id af79cd13be357-8eb49b5bfb0mr2404787385a.18.1777036904421; Fri, 24 Apr 2026 06:21:44 -0700 (PDT) Received: from gourry-fedora-PF4VCD3F (pool-173-79-70-94.washdc.fios.verizon.net. [173.79.70.94]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8e7d8edc2b9sm1999356785a.23.2026.04.24.06.21.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 06:21:43 -0700 (PDT) Date: Fri, 24 Apr 2026 09:21:41 -0400 From: Gregory Price To: Donet Tom Cc: Bharata B Rao , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jonathan.Cameron@huawei.com, dave.hansen@intel.com, mgorman@techsingularity.net, mingo@redhat.com, peterz@infradead.org, raghavendra.kt@amd.com, riel@surriel.com, rientjes@google.com, sj@kernel.org, weixugc@google.com, willy@infradead.org, ying.huang@linux.alibaba.com, ziy@nvidia.com, dave@stgolabs.net, nifan.cxl@gmail.com, xuezhengchu@huawei.com, yiannis@zptcorp.com, akpm@linux-foundation.org, david@redhat.com, byungchul@sk.com, kinseyho@google.com, joshua.hahnjy@gmail.com, yuanchu@google.com, balbirs@nvidia.com, alok.rathore@samsung.com, shivankg@amd.com Subject: Re: [RFC PATCH v6 3/5] mm: Hot page tracking and promotion - pghot Message-ID: References: <20260323095104.238982-1-bharata@amd.com> <20260323095104.238982-4-bharata@amd.com> <250e68f3-3664-4148-bfbf-52fd4230a3b9@linux.ibm.com> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <250e68f3-3664-4148-bfbf-52fd4230a3b9@linux.ibm.com> On Fri, Apr 24, 2026 at 06:27:02PM +0530, Donet Tom wrote: > > + > > + /* > > + * Record only accesses from lower tiers. > > + */ > > + if (node_is_toptier(pfn_to_nid(pfn))) > > + return 0; > > > Just a thought—could we check this at the beginning of the function, before > the switch case? > > Can you please trim responses to omit un-related code? Not all of us use mail clients that auto-collapse quoted regions and it takes a lot of scrolling to reach here n_n;;; > > +static void kmigrated_do_work(pg_data_t *pgdat) > > +{ > > + unsigned long section_nr, s_begin, start_pfn; > > + struct mem_section *ms; > > + int nid; > > + > > + clear_bit(PGDAT_KMIGRATED_ACTIVATE, &pgdat->flags); > > + s_begin = next_present_section_nr(-1); > > + for_each_present_section_nr(s_begin, section_nr) { > > + start_pfn = section_nr_to_pfn(section_nr); > > > I may be missing something, but in pghot_setup_hot_map() and > kmigrated_do_work() we seem to iterate over all memory sections. On large > memory systems, could this become a bottleneck right? > I think this is going to end up being a function of page / section size. I would hesitate to over-optimize on this early-on, otherwise we'll find ourselves re-building a bunch of DAMON functionality that chunks memory into regions and such. But it is a concern. > > Since hot_map is allocated only for lower-tier memory and the hotness > information is primarily used there, would it make sense to skip scanning > higher-tier sections? > > for_each_online_node(nid) { >         if (node_is_toptier(nid)) >             continue; > >         start_pfn = node_start_pfn(nid); >         end_pfn = node_end_pfn(nid); > >         s_begin = pfn_to_section_nr(start_pfn); >         for_each_present_section_nr(s_begin, section_nr) { >     } > } > > Would this approach be reasonable, or am I overlooking something? > re: your note later on - kmigrated doesn't run for top tier nodes kmigrated_run() { if (node_is_toptier(nid)) return 0; } > > + > > +static int kmigrated_run(int nid) > > +{ > > + pg_data_t *pgdat = NODE_DATA(nid); > > + int ret; > > + > > + if (node_is_toptier(nid)) > > + return 0; > > I might be missing something, but since this function is only called from > pghot_init(), would it make sense to check the condition before calling > kmigrated_run() to avoid the function call overhead? > this gets optimized out when static is inlined and optimized. ~Gregory