Skip to content
Snippets Groups Projects
Select Git revision
  • 0433ffbe47d66c5c561b54340ee47adf8826bcc4
  • openEuler-1.0-LTS default protected
  • openEuler-22.09
  • OLK-5.10
  • openEuler-22.03-LTS
  • openEuler-22.03-LTS-Ascend
  • master
  • openEuler-22.03-LTS-LoongArch-NW
  • openEuler-22.09-HCK
  • openEuler-20.03-LTS-SP3
  • openEuler-21.09
  • openEuler-21.03
  • openEuler-20.09
  • 4.19.90-2210.5.0
  • 5.10.0-123.0.0
  • 5.10.0-60.63.0
  • 5.10.0-60.62.0
  • 4.19.90-2210.4.0
  • 5.10.0-121.0.0
  • 5.10.0-60.61.0
  • 4.19.90-2210.3.0
  • 5.10.0-60.60.0
  • 5.10.0-120.0.0
  • 5.10.0-60.59.0
  • 5.10.0-119.0.0
  • 4.19.90-2210.2.0
  • 4.19.90-2210.1.0
  • 5.10.0-118.0.0
  • 5.10.0-106.19.0
  • 5.10.0-60.58.0
  • 4.19.90-2209.6.0
  • 5.10.0-106.18.0
  • 5.10.0-106.17.0
33 results

builtin-kmem.c

Blame
  • builtin-kmem.c 17.86 KiB
    #include "builtin.h"
    #include "perf.h"
    
    #include "util/evlist.h"
    #include "util/evsel.h"
    #include "util/util.h"
    #include "util/cache.h"
    #include "util/symbol.h"
    #include "util/thread.h"
    #include "util/header.h"
    #include "util/session.h"
    #include "util/tool.h"
    
    #include "util/parse-options.h"
    #include "util/trace-event.h"
    
    #include "util/debug.h"
    
    #include <linux/rbtree.h>
    
    struct alloc_stat;
    typedef int (*sort_fn_t)(struct alloc_stat *, struct alloc_stat *);
    
    static int			alloc_flag;
    static int			caller_flag;
    
    static int			alloc_lines = -1;
    static int			caller_lines = -1;
    
    static bool			raw_ip;
    
    static int			*cpunode_map;
    static int			max_cpu_num;
    
    struct alloc_stat {
    	u64	call_site;
    	u64	ptr;
    	u64	bytes_req;
    	u64	bytes_alloc;
    	u32	hit;
    	u32	pingpong;
    
    	short	alloc_cpu;
    
    	struct rb_node node;
    };
    
    static struct rb_root root_alloc_stat;
    static struct rb_root root_alloc_sorted;
    static struct rb_root root_caller_stat;
    static struct rb_root root_caller_sorted;
    
    static unsigned long total_requested, total_allocated;
    static unsigned long nr_allocs, nr_cross_allocs;
    
    #define PATH_SYS_NODE	"/sys/devices/system/node"
    
    static int init_cpunode_map(void)
    {
    	FILE *fp;
    	int i, err = -1;
    
    	fp = fopen("/sys/devices/system/cpu/kernel_max", "r");
    	if (!fp) {
    		max_cpu_num = 4096;
    		return 0;
    	}
    
    	if (fscanf(fp, "%d", &max_cpu_num) < 1) {
    		pr_err("Failed to read 'kernel_max' from sysfs");