From nobody Fri Nov 22 20:46:51 2024 Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) (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 BDF5F193091 for ; Sat, 16 Nov 2024 17:59:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731779971; cv=none; b=r1j5nCgyVh2ks0FsmuYre4iZyeQQ01otKuK4iCXn441tjGO+e+rjvHPdQH+GF/2oukLZkiOGanfJUUKOBYUb7ar5MrVRcpf6cxILpRDJpt59wup0GQGbF8/Ntr713IwWosAOx/vf4q9bnWqOo2uxaYjZydLp8KL08/WDrRHUDTQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731779971; c=relaxed/simple; bh=lfJrkQU7kDKAcbgAg+MX5GusICFlw92JF3DwO3UuDT0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ra+RoX+kGyPQidKClvNfihNbaE2Xyv5IoartOdSTUJdp8Q8IXn1KYboVMr9P+ZqIVOoZ/YaZpD2Kp1kpZwXpTEb9Jb3hL0HZ+82bjuiKQnZ0TWi8p4e+4oFG3YBVb4xbl4P5ORQR3MoB6bBRoCz4zyMSQCJ74b3jRdVqcCphdfQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=soleen.com; spf=pass smtp.mailfrom=soleen.com; dkim=pass (2048-bit key) header.d=soleen-com.20230601.gappssmtp.com header.i=@soleen-com.20230601.gappssmtp.com header.b=xSLgKRvq; arc=none smtp.client-ip=209.85.222.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=soleen.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=soleen.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=soleen-com.20230601.gappssmtp.com header.i=@soleen-com.20230601.gappssmtp.com header.b="xSLgKRvq" Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-7b15eadee87so132185985a.2 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=vger.kernel.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=xSLgKRvq2J3aFK5p2JVdxbkHbQzrBADD+qUNuUzCr9f7Ryktdoi1aafaEp7jaaG1Ny uwFOpin86TL9/Yd052RzVYfnaJZ/IScJPIhV91qJ89ErkdcuoIiqjIYZSIzg6+jQ3DaN tD0QpS6Kq8l3ocpuZ/aid4OQ59jdZ0QNxCqXL91+gL9z8VvUVcccmvucwmqpYBqKsbrl qka94THxQJyK4RmOAULJ9vSPrSxgOF4XeFlSGU0/6Dnv8UVGYxHb9KVpRq2sjSP4fb/x ScN7lNwuBRug+LnMECmSD1M6HgOnrZIL327Vm9HdbBUuZrp+gn6soQvjPXZiSm2PmOnD Y69w== 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=sg+s6NhvLIi37XUx5QFZP2OOMbCi6NDiZbzJo3l65+YGaJCIZtBhVFk8vSSi5AEq82 kiICqB7Kl+jKwbljD6mZ42NOXsNfJbo6FpfU/Fv8eSs1f+5WR2ecFOhYtqet3Lcju542 G/sIBQ8q6eqwyy3mv3KGK6Dt+lknKypeVdpZZ5yvGss16Sq9aLINrt2w0Ef4w4Cn8Svn 8+3fhi7YlNnyVVTD/ofrBDvToagYEtIQmWrENCsQzxRKQMIiLBlYxvN68KQvJDXnm3oG eDuzvSQriIMhPjwfIDEmHIqcGLt4SvtaIB0p//oYEV6GEH6+DRT1k25dQy74DfgrABoV 5w7g== X-Forwarded-Encrypted: i=1; AJvYcCVvFqdHRPYB7WZeTiORfvpoyykaYBQ50tsjl1MXIHhlRA0RB/1mFhPkVTydBCQ3Dm533jKvVIDI4ujXAmw=@vger.kernel.org X-Gm-Message-State: AOJu0YydGJqYkJjPWtb/FGwNEt5PZMXmY9pM5ZdG1EcoVi8zC2FUe+D8 ZdtPUCvjrqzk2sD6hTP0fffaaBC8dI+ugks1OEZF0OdDkIDcKQbBJ1SjKmj5Gek= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 fi= le *file, sizeof(struct proc_maps_private)); } =20 -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 =3D vma->vm_mm ? anon_vma_name(vma) : NUL= L; - - *name =3D NULL; - *path =3D NULL; - *name_fmt =3D 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 =3D "[anon_shmem:%s]"; - *name =3D anon_name->name; - } else { - *path =3D file_user_path(vma->vm_file); - } - return; - } - - if (vma->vm_ops && vma->vm_ops->name) { - *name =3D vma->vm_ops->name(vma); - if (*name) - return; - } - - *name =3D arch_vma_name(vma); - if (*name) - return; - - if (!vma->vm_mm) { - *name =3D "[vdso]"; - return; - } - - if (vma_is_initial_heap(vma)) { - *name =3D "[heap]"; - return; - } - - if (vma_is_initial_stack(vma)) { - *name =3D "[stack]"; - return; - } - - if (anon_name) { - *name_fmt =3D "[anon:%s]"; - *name =3D 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 *i= node, =20 extern int file_update_time(struct file *file); =20 +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) =20 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 =3D vma->vm_mm ? anon_vma_name(vma) : NUL= L; + + *name =3D NULL; + *path =3D NULL; + *name_fmt =3D 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 =3D "[anon_shmem:%s]"; + *name =3D anon_name->name; + } else { + *path =3D file_user_path(vma->vm_file); + } + return; + } + + if (vma->vm_ops && vma->vm_ops->name) { + *name =3D vma->vm_ops->name(vma); + if (*name) + return; + } + + *name =3D arch_vma_name(vma); + if (*name) + return; + + if (!vma->vm_mm) { + *name =3D "[vdso]"; + return; + } + + if (vma_is_initial_heap(vma)) { + *name =3D "[heap]"; + return; + } + + if (vma_is_initial_stack(vma)) { + *name =3D "[stack]"; + return; + } + + if (anon_name) { + *name_fmt =3D "[anon:%s]"; + *name =3D anon_name->name; + return; + } +} +EXPORT_SYMBOL_GPL(get_vma_name); --=20 2.47.0.338.g60cca15819-goog