From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) (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 E0DC13F4DC7 for ; Thu, 23 Jul 2026 07:50:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.71 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793021; cv=none; b=bQp6x3hQVPTQFt4SW93fEUv68DcBfxHoCUseUEc8bok4HoPb6ThMS20O5AvP87gyxXsUsOwuLUrLwXLEkCZ70qbLqfwSUhQASAEbA5oXKD4u73I5h/ashIUwpjkFYwPJOcaNurYuHXUrkfy9bIXB7LAClFX2eR74cW3DKgFxL54= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784793021; c=relaxed/simple; bh=e6wy3Ur/BAHauo6srooaMZDjM6N0t/WihhOe8fobGGw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=kdvceddSbNdI9HPziyQvOkscM1YminP4A3H+shufMDGt5K2SEWpfLJ4DmCrCLdFhHtvLeFBCeyQteVlwbz2jj1w9t06ncFzjGBZLGPUCHs03yr25onDIU3j00YeDoGbwhmrWQIkQyRg2RNQD6qgjbIQ5Ugq8/1Z5q+xnirdOQqo= 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=KX5dVUdy; arc=none smtp.client-ip=209.85.216.71 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="KX5dVUdy" Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-38e2f61c09dso759290a91.2 for ; Thu, 23 Jul 2026 00:50:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784793019; x=1785397819; 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=Rrv5x+4mpVYYp8CMRoch1CZB0fcAbFjciupWA91d6dc=; b=KX5dVUdyGomRYnbcRmBkAwtsGALimhpJL7QfOc/Yf8x48YXGEx+oXG+UQjaOFAXEMU 9fqRXXu+1hjA/jg8YB3OPNdSWXtPNeWNy5pPoZ1Qd/12t/jyFkSky+DHSn1d+Dp0lRP+ EcqftcqH58vW3LJgdIfEttA/3Vgv2nqbJOnEcYKWuCZDxM3MhF/6f7Tc0QaGEWL1WCfr 14Ygywoxuz0Cf2hBQ2mA5qICUHbJoDd5RcTDLyQsT6aMqCRQnFQcjTYpdwCS7KpRC+Nd YG2nFcwW6oFpFDV1DlxoO1mmPAqLbKLZRIgGi2IXF9ZvDZAM8CwUiRiWOzb2CDMdmQA+ 1RyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784793019; x=1785397819; 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=Rrv5x+4mpVYYp8CMRoch1CZB0fcAbFjciupWA91d6dc=; b=sa/bfogsJz4UncyhRycv6NJ4Qa+6vpAMUORO/HKSWeaUmKQ+nZo0YnXbcFTJr0D3Wj A25EiG2OlUfeeyHtyrI4eWvB1ElNNmeYEEeBu1LzQMXDS3YMSraAlkqdl2WBN1QwjAbg zwowZeabn4SWhBOCY+iD0/FDio04T1yb2ZzYxgHro7lKgXQqUzYq3NA4Bi0a2GAu15TK IWTc8kW7Pvqa83rsjgCYnyvdMUShBuxEbZ8uwz66lMm5oWRvCB2VmzUMyYIRVawAu9TF TmNNDFgunBJbVSolc7G9KbpXm/LF3b6Tc91k8rJb+EDAQljHsx/UfGfB1edaHU1SDnPu UGTQ== X-Forwarded-Encrypted: i=1; AHgh+RoBDcoSqvPNGos9U1mHRUDsfIiSlxzn+nPAI4Irx4hrDGMGfdrwUg6AA5+peyySBBaqn6pvTzNV/LxgZbo=@vger.kernel.org X-Gm-Message-State: AOJu0YxyZQ0jeVYKET0QGjdtE1xTddthZgAC0f+SiX/yKXNPrxWCpQm7 KYesdv2fstF+f1WzkljKEKSvL4fgEVAMrTh/5MJl3YsokYMHl5A2KhuciqIkdXyAVgtWoU4tS77 oki/8Bg+W0w== X-Received: from dlec12-n2.prod.google.com ([2002:a05:701b:428c:20b0:13b:848c:abaf]) (user=jyescas job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2f06:b0:38e:adf1:5b03 with SMTP id 98e67ed59e1d1-38ec6665307mr2164293a91.35.1784793018950; Thu, 23 Jul 2026 00:50:18 -0700 (PDT) Date: Thu, 23 Jul 2026 00:47:12 -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-9-jyescas@google.com> Subject: [RFC PATCH 08/16] mm: Define function that creates the "nr_pages_allocs" file 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 implements the function that creates the "nr_pages_allocs". This file will be used to make the allocations. When the user wants to make an allocation, it will write the number of allocations to this file. For example, if want to make 56 allocations of order 9 in the Node 0, Normal Zone and Migrate type Movable, we execute this command: echo 56 > /mm/node-0/zone-Normal/order-9/migrate-Movable/nr_pages_allocs Signed-off-by: Juan Yescas --- mm/page_alloc_hogger.c | 58 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c index a727c4f48ffb..3ffad74a0bdf 100644 --- a/mm/page_alloc_hogger.c +++ b/mm/page_alloc_hogger.c @@ -127,6 +127,58 @@ struct page_alloc { struct kmem_cache *req_alloc_cache; struct kmem_cache *page_alloc_cache; + +/** + * req_page_alloc_write() - Allocates the pages on the requested node, zone, + * order and migrate type. Once the allocation is performed, a file is created + * to free the allocation later. + */ +static ssize_t req_page_alloc_write(struct file *file, const char __user *ubuf, + size_t cnt, loff_t *ppos) +{ + return cnt; +} + +static const struct file_operations req_page_alloc_fops = { + .owner = THIS_MODULE, + .open = simple_open, + .write = req_page_alloc_write, +}; + +/** + * create_nr_pages_allocs_file() - Creates the file "nr_pages_allocs". + * + * The "nr_pages_allocs" file will be used to write the number of allocations + * that will be performed. When the allocations are performed, a new file for + * each allocation will be created in @migratedir. + */ +static inline int create_nr_pages_allocs_file(struct dentry *migratedir, + int node_idx, int zone_idx, + int order, int mtype) +{ + struct req_alloc *req; + struct dentry *nr_pages; + + req = kmem_cache_alloc(req_alloc_cache, GFP_KERNEL); + if (!req) { + pr_err("Failed to create nr_pages_allocs_info"); + return -ENOMEM; + } + + req->node_idx = node_idx; + req->zone_idx = zone_idx; + req->order = order; + req->migrate_type = mtype; + req->parentdir = migratedir; + + nr_pages = debugfs_create_file("nr_pages_allocs", 0644, migratedir, req, + &req_page_alloc_fops); + if (IS_ERR(nr_pages)) + return PTR_ERR(nr_pages); + + return 0; +} + /** * create_migrate_type_subdirs() - Creates a directory for each migrate type * inside the order directory. Once the migrate type directory is created, it @@ -138,6 +190,7 @@ static inline int create_migrate_type_subdirs(struct dentry *orderdir, { struct dentry *migratedir; char dirname[24]; + int ret; for (int mtype = 0; mtype < MIGRATE_TYPES; mtype++) { #ifdef CONFIG_CMA @@ -153,6 +206,11 @@ static inline int create_migrate_type_subdirs(struct dentry *orderdir, migratedir = debugfs_create_dir(dirname, orderdir); if (IS_ERR(migratedir)) return PTR_ERR(migratedir); + + ret = create_nr_pages_allocs_file(migratedir, node_idx, + zone_idx, order, mtype); + if (ret) + return ret; } return 0; -- 2.55.0.229.g6434b31f56-goog