/* SPDX-License-Identifier: GPL-2.0-or-later */ /* Internal procfs definitions * * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. * Written by David Howells (dhowells@redhat.com)
*/
/* * This is not completely implemented yet. The idea is to * create an in-memory tree (like the actual /proc filesystem * tree) of these proc_dir_entries, so that we can dynamically * add new files to /proc. * * parent/subdir are used for the directory structure (every /proc file has a * parent, but "subdir" is empty for all non-directory entries). * subdir_node is used to build the rb tree "subdir" of the parent.
*/ struct proc_dir_entry { /* * number of callers into module in progress; * negative -> it's going away RSN
*/
atomic_t in_use;
refcount_t refcnt; struct list_head pde_openers; /* who did ->open, but not ->release */ /* protects ->pde_openers and all struct pde_opener instances */
spinlock_t pde_unload_lock; struct completion *pde_unload_completion; conststruct inode_operations *proc_iops; union { conststruct proc_ops *proc_ops; conststruct file_operations *proc_dir_ops;
}; union { conststruct seq_operations *seq_ops; int (*single_show)(struct seq_file *, void *);
};
proc_write_t write; void *data; unsignedint state_size; unsignedint low_ino;
nlink_t nlink;
kuid_t uid;
kgid_t gid;
loff_t size; struct proc_dir_entry *parent; struct rb_root subdir; struct rb_node subdir_node; char *name;
umode_t mode;
u8 flags;
u8 namelen; char inline_name[];
} __randomize_layout;
unsigned name_to_int(conststruct qstr *qstr); /* * Offset of the first process in the /proc root directory..
*/ #define FIRST_PROCESS_ENTRY 256
/* Worst case buffer size needed for holding an integer. */ #define PROC_NUMBUF 13
#ifdef CONFIG_PAGE_MAPCOUNT /** * folio_precise_page_mapcount() - Number of mappings of this folio page. * @folio: The folio. * @page: The page. * * The number of present user page table entries that reference this page * as tracked via the RMAP: either referenced directly (PTE) or as part of * a larger area that covers this page (e.g., PMD). * * Use this function only for the calculation of existing statistics * (USS, PSS, mapcount_max) and for debugging purposes (/proc/kpagecount). * * Do not add new users. * * Returns: The number of mappings of this folio page. 0 for * folios that are not mapped to user space or are not tracked via the RMAP * (e.g., shared zeropage).
*/ staticinlineint folio_precise_page_mapcount(struct folio *folio, struct page *page)
{ int mapcount = atomic_read(&page->_mapcount) + 1;
if (page_mapcount_is_type(mapcount))
mapcount = 0; if (folio_test_large(folio))
mapcount += folio_entire_mapcount(folio);
/** * folio_average_page_mapcount() - Average number of mappings per page in this * folio * @folio: The folio. * * The average number of user page table entries that reference each page in * this folio as tracked via the RMAP: either referenced directly (PTE) or * as part of a larger area that covers this page (e.g., PMD). * * The average is calculated by rounding to the nearest integer; however, * to avoid duplicated code in current callers, the average is at least * 1 if any page of the folio is mapped. * * Returns: The average number of mappings per page in this folio.
*/ staticinlineint folio_average_page_mapcount(struct folio *folio)
{ int mapcount, entire_mapcount, avg;
if (!folio_test_large(folio)) return atomic_read(&folio->_mapcount) + 1;
externconststruct dentry_operations proc_net_dentry_ops; staticinlinevoid pde_force_lookup(struct proc_dir_entry *pde)
{ /* /proc/net/ entries can be changed under us by setns(CLONE_NEWNET) */
pde->flags |= PROC_ENTRY_FORCE_LOOKUP;
}
/* * Add a new procfs dentry that can't serve as a mountpoint. That should * encompass anything that is ephemeral and can just disappear while the * process is still around.
*/ staticinlinestruct dentry *proc_splice_unmountable(struct inode *inode, struct dentry *dentry, conststruct dentry_operations *d_ops)
{
dont_mount(dentry); return d_splice_alias_ops(inode, dentry, d_ops);
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.