From patchwork Sat Nov 16 17:59:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13877670 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A20AD68BE7 for ; Sat, 16 Nov 2024 17:59:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 161DD9C001B; Sat, 16 Nov 2024 12:59:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 10D019C0018; Sat, 16 Nov 2024 12:59:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E539A9C001B; Sat, 16 Nov 2024 12:59:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C54449C0018 for ; Sat, 16 Nov 2024 12:59:30 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6992A121CFF for ; Sat, 16 Nov 2024 17:59:30 +0000 (UTC) X-FDA: 82792718988.21.09DE5E2 Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) by imf17.hostedemail.com (Postfix) with ESMTP id A856140002 for ; Sat, 16 Nov 2024 17:58:52 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=RtYCXKvy; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf17.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.171 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731779903; a=rsa-sha256; cv=none; b=uvA3pUExmdY7k7Cm5GQetsLGUtbMn15s3/sfaBJp78p6oSukR9z4xmYDsebQPVNwQBRzJJ 8j0yzoTaMyQP2nykR5HpGCADMcQnLHap++FM8FV+qz9z8bK59oB8DbP/1G0s+sxbAwKTyV LMHZFUT1nCsiFWyAvFk9CURUO7kOg2E= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=RtYCXKvy; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf17.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.171 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731779903; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=q+AdtzJV8StRb0yy8pEXghurQ0eEZGVtS6O69RbdSyA=; b=H/PTs4C61ZWhsiS/FNHNxUdyo5xsHJp6ajlXAKw0DyX3G20V4HnE++h/StkbXXLi8+iGHV oTZ7dkw9+D7nRGEopFOKhMFjvZ/hq2ZG2zGg0lwbxEa/pptjMethICaQQ21QBCfnjE/P7B uKvsPjGs6XmrLH5QFXNEO6nFy7s5Apg= Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-7b13fe8f4d0so120526585a.0 for ; Sat, 16 Nov 2024 09:59:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1731779968; x=1732384768; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=q+AdtzJV8StRb0yy8pEXghurQ0eEZGVtS6O69RbdSyA=; b=RtYCXKvy6hqvGdL2oOeYhBCfRc6jIHhWtAFn7VIEz251vHxMRfiG9YG5O5K/CTYavi sy3syvQi48E6HO+KoaM0rFRalhgZWXvxaMeb6UeDkDCPqX+pzswVJUuhKqnDhkoyh7r2 UtCSSt7Le5+MnqeTupCmRFir+VAj2wRPipBzH+BjWUdRx0aJ4NQLkbfkDkZC9BYWOt4i 4ensBR/bDhpCDN5O2J5P1spV4tm6eIygUCnItevcZTEVuik7fWSbEJc/CQ84j8bHSksN GjvhaFAqSpXdpyEbMeIkimvCGm52o/KaQtVH8ymafWulcjrjiyU9pgsY79lU9gR0+/dw NqMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731779968; x=1732384768; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q+AdtzJV8StRb0yy8pEXghurQ0eEZGVtS6O69RbdSyA=; b=JMwGb7sHQSfJjIVVA/Cf3Wqso25bJ/ILj6selzNjMVMgsvdr/ZpqEXOA8Br5vg9f60 pTftDan6CegzNxNyOZGCM7WhPDXiLJROZXK1nLuhfEPqPgXt0U4OW5YMTPBGjtvZpkRH SzykMJ2AcKHsohVTmt5ibW8MBTMVYdsafWN+u+HlPglS0U4W0X0a78+OpmXMZu9+/be8 bFUH6cRjnr861PNjXjwhgOBLWMW6/pGOB6j+SDREBGcAEdO6+39DuuVEkijcR7nCjQGv NpfFsFqzoKN+FJTX+TIpv/T0BW9hgjYI6eR7T4+XeGXVckU5CEepO8TtBaC53DgJlR4G vKIQ== X-Forwarded-Encrypted: i=1; AJvYcCUcszBQSKR2svoZjvdPOvbrXpXPpmCxrHSASvPo+CLSu6cUiv7V68ueBOPJlbkTg9HVF3ipGUC9rg==@kvack.org X-Gm-Message-State: AOJu0Yw+DheFjxvgtlD2HRvB8xXR5JyusMBMyF9bELCZLB7Zx/nT/gI1 c/zEgrL+6iKMiV6bq8AHqV8F8xNoTNcEHwWP+X+EybN4kllad9OIqkz1UhUrzP8= X-Google-Smtp-Source: AGHT+IHID5UaFDu345/iXR65Tjm/g4UasFabizEe9rsgDtnAMppuhhS2EDxuUbmo+8naXZvVw6Ss7Q== X-Received: by 2002:a05:620a:468d:b0:7b1:5504:2772 with SMTP id af79cd13be357-7b362378df6mr1035738885a.55.1731779967540; Sat, 16 Nov 2024 09:59:27 -0800 (PST) Received: from soleen.c.googlers.com.com (51.57.86.34.bc.googleusercontent.com. [34.86.57.51]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7b35ca309d6sm280530085a.94.2024.11.16.09.59.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 09:59:26 -0800 (PST) From: Pasha Tatashin To: pasha.tatashin@soleen.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org, akpm@linux-foundation.org, corbet@lwn.net, derek.kiernan@amd.com, dragan.cvetic@amd.com, arnd@arndb.de, gregkh@linuxfoundation.org, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, tj@kernel.org, hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev, shakeel.butt@linux.dev, muchun.song@linux.dev, Liam.Howlett@oracle.com, lorenzo.stoakes@oracle.com, vbabka@suse.cz, jannh@google.com, shuah@kernel.org, vegard.nossum@oracle.com, vattunuru@marvell.com, schalla@marvell.com, david@redhat.com, willy@infradead.org, osalvador@suse.de, usama.anjum@collabora.com, andrii@kernel.org, ryan.roberts@arm.com, peterx@redhat.com, oleg@redhat.com, tandersen@netflix.com, rientjes@google.com, gthelen@google.com Subject: [RFCv1 1/6] mm: Make get_vma_name() function public Date: Sat, 16 Nov 2024 17:59:17 +0000 Message-ID: <20241116175922.3265872-2-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog In-Reply-To: <20241116175922.3265872-1-pasha.tatashin@soleen.com> References: <20241116175922.3265872-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: A856140002 X-Rspamd-Server: rspam01 X-Stat-Signature: 749866uy11mahcugstirakxttuirz733 X-HE-Tag: 1731779932-331541 X-HE-Meta: U2FsdGVkX19sDQSTkYLIt0Z7bqOe208knlyuPxeVipNvvglNyT9qDXEXtknnbM+qtXkIDtTOkv/8yomvtkFXxLJvHCszjtvcjIEfIjl6D8dgXPoVSFROVF8uEz+kpXazlLRlDqpPLttti9hfp4yOZJdDR91XMBTHE/lJxQtKlddsVecDGSstTtBxfme45SJnXEH4vA+HLqc8tDaXgsALAr0fR1w3nyrrCmavhHIW6owt9OvcD0qpQtyIF/6/J21YC0RqU264aGQdEAsaftamTRaB5HraKRZR6MHM8oni/nAJKz1ytkPhJw5JfgFydMthMorjamjsK3FYPnOLtijoRJCsT64XlyibuTanCyLBr4kYsFxmZRNGvT4WvlCs1Wg+h4wIeww+HW2BULFYDlSnkGxk+iziZiZF6h4aYgrIlq1+GIo2kg+ccmyob8icsLD4y5y7pv9OK9vDulnddvDDENFlE7Z70kq36yoENxn9/5bX2yxxhCjDQujKuBtJhFkk8S88nNx/lTokVtaenCbSdyQcbUqIfYJtH7nOt/aQRvUBARwys9SmIsEldHiS9H5b43fSRMyjapt/UfipbvLLyuv6NA1yiH/4TRP5+bbc+YNtp/cvnhlnroslvRMG3EvZEpXDC7dBHLsFVMVTHaVrbiPlQ+IuZlECjiqijm60mHKvlNuUuyNxJyBbuSI0jjtCi4RE8zjKm9LncFCVkXlBFfViJaah3DREUglfzuzIT0HSKfI4CWNRuDvsj3Vy1UlOuuZX6a/3GieGIm4Qy708zslTHorzek22JZrkwUOvcmOp94QIJszeQ4tzHxsTKNV0WLJfguBmg3EOGUz4eF6IJ+zYpnF4+SgZR2KxEdzVY66wvfBjsasg8AX7qdGWYg7l1a6CKNVr8fR2G7vB6MtG/oNb794Q49vRMhEjpJsQ905gp//N9FYaIwesk8tDLO/pg92IYuoArFLWUAnDQ2f BlJKU/PK e702eT9NSr2nSQd+nd+cuC/RoSEHvcxi9ZoyINaX1iBwPA3TGZ6otuhF4hiy3ceTexnyYgaGL39LlZESEyGxMc+UVwuUNofSC0aYJ8HOSZXtiVJjrOEBgEqNO7vUelx0ax6n4aAqtzGRhj1DbjVEoSjUgtvHn0gxjw6Tp3nAjDu0c2eAScwCOTdEDLD+xLgbqLkVCyQertKnjYRoN/V+NzgPb3lA9V6xDsmP7OxjU1qxoNvTEBP3RIvSFtlPNjpSU02jMIoB56cP614Sy956Mm9+K/oTjApGYI18yowkaCvtk/3TxJ1c1ixdsLP5KasZEwru6NATOmKnEFH8/XI/m/A2GMT2FO+qNXH1Iq/fF1hXWZOyxsjW54hwTlDr2ZqP+bD8K4d6kz9lQyWjnpSYafXxQEQcDjCEuYXq2LWe1ldB8US/NjvtQYsQZ3w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Page Detective will be using get_vma_name() that is currently used by fs/proc to show names of VMAs in /proc//smaps for example. Move this function to mm/vma.c, and make it accessible by modules. Signed-off-by: Pasha Tatashin --- fs/proc/task_mmu.c | 61 ---------------------------------------------- include/linux/fs.h | 3 +++ mm/vma.c | 60 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 61 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index e52bd96137a6..b28c42b7a591 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -240,67 +240,6 @@ static int do_maps_open(struct inode *inode, struct file *file, sizeof(struct proc_maps_private)); } -static void get_vma_name(struct vm_area_struct *vma, - const struct path **path, - const char **name, - const char **name_fmt) -{ - struct anon_vma_name *anon_name = vma->vm_mm ? anon_vma_name(vma) : NULL; - - *name = NULL; - *path = NULL; - *name_fmt = NULL; - - /* - * Print the dentry name for named mappings, and a - * special [heap] marker for the heap: - */ - if (vma->vm_file) { - /* - * If user named this anon shared memory via - * prctl(PR_SET_VMA ..., use the provided name. - */ - if (anon_name) { - *name_fmt = "[anon_shmem:%s]"; - *name = anon_name->name; - } else { - *path = file_user_path(vma->vm_file); - } - return; - } - - if (vma->vm_ops && vma->vm_ops->name) { - *name = vma->vm_ops->name(vma); - if (*name) - return; - } - - *name = arch_vma_name(vma); - if (*name) - return; - - if (!vma->vm_mm) { - *name = "[vdso]"; - return; - } - - if (vma_is_initial_heap(vma)) { - *name = "[heap]"; - return; - } - - if (vma_is_initial_stack(vma)) { - *name = "[stack]"; - return; - } - - if (anon_name) { - *name_fmt = "[anon:%s]"; - *name = anon_name->name; - return; - } -} - static void show_vma_header_prefix(struct seq_file *m, unsigned long start, unsigned long end, vm_flags_t flags, unsigned long long pgoff, diff --git a/include/linux/fs.h b/include/linux/fs.h index 3559446279c1..a25b72397af5 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3474,6 +3474,9 @@ void setattr_copy(struct mnt_idmap *, struct inode *inode, extern int file_update_time(struct file *file); +void get_vma_name(struct vm_area_struct *vma, const struct path **path, + const char **name, const char **name_fmt); + static inline bool vma_is_dax(const struct vm_area_struct *vma) { return vma->vm_file && IS_DAX(vma->vm_file->f_mapping->host); diff --git a/mm/vma.c b/mm/vma.c index 7621384d64cf..1bd589fbc3c7 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -2069,3 +2069,63 @@ void mm_drop_all_locks(struct mm_struct *mm) mutex_unlock(&mm_all_locks_mutex); } + +void get_vma_name(struct vm_area_struct *vma, const struct path **path, + const char **name, const char **name_fmt) +{ + struct anon_vma_name *anon_name = vma->vm_mm ? anon_vma_name(vma) : NULL; + + *name = NULL; + *path = NULL; + *name_fmt = NULL; + + /* + * Print the dentry name for named mappings, and a + * special [heap] marker for the heap: + */ + if (vma->vm_file) { + /* + * If user named this anon shared memory via + * prctl(PR_SET_VMA ..., use the provided name. + */ + if (anon_name) { + *name_fmt = "[anon_shmem:%s]"; + *name = anon_name->name; + } else { + *path = file_user_path(vma->vm_file); + } + return; + } + + if (vma->vm_ops && vma->vm_ops->name) { + *name = vma->vm_ops->name(vma); + if (*name) + return; + } + + *name = arch_vma_name(vma); + if (*name) + return; + + if (!vma->vm_mm) { + *name = "[vdso]"; + return; + } + + if (vma_is_initial_heap(vma)) { + *name = "[heap]"; + return; + } + + if (vma_is_initial_stack(vma)) { + *name = "[stack]"; + return; + } + + if (anon_name) { + *name_fmt = "[anon:%s]"; + *name = anon_name->name; + return; + } +} +EXPORT_SYMBOL_GPL(get_vma_name);