From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (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 1DEFD371D05 for ; Thu, 6 Aug 2026 17:03:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786035809; cv=none; b=ru7xtJIw7+xlO2IaBkM63WguWqBmtYc4clezMa9wzu5GJ0J0NLEz4rH+yTVH9QQEDG3TKTyhk2Rm+1gcNP+TrsnICPuWE9QGnDLOBMC3pXjhEGr6ZXfA9RC9UYnhgBtOcZFjiWW7NgfRoQI0Q2V1K0mcUrRfPJTucp6l3C0U7jA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786035809; c=relaxed/simple; bh=wH2Z/7SStNPXHVKuBAna047dlnh8OKumWppmtohqDBg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JsJXKgd8Jt/YyuobpmRtwN1+h5u5hLoyrMHDlsBjyz/cie8A4OrpfEddUA+KsV5f+PfwaPVMMUoEqepwe0q15mdENTIeBjBermKAh2x+wQimiPuqb6Kyx2e6/z3l9h+nxWvwEtaOqcbeKYP6SXj+f1REjWrMLAUNUf1hZiXBuY8= 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=VrqJHNGR; arc=none smtp.client-ip=209.85.210.179 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="VrqJHNGR" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-84e0688b7e8so2362461b3a.1 for ; Thu, 06 Aug 2026 10:03:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1786035806; x=1786640606; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=jTcIYdDJrbFYM8SM/eR5/FInV0ODp6bCP4uR1qvvuCk=; b=VrqJHNGRRUoP/msyVxM5mpPdeQqY8og/M7kLPYkdcG45zy74Hyo001nabIAtdc7oJw 6vnl1+Kgrblow4hzFefbVXqdy3K9PS/Vtp9Uh/sQUWDxiBYU337hp3YeqE3uoafhsyXh P7feEkHaE1EWfbTSdedW6ODLSYsdSfgAinn7KkDDQJ8s9XdwQVybCzAye985P45C/3dG p1m0CmzVnpuDUmlH+oqW9iKpj0+fuNQalecoj0d+WMUelnq66jjLAYU/ke1iV/SKKeKP vVHR/Ara/zOrRjqpRlJWhrhRAmU8qPjZ3a0AKu/IWGb3H7k9bKC2U+tWqaFT0vLHwGQC 6coA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786035806; x=1786640606; h=in-reply-to:content-disposition:content-type: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 :content-type; bh=jTcIYdDJrbFYM8SM/eR5/FInV0ODp6bCP4uR1qvvuCk=; b=kckXJ6grDDn8E1mPmQdVxo66Mcb5pszivGW1ARlUfunim48rSqBd+CaqBd/I3eWiFr 3UWYYJWRCSjTISmErWElpyJl0PBHut9u27twsn5GKL52XAUKXEk9yWXUjtm71TQNO1iO wNG2DUIBu0nheKlZUadXpMZKx1uJzJBOR1rgkuFZiO063aMRQT50XxctapA+mS8Et6xp rkg44rP+yFiMCIESbUZERd74R+XGMbgdHVWTOn/lUmV0rZl+upGDct+q/e1b5tjcGvB3 Te4Vv9PqQzRHPUWyVdxHpP+NRHA8ybNbfD9JQeu/Dn5Ye2JVHPhxIW1YcCCbuodAGKgk hD5w== X-Forwarded-Encrypted: i=1; AHgh+RqegU/sHQTUO9Op8GuRxzU1of3oRvigjdttQSevuzOIOQmRYv9kIyqsOBFdM7D5TmXRvH9WcUCJi8w3IKY=@vger.kernel.org X-Gm-Message-State: AOJu0YxRPBlTYS8boE2AdQEz8qVh3WVe/iZiQgxxx+3RIGA1Bi2Helon vwN1O1sTOxjr4x7ax+L1xsPIPquX929STxP6eYm8MDKLXmWKdSEbVV8Cy0fqlEIJuWA= X-Gm-Gg: AR+sD11DuyMCp1zqYDGbJtx77IA5uuub1CAcCh8RlxJ7a16S7MptpUT2CAGkW95JPDH XWnLVa4jIQaWL2/QJ1gKL1b0w8TN3a+SzOZrTJIYSZkBwma89/2SfvxwrY0QXriUdl5nHDXykgS 4XYEQJL0sakZ7CZYYYAJEJI2aavnl5XuHwCb8VKLjgDYeIZeCZOtG5ZMJttucWJ6RT963xmpQ6X LnGGgs59jTIRyNNtVinYCsxFDchUoD64LXQrFpYavCrlFPbRTcOZMNjeCY7Qbwk8rFZ40/ubkUK YtScs9Uyi6ovfJSeVXkMYaPSrp5ZivioRIBEy6IMv7qJcBo6Z8Sj2HPIWpparnszaXWnac2T4yD KpraIrlupMNSeekSP7lHS8ekovwcFW9VyjQ4/PmoO9tdxq395IqEITTuLtJVSj/qQgLV2rxtCT6 C6XgxBcY34S7KZR7othjS2rWMHRwHeP8jkf94wzMFN6T7L/icnSf9woGRemhXJ2NQ4 X-Received: by 2002:a05:6a00:2ea8:b0:848:4c0c:9482 with SMTP id d2e1a72fcca58-84f2e0cc746mr17400031b3a.35.1786035804907; Thu, 06 Aug 2026 10:03:24 -0700 (PDT) Received: from fedora ([2607:fb91:201f:cebc:3a68:390a:144e:1b87]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84f453bb24csm1745790b3a.24.2026.08.06.10.03.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 10:03:24 -0700 (PDT) Date: Thu, 6 Aug 2026 12:03:19 -0500 From: Gregory Price To: "Lorenzo Stoakes (ARM)" Cc: linux-mm@kvack.org, damon@lists.linux.dev, linux-kernel@vger.kernel.org, kernel-team@meta.com, sj@kernel.org, akpm@linux-foundation.org, david@kernel.org, ziy@nvidia.com, baolin.wang@linux.alibaba.com, liam@infradead.org, npache@redhat.com, ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org, lance.yang@linux.dev, usama.arif@linux.dev, vbabka@kernel.org, jannh@google.com, matthew.brost@intel.com, joshua.hahnjy@gmail.com, rakie.kim@sk.com, byungchul@sk.com, ying.huang@linux.alibaba.com, apopple@nvidia.com, stable@vger.kernel.org Subject: Re: [PATCH 2/4] mm/huge_memory: skip zone device folios in madvise_free_huge_pmd() Message-ID: References: <20260728194714.3713735-1-gourry@gourry.net> <20260728194714.3713735-3-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 Thu, Aug 06, 2026 at 02:59:22PM +0100, Lorenzo Stoakes (ARM) wrote: > I kinda wish he had some generalised folio handler like: > > struct folio_ops { > int (*handle_empty_entry)(void *priv); > int (*handle_normal_folio)(void *priv, struct folio *folio); > int (*handle_softleaf_pte_entry)(void *priv, const pte_t *ptep); > int (*handle_zone_folio)(void *priv, struct folio *folio); > ... > }; > > Or I don't know an equivalent type of thing, as we keep having these same > patterns emerge in mm that are duplicated in a million places with slight > variations... :) > > I wonder if C is expressive enough to get us to something sane though. > This is functionally folio->pgmap except it's not generalized and it causes us pain :[ I briefly took a forray into moving pgmap to be node-scope, and that works decently, but first i'm just trying to clena up what i can for zone device. Anyway, i get what you're getting at here, and that would be nice. > > Fixes: 368076f52ebe ("mm/huge_memory: add device-private THP support to PMD operations") > > Cc: > > Signed-off-by: Gregory Price (Meta) > > Anyway LGTM so: > > Reviewed-by: Lorenzo Stoakes (ARM) > many thanks :]