From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09EE4C433DF for ; Wed, 26 Aug 2020 12:53:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4794D208E4 for ; Wed, 26 Aug 2020 12:53:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4794D208E4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C6BFA6B0005; Wed, 26 Aug 2020 08:53:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C1ADC6B0006; Wed, 26 Aug 2020 08:53:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B0A3D6B0007; Wed, 26 Aug 2020 08:53:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0163.hostedemail.com [216.40.44.163]) by kanga.kvack.org (Postfix) with ESMTP id 9C0C26B0005 for ; Wed, 26 Aug 2020 08:53:41 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 4E3CA8249980 for ; Wed, 26 Aug 2020 12:53:41 +0000 (UTC) X-FDA: 77192711442.26.wax92_100f9df27064 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id D54EB1804B65C for ; Wed, 26 Aug 2020 12:53:39 +0000 (UTC) X-HE-Tag: wax92_100f9df27064 X-Filterd-Recvd-Size: 14710 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Wed, 26 Aug 2020 12:53:36 +0000 (UTC) Received: from bogon.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dx+MVIW0ZfSj4OAA--.1019S2; Wed, 26 Aug 2020 20:53:28 +0800 (CST) From: Jinyang He To: Huacai Chen , Jiaxun Yang , Andrew Morton Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Tiezhu Yang , Xuefeng Li Subject: [PATCH] MIPS: Loongson: Fix complie errors without CONFIG_SMP Date: Wed, 26 Aug 2020 20:53:27 +0800 Message-Id: <1598446407-8845-1-git-send-email-hejinyang@loongson.cn> X-Mailer: git-send-email 2.1.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-CM-TRANSID:AQAAf9Dx+MVIW0ZfSj4OAA--.1019S2 X-Coremail-Antispam: 1UD129KBjvJXoWfGryUKw15ZryDAry5JF17GFg_yoWkZw4rpF srAr1kGF48WryUArZ5A39Y9ry3Xwn5GrW2y3yj9ry3u3ZIq3WUJrs3Kr1avr18JF4vk3Wx WFZxWr1fWr12yw7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkv14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY02Avz4vE14v_Xr1l 42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJV WUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAK I48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r 4UMIIF0xvE42xK8VAvwI8IcIk0rVWrJr0_WFyUJwCI42IY6I8E87Iv67AKxVWUJVW8JwCI 42IY6I8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x0JU6wZcUUUUU= X-CM-SenderInfo: pkhmx0p1dqwqxorr0wxvrqhubq/ X-Rspamd-Queue-Id: D54EB1804B65C X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Machine as follows, [ 0.000000] MIPS: machine is loongson,loongson64c-4core-ls7a If SMP if off, error as follows: 0x0: In file included from ./include/linux/gfp.h:9:0, from ./include/linux/xarray.h:14, from ./include/linux/radix-tree.h:18, from ./include/linux/fs.h:15, from ./include/linux/compat.h:17, from arch/mips/kernel/asm-offsets.c:12: ./include/linux/topology.h: In function =E2=80=98numa_node_id=E2=80=99: ./include/linux/topology.h:119:2: error: implicit declaration of function= =E2=80=98cpu_logical_map=E2=80=99 [-Werror=3Dimplicit-function-declarati= on] return cpu_to_node(raw_smp_processor_id()); ^ In uniprocessor machines cpu_to_node(cpu) values 0. arch/mips/include/asm/mach-loongson64/topology.h -> 0x0 And then errors follows, 0x1: In file included from ./arch/mips/include/asm/mach-loongson64/topology.h:= 5:0, from ./arch/mips/include/asm/topology.h:11, from ./include/linux/topology.h:36, from ./include/linux/gfp.h:9, from ./include/linux/xarray.h:14, from ./include/linux/radix-tree.h:18, from ./include/linux/fs.h:15, from ./include/linux/compat.h:17, from arch/mips/kernel/asm-offsets.c:12: ./arch/mips/include/asm/smp.h:28:44: error: macro "raw_smp_processor_id" = passed 1 arguments, but takes just 0 static inline int raw_smp_processor_id(void) ^ ./arch/mips/include/asm/smp.h:29:1: error: expected =E2=80=98=3D=E2=80=99= , =E2=80=98,=E2=80=99, =E2=80=98;=E2=80=99, =E2=80=98asm=E2=80=99 or =E2=80= =98__attribute__=E2=80=99 before =E2=80=98{=E2=80=99 token { ^ ./arch/mips/include/asm/smp.h:38:0: warning: "raw_smp_processor_id" redef= ined #define raw_smp_processor_id raw_smp_processor_id ^ In file included from ./arch/mips/include/asm/cpu-type.h:12:0, from ./arch/mips/include/asm/timex.h:19, from ./include/linux/timex.h:65, from ./include/linux/time32.h:13, from ./include/linux/time.h:73, from ./include/linux/compat.h:10, from arch/mips/kernel/asm-offsets.c:12: ./include/linux/smp.h:160:0: note: this is the location of the previous d= efinition #define raw_smp_processor_id() 0 ^ 0x2: In file included from ./arch/mips/include/asm/mach-loongson64/topology.h:= 5:0, from ./arch/mips/include/asm/topology.h:11, from ./include/linux/topology.h:36, from ./include/linux/gfp.h:9, from ./include/linux/xarray.h:14, from ./include/linux/radix-tree.h:18, from ./include/linux/fs.h:15, from ./include/linux/compat.h:17, from arch/mips/kernel/asm-offsets.c:12: ./arch/mips/include/asm/smp.h:42:29: error: =E2=80=98CONFIG_MIPS_NR_CPU_N= R_MAP=E2=80=99 undeclared here (not in a function) extern int __cpu_number_map[CONFIG_MIPS_NR_CPU_NR_MAP]; ^ 0x3: ./arch/mips/include/asm/smp.h:69:20: error: redefinition of =E2=80=98smp_= send_reschedule=E2=80=99 static inline void smp_send_reschedule(int cpu) ^ In file included from ./arch/mips/include/asm/cpu-type.h:12:0, from ./arch/mips/include/asm/timex.h:19, from ./include/linux/timex.h:65, from ./include/linux/time32.h:13, from ./include/linux/time.h:73, from ./include/linux/compat.h:10, from arch/mips/kernel/asm-offsets.c:12: ./include/linux/smp.h:167:20: note: previous definition of =E2=80=98smp_s= end_reschedule=E2=80=99 was here static inline void smp_send_reschedule(int cpu) { } ^ In file included from ./arch/mips/include/asm/mach-loongson64/topology.h:= 5:0, from ./arch/mips/include/asm/topology.h:11, from ./include/linux/topology.h:36, from ./include/linux/gfp.h:9, from ./include/linux/xarray.h:14, from ./include/linux/radix-tree.h:18, from ./include/linux/fs.h:15, from ./include/linux/compat.h:17, from arch/mips/kernel/asm-offsets.c:12: ./arch/mips/include/asm/smp.h: In function =E2=80=98smp_send_reschedule=E2= =80=99: 0x4: ./arch/mips/include/asm/smp.h:73:8: error: dereferencing pointer to incom= plete type mp_ops->send_ipi_single(cpu, SMP_RESCHEDULE_YOURSELF); ^ ./arch/mips/include/asm/smp.h: In function =E2=80=98kexec_nonboot_cpu=E2=80= =99: ./arch/mips/include/asm/smp.h:99:15: error: dereferencing pointer to inco= mplete type return mp_ops->kexec_nonboot_cpu(); ^ ./arch/mips/include/asm/smp.h:99:2: warning: =E2=80=98return=E2=80=99 wit= h a value, in function returning void return mp_ops->kexec_nonboot_cpu(); ^ ./arch/mips/include/asm/smp.h: In function =E2=80=98kexec_nonboot_cpu_fun= c=E2=80=99: ./arch/mips/include/asm/smp.h:106:15: error: dereferencing pointer to inc= omplete type return mp_ops->kexec_nonboot_cpu; ^ ./arch/mips/include/asm/smp.h: In function =E2=80=98arch_send_call_functi= on_single_ipi=E2=80=99: ./arch/mips/include/asm/smp.h:128:8: error: dereferencing pointer to inco= mplete type mp_ops->send_ipi_single(cpu, SMP_CALL_FUNCTION); ^ ./arch/mips/include/asm/smp.h: In function =E2=80=98arch_send_call_functi= on_ipi_mask=E2=80=99: ./arch/mips/include/asm/smp.h:135:8: error: dereferencing pointer to inco= mplete type mp_ops->send_ipi_mask(mask, SMP_CALL_FUNCTION); ^ For 0x2, CONFIG_MIPS_NR_CPU_NR_MAP can't depend on SMP, otherwise its ranges not include 1. arch/mips/Kconfig -> 0x2 For 0x1, 0x3, 0x4 can be fixed by checking CONFIG_SMP, arch/mips/include/asm/smp.h -> 0x1, 0x3, 0x4 After fix them, errors as follows, 0x5: mm/percpu.o: In function `setup_per_cpu_areas': (.init.text+0xa00): multiple definition of `setup_per_cpu_areas' arch/mips/mm/init.o:(.init.text+0xa8): first defined here Normally, setup_per_cpu_areas is defined at arch/mips/mm/init.c with CONFIG_HAVE_SETUP_PER_CPU_AREA. mm/percpu.c defines it with CONFIG_SMP && !CONFIG_HAVE_SETUP_PER_CPU_AREA || !CONFIG_SMP. Obviously, !CONFIG_SMP causes the multiple definition. arch/mips/mm/init.c -> 0x5 New errors as follows, 0x6: mm/page_alloc.o: In function `get_page_from_freelist': page_alloc.c:(.text+0x4734): undefined reference to `node_reclaim_distanc= e' page_alloc.c:(.text+0x473c): undefined reference to `node_reclaim_distanc= e' mm/page_alloc.c -> 0x6 Now, it can complie right and loongson3-llsc-check returns success. And it can start success. Origin(use SMP): $ lscpu Architecture: mips64 Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 1 Core(s) per socket: 4 Socket(s): 1 NUMA node(s): 1 Model name: Loongson-3A R3 (Loongson-3A3000) @ 1450MHz CPU max MHz: 1450.0000 CPU min MHz: 725.0000 L1d cache: 64K L1i cache: 64K L2 cache: 256K L3 cache: 2048K NUMA node0 CPU(s): 0-3 Now(not use SMP): $ lscpu Architecture: mips64 Byte Order: Little Endian CPU(s): 1 On-line CPU(s) list: 0 Thread(s) per core: 1 Core(s) per socket: 1 Socket(s): 1 NUMA node(s): 1 L1d cache: 64K L1i cache: 64K L2 cache: 2048K NUMA node0 CPU(s): 0 Signed-off-by: Jinyang He --- arch/mips/Kconfig | 2 +- arch/mips/include/asm/mach-loongson64/topology.h | 4 ++++ arch/mips/include/asm/smp.h | 20 ++++++++++++++++++= ++ arch/mips/mm/init.c | 2 +- mm/page_alloc.c | 6 +++--- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index c95fa3a..c3b2864 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -2876,7 +2876,7 @@ config MIPS_NR_CPU_NR_MAP_1024 =20 config MIPS_NR_CPU_NR_MAP int - depends on SMP + default 1 if !SMP default 1024 if MIPS_NR_CPU_NR_MAP_1024 default NR_CPUS if !MIPS_NR_CPU_NR_MAP_1024 =20 diff --git a/arch/mips/include/asm/mach-loongson64/topology.h b/arch/mips= /include/asm/mach-loongson64/topology.h index 3414a1f..2157fe1 100644 --- a/arch/mips/include/asm/mach-loongson64/topology.h +++ b/arch/mips/include/asm/mach-loongson64/topology.h @@ -4,7 +4,11 @@ =20 #ifdef CONFIG_NUMA =20 +#ifdef CONFIG_SMP #define cpu_to_node(cpu) (cpu_logical_map(cpu) >> 2) +#else +#define cpu_to_node(cpu) 0 +#endif =20 extern cpumask_t __node_cpumask[]; #define cpumask_of_node(node) (&__node_cpumask[node]) diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h index 5d9ff61..8ea3733 100644 --- a/arch/mips/include/asm/smp.h +++ b/arch/mips/include/asm/smp.h @@ -25,6 +25,7 @@ extern cpumask_t cpu_sibling_map[]; extern cpumask_t cpu_core_map[]; extern cpumask_t cpu_foreign_map[]; =20 +#ifdef CONFIG_SMP static inline int raw_smp_processor_id(void) { #if defined(__VDSO__) @@ -36,6 +37,7 @@ static inline int raw_smp_processor_id(void) #endif } #define raw_smp_processor_id raw_smp_processor_id +#endif =20 /* Map from cpu id to sequential logical cpu number. This will only not be idempotent when cpus failed to come on-line. */ @@ -66,12 +68,14 @@ extern void calculate_cpu_foreign_map(void); * it goes straight through and wastes no time serializing * anything. Worst case is that we lose a reschedule ... */ +#ifdef CONFIG_SMP static inline void smp_send_reschedule(int cpu) { extern const struct plat_smp_ops *mp_ops; /* private */ =20 mp_ops->send_ipi_single(cpu, SMP_RESCHEDULE_YOURSELF); } +#endif =20 #ifdef CONFIG_HOTPLUG_CPU static inline int __cpu_disable(void) @@ -92,6 +96,8 @@ extern void play_dead(void); #endif =20 #ifdef CONFIG_KEXEC + +#ifdef CONFIG_SMP static inline void kexec_nonboot_cpu(void) { extern const struct plat_smp_ops *mp_ops; /* private */ @@ -105,6 +111,15 @@ static inline void *kexec_nonboot_cpu_func(void) =20 return mp_ops->kexec_nonboot_cpu; } +#else /* CONFIG_SMP */ +static inline void kexec_nonboot_cpu(void) { } + +static inline void *kexec_nonboot_cpu_func(void) +{ + return NULL; +} +#endif /* CONFIG_SMP */ + #endif =20 /* @@ -121,6 +136,7 @@ int mips_smp_ipi_allocate(const struct cpumask *mask)= ; */ int mips_smp_ipi_free(const struct cpumask *mask); =20 +#ifdef CONFIG_SMP static inline void arch_send_call_function_single_ipi(int cpu) { extern const struct plat_smp_ops *mp_ops; /* private */ @@ -134,5 +150,9 @@ static inline void arch_send_call_function_ipi_mask(c= onst struct cpumask *mask) =20 mp_ops->send_ipi_mask(mask, SMP_CALL_FUNCTION); } +#else /* CONFIG_SMP */ +static inline void arch_send_call_function_single_ipi(int cpu) { } +static inline void arch_send_call_function_ipi_mask(const struct cpumask= *mask) { } +#endif /* CONFIG_SMP */ =20 #endif /* __ASM_SMP_H */ diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c index 6c7bbfe..867bff2 100644 --- a/arch/mips/mm/init.c +++ b/arch/mips/mm/init.c @@ -513,7 +513,7 @@ void __ref free_initmem(void) free_initmem_default(POISON_FREE_INITMEM); } =20 -#ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA +#if defined(CONFIG_HAVE_SETUP_PER_CPU_AREA) && defined(CONFIG_SMP) unsigned long __per_cpu_offset[NR_CPUS] __read_mostly; EXPORT_SYMBOL(__per_cpu_offset); =20 diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 0e2bab4..45a891c 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3635,18 +3635,18 @@ bool zone_watermark_ok_safe(struct zone *z, unsig= ned int order, free_pages); } =20 -#ifdef CONFIG_NUMA +#if defined(CONFIG_NUMA) && defined(CONFIG_SMP) static bool zone_allows_reclaim(struct zone *local_zone, struct zone *zo= ne) { return node_distance(zone_to_nid(local_zone), zone_to_nid(zone)) <=3D node_reclaim_distance; } -#else /* CONFIG_NUMA */ +#else /* CONFIG_NUMA && CONFIG_SMP */ static bool zone_allows_reclaim(struct zone *local_zone, struct zone *zo= ne) { return true; } -#endif /* CONFIG_NUMA */ +#endif /* CONFIG_NUMA && CONFIG_SMP */ =20 /* * The restriction on ZONE_DMA32 as being a suitable zone to use to avoi= d --=20 2.1.0