From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) (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 5E6A63BB69D for ; Thu, 6 Aug 2026 01:13:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785978785; cv=none; b=k4HKNjfU/LG3EMSNlvzfEaTIJSo+29twFK/688fg8xUxTVce8dr7V5y81cYQE4ZQG7C+NZXi6/AkL44lYc22cc8O4A3YU0+qglB3GKWbTtnpuJ35z/vBufuCqOK4iHuURaTHLmnj81AMzlqhV+gpMT85jaaTCjCooIfxzGN8/zs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785978785; c=relaxed/simple; bh=kFF5ybhqynoFgUT5UbDhCcpxK7wDpu7an1BWImtMbhg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=EYjkpIdR33jTKjxyfvpzfplXpUEVx0jc6hVYnNes/twQoNYTrzuZaVMe+KZGnITnFmrGkY6fzoccvr26o4qDvG3M1sHhtZQSxowB5BTFKweFdbHreCoIbY2C7OXFr1yKuqEA6XMWzWe4/Fqmf8NS0hU45LHnphKW5FkaSdXxlgM= 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=BViTDMjn; arc=none smtp.client-ip=209.85.215.197 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="BViTDMjn" Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-cbbb9c9bfc3so1000513a12.1 for ; Wed, 05 Aug 2026 18:13:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1785978784; x=1786583584; 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=w+7m+wEFnwXkxLiUbjcNNWB1I8uLbBVbpTJLAVglWe8=; b=BViTDMjnAnAucXnXbhNifD6AtsjBFmzkmfRCztH+NLc/bcsL8aqi/gyMiEhRQP6Dwi bRCnaAQZSeYuzWU7hBeZ/kDB4CgrcUO1enJckh2oSKyRgYPcWmakal3ERNjSMDAq7HFS 2T7cUJ9SV5+OuYkkNWE2ZxV0B8+WmH5XLgokL6S/J/Kt0bv/hfjbrjF9152+zsuARFs/ RU0y/3NPkEBEu3gKTZOZjNeGTG45TE+2sTlKozq+EOtSMLsenA8+9W08amnGWKEjlMNP KbRIjNOEFi20N+bABhh2MQ7ZBZzk9W0z2Zfd6Fx01cjA+vLoJuRc7dwF3GBdf/PhJFwj Y5WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785978784; x=1786583584; 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=w+7m+wEFnwXkxLiUbjcNNWB1I8uLbBVbpTJLAVglWe8=; b=jXubSNMLVczMc57tvIGyAGCpr0t246eYYtXjgEglpdNyJcTuDfJ8AuP3dIJZ2O+AsJ rzuWD7YedzCWA2kdyfJubrEfHejrbfKHhhMchaHzk7XGRjZc452TedCQL2liEPww6U4V 90Mm20n2hhbyXsQqa/OemDSTyBZi+GwXQBhwZx8zWCMQjITPdB4ANI+Zm95pIk9h5xVG /jYPrIEdGrxuJTCdmhq9pa7EZ6vHGv7cyYHk5t+HpnIxwVeKw/9YwBZMQbUDLqoqNgEa xx6bFenVPowB2zLKujNA39ftGr6dLXKu09wEz2SlDTikyPU849XpK60zI5YFlHBqEz6U Wndg== X-Forwarded-Encrypted: i=1; AHgh+RrNJK1/6hftawd9cYCRreBOVgFAuZwsC4pBt+lYe7RCRlH+aqGX6Bc2EKxMYznXFoXIFHbwOHn/lLYWrEI=@vger.kernel.org X-Gm-Message-State: AOJu0YzR0RikKMXJAeogZQoJkSUZVh46w2UWDatl7NIRf+45PyNskoW0 rfi9o3xck2G2fj3ZIwks+8PrR7IuS6J3XjpTHgq700xfIpq6RZTwQXCMiLKxhri8bR8TH2rvL+d xiaWNKxlXQw== X-Received: from dyw7.prod.google.com ([2002:a05:7300:8807:b0:315:206:5a14]) (user=jyescas job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:178b:b0:3c3:fb32:a004 with SMTP id adf61e73a8af0-3cb85fac065mr13957847637.34.1785978783412; Wed, 05 Aug 2026 18:13:03 -0700 (PDT) Date: Wed, 5 Aug 2026 18:09:14 -0700 In-Reply-To: <20260806011048.517229-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: <20260806011048.517229-1-jyescas@google.com> X-Mailer: git-send-email 2.55.0.629.g250fe7f194-goog Message-ID: <20260806011048.517229-14-jyescas@google.com> Subject: [RFC PATCH v2 13/16] mm: Create the file associated with an allocation 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, ljs@kernel.org, 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 the file associated with an allocation. The name of the file will be given by incrementing the atomic long "allocs_file_seq". This file will be used to free the allocation when the user requests it. The implementation will be included in a follow-up patch of this topic. Signed-off-by: Juan Yescas --- Changes in v2: - Update commit message. - Set file permissions to 0400 instead of 0644. mm/page_alloc_hogger.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c index e22247b7bd98..a70c924e4172 100644 --- a/mm/page_alloc_hogger.c +++ b/mm/page_alloc_hogger.c @@ -185,12 +185,26 @@ static inline void set_migrate_type_to_alloc_from(int migrate_type, gfp_t *flags } } +static ssize_t page_alloc_read(struct file *file, char __user *ubuf, + size_t cnt, loff_t *ppos) +{ + /* Which information should be print about the page or allocation? */ + return 0; +} + +static const struct file_operations page_alloc_fops = { + .owner = THIS_MODULE, + .open = simple_open, + .read = page_alloc_read, +}; + static int make_alloc(struct req_alloc *req, gfp_t flags, unsigned long *alloc_id) { struct page_alloc *pa; struct page *page; char new_alloc_name[20]; + struct dentry *new_alloc_dentry; int ret; page = alloc_pages_node_noprof(req->node_idx, flags, req->order); @@ -205,18 +219,30 @@ static int make_alloc(struct req_alloc *req, snprintf(new_alloc_name, sizeof(new_alloc_name), "%lu", *alloc_id); + new_alloc_dentry = debugfs_create_file( + new_alloc_name, 0400, req->parentdir, + pa, &page_alloc_fops); + if (IS_ERR(new_alloc_dentry)) { + ret = PTR_ERR(new_alloc_dentry); + goto free_page_alloc; + } + pa->req_alloc = req; pa->page = page; + pa->alloc_dentry = new_alloc_dentry; ret = xa_insert(&allocs_xa, *alloc_id, pa, GFP_KERNEL); if (ret) - goto free_page_alloc; + goto remove_alloc_dentry; } else { return -ENOMEM; } return 0; +remove_alloc_dentry: + debugfs_remove(new_alloc_dentry); + free_page_alloc: kmem_cache_free(page_alloc_cache, pa); -- 2.55.0.629.g250fe7f194-goog