// SPDX-License-Identifier: GPL-2.0-only#include<linux/alloc_tag.h>#include<linux/execmem.h>#include<linux/fs.h>#include<linux/gfp.h>#include<linux/kallsyms.h>#include<linux/module.h>#include<linux/mutex.h>#include<linux/compat.h>#include<linux/page_ext.h>#include<linux/pgalloc_tag.h>#include<linux/proc_fs.h>#include<linux/rcupdate.h>#include<linux/seq_buf.h>#include<linux/seq_file.h>#include<linux/string_choices.h>#include<linux/vmalloc.h>#include<linux/kmemleak.h>#include<uapi/linux/alloc_tag.h>#include"internal.h"#include"page_alloc.h"#define ALLOCINFO_FILE_NAME "allocinfo"#define MODULE_ALLOC_TAG_VMAP_SIZE (100000UL * sizeof(struct alloc_tag))#define SECTION_START(NAME) (CODETAG_SECTION_START_PREFIX NAME)#define SECTION_STOP(NAME) (CODETAG_SECTION_STOP_PREFIX NAME)#ifdef CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULTstaticboolmem_profiling_support=true;#elsestaticboolmem_profiling_support;#endif/* * Memory allocation profiling is permanently disabled and cannot be enabled. * Must be called after setup_early_mem_profiling(). */boolmem_alloc_profiling_permanently_disabled(void){return!mem_profiling_support;}staticstructcodetag_type*alloc_tag_cttype;#ifdef CONFIG_ARCH_MODULE_NEEDS_WEAK_PER_CPUDEFINE_PER_CPU(structalloc_tag_counters,_shared_alloc_tag);EXPORT_SYMBOL(_shared_alloc_tag);#endifDEFINE_STATIC_KEY_MAYBE(CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT,mem_alloc_profiling_key);EXPORT_SYMBOL(mem_alloc_profiling_key);DEFINE_STATIC_KEY_FALSE(mem_profiling_compressed);structalloc_tag_kernel_sectionkernel_tags={NULL,0};unsignedlongalloc_tag_ref_mask;intalloc_tag_ref_offs;structallocinfo_private{structcodetag_iteratoriter;structcodetag_iteratorreported_iter;boolprint_header;structallocinfo_filterfilter;/* ioctl uses a separate iterator not to interfere with reads */structcodetag_iteratorioctl_iter;boolpositioned;/* seq_open_private() sets to 0 */structmutexioctl_lock;};staticvoid*allocinfo_start(structseq_file*m,loff_t*pos){structallocinfo_private*priv;loff_tnode=*pos;priv=(structallocinfo_private*)m->private;codetag_lock_module_list(alloc_tag_cttype);