From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) (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 B72EC3EEAD7 for ; Thu, 23 Jul 2026 07:49:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.72 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784792999; cv=none; b=KEvxzBrjqATUm488HfSJC7ocmdwHPbT3RVqKRqD4hOG9BJPILaz4zd9XmGygYdVXCot5ZeahLwyMZDcGXKRdcKb67n7sMUbfWFeOyM8Be+OK8xiv4ugpgzY+sZmLsV1UeSl18u+STGC4p4N4pbj6oTVxJLYjbzj8/jrQJmmQkPw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784792999; c=relaxed/simple; bh=0SwVKEcKK/mkQ9g52EEyNwIz3tvvQPWAa8AT5fBkS/k=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=lQiRrwNKdWtrCVMNYAyKvsExew8rvoSiExRce1YGFxwSHqos/T3DCAFAYKIDANjCQKbDp2Nzfbrj8Ws7S/CO+3xD8j/v6f684JL62OG+ruC4hKeqBQ4pe2WLTE+IP30CfMVKGg4UPKZO+UJ7pbWVkIqlUPyy0MGqDCILuPBz2fo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jyescas.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=I5wQSxQm; arc=none smtp.client-ip=209.85.216.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jyescas.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="I5wQSxQm" Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-38e7ff7b375so591134a91.1 for ; Thu, 23 Jul 2026 00:49:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784792997; x=1785397797; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=mqLzhDVDDZLVR/FPTjNaPDqvXax9+3/sETwGozJ8afI=; b=I5wQSxQmsdm/UrBTamEJN12DsZuQtVZy7O/9sgFthbg+cPK+gZDipkpvT8VhFfaH8j vA4dngyb0qjpi3R5rXTbaQSkT8Mk6uhF3Rm34AkmclynJPLROil+t0TWOC00uINKlLuc MFiQV4q0Cyxdmi2SQWlY3FbS7wtgkk8lHpKcrvJbNXC1Hz/zJTReNXIJWICgEzoj/JUu pCSIoWyvoRVVUvLB3zyLjXlaaRQtaS0oi5OMDNe/e3CsTml/2yVPvv7tNIziPs6k//GX WCZh1l45wmxZJ3334NQevuEBvvnckqh4HdU+boWuqn1ECUWoLRFgQDToY66GDzsOASag N8BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784792997; x=1785397797; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=mqLzhDVDDZLVR/FPTjNaPDqvXax9+3/sETwGozJ8afI=; b=jQth9bkvoy1rFY/4zeY1X1oUeJ7r+lgM3L3tupWfwSGJEtSvwvWjViM3DOfkL1bQoq CUtJe0dejGEAfDtqM7tvhLEC/5Dw1c6N1sO7x2JoYNxbuQvp5Ow3/rdb2LzUv3imfG0Z c6M6BUGXYUEMMJuTa6GlR3XlQlIGFWjtGXSH/JvznZ9fGH8dliSCjlIeHa06ROc33W08 IGqcCi0N9HjtuKYvpDZOcW/AsI0IgjiEvr20N8tRs13uhpFxqlHTy5+Q4bGc8ITKTbxg ObGteND/UCNTCPCgfzKL0lPPj1/8BtTSxkVuOn/XxkSzdgTEvUqD+wrlGQs8O3u40Eco aONQ== X-Forwarded-Encrypted: i=1; AHgh+Rp3O6kN78uSEwKKcE6EGwAWTQucVfDkzBWiTu+JStyeKxKvkZdouiWF6Ha8tSes8qdisH9x6dHzGPkvGsQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yzzq4VW6oTskLUtgxlV6G8p6jhAV/bk68nGkRI4Na2ujS1e1P/l qnsFgXrsdU1Fhqlavr9aw9Y0w9x9x57e+ODNDrxpgUVm0jN2dfjNNuBSYxFDRPFohb2NZVZgee9 15naSvA0gFg== X-Received: from dlbrh17.prod.google.com ([2002:a05:7022:f311:b0:13c:ea63:bd6f]) (user=jyescas job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:3a4c:b0:38e:524:8797 with SMTP id 98e67ed59e1d1-38ec645e505mr2022963a91.13.1784792996824; Thu, 23 Jul 2026 00:49:56 -0700 (PDT) Date: Thu, 23 Jul 2026 00:47:09 -0700 In-Reply-To: <20260723074854.1013941-1-jyescas@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260723074854.1013941-1-jyescas@google.com> X-Mailer: git-send-email 2.55.0.229.g6434b31f56-goog Message-ID: <20260723074854.1013941-6-jyescas@google.com> Subject: [RFC PATCH 05/16] mm: Define function to create a dir for populated zone From: Juan Yescas To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , open list , "open list:MEMORY MANAGEMENT - CORE" Cc: jyescas@google.com, android-mm@google.com, fvdl@google.com, tkjos@google.com, minchan@google.com, dskiba@google.com, open list , "open list:MEMORY MANAGEMENT - CORE" Content-Type: text/plain; charset="UTF-8" This change creates a directory for each populated zone in the node. Note: ZONE_DEVICE pages won't be exposed in this driver due they are not managed by the Buddy Allocator. Signed-off-by: Juan Yescas --- mm/page_alloc_hogger.c | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c index 880de1a6e9ea..1cec9ec5e35e 100644 --- a/mm/page_alloc_hogger.c +++ b/mm/page_alloc_hogger.c @@ -88,6 +88,7 @@ #include #include #include +#include #include #include #include @@ -126,6 +127,41 @@ struct page_alloc { struct kmem_cache *req_alloc_cache; struct kmem_cache *page_alloc_cache; +/** + * create_zones_subdirs() - Creates a directory for each populated zone in the + * node. Once that the zone directory is created, it creates a directory for + * each order supported. + * + * Note: ZONE_DEVICE pages won't be allocated using this driver. The main reason + * is because they are not managed by the Buddy Allocator or CMA allocator. + */ +static inline int create_zones_subdirs(struct dentry *nodedir, int node_idx, + struct pglist_data *pgdata) +{ + struct dentry *zonedir; + struct zone *zone; + struct zone *node_zones = pgdata->node_zones; + int zone_idx; + char dirname[24]; + + for (zone = node_zones, zone_idx = 0; zone - node_zones < MAX_NR_ZONES; + ++zone, ++zone_idx) { + if (!populated_zone(zone)) + continue; + + /* ZONE_DEVICE pages won't be allocated using this driver. */ + if (zone_is_zone_device(zone)) + continue; + + snprintf(dirname, sizeof(dirname), "zone-%s", zone->name); + zonedir = debugfs_create_dir(dirname, nodedir); + if (IS_ERR(zonedir)) + return PTR_ERR(zonedir); + } + + return 0; +} + /** * create_nodes_subdirs() - Creates a directory for each online node in the * system. Once that the node directory is created, it creates a directory for @@ -136,12 +172,19 @@ static inline int create_nodes_subdirs(struct dentry *mmdir) struct dentry *nodedir; int node_idx; char dirname[12]; + int ret; for_each_online_node(node_idx) { + struct pglist_data *pgdata = NODE_DATA(node_idx); + snprintf(dirname, sizeof(dirname), "node-%d", node_idx); nodedir = debugfs_create_dir(dirname, mmdir); if (IS_ERR(nodedir)) return PTR_ERR(nodedir); + + ret = create_zones_subdirs(nodedir, node_idx, pgdata); + if (ret) + return ret; } return 0; -- 2.55.0.229.g6434b31f56-goog