numa: fix compile error after open NUMA config [2/2]
authorTao Zeng <tao.zeng@amlogic.com>
Wed, 20 Mar 2019 06:20:08 +0000 (14:20 +0800)
committerTao Zeng <tao.zeng@amlogic.com>
Wed, 20 Mar 2019 08:02:39 +0000 (00:02 -0800)
PD#SWPL-5301

Problem:
When open NUMA config on ARM64, there is compile error

Solution:
fix some compile problems

Verify:
p212

Change-Id: I1ae9ef975c680e3e5545186aac9ca2b57597bfe4
Signed-off-by: Tao Zeng <tao.zeng@amlogic.com>
drivers/amlogic/memory_ext/Kconfig
drivers/amlogic/memory_ext/page_trace.c
include/linux/amlogic/page_trace.h
include/linux/mm.h
mm/slab_common.c

index 65fe232..88856a7 100644 (file)
@@ -11,6 +11,7 @@ config AMLOGIC_PAGE_TRACE
        bool "Amlogic trace for page allocate"
        depends on AMLOGIC_MEMORY_EXTEND
        depends on KALLSYMS
+       depends on !NUMA_BALANCING
        default y
        help
                Amlogic page trace will record function address of caller for page
index 1c2f8ba..4350dbc 100644 (file)
 #define DEBUG_PAGE_TRACE       0
 #endif
 
+#ifdef CONFIG_NUMA
+#define COMMON_CALLER_SIZE     64      /* more function names if NUMA */
+#else
 #define COMMON_CALLER_SIZE     32
+#endif
 
 /*
  * this is a driver which will hook during page alloc/free and
@@ -95,6 +99,14 @@ static struct fun_symbol common_func[] __initdata = {
        {"vmalloc",                     1},
        {"__alloc_page_frag",           1},
        {"kmalloc_order",               0},
+#ifdef CONFIG_NUMA
+       {"alloc_pages_current",         1},
+       {"alloc_page_interleave",       1},
+       {"kmalloc_large_node",          1},
+       {"kmem_cache_alloc_node",       1},
+       {"__kmalloc_node",              1},
+       {"alloc_pages_vma",             1},
+#endif
 #ifdef CONFIG_SLUB     /* for some static symbols not exported in headfile */
        {"new_slab",                    0},
        {"slab_alloc",                  0},
@@ -1065,8 +1077,9 @@ void __init page_trace_mem_init(void)
         * flags, you should disable AMLOGIC_PAGE_TRACE or reduce some page
         * flags.
         */
-       BUILD_BUG_ON((__NR_PAGEFLAGS + ZONES_WIDTH) > 32);
-       BUILD_BUG_ON(NODES_WIDTH > 0);
+       BUILD_BUG_ON((__NR_PAGEFLAGS + ZONES_WIDTH +
+                     NODES_WIDTH + SECTIONS_WIDTH +
+                     LAST_CPUPID_SHIFT) > 32);
 #else
        if (page_trace_disable)
                return;
index 7d72430..300e7ef 100644 (file)
@@ -92,7 +92,11 @@ static inline struct page_trace *find_page_base(struct page *page)
 {
        return NULL;
 }
-static unsigned long find_back_trace(void)
+static inline unsigned long find_back_trace(void)
+{
+       return 0;
+}
+static inline unsigned long get_page_trace(struct page *page)
 {
        return 0;
 }
index b36a674..9983415 100644 (file)
@@ -700,13 +700,25 @@ int alloc_set_pte(struct fault_env *fe, struct mem_cgroup *memcg,
  */
 
 /* Page flags: | [SECTION] | [NODE] | ZONE | [LAST_CPUPID] | ... | FLAGS | */
-#define SECTIONS_PGOFF         ((sizeof(unsigned long)*8) - SECTIONS_WIDTH)
-#define NODES_PGOFF            (SECTIONS_PGOFF - NODES_WIDTH)
 #if defined(CONFIG_AMLOGIC_PAGE_TRACE) && defined(CONFIG_64BIT)
-#define ZONES_PGOFF            ((sizeof(unsigned int) * 8) - ZONES_WIDTH)
+/*
+ * We use high 32bit of page->flags for page trace, Make sure:
+ * __NR_PAGEFLAGS    : about 21 bits
+ * ZONES_WIDTH       : about  2 bits, MAX 4 zone types
+ * NODES_WIDTH       : about  2 bits if open CONFIG_NUMA, else 0 bit
+ * SECTIONS_WIDTH    : 0 bit if defined CONFIG_SPARSEMEM_VMEMMAP otherwise 18
+ *                     bits on ARM64
+ * LAST_CPUPID_SHIFT : 0 bit if not define CONFIG_NUMA_BALANCING, otherwise
+ *                     8 + NR_CPUS_BITS
+ * All of these macros should be using less than 32bits in total, otherwise
+ * compile will fail
+ */
+#define SECTIONS_PGOFF         ((sizeof(unsigned int)*8) - SECTIONS_WIDTH)
 #else
-#define ZONES_PGOFF            (NODES_PGOFF - ZONES_WIDTH)
+#define SECTIONS_PGOFF         ((sizeof(unsigned long)*8) - SECTIONS_WIDTH)
 #endif /* CONFIG_AMLOGIC_PAGE_TRACE */
+#define NODES_PGOFF            (SECTIONS_PGOFF - NODES_WIDTH)
+#define ZONES_PGOFF            (NODES_PGOFF - ZONES_WIDTH)
 #define LAST_CPUPID_PGOFF      (ZONES_PGOFF - LAST_CPUPID_WIDTH)
 
 /*
index 45b23eb..f775c43 100644 (file)
@@ -1044,9 +1044,7 @@ static inline void *aml_slub_alloc_large(size_t size, gfp_t flags, int order)
                unsigned long used_pages = PAGE_ALIGN(size) / PAGE_SIZE;
                unsigned long total_pages = 1 << order;
                unsigned long saved = 0;
-       #ifdef CONFIG_AMLOGIC_PAGE_TRACE
-               unsigned long fun;
-       #endif
+               unsigned long fun = 0;
                int i;
 
                /* record how many pages in first page*/