[PATCH] mm: Move HOLES_IN_ZONE into mm

2021-04-17 Thread Kefeng Wang
commit a55749639dc1 ("ia64: drop marked broken DISCONTIGMEM and 
VIRTUAL_MEM_MAP")
drop VIRTUAL_MEM_MAP, so there is no need HOLES_IN_ZONE on ia64.

Also move HOLES_IN_ZONE into mm/Kconfig, select it if architecture needs
this feature.

Signed-off-by: Kefeng Wang 
---
 arch/arm64/Kconfig | 4 +---
 arch/ia64/Kconfig  | 3 ---
 arch/mips/Kconfig  | 3 ---
 mm/Kconfig | 3 +++
 4 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index f0b17d758912..3c5a53e0db91 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -202,6 +202,7 @@ config ARM64
select HAVE_KPROBES
select HAVE_KRETPROBES
select HAVE_GENERIC_VDSO
+   select HOLES_IN_ZONE
select IOMMU_DMA if IOMMU_SUPPORT
select IRQ_DOMAIN
select IRQ_FORCED_THREADING
@@ -1053,9 +1054,6 @@ config NEED_PER_CPU_EMBED_FIRST_CHUNK
def_bool y
depends on NUMA
 
-config HOLES_IN_ZONE
-   def_bool y
-
 source "kernel/Kconfig.hz"
 
 config ARCH_SPARSEMEM_ENABLE
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 279252e3e0f7..36499e99102d 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -308,9 +308,6 @@ config NODES_SHIFT
  MAX_NUMNODES will be 2^(This value).
  If in doubt, use the default.
 
-config HOLES_IN_ZONE
-   bool
-
 config HAVE_ARCH_NODEDATA_EXTENSION
def_bool y
depends on NUMA
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 7a174ea61ca5..c6d522fbd67d 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -1233,9 +1233,6 @@ config HAVE_PLAT_MEMCPY
 config ISA_DMA_API
bool
 
-config HOLES_IN_ZONE
-   bool
-
 config SYS_SUPPORTS_RELOCATABLE
bool
help
diff --git a/mm/Kconfig b/mm/Kconfig
index a8a367c30053..afc57cbf1cea 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -128,6 +128,9 @@ config HAVE_FAST_GUP
depends on MMU
bool
 
+config HOLES_IN_ZONE
+   bool
+
 # Don't discard allocated memory used to track "memory" and "reserved" 
memblocks
 # after early boot, so it can still be used to test for validity of memory.
 # Also, memblocks are updated with memory hot(un)plug.
-- 
2.26.2



Re: [PATCH v6] RISC-V: enable XIP

2021-03-31 Thread Kefeng Wang
Hi,some error when enable XIP_KERNEL config,ARCH_HAS_STRICT_KERNEL_RWX 
should disable when enable XIP_KERNEL,


but there

riscv64-linux-ld: section .data LMA [0080,008cd37f] 
overlaps section .rodata LMA [00706bc0,0085dd67]
riscv64-linux-ld: section .pci_fixup LMA 
[0085dd68,00861397] overlaps section .data LMA 
[0080,008cd37f]

riscv64-linux-ld: arch/riscv/mm/init.o: in function `.L138':
init.c:(.text+0x232): undefined reference to `__init_text_begin'
riscv64-linux-ld: arch/riscv/mm/init.o: in function 
`protect_kernel_text_data':

init.c:(.text+0x23a): undefined reference to `__init_data_begin'
riscv64-linux-ld: init.c:(.text+0x28c): undefined reference to 
`__init_text_begin'
riscv64-linux-ld: init.c:(.text+0x2a0): undefined reference to 
`__init_data_begin'


On 2021/3/22 8:12, Vitaly Wool wrote:

Introduce XIP (eXecute In Place) support for RISC-V platforms.
It allows code to be executed directly from non-volatile storage
directly addressable by the CPU, such as QSPI NOR flash which can
be found on many RISC-V platforms. This makes way for significant
optimization of RAM footprint. The XIP kernel is not compressed
since it has to run directly from flash, so it will occupy more
space on the non-volatile storage. The physical flash address used
to link the kernel object files and for storing it has to be known
at compile time and is represented by a Kconfig option.

XIP on RISC-V will for the time being only work on MMU-enabled
kernels.

Signed-off-by: Vitaly Wool 

---

Changes in v2:
- dedicated macro for XIP address fixup when MMU is not enabled yet
   o both for 32-bit and 64-bit RISC-V
- SP is explicitly set to a safe place in RAM before __copy_data call
- removed redundant alignment requirements in vmlinux-xip.lds.S
- changed long -> uintptr_t typecast in __XIP_FIXUP macro.
Changes in v3:
- rebased against latest for-next
- XIP address fixup macro now takes an argument
- SMP related fixes
Changes in v4:
- rebased against the current for-next
- less #ifdef's in C/ASM code
- dedicated XIP_FIXUP_OFFSET assembler macro in head.S
- C-specific definitions moved into #ifndef __ASSEMBLY__
- Fixed multi-core boot
Changes in v5:
- fixed build error for non-XIP kernels
Changes in v6:
- XIP_PHYS_RAM_BASE config option renamed to PHYS_RAM_BASE
- added PHYS_RAM_BASE_FIXED config flag to allow usage of
   PHYS_RAM_BASE in non-XIP configurations if needed
- XIP_FIXUP macro rewritten with a tempoarary variable to avoid side
   effects
- fixed crash for non-XIP kernels that don't use built-in DTB

  arch/riscv/Kconfig  |  49 ++-
  arch/riscv/Makefile |   8 +-
  arch/riscv/boot/Makefile|  13 +++
  arch/riscv/include/asm/pgtable.h|  65 --
  arch/riscv/kernel/cpu_ops_sbi.c |  11 ++-
  arch/riscv/kernel/head.S|  49 ++-
  arch/riscv/kernel/head.h|   3 +
  arch/riscv/kernel/setup.c   |   8 +-
  arch/riscv/kernel/vmlinux-xip.lds.S | 132 
  arch/riscv/kernel/vmlinux.lds.S |   6 ++
  arch/riscv/mm/init.c| 100 +++--
  11 files changed, 426 insertions(+), 18 deletions(-)
  create mode 100644 arch/riscv/kernel/vmlinux-xip.lds.S

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 8ea60a0a19ae..bd6f82240c34 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -441,7 +441,7 @@ config EFI_STUB
  
  config EFI

bool "UEFI runtime support"
-   depends on OF
+   depends on OF && !XIP_KERNEL
select LIBFDT
select UCS2_STRING
select EFI_PARAMS_FROM_FDT
@@ -465,11 +465,56 @@ config STACKPROTECTOR_PER_TASK
def_bool y
depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_TLS
  
+config PHYS_RAM_BASE_FIXED

+   bool "Explicitly specified physical RAM address"
+   default n
+
+config PHYS_RAM_BASE
+   hex "Platform Physical RAM address"
+   depends on PHYS_RAM_BASE_FIXED
+   default "0x8000"
+   help
+ This is the physical address of RAM in the system. It has to be
+ explicitly specified to run early relocations of read-write data
+ from flash to RAM.
+
+config XIP_KERNEL
+   bool "Kernel Execute-In-Place from ROM"
+   depends on MMU
+   select PHYS_RAM_BASE_FIXED
+   help
+ Execute-In-Place allows the kernel to run from non-volatile storage
+ directly addressable by the CPU, such as NOR flash. This saves RAM
+ space since the text section of the kernel is not loaded from flash
+ to RAM.  Read-write sections, such as the data section and stack,
+ are still copied to RAM.  The XIP kernel is not compressed since
+ it has to run directly from flash, so it will take more space to
+ store it.  The flash address used to link the kernel object files,
+ and for storing it, is configuration dependent. 

Re: [PATCH v2] mm: Move mem_init_print_info() into mm_init()

2021-03-30 Thread Kefeng Wang

Hi Andrew, kindly ping

On 2021/3/17 9:52, Kefeng Wang wrote:

mem_init_print_info() is called in mem_init() on each architecture,
and pass NULL argument, so using void argument and move it into mm_init().

Acked-by: Dave Hansen 
Signed-off-by: Kefeng Wang 
---
v2:
- Cleanup 'str' line suggested by Christophe and ACK

  arch/alpha/mm/init.c |  1 -
  arch/arc/mm/init.c   |  1 -
  arch/arm/mm/init.c   |  2 --
  arch/arm64/mm/init.c |  2 --
  arch/csky/mm/init.c  |  1 -
  arch/h8300/mm/init.c |  2 --
  arch/hexagon/mm/init.c   |  1 -
  arch/ia64/mm/init.c  |  1 -
  arch/m68k/mm/init.c  |  1 -
  arch/microblaze/mm/init.c|  1 -
  arch/mips/loongson64/numa.c  |  1 -
  arch/mips/mm/init.c  |  1 -
  arch/mips/sgi-ip27/ip27-memory.c |  1 -
  arch/nds32/mm/init.c |  1 -
  arch/nios2/mm/init.c |  1 -
  arch/openrisc/mm/init.c  |  2 --
  arch/parisc/mm/init.c|  2 --
  arch/powerpc/mm/mem.c|  1 -
  arch/riscv/mm/init.c |  1 -
  arch/s390/mm/init.c  |  2 --
  arch/sh/mm/init.c|  1 -
  arch/sparc/mm/init_32.c  |  2 --
  arch/sparc/mm/init_64.c  |  1 -
  arch/um/kernel/mem.c |  1 -
  arch/x86/mm/init_32.c|  2 --
  arch/x86/mm/init_64.c|  2 --
  arch/xtensa/mm/init.c|  1 -
  include/linux/mm.h   |  2 +-
  init/main.c  |  1 +
  mm/page_alloc.c  | 10 +-
  30 files changed, 7 insertions(+), 42 deletions(-)

diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c
index 3c42b3147fd6..a97650a618f1 100644
--- a/arch/alpha/mm/init.c
+++ b/arch/alpha/mm/init.c
@@ -282,5 +282,4 @@ mem_init(void)
set_max_mapnr(max_low_pfn);
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
memblock_free_all();
-   mem_init_print_info(NULL);
  }
diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
index ce07e697916c..33832e36bdb7 100644
--- a/arch/arc/mm/init.c
+++ b/arch/arc/mm/init.c
@@ -194,7 +194,6 @@ void __init mem_init(void)
  {
memblock_free_all();
highmem_init();
-   mem_init_print_info(NULL);
  }
  
  #ifdef CONFIG_HIGHMEM

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 828a2561b229..7022b7b5c400 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -316,8 +316,6 @@ void __init mem_init(void)
  
  	free_highpages();
  
-	mem_init_print_info(NULL);

-
/*
 * Check boundaries twice: Some fundamental inconsistencies can
 * be detected at build time already.
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 3685e12aba9b..e8f29a0bb2f1 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -491,8 +491,6 @@ void __init mem_init(void)
/* this will put all unused low memory onto the freelists */
memblock_free_all();
  
-	mem_init_print_info(NULL);

-
/*
 * Check boundaries twice: Some fundamental inconsistencies can be
 * detected at build time already.
diff --git a/arch/csky/mm/init.c b/arch/csky/mm/init.c
index 894050a8ce09..bf2004aa811a 100644
--- a/arch/csky/mm/init.c
+++ b/arch/csky/mm/init.c
@@ -107,7 +107,6 @@ void __init mem_init(void)
free_highmem_page(page);
}
  #endif
-   mem_init_print_info(NULL);
  }
  
  void free_initmem(void)

diff --git a/arch/h8300/mm/init.c b/arch/h8300/mm/init.c
index 1f3b345d68b9..f7bf4693e3b2 100644
--- a/arch/h8300/mm/init.c
+++ b/arch/h8300/mm/init.c
@@ -98,6 +98,4 @@ void __init mem_init(void)
  
  	/* this will put all low memory onto the freelists */

memblock_free_all();
-
-   mem_init_print_info(NULL);
  }
diff --git a/arch/hexagon/mm/init.c b/arch/hexagon/mm/init.c
index f2e6c868e477..f01e91e10d95 100644
--- a/arch/hexagon/mm/init.c
+++ b/arch/hexagon/mm/init.c
@@ -55,7 +55,6 @@ void __init mem_init(void)
  {
/*  No idea where this is actually declared.  Seems to evade LXR.  */
memblock_free_all();
-   mem_init_print_info(NULL);
  
  	/*

 *  To-Do:  someone somewhere should wipe out the bootmem map
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index 16d0d7d22657..83280e2df807 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -659,7 +659,6 @@ mem_init (void)
set_max_mapnr(max_low_pfn);
high_memory = __va(max_low_pfn * PAGE_SIZE);
memblock_free_all();
-   mem_init_print_info(NULL);
  
  	/*

 * For fsyscall entrpoints with no light-weight handler, use the 
ordinary
diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
index 14c1e541451c..1759ab875d47 100644
--- a/arch/m68k/mm/init.c
+++ b/arch/m68k/mm/init.c
@@ -153,5 +153,4 @@ void __init mem_init(void)
/* this will put all memory onto the freelists */
memblock_free_all();
init_pointer_tables

Re: [PATCH -next] sched/fair: Move update_nohz_stats() under CONFIG_NO_HZ_COMMON

2021-03-30 Thread Kefeng Wang



On 2021/3/30 20:22, Vincent Guittot wrote:

On Tue, 30 Mar 2021 at 14:06, Kefeng Wang  wrote:

update_nohz_stats() only call _nohz_idle_balance() under CONFIG_NO_HZ_COMMON.

a similar patch has already been sent and reviewed :
20210329144029.29200-1-yuehaib...@huawei.com

ok please ignore it.



[PATCH -next] sched/fair: Move update_nohz_stats() under CONFIG_NO_HZ_COMMON

2021-03-30 Thread Kefeng Wang
update_nohz_stats() only call _nohz_idle_balance() under CONFIG_NO_HZ_COMMON.

Signed-off-by: Kefeng Wang 
---
 kernel/sched/fair.c | 40 ++--
 1 file changed, 18 insertions(+), 22 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 6d73bdbb2d40..2a20ada83cbb 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8395,28 +8395,6 @@ group_type group_classify(unsigned int imbalance_pct,
return group_has_spare;
 }
 
-static bool update_nohz_stats(struct rq *rq)
-{
-#ifdef CONFIG_NO_HZ_COMMON
-   unsigned int cpu = rq->cpu;
-
-   if (!rq->has_blocked_load)
-   return false;
-
-   if (!cpumask_test_cpu(cpu, nohz.idle_cpus_mask))
-   return false;
-
-   if (!time_after(jiffies, READ_ONCE(rq->last_blocked_load_update_tick)))
-   return true;
-
-   update_blocked_averages(cpu);
-
-   return rq->has_blocked_load;
-#else
-   return false;
-#endif
-}
-
 /**
  * update_sg_lb_stats - Update sched_group's statistics for load balancing.
  * @env: The load balancing environment.
@@ -10380,6 +10358,24 @@ void nohz_balance_enter_idle(int cpu)
WRITE_ONCE(nohz.has_blocked, 1);
 }
 
+static bool update_nohz_stats(struct rq *rq)
+{
+   unsigned int cpu = rq->cpu;
+
+   if (!rq->has_blocked_load)
+   return false;
+
+   if (!cpumask_test_cpu(cpu, nohz.idle_cpus_mask))
+   return false;
+
+   if (!time_after(jiffies, READ_ONCE(rq->last_blocked_load_update_tick)))
+   return true;
+
+   update_blocked_averages(cpu);
+
+   return rq->has_blocked_load;
+}
+
 /*
  * Internal function that runs load balance for all idle cpus. The load balance
  * can be a simple update of blocked load or a complete load balance with
-- 
2.26.2



Re: [syzbot] KASAN: slab-out-of-bounds Read in riscv_intc_irq

2021-03-18 Thread Kefeng Wang



On 2021/3/18 22:11, Dmitry Vyukov wrote:

On Thu, Mar 18, 2021 at 1:21 PM Kefeng Wang  wrote:

On 2021/3/14 18:47, Dmitry Vyukov wrote:

On Sun, Mar 14, 2021 at 11:14 AM syzbot
 wrote:

Hello,

syzbot found the following issue on:

HEAD commit:0d7588ab riscv: process: Fix no prototype for arch_dup_tas..
git tree:   git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git 
fixes
console output: https://syzkaller.appspot.com/x/log.txt?x=15a35756d0
kernel config:  https://syzkaller.appspot.com/x/.config?x=81c0b708b31626cc
dashboard link: https://syzkaller.appspot.com/bug?extid=005654dd9b8f26bd4c07
userspace arch: riscv64

Unfortunately, I don't have any reproducer for this issue yet.

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+005654dd9b8f26bd4...@syzkaller.appspotmail.com

==
BUG: KASAN: slab-out-of-bounds in riscv_intc_irq+0x24/0xcc 
drivers/irqchip/irq-riscv-intc.c:24
Read of size 8 at addr ffe00c963bd0 by task kworker/1:1/4388

CPU: 1 PID: 4388 Comm: kworker/1:1 Not tainted 
5.12.0-rc2-syzkaller-00467-g0d7588ab9ef9 #0
Hardware name: riscv-virtio,qemu (DT)
Workqueue: events nsim_dev_trap_report_work
Call Trace:
[] walk_stackframe+0x0/0x23c arch/riscv/kernel/traps.c:201

Allocated by task 76347056:
(stack is not available)

Last potentially related work creation:

There seems to be some issue with riscv stack unwinder.
This does not have stacks.

Hi, could you test with the following  patch about the no stack
issue(from v5.11-rc4), I made a mistake when do some cleanup...

https://lore.kernel.org/linux-riscv/ce5b3533-b75d-c31c-4319-9d29769bb...@huawei.com/T/#t

Hi Kefeng,

Please see:
http://bit.do/syzbot#no-custom-patches

Is a unit-test for this possible? Fuzzing is not a replacement for unit testing.


ok, I mean that the issue about stack unwinder which may cause by my 
previous patch,


if some one want the stack back, it could try the bugfix.


.



Re: [syzbot] KASAN: slab-out-of-bounds Read in riscv_intc_irq

2021-03-18 Thread Kefeng Wang



On 2021/3/14 18:47, Dmitry Vyukov wrote:

On Sun, Mar 14, 2021 at 11:14 AM syzbot
 wrote:

Hello,

syzbot found the following issue on:

HEAD commit:0d7588ab riscv: process: Fix no prototype for arch_dup_tas..
git tree:   git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git 
fixes
console output: https://syzkaller.appspot.com/x/log.txt?x=15a35756d0
kernel config:  https://syzkaller.appspot.com/x/.config?x=81c0b708b31626cc
dashboard link: https://syzkaller.appspot.com/bug?extid=005654dd9b8f26bd4c07
userspace arch: riscv64

Unfortunately, I don't have any reproducer for this issue yet.

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+005654dd9b8f26bd4...@syzkaller.appspotmail.com

==
BUG: KASAN: slab-out-of-bounds in riscv_intc_irq+0x24/0xcc 
drivers/irqchip/irq-riscv-intc.c:24
Read of size 8 at addr ffe00c963bd0 by task kworker/1:1/4388

CPU: 1 PID: 4388 Comm: kworker/1:1 Not tainted 
5.12.0-rc2-syzkaller-00467-g0d7588ab9ef9 #0
Hardware name: riscv-virtio,qemu (DT)
Workqueue: events nsim_dev_trap_report_work
Call Trace:
[] walk_stackframe+0x0/0x23c arch/riscv/kernel/traps.c:201

Allocated by task 76347056:
(stack is not available)

Last potentially related work creation:

There seems to be some issue with riscv stack unwinder.
This does not have stacks.


Hi, could you test with the following  patch about the no stack 
issue(from v5.11-rc4), I made a mistake when do some cleanup...


https://lore.kernel.org/linux-riscv/ce5b3533-b75d-c31c-4319-9d29769bb...@huawei.com/T/#t


"BUG: unable to handle kernel access to user memory in schedule_tail"
does not have proper stacks:
https://syzkaller.appspot.com/bug?id=9de8c24d24004fd5e482555f5ad8314da2fb1cee

I also found 2 riscv reports in "KASAN: use-after-free Read in
idr_for_each (2)":
https://syzkaller.appspot.com/bug?id=7f84dfc3902878befc22e52eb5c7298d0ad70cf3

both don't have any stacks:

==
BUG: KASAN: use-after-free in radix_tree_next_slot
include/linux/radix-tree.h:422 [inline]
BUG: KASAN: use-after-free in idr_for_each+0xf4/0x160 lib/idr.c:202
Read of size 8 at addr ffe010c00878 by task syz-executor.1/4828

CPU: 0 PID: 4828 Comm: syz-executor.1 Not tainted
5.12.0-rc2-syzkaller-00467-g0d7588ab9ef9 #0
Hardware name: riscv-virtio,qemu (DT)
Call Trace:
[] walk_stackframe+0x0/0x23c arch/riscv/kernel/traps.c:201

Allocated by task 4828:
(stack is not available)

Freed by task 4473:
(stack is not available)



---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkal...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

___
linux-riscv mailing list
linux-ri...@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
.



Re: [PATCH v2] mm: Move mem_init_print_info() into mm_init()

2021-03-17 Thread Kefeng Wang



On 2021/3/18 2:48, Dave Hansen wrote:

On 3/16/21 6:52 PM, Kefeng Wang wrote:

mem_init_print_info() is called in mem_init() on each architecture,
and pass NULL argument, so using void argument and move it into mm_init().

Acked-by: Dave Hansen 

It's not a big deal but you might want to say something like:

Acked-by: Dave Hansen  # x86 bits

Just to make it clear that I didn't look at the alpha bits at all. :)

Get it, will be careful, thanks.

.



Re: [PATCH v2] mm: Move mem_init_print_info() into mm_init()

2021-03-16 Thread Kefeng Wang



On 2021/3/17 13:48, Christophe Leroy wrote:



Le 17/03/2021 à 02:52, Kefeng Wang a écrit :

mem_init_print_info() is called in mem_init() on each architecture,
and pass NULL argument, so using void argument and move it into 
mm_init().


Acked-by: Dave Hansen 
Signed-off-by: Kefeng Wang 
---
v2:
- Cleanup 'str' line suggested by Christophe and ACK

  arch/alpha/mm/init.c |  1 -
  arch/arc/mm/init.c   |  1 -
  arch/arm/mm/init.c   |  2 --
  arch/arm64/mm/init.c |  2 --
  arch/csky/mm/init.c  |  1 -
  arch/h8300/mm/init.c |  2 --
  arch/hexagon/mm/init.c   |  1 -
  arch/ia64/mm/init.c  |  1 -
  arch/m68k/mm/init.c  |  1 -
  arch/microblaze/mm/init.c    |  1 -
  arch/mips/loongson64/numa.c  |  1 -
  arch/mips/mm/init.c  |  1 -
  arch/mips/sgi-ip27/ip27-memory.c |  1 -
  arch/nds32/mm/init.c |  1 -
  arch/nios2/mm/init.c |  1 -
  arch/openrisc/mm/init.c  |  2 --
  arch/parisc/mm/init.c    |  2 --
  arch/powerpc/mm/mem.c    |  1 -
  arch/riscv/mm/init.c |  1 -
  arch/s390/mm/init.c  |  2 --
  arch/sh/mm/init.c    |  1 -
  arch/sparc/mm/init_32.c  |  2 --
  arch/sparc/mm/init_64.c  |  1 -
  arch/um/kernel/mem.c |  1 -
  arch/x86/mm/init_32.c    |  2 --
  arch/x86/mm/init_64.c    |  2 --
  arch/xtensa/mm/init.c    |  1 -
  include/linux/mm.h   |  2 +-
  init/main.c  |  1 +
  mm/page_alloc.c  | 10 +-
  30 files changed, 7 insertions(+), 42 deletions(-)




diff --git a/include/linux/mm.h b/include/linux/mm.h
index 89314651dd62..c2e0b3495c5a 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2373,7 +2373,7 @@ extern unsigned long free_reserved_area(void 
*start, void *end,

  int poison, const char *s);
    extern void adjust_managed_page_count(struct page *page, long 
count);

-extern void mem_init_print_info(const char *str);
+extern void mem_init_print_info(void);


Sorry I didn't see that in previous patch.

'extern' keyword is pointless for function prototypes and is 
deprecated, you should remove it.


That said,

Reviewed-by: Christophe Leroy  # focussed on 
powerpc
Thanks, let's wait for more feedback from other architectures, if 
necessary,  will send a new one.


    extern void reserve_bootmem_region(phys_addr_t start, phys_addr_t 
end);

.



Re: [PATCH] mm: Move mem_init_print_info() into mm_init()

2021-03-16 Thread Kefeng Wang

please use v2, sorry for the wrong version.

On 2021/3/17 2:01, kernel test robot wrote:

Hi Kefeng,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on tip/x86/mm]
[also build test ERROR on linus/master v5.12-rc3 next-20210316]
[cannot apply to hnaz-linux-mm/master sparc/master sparc-next/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Kefeng-Wang/mm-Move-mem_init_print_info-into-mm_init/20210316-222501
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
a500fc918f7b8dc3dff2e6c74f3e73e856c18248
config: riscv-randconfig-r031-20210316 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 
50c7504a93fdb90c26870db8c8ea7add895c7725)
reproduce (this is a W=1 build):
 wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
 chmod +x ~/bin/make.cross
 # install riscv cross compiling tool for clang build
 # apt-get install binutils-riscv64-linux-gnu
 # 
https://github.com/0day-ci/linux/commit/0b2c07917fb7f9f87f0e2ecac3a3985155778856
 git remote add linux-review https://github.com/0day-ci/linux
 git fetch --no-tags linux-review 
Kefeng-Wang/mm-Move-mem_init_print_info-into-mm_init/20210316-222501
 git checkout 0b2c07917fb7f9f87f0e2ecac3a3985155778856
 # save the attached .config to linux build tree
 COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

mm/page_alloc.c:3600:15: warning: no previous prototype for function 
'should_fail_alloc_page' [-Wmissing-prototypes]
noinline bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
  ^
mm/page_alloc.c:3600:10: note: declare 'static' if the function is not 
intended to be used outside of this translation unit
noinline bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
 ^
 static

mm/page_alloc.c:7744:3: error: use of undeclared identifier 'str'

str ? ", " : "", str ? str : "");
^
mm/page_alloc.c:7744:20: error: use of undeclared identifier 'str'
str ? ", " : "", str ? str : "");
 ^
mm/page_alloc.c:7744:26: error: use of undeclared identifier 'str'
str ? ", " : "", str ? str : "");
   ^
1 warning and 3 errors generated.


vim +/str +7744 mm/page_alloc.c

7ee3d4e8cd5605 Jiang Liu   2013-07-03  7729
756a025f000919 Joe Perches 2016-03-17  7730 pr_info("Memory: %luK/%luK available 
(%luK kernel code, %luK rwdata, %luK rodata, %luK init, %luK bss, %luK reserved, %luK 
cma-reserved"
7ee3d4e8cd5605 Jiang Liu   2013-07-03  7731  #ifdef CONFIG_HIGHMEM
7ee3d4e8cd5605 Jiang Liu   2013-07-03  7732 ", %luK highmem"
7ee3d4e8cd5605 Jiang Liu   2013-07-03  7733  #endif
7ee3d4e8cd5605 Jiang Liu   2013-07-03  7734 "%s%s)\n",
756a025f000919 Joe Perches 2016-03-17  7735 nr_free_pages() << 
(PAGE_SHIFT - 10),
756a025f000919 Joe Perches 2016-03-17  7736 physpages << 
(PAGE_SHIFT - 10),
7ee3d4e8cd5605 Jiang Liu   2013-07-03  7737 codesize >> 10, datasize >> 
10, rosize >> 10,
7ee3d4e8cd5605 Jiang Liu   2013-07-03  7738 (init_data_size + init_code_size) 
>> 10, bss_size >> 10,
ca79b0c211af63 Arun KS 2018-12-28  7739 (physpages - totalram_pages() 
- totalcma_pages) << (PAGE_SHIFT - 10),
e48322abb061d7 Pintu Kumar 2014-12-18  7740 totalcma_pages << 
(PAGE_SHIFT - 10),
7ee3d4e8cd5605 Jiang Liu   2013-07-03  7741  #ifdef CONFIG_HIGHMEM
ca79b0c211af63 Arun KS 2018-12-28  7742 totalhigh_pages() << 
(PAGE_SHIFT - 10),
7ee3d4e8cd5605 Jiang Liu   2013-07-03  7743  #endif
7ee3d4e8cd5605 Jiang Liu   2013-07-03 @7744 str ? ", " : "", str ? str : 
"");
7ee3d4e8cd5605 Jiang Liu   2013-07-03  7745  }
7ee3d4e8cd5605 Jiang Liu   2013-07-03  7746

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


[PATCH v2] mm: Move mem_init_print_info() into mm_init()

2021-03-16 Thread Kefeng Wang
mem_init_print_info() is called in mem_init() on each architecture,
and pass NULL argument, so using void argument and move it into mm_init().

Acked-by: Dave Hansen 
Signed-off-by: Kefeng Wang 
---
v2:
- Cleanup 'str' line suggested by Christophe and ACK

 arch/alpha/mm/init.c |  1 -
 arch/arc/mm/init.c   |  1 -
 arch/arm/mm/init.c   |  2 --
 arch/arm64/mm/init.c |  2 --
 arch/csky/mm/init.c  |  1 -
 arch/h8300/mm/init.c |  2 --
 arch/hexagon/mm/init.c   |  1 -
 arch/ia64/mm/init.c  |  1 -
 arch/m68k/mm/init.c  |  1 -
 arch/microblaze/mm/init.c|  1 -
 arch/mips/loongson64/numa.c  |  1 -
 arch/mips/mm/init.c  |  1 -
 arch/mips/sgi-ip27/ip27-memory.c |  1 -
 arch/nds32/mm/init.c |  1 -
 arch/nios2/mm/init.c |  1 -
 arch/openrisc/mm/init.c  |  2 --
 arch/parisc/mm/init.c|  2 --
 arch/powerpc/mm/mem.c|  1 -
 arch/riscv/mm/init.c |  1 -
 arch/s390/mm/init.c  |  2 --
 arch/sh/mm/init.c|  1 -
 arch/sparc/mm/init_32.c  |  2 --
 arch/sparc/mm/init_64.c  |  1 -
 arch/um/kernel/mem.c |  1 -
 arch/x86/mm/init_32.c|  2 --
 arch/x86/mm/init_64.c|  2 --
 arch/xtensa/mm/init.c|  1 -
 include/linux/mm.h   |  2 +-
 init/main.c  |  1 +
 mm/page_alloc.c  | 10 +-
 30 files changed, 7 insertions(+), 42 deletions(-)

diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c
index 3c42b3147fd6..a97650a618f1 100644
--- a/arch/alpha/mm/init.c
+++ b/arch/alpha/mm/init.c
@@ -282,5 +282,4 @@ mem_init(void)
set_max_mapnr(max_low_pfn);
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
memblock_free_all();
-   mem_init_print_info(NULL);
 }
diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
index ce07e697916c..33832e36bdb7 100644
--- a/arch/arc/mm/init.c
+++ b/arch/arc/mm/init.c
@@ -194,7 +194,6 @@ void __init mem_init(void)
 {
memblock_free_all();
highmem_init();
-   mem_init_print_info(NULL);
 }
 
 #ifdef CONFIG_HIGHMEM
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 828a2561b229..7022b7b5c400 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -316,8 +316,6 @@ void __init mem_init(void)
 
free_highpages();
 
-   mem_init_print_info(NULL);
-
/*
 * Check boundaries twice: Some fundamental inconsistencies can
 * be detected at build time already.
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 3685e12aba9b..e8f29a0bb2f1 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -491,8 +491,6 @@ void __init mem_init(void)
/* this will put all unused low memory onto the freelists */
memblock_free_all();
 
-   mem_init_print_info(NULL);
-
/*
 * Check boundaries twice: Some fundamental inconsistencies can be
 * detected at build time already.
diff --git a/arch/csky/mm/init.c b/arch/csky/mm/init.c
index 894050a8ce09..bf2004aa811a 100644
--- a/arch/csky/mm/init.c
+++ b/arch/csky/mm/init.c
@@ -107,7 +107,6 @@ void __init mem_init(void)
free_highmem_page(page);
}
 #endif
-   mem_init_print_info(NULL);
 }
 
 void free_initmem(void)
diff --git a/arch/h8300/mm/init.c b/arch/h8300/mm/init.c
index 1f3b345d68b9..f7bf4693e3b2 100644
--- a/arch/h8300/mm/init.c
+++ b/arch/h8300/mm/init.c
@@ -98,6 +98,4 @@ void __init mem_init(void)
 
/* this will put all low memory onto the freelists */
memblock_free_all();
-
-   mem_init_print_info(NULL);
 }
diff --git a/arch/hexagon/mm/init.c b/arch/hexagon/mm/init.c
index f2e6c868e477..f01e91e10d95 100644
--- a/arch/hexagon/mm/init.c
+++ b/arch/hexagon/mm/init.c
@@ -55,7 +55,6 @@ void __init mem_init(void)
 {
/*  No idea where this is actually declared.  Seems to evade LXR.  */
memblock_free_all();
-   mem_init_print_info(NULL);
 
/*
 *  To-Do:  someone somewhere should wipe out the bootmem map
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index 16d0d7d22657..83280e2df807 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -659,7 +659,6 @@ mem_init (void)
set_max_mapnr(max_low_pfn);
high_memory = __va(max_low_pfn * PAGE_SIZE);
memblock_free_all();
-   mem_init_print_info(NULL);
 
/*
 * For fsyscall entrpoints with no light-weight handler, use the 
ordinary
diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
index 14c1e541451c..1759ab875d47 100644
--- a/arch/m68k/mm/init.c
+++ b/arch/m68k/mm/init.c
@@ -153,5 +153,4 @@ void __init mem_init(void)
/* this will put all memory onto the freelists */
memblock_free_all();
init_pointer_tables();
-   mem_init_print_info(NULL);
 }
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm

Re: [PATCH] net: bridge: Fix jump_label config

2021-03-16 Thread Kefeng Wang



On 2021/2/27 4:19, Cong Wang wrote:

On Thu, Feb 25, 2021 at 5:39 PM Kefeng Wang  wrote:


On 2021/2/26 5:22, Cong Wang wrote:

On Wed, Feb 24, 2021 at 8:03 AM Kefeng Wang  wrote:

HAVE_JUMP_LABLE is removed by commit e9666d10a567 ("jump_label: move
'asm goto' support test to Kconfig"), use CONFIG_JUMP_LABLE instead
of HAVE_JUMP_LABLE.

Fixes: 971502d77faa ("bridge: netfilter: unroll NF_HOOK helper in bridge input 
path")
Signed-off-by: Kefeng Wang 

Hmm, why do we have to use a macro here? static_key_false() is defined
in both cases, CONFIG_JUMP_LABEL=y or CONFIG_JUMP_LABEL=n.

It seems that all nf_hooks_needed related are using the macro,

see net/netfilter/core.c and include/linux/netfilter.h,

#ifdef CONFIG_JUMP_LABEL
struct static_key nf_hooks_needed[NFPROTO_NUMPROTO][NF_MAX_HOOKS];
EXPORT_SYMBOL(nf_hooks_needed);
#endif

nf_static_key_inc()/nf_static_key_dec()

Same question: why? Clearly struct static_key is defined in both cases:


Hi Cong,  the nf_hooks_needed is wrapped up by this macro, so this place 
should use it,


or we will meet the build issue,  thanks.

../net/bridge/br_input.c: In function ‘nf_hook_bridge_pre’:
../net/bridge/br_input.c:211:25: error: ‘nf_hooks_needed’ undeclared 
(first use in this function)
  211 |  if 
(!static_key_false(_hooks_needed[NFPROTO_BRIDGE][NF_BR_PRE_ROUTING]))





#else
struct static_key {
 atomic_t enabled;
};
#endif  /* CONFIG_JUMP_LABEL */

Thanks.



[PATCH RESEND] mm: Move mem_init_print_info() into mm_init()

2021-03-16 Thread Kefeng Wang
mem_init_print_info() is called in mem_init() on each architecture,
and pass NULL argument, so using void argument and move it into mm_init().

Signed-off-by: Kefeng Wang 
---

Resend with 'str' line cleanup, and only test on ARM64 qemu.

 arch/alpha/mm/init.c | 1 -
 arch/arc/mm/init.c   | 1 -
 arch/arm/mm/init.c   | 2 --
 arch/arm64/mm/init.c | 2 --
 arch/csky/mm/init.c  | 1 -
 arch/h8300/mm/init.c | 2 --
 arch/hexagon/mm/init.c   | 1 -
 arch/ia64/mm/init.c  | 1 -
 arch/m68k/mm/init.c  | 1 -
 arch/microblaze/mm/init.c| 1 -
 arch/mips/loongson64/numa.c  | 1 -
 arch/mips/mm/init.c  | 1 -
 arch/mips/sgi-ip27/ip27-memory.c | 1 -
 arch/nds32/mm/init.c | 1 -
 arch/nios2/mm/init.c | 1 -
 arch/openrisc/mm/init.c  | 2 --
 arch/parisc/mm/init.c| 2 --
 arch/powerpc/mm/mem.c| 1 -
 arch/riscv/mm/init.c | 1 -
 arch/s390/mm/init.c  | 2 --
 arch/sh/mm/init.c| 1 -
 arch/sparc/mm/init_32.c  | 2 --
 arch/sparc/mm/init_64.c  | 1 -
 arch/um/kernel/mem.c | 1 -
 arch/x86/mm/init_32.c| 2 --
 arch/x86/mm/init_64.c| 2 --
 arch/xtensa/mm/init.c| 1 -
 include/linux/mm.h   | 2 +-
 init/main.c  | 1 +
 mm/page_alloc.c  | 6 +++---
 30 files changed, 5 insertions(+), 40 deletions(-)

diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c
index 3c42b3147fd6..a97650a618f1 100644
--- a/arch/alpha/mm/init.c
+++ b/arch/alpha/mm/init.c
@@ -282,5 +282,4 @@ mem_init(void)
set_max_mapnr(max_low_pfn);
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
memblock_free_all();
-   mem_init_print_info(NULL);
 }
diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
index ce07e697916c..33832e36bdb7 100644
--- a/arch/arc/mm/init.c
+++ b/arch/arc/mm/init.c
@@ -194,7 +194,6 @@ void __init mem_init(void)
 {
memblock_free_all();
highmem_init();
-   mem_init_print_info(NULL);
 }
 
 #ifdef CONFIG_HIGHMEM
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 828a2561b229..7022b7b5c400 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -316,8 +316,6 @@ void __init mem_init(void)
 
free_highpages();
 
-   mem_init_print_info(NULL);
-
/*
 * Check boundaries twice: Some fundamental inconsistencies can
 * be detected at build time already.
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 3685e12aba9b..e8f29a0bb2f1 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -491,8 +491,6 @@ void __init mem_init(void)
/* this will put all unused low memory onto the freelists */
memblock_free_all();
 
-   mem_init_print_info(NULL);
-
/*
 * Check boundaries twice: Some fundamental inconsistencies can be
 * detected at build time already.
diff --git a/arch/csky/mm/init.c b/arch/csky/mm/init.c
index 894050a8ce09..bf2004aa811a 100644
--- a/arch/csky/mm/init.c
+++ b/arch/csky/mm/init.c
@@ -107,7 +107,6 @@ void __init mem_init(void)
free_highmem_page(page);
}
 #endif
-   mem_init_print_info(NULL);
 }
 
 void free_initmem(void)
diff --git a/arch/h8300/mm/init.c b/arch/h8300/mm/init.c
index 1f3b345d68b9..f7bf4693e3b2 100644
--- a/arch/h8300/mm/init.c
+++ b/arch/h8300/mm/init.c
@@ -98,6 +98,4 @@ void __init mem_init(void)
 
/* this will put all low memory onto the freelists */
memblock_free_all();
-
-   mem_init_print_info(NULL);
 }
diff --git a/arch/hexagon/mm/init.c b/arch/hexagon/mm/init.c
index f2e6c868e477..f01e91e10d95 100644
--- a/arch/hexagon/mm/init.c
+++ b/arch/hexagon/mm/init.c
@@ -55,7 +55,6 @@ void __init mem_init(void)
 {
/*  No idea where this is actually declared.  Seems to evade LXR.  */
memblock_free_all();
-   mem_init_print_info(NULL);
 
/*
 *  To-Do:  someone somewhere should wipe out the bootmem map
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index 16d0d7d22657..83280e2df807 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -659,7 +659,6 @@ mem_init (void)
set_max_mapnr(max_low_pfn);
high_memory = __va(max_low_pfn * PAGE_SIZE);
memblock_free_all();
-   mem_init_print_info(NULL);
 
/*
 * For fsyscall entrpoints with no light-weight handler, use the 
ordinary
diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
index 14c1e541451c..1759ab875d47 100644
--- a/arch/m68k/mm/init.c
+++ b/arch/m68k/mm/init.c
@@ -153,5 +153,4 @@ void __init mem_init(void)
/* this will put all memory onto the freelists */
memblock_free_all();
init_pointer_tables();
-   mem_init_print_info(NULL);
 }
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index 05cf1fb3f5ff..ab55c70380a5 100644

Re: [PATCH] mm: Move mem_init_print_info() into mm_init()

2021-03-16 Thread Kefeng Wang



On 2021/3/16 22:47, Christophe Leroy wrote:



Le 16/03/2021 à 15:26, Kefeng Wang a écrit :

mem_init_print_info() is called in mem_init() on each architecture,
and pass NULL argument, cleanup it by using void argument and move
it into mm_init().

Signed-off-by: Kefeng Wang 
---
  arch/alpha/mm/init.c | 1 -
  arch/arc/mm/init.c   | 1 -
  arch/arm/mm/init.c   | 2 --
  arch/arm64/mm/init.c | 2 --
  arch/csky/mm/init.c  | 1 -
  arch/h8300/mm/init.c | 2 --
  arch/hexagon/mm/init.c   | 1 -
  arch/ia64/mm/init.c  | 1 -
  arch/m68k/mm/init.c  | 1 -
  arch/microblaze/mm/init.c    | 1 -
  arch/mips/loongson64/numa.c  | 1 -
  arch/mips/mm/init.c  | 1 -
  arch/mips/sgi-ip27/ip27-memory.c | 1 -
  arch/nds32/mm/init.c | 1 -
  arch/nios2/mm/init.c | 1 -
  arch/openrisc/mm/init.c  | 2 --
  arch/parisc/mm/init.c    | 2 --
  arch/powerpc/mm/mem.c    | 1 -
  arch/riscv/mm/init.c | 1 -
  arch/s390/mm/init.c  | 2 --
  arch/sh/mm/init.c    | 1 -
  arch/sparc/mm/init_32.c  | 2 --
  arch/sparc/mm/init_64.c  | 1 -
  arch/um/kernel/mem.c | 1 -
  arch/x86/mm/init_32.c    | 2 --
  arch/x86/mm/init_64.c    | 2 --
  arch/xtensa/mm/init.c    | 1 -
  include/linux/mm.h   | 2 +-
  init/main.c  | 1 +
  mm/page_alloc.c  | 2 +-
  30 files changed, 3 insertions(+), 38 deletions(-)




diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 55d938297ce6..e4a6bf69c806 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -7728,7 +7728,7 @@ unsigned long free_reserved_area(void *start, 
void *end, int poison, const char

  return pages;
  }
  -void __init mem_init_print_info(const char *str)
+void __init mem_init_print_info(void)
  {
  unsigned long physpages, codesize, datasize, rosize, bss_size;
  unsigned long init_code_size, init_data_size;



And what about the 'str' in the last line of the function ?

pr_info("Memory: %luK/%luK available (%luK kernel code, %luK 
rwdata, %luK rodata, %luK init, %luK bss, %luK reserved, %luK 
cma-reserved"

#ifdef    CONFIG_HIGHMEM
    ", %luK highmem"
#endif
    "%s%s)\n",
    nr_free_pages() << (PAGE_SHIFT - 10),
    physpages << (PAGE_SHIFT - 10),
    codesize >> 10, datasize >> 10, rosize >> 10,
    (init_data_size + init_code_size) >> 10, bss_size >> 10,
    (physpages - totalram_pages() - totalcma_pages) << (PAGE_SHIFT 
- 10),

    totalcma_pages << (PAGE_SHIFT - 10),
#ifdef    CONFIG_HIGHMEM
    totalhigh_pages() << (PAGE_SHIFT - 10),
#endif
    str ? ", " : "", str ? str : "");


oh,   I send a bad version,firstly I want to split two patches, one for 
function move, one for function change.


sorry, please ignore it, thanks for your remind.




Christophe
.



[PATCH] mm: Move mem_init_print_info() into mm_init()

2021-03-16 Thread Kefeng Wang
mem_init_print_info() is called in mem_init() on each architecture,
and pass NULL argument, cleanup it by using void argument and move
it into mm_init().

Signed-off-by: Kefeng Wang 
---
 arch/alpha/mm/init.c | 1 -
 arch/arc/mm/init.c   | 1 -
 arch/arm/mm/init.c   | 2 --
 arch/arm64/mm/init.c | 2 --
 arch/csky/mm/init.c  | 1 -
 arch/h8300/mm/init.c | 2 --
 arch/hexagon/mm/init.c   | 1 -
 arch/ia64/mm/init.c  | 1 -
 arch/m68k/mm/init.c  | 1 -
 arch/microblaze/mm/init.c| 1 -
 arch/mips/loongson64/numa.c  | 1 -
 arch/mips/mm/init.c  | 1 -
 arch/mips/sgi-ip27/ip27-memory.c | 1 -
 arch/nds32/mm/init.c | 1 -
 arch/nios2/mm/init.c | 1 -
 arch/openrisc/mm/init.c  | 2 --
 arch/parisc/mm/init.c| 2 --
 arch/powerpc/mm/mem.c| 1 -
 arch/riscv/mm/init.c | 1 -
 arch/s390/mm/init.c  | 2 --
 arch/sh/mm/init.c| 1 -
 arch/sparc/mm/init_32.c  | 2 --
 arch/sparc/mm/init_64.c  | 1 -
 arch/um/kernel/mem.c | 1 -
 arch/x86/mm/init_32.c| 2 --
 arch/x86/mm/init_64.c| 2 --
 arch/xtensa/mm/init.c| 1 -
 include/linux/mm.h   | 2 +-
 init/main.c  | 1 +
 mm/page_alloc.c  | 2 +-
 30 files changed, 3 insertions(+), 38 deletions(-)

diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c
index 3c42b3147fd6..a97650a618f1 100644
--- a/arch/alpha/mm/init.c
+++ b/arch/alpha/mm/init.c
@@ -282,5 +282,4 @@ mem_init(void)
set_max_mapnr(max_low_pfn);
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
memblock_free_all();
-   mem_init_print_info(NULL);
 }
diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
index ce07e697916c..33832e36bdb7 100644
--- a/arch/arc/mm/init.c
+++ b/arch/arc/mm/init.c
@@ -194,7 +194,6 @@ void __init mem_init(void)
 {
memblock_free_all();
highmem_init();
-   mem_init_print_info(NULL);
 }
 
 #ifdef CONFIG_HIGHMEM
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 828a2561b229..7022b7b5c400 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -316,8 +316,6 @@ void __init mem_init(void)
 
free_highpages();
 
-   mem_init_print_info(NULL);
-
/*
 * Check boundaries twice: Some fundamental inconsistencies can
 * be detected at build time already.
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 3685e12aba9b..e8f29a0bb2f1 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -491,8 +491,6 @@ void __init mem_init(void)
/* this will put all unused low memory onto the freelists */
memblock_free_all();
 
-   mem_init_print_info(NULL);
-
/*
 * Check boundaries twice: Some fundamental inconsistencies can be
 * detected at build time already.
diff --git a/arch/csky/mm/init.c b/arch/csky/mm/init.c
index 894050a8ce09..bf2004aa811a 100644
--- a/arch/csky/mm/init.c
+++ b/arch/csky/mm/init.c
@@ -107,7 +107,6 @@ void __init mem_init(void)
free_highmem_page(page);
}
 #endif
-   mem_init_print_info(NULL);
 }
 
 void free_initmem(void)
diff --git a/arch/h8300/mm/init.c b/arch/h8300/mm/init.c
index 1f3b345d68b9..f7bf4693e3b2 100644
--- a/arch/h8300/mm/init.c
+++ b/arch/h8300/mm/init.c
@@ -98,6 +98,4 @@ void __init mem_init(void)
 
/* this will put all low memory onto the freelists */
memblock_free_all();
-
-   mem_init_print_info(NULL);
 }
diff --git a/arch/hexagon/mm/init.c b/arch/hexagon/mm/init.c
index f2e6c868e477..f01e91e10d95 100644
--- a/arch/hexagon/mm/init.c
+++ b/arch/hexagon/mm/init.c
@@ -55,7 +55,6 @@ void __init mem_init(void)
 {
/*  No idea where this is actually declared.  Seems to evade LXR.  */
memblock_free_all();
-   mem_init_print_info(NULL);
 
/*
 *  To-Do:  someone somewhere should wipe out the bootmem map
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index 16d0d7d22657..83280e2df807 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -659,7 +659,6 @@ mem_init (void)
set_max_mapnr(max_low_pfn);
high_memory = __va(max_low_pfn * PAGE_SIZE);
memblock_free_all();
-   mem_init_print_info(NULL);
 
/*
 * For fsyscall entrpoints with no light-weight handler, use the 
ordinary
diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
index 14c1e541451c..1759ab875d47 100644
--- a/arch/m68k/mm/init.c
+++ b/arch/m68k/mm/init.c
@@ -153,5 +153,4 @@ void __init mem_init(void)
/* this will put all memory onto the freelists */
memblock_free_all();
init_pointer_tables();
-   mem_init_print_info(NULL);
 }
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index 05cf1fb3f5ff..ab55c70380a5 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm

Re: [PATCH] net: bridge: Fix jump_label config

2021-02-26 Thread Kefeng Wang



On 2021/2/27 4:19, Cong Wang wrote:

On Thu, Feb 25, 2021 at 5:39 PM Kefeng Wang  wrote:


On 2021/2/26 5:22, Cong Wang wrote:

On Wed, Feb 24, 2021 at 8:03 AM Kefeng Wang  wrote:

HAVE_JUMP_LABLE is removed by commit e9666d10a567 ("jump_label: move
'asm goto' support test to Kconfig"), use CONFIG_JUMP_LABLE instead
of HAVE_JUMP_LABLE.

Fixes: 971502d77faa ("bridge: netfilter: unroll NF_HOOK helper in bridge input 
path")
Signed-off-by: Kefeng Wang 

Hmm, why do we have to use a macro here? static_key_false() is defined
in both cases, CONFIG_JUMP_LABEL=y or CONFIG_JUMP_LABEL=n.

It seems that all nf_hooks_needed related are using the macro,

see net/netfilter/core.c and include/linux/netfilter.h,

#ifdef CONFIG_JUMP_LABEL
struct static_key nf_hooks_needed[NFPROTO_NUMPROTO][NF_MAX_HOOKS];
EXPORT_SYMBOL(nf_hooks_needed);
#endif

nf_static_key_inc()/nf_static_key_dec()

Same question: why? Clearly struct static_key is defined in both cases:


Ok,  I mean that I don't change the original logic, but that's no need 
this macro actually,


it could be built with or without CONFIG_JUMP_LABEL, only increased the 
size a little bit.





#else
struct static_key {
 atomic_t enabled;
};
#endif  /* CONFIG_JUMP_LABEL */

Thanks.



Re: [PATCH] RISC-V: Make NUMA depend on SMP

2021-02-26 Thread Kefeng Wang



On 2021/2/27 4:25, Palmer Dabbelt wrote:

From: Palmer Dabbelt 

In theory these are orthogonal, but in practice all NUMA systems are
SMP.  NUMA && !SMP doesn't build, everyone else is coupling them, and I
don't really see any value in supporting that configuration.

Fixes: 4f0e8eef772e ("riscv: Add numa support for riscv64 platform")
Suggested-by: Andrew Morton 
Suggested-by: Atish Patra 
Signed-off-by: Palmer Dabbelt 


Reported-and-Tested-by:  Kefeng Wang 



---
This is on fixes.
---
  arch/riscv/Kconfig | 1 +
  1 file changed, 1 insertion(+)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index a998babc1237..85d626b8ce5e 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -314,6 +314,7 @@ endchoice
  # Common NUMA Features
  config NUMA
bool "NUMA Memory Allocation and Scheduler Support"
+   depends on SMP
select GENERIC_ARCH_NUMA
select OF_NUMA
select ARCH_SUPPORTS_NUMA_BALANCING


Re: [PATCH] net: bridge: Fix jump_label config

2021-02-25 Thread Kefeng Wang



On 2021/2/26 5:22, Cong Wang wrote:

On Wed, Feb 24, 2021 at 8:03 AM Kefeng Wang  wrote:

HAVE_JUMP_LABLE is removed by commit e9666d10a567 ("jump_label: move
'asm goto' support test to Kconfig"), use CONFIG_JUMP_LABLE instead
of HAVE_JUMP_LABLE.

Fixes: 971502d77faa ("bridge: netfilter: unroll NF_HOOK helper in bridge input 
path")
Signed-off-by: Kefeng Wang 

Hmm, why do we have to use a macro here? static_key_false() is defined
in both cases, CONFIG_JUMP_LABEL=y or CONFIG_JUMP_LABEL=n.


It seems that all nf_hooks_needed related are using the macro,

see net/netfilter/core.c and include/linux/netfilter.h,

  #ifdef CONFIG_JUMP_LABEL
  struct static_key nf_hooks_needed[NFPROTO_NUMPROTO][NF_MAX_HOOKS];
EXPORT_SYMBOL(nf_hooks_needed);
#endif

  nf_static_key_inc()/nf_static_key_dec()




Thanks.



Re: [PATCH] net: bridge: Fix jump_label config

2021-02-24 Thread Kefeng Wang



On 2021/2/25 2:54, Jakub Kicinski wrote:

On Wed, 24 Feb 2021 23:38:03 +0800 Kefeng Wang wrote:

HAVE_JUMP_LABLE is removed by commit e9666d10a567 ("jump_label: move
'asm goto' support test to Kconfig"), use CONFIG_JUMP_LABLE instead
of HAVE_JUMP_LABLE.

Fixes: 971502d77faa ("bridge: netfilter: unroll NF_HOOK helper in bridge input 
path")
Signed-off-by: Kefeng Wang 

You need to CC the authors of the commit you're blaming. Please make
use of scripts/get_maintainers.pl and repost.


Yes, I use get_maintainers.pl, but only add maintainers to the list, 
thanks for your reminder,


cc the author Florian now.



[PATCH] net: bridge: Fix jump_label config

2021-02-24 Thread Kefeng Wang
HAVE_JUMP_LABLE is removed by commit e9666d10a567 ("jump_label: move
'asm goto' support test to Kconfig"), use CONFIG_JUMP_LABLE instead
of HAVE_JUMP_LABLE.

Fixes: 971502d77faa ("bridge: netfilter: unroll NF_HOOK helper in bridge input 
path")
Signed-off-by: Kefeng Wang 
---
 net/bridge/br_input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index 85d9dae2..065b6cfba40f 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -207,7 +207,7 @@ static int nf_hook_bridge_pre(struct sk_buff *skb, struct 
sk_buff **pskb)
int ret;
 
net = dev_net(skb->dev);
-#ifdef HAVE_JUMP_LABEL
+#ifdef CONFIG_JUMP_LABEL
if 
(!static_key_false(_hooks_needed[NFPROTO_BRIDGE][NF_BR_PRE_ROUTING]))
goto frame_finish;
 #endif
-- 
2.26.2



Re: [PATCH -next] RISCV: Add some depends for NUMA

2021-02-04 Thread Kefeng Wang



On 2021/2/5 14:58, Palmer Dabbelt wrote:
On Wed, 03 Feb 2021 06:23:43 PST (-0800), wangkefeng.w...@huawei.com 
wrote:
The numa feature is useless for riscv32 platform(MAXPHYSMEM_1GB if 
32bit),


I'm not convinced of that.  There's no reason NUMA shouldn't work on 
32-bit, it

doesn't depend on having a large amount of memory just having non-uniform
memory.  I could buy the argument that build a 32-bit NUMA system 
would be
wacky, but IIUC it works now and I don't see any reason to throw that 
away.


I think the RV32 won't benefit from NUMA, there's no too much memory 
support on RV32,


and it may increase the Image size,  so I decided to drop support for RV32.




and it should depends on SMP feature, this also fix the build error,


I can buy that CONFIG_NUMA doesn't really make sense without 
CONFIG_SMP, as
there's not a whole lot to do, but I also don't see any reason from 
disallowing
users from picking it.  arm64 allows !SMP && NUMA, and I don't see any 
reason

it wouldn't work just as well for us.


ARM64 won' support !SMP after following patch, and for most 
architecture,  the NUMA feature


depends or select SMP feature.


commit 4b3dc9679cf779339d9049800803dfc3c83433d1
Author: Will Deacon 
Date:   Fri May 29 18:28:44 2015 +0100

    arm64: force CONFIG_SMP=y and remove redundant #ifdefs






  riscv64-buildroot-linux-gnu-ld: mm/page_alloc.o: in function `.L0 ':
  page_alloc.c:(.text+0x4808): undefined reference to 
`node_reclaim_distance'


The only instance of node_reclaim_distance I see in mm/page_alloc.c is 
already
guarded with CONFIG_NUMA, but the definition of node_reclaim_distance 
isn't.
I'll send out some patches to add the guard which might make sorting 
this out

earlier, but I don't see it fixing any failures.





Re: [PATCH -next] RISCV: Add some depends for NUMA

2021-02-04 Thread Kefeng Wang



On 2021/2/4 3:59, Atish Patra wrote:

On Wed, Feb 3, 2021 at 6:20 AM Kefeng Wang  wrote:

The numa feature is useless for riscv32 platform(MAXPHYSMEM_1GB if 32bit),
and it should depends on SMP feature, this also fix the build error,

   riscv64-buildroot-linux-gnu-ld: mm/page_alloc.o: in function `.L0 ':
   page_alloc.c:(.text+0x4808): undefined reference to `node_reclaim_distance'


Thanks for the fix. The commit text is a bit ambiguous. The
compilation issue error is due to SMP.
RV32 dependency is just another fix  as NUMA is not very useful for RV32.


Yes, the two depends fix different issue,the lack of SMP leads to the 
compilation issue,  another


depend is to remove support on RV32.

Thanks for your review, if necessary, I could resend with changelog 
updated.



Reviewed-by: Atish Patra 


[PATCH -next] RISCV: Add some depends for NUMA

2021-02-03 Thread Kefeng Wang
The numa feature is useless for riscv32 platform(MAXPHYSMEM_1GB if 32bit),
and it should depends on SMP feature, this also fix the build error,

  riscv64-buildroot-linux-gnu-ld: mm/page_alloc.o: in function `.L0 ':
  page_alloc.c:(.text+0x4808): undefined reference to `node_reclaim_distance'

Fixes: 4f0e8eef772e ("riscv: Add numa support for riscv64 platform")
Signed-off-by: Kefeng Wang 
---
 arch/riscv/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 22fa17898d29..ac7f5801bd82 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -312,6 +312,8 @@ endchoice
 # Common NUMA Features
 config NUMA
bool "NUMA Memory Allocation and Scheduler Support"
+   depends on SMP
+   depends on 64BIT
select GENERIC_ARCH_NUMA
select OF_NUMA
select ARCH_SUPPORTS_NUMA_BALANCING
-- 
2.26.2



Re: [PATCH v3 0/4] initrd: Use unified initrd reserve function in ARM/RISCV

2021-01-21 Thread Kefeng Wang



On 2021/1/18 17:17, Russell King - ARM Linux admin wrote:

On Mon, Jan 18, 2021 at 09:01:40AM +0800, Kefeng Wang wrote:

On 2021/1/17 18:09, Russell King - ARM Linux admin wrote:

On Sun, Jan 17, 2021 at 12:57:55PM +0800, Kefeng Wang wrote:

Correct Russell's mail address (from li...@armlinux.org.uk to
rmk+ker...@armlinux.org.uk, should update the MAINTAINERS)

No. MAINTAINERS is correct.

I got following message,  so I check mail of your recent patches, and send a
new one.

Please ignore it, there may be some other problems.

"*Delivery has failed to these recipients or groups:*

li...@armlinux.org.uk <mailto:li...@armlinux.org.uk>
A communication failure occurred during the delivery of this message. Please
to resend the message later. If the problem continues, contact your
helpdesk."

That is a most unhelpful bounce message - I suppose it's designed for
non-technical people to ensure that the problem can't be resolved.

>From what I can see from my end, every attempt involving your email
address last week (wangkefeng.w...@huawei.com) has been successful, so
I suspect the problem is not at my end.


ok,thank you for letting me know that the email has been received,

any comment about the ARM part in the patchset  ;)



In any case, all @armlinux.org.uk addresses hit the same server, so
if there's a "communication failure" for the domain, it would affect
all local-parts equally.



Re: [PATCH v3 0/4] initrd: Use unified initrd reserve function in ARM/RISCV

2021-01-16 Thread Kefeng Wang
Correct Russell's mail address (from li...@armlinux.org.uk to 
rmk+ker...@armlinux.org.uk, should update the MAINTAINERS)


On 2021/1/15 13:46, Kefeng Wang wrote:

Use the same implementation of initrd reserve to avoid duplication.

v3:
- split into four patches, suggested-by Palmer Dabbelt
v2:
- fix build error found by kernel test robot

Kefeng Wang (4):
   initrd: Add the preprocessor guard in initrd.h
   initramfs: Provide a common initrd reserve function
   ARM: Covert to reserve_initrd_mem()
   riscv: Covert to reserve_initrd_mem()

  arch/arm/mm/init.c | 43 +
  arch/riscv/mm/init.c   | 54 +-
  include/linux/initrd.h | 11 +
  init/initramfs.c   | 45 +++
  4 files changed, 58 insertions(+), 95 deletions(-)



Re: [PATCH v3 3/4] ARM: Covert to reserve_initrd_mem()

2021-01-16 Thread Kefeng Wang

update Russell's mail address.


On 2021/1/15 13:46, Kefeng Wang wrote:

Covert to the generic reserve_initrd_mem() function.

Signed-off-by: Kefeng Wang 
---
  arch/arm/mm/init.c | 43 +--
  1 file changed, 1 insertion(+), 42 deletions(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 828a2561b229..a29e14cd626c 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -153,47 +153,6 @@ phys_addr_t __init arm_memblock_steal(phys_addr_t size, 
phys_addr_t align)
return phys;
  }
  
-static void __init arm_initrd_init(void)

-{
-#ifdef CONFIG_BLK_DEV_INITRD
-   phys_addr_t start;
-   unsigned long size;
-
-   initrd_start = initrd_end = 0;
-
-   if (!phys_initrd_size)
-   return;
-
-   /*
-* Round the memory region to page boundaries as per free_initrd_mem()
-* This allows us to detect whether the pages overlapping the initrd
-* are in use, but more importantly, reserves the entire set of pages
-* as we don't want these pages allocated for other purposes.
-*/
-   start = round_down(phys_initrd_start, PAGE_SIZE);
-   size = phys_initrd_size + (phys_initrd_start - start);
-   size = round_up(size, PAGE_SIZE);
-
-   if (!memblock_is_region_memory(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region - disabling 
initrd\n",
-  (u64)start, size);
-   return;
-   }
-
-   if (memblock_is_region_reserved(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx overlaps in-use memory region - 
disabling initrd\n",
-  (u64)start, size);
-   return;
-   }
-
-   memblock_reserve(start, size);
-
-   /* Now convert initrd to virtual addresses */
-   initrd_start = __phys_to_virt(phys_initrd_start);
-   initrd_end = initrd_start + phys_initrd_size;
-#endif
-}
-
  #ifdef CONFIG_CPU_ICACHE_MISMATCH_WORKAROUND
  void check_cpu_icache_size(int cpuid)
  {
@@ -215,7 +174,7 @@ void __init arm_memblock_init(const struct machine_desc 
*mdesc)
/* Register the kernel text, kernel data and initrd with memblock. */
memblock_reserve(__pa(KERNEL_START), KERNEL_END - KERNEL_START);
  
-	arm_initrd_init();

+   reserve_initrd_mem();
  
  	arm_mm_memblock_reserve();
  


Re: drivers/scsi/myrs.c:2449:13: sparse: sparse: incorrect type in assignment (different base types)

2021-01-15 Thread Kefeng Wang



On 2021/1/15 16:50, kernel test robot wrote:

Hi Kefeng,

First bad commit (maybe != root cause):


Hi, the commit in patchset[1], which make riscv random build happier, 
won't lead to the following problem.


I think the driver should fix the sparse error.


[1] https://lkml.org/lkml/2020/5/10/456



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   5ee88057889bbca5f5bb96031b62b3756b33e164
commit: ed1ed4c0da5447c5e322481ce2ef9f03336c6ffb riscv: mmiowb: Fix implicit 
declaration of function 'smp_processor_id'
date:   8 months ago
config: riscv-randconfig-s032-20210115 (attached as .config)
compiler: riscv32-linux-gcc (GCC) 9.3.0
reproduce:
 wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
 chmod +x ~/bin/make.cross
 # apt-get install sparse
 # sparse version: v0.6.3-208-g46a52ca4-dirty
 # 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ed1ed4c0da5447c5e322481ce2ef9f03336c6ffb
 git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
 git fetch --no-tags linus master
 git checkout ed1ed4c0da5447c5e322481ce2ef9f03336c6ffb
 # save the attached .config to linux build tree
 COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 
CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=riscv

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 


"sparse warnings: (new ones prefixed by >>)"
drivers/scsi/myrs.c:1532:5: sparse: sparse: symbol 'myrs_host_reset' was 
not declared. Should it be static?
drivers/scsi/myrs.c:1922:27: sparse: sparse: symbol 'myrs_template' was not 
declared. Should it be static?
drivers/scsi/myrs.c:2036:31: sparse: sparse: symbol 'myrs_raid_functions' 
was not declared. Should it be static?
drivers/scsi/myrs.c:2046:6: sparse: sparse: symbol 'myrs_flush_cache' was 
not declared. Should it be static?
drivers/scsi/myrs.c:2275:34: sparse: sparse: incorrect type in argument 1 
(different address spaces) @@ expected void [noderef]  *base @@ 
got struct myrs_hba *cs @@
drivers/scsi/myrs.c:2275:34: sparse: expected void [noderef]  
*base
drivers/scsi/myrs.c:2275:34: sparse: got struct myrs_hba *cs
drivers/scsi/myrs.c:2434:9: sparse: sparse: cast from restricted __le32
drivers/scsi/myrs.c:2502:9: sparse: sparse: cast from restricted __le32
drivers/scsi/myrs.c:2427:9: sparse: sparse: cast from restricted __le32
drivers/scsi/myrs.c:2502:9: sparse: sparse: cast from restricted __le32
drivers/scsi/myrs.c:2413:9: sparse: sparse: cast from restricted __le32

drivers/scsi/myrs.c:2449:13: sparse: sparse: incorrect type in assignment 
(different base types) @@ expected restricted __le32 [usertype] val @@ 
got unsigned int [assigned] [usertype] __v @@

drivers/scsi/myrs.c:2449:13: sparse: expected restricted __le32 
[usertype] val
drivers/scsi/myrs.c:2449:13: sparse: got unsigned int [assigned] 
[usertype] __v
drivers/scsi/myrs.c:2549:13: sparse: sparse: incorrect type in assignment 
(different base types) @@ expected restricted __le32 [usertype] val @@ 
got unsigned int [assigned] [usertype] __v @@
drivers/scsi/myrs.c:2549:13: sparse: expected restricted __le32 
[usertype] val
drivers/scsi/myrs.c:2549:13: sparse: got unsigned int [assigned] 
[usertype] __v
drivers/scsi/myrs.c:2552:18: sparse: sparse: restricted __le32 degrades to 
integer
drivers/scsi/myrs.c:2427:9: sparse: sparse: cast from restricted __le32
drivers/scsi/myrs.c:2495:9: sparse: sparse: cast from restricted __le32
drivers/scsi/myrs.c:2472:9: sparse: sparse: cast from restricted __le32
drivers/scsi/myrs.c:2441:13: sparse: sparse: incorrect type in assignment 
(different base types) @@ expected restricted __le32 [usertype] val @@ 
got unsigned int [assigned] [usertype] __v @@
drivers/scsi/myrs.c:2441:13: sparse: expected restricted __le32 
[usertype] val
drivers/scsi/myrs.c:2441:13: sparse: got unsigned int [assigned] 
[usertype] __v
drivers/scsi/myrs.c:2406:9: sparse: sparse: cast from restricted __le32
drivers/scsi/myrs.c:2479:13: sparse: sparse: incorrect type in assignment 
(different base types) @@ expected restricted __le32 [usertype] val @@ 
got unsigned int [assigned] [usertype] __v @@
drivers/scsi/myrs.c:2479:13: sparse: expected restricted __le32 
[usertype] val
drivers/scsi/myrs.c:2479:13: sparse: got unsigned int [assigned] 
[usertype] __v
drivers/scsi/myrs.c:2457:9: sparse: sparse: cast from restricted __le32
drivers/scsi/myrs.c:2413:9: sparse: sparse: cast from restricted __le32
--
drivers/isdn/hardware/mISDN/avmfritz.c:175:9: sparse: sparse: cast removes 
address space '' of expression
drivers/isdn/hardware/mISDN/avmfritz.c:175:9: sparse: 

Re: [PATCH v2] initramfs: Provide a common initrd reserve function

2021-01-14 Thread Kefeng Wang



On 2021/1/15 10:33, Palmer Dabbelt wrote:
On Wed, 13 Jan 2021 18:33:58 PST (-0800), wangkefeng.w...@huawei.com 
wrote:

The ARM and riscv have same logic to check and reserve
the memory of initrd, let's provide a common function to
reduce duplicated code.

Add __LINUX_INITRD_H define in initrd.h to prevent build error
(found by kernel test robot ) from the multiple
inclusion of same header file multiple time.


This is doing a bunch of different things:

* Fixing the lack of a preprocessor guard in initrd.h
* Adding some generic code.
* Converting two architectures over to that generic code.

It needs to be split into four patches.  I'm happy to take them via 
the RISC-V tree (with an Ack from for the arch/arm/ stuff), but not 
all together.


It looks like csky copied this as well, they at least have exactly the 
same message.


Send v3, according to the suggestion,thanks.



[PATCH v3 2/4] initramfs: Provide a common initrd reserve function

2021-01-14 Thread Kefeng Wang
Some architectures(eg, ARM and riscv) have similar logic to
check and reserve the memory of initrd, let's provide a common
function reserve_initrd_mem() to reduce duplicated code.

Signed-off-by: Kefeng Wang 
---
 include/linux/initrd.h |  6 ++
 init/initramfs.c   | 45 ++
 2 files changed, 51 insertions(+)

diff --git a/include/linux/initrd.h b/include/linux/initrd.h
index fc30ac30e10e..85c15717af34 100644
--- a/include/linux/initrd.h
+++ b/include/linux/initrd.h
@@ -18,6 +18,12 @@ extern int initrd_below_start_ok;
 extern unsigned long initrd_start, initrd_end;
 extern void free_initrd_mem(unsigned long, unsigned long);
 
+#ifdef CONFIG_BLK_DEV_INITRD
+extern void __init reserve_initrd_mem(void);
+#else
+static inline void __init reserve_initrd_mem(void) {}
+#endif
+
 extern phys_addr_t phys_initrd_start;
 extern unsigned long phys_initrd_size;
 
diff --git a/init/initramfs.c b/init/initramfs.c
index 55b74d7e5260..f75c89e9d602 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -535,6 +535,51 @@ extern unsigned long __initramfs_size;
 #include 
 #include 
 
+void __init reserve_initrd_mem(void)
+{
+   phys_addr_t start;
+   unsigned long size;
+
+   /* Ignore the virtul address computed during device tree parsing */
+   initrd_start = initrd_end = 0;
+
+   if (!phys_initrd_size)
+   return;
+   /*
+* Round the memory region to page boundaries as per free_initrd_mem()
+* This allows us to detect whether the pages overlapping the initrd
+* are in use, but more importantly, reserves the entire set of pages
+* as we don't want these pages allocated for other purposes.
+*/
+   start = round_down(phys_initrd_start, PAGE_SIZE);
+   size = phys_initrd_size + (phys_initrd_start - start);
+   size = round_up(size, PAGE_SIZE);
+
+   if (!memblock_is_region_memory(start, size)) {
+   pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region",
+  (u64)start, size);
+   goto disable;
+   }
+
+   if (memblock_is_region_reserved(start, size)) {
+   pr_err("INITRD: 0x%08llx+0x%08lx overlaps in-use memory 
region\n",
+  (u64)start, size);
+   goto disable;
+   }
+
+   memblock_reserve(start, size);
+   /* Now convert initrd to virtual addresses */
+   initrd_start = (unsigned long)__va(phys_initrd_start);
+   initrd_end = initrd_start + phys_initrd_size;
+   initrd_below_start_ok = 1;
+
+   return;
+disable:
+   pr_cont(" - disabling initrd\n");
+   initrd_start = 0;
+   initrd_end = 0;
+}
+
 void __weak __init free_initrd_mem(unsigned long start, unsigned long end)
 {
 #ifdef CONFIG_ARCH_KEEP_MEMBLOCK
-- 
2.26.2



[PATCH v3 4/4] riscv: Covert to reserve_initrd_mem()

2021-01-14 Thread Kefeng Wang
Covert to the generic reserve_initrd_mem() function.

Signed-off-by: Kefeng Wang 
---
 arch/riscv/mm/init.c | 54 +---
 1 file changed, 1 insertion(+), 53 deletions(-)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index bf5379135e39..1eaae54c8ea1 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -105,55 +105,6 @@ void __init mem_init(void)
print_vm_layout();
 }
 
-#ifdef CONFIG_BLK_DEV_INITRD
-static void __init setup_initrd(void)
-{
-   phys_addr_t start;
-   unsigned long size;
-
-   /* Ignore the virtul address computed during device tree parsing */
-   initrd_start = initrd_end = 0;
-
-   if (!phys_initrd_size)
-   return;
-   /*
-* Round the memory region to page boundaries as per free_initrd_mem()
-* This allows us to detect whether the pages overlapping the initrd
-* are in use, but more importantly, reserves the entire set of pages
-* as we don't want these pages allocated for other purposes.
-*/
-   start = round_down(phys_initrd_start, PAGE_SIZE);
-   size = phys_initrd_size + (phys_initrd_start - start);
-   size = round_up(size, PAGE_SIZE);
-
-   if (!memblock_is_region_memory(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region",
-  (u64)start, size);
-   goto disable;
-   }
-
-   if (memblock_is_region_reserved(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx overlaps in-use memory 
region\n",
-  (u64)start, size);
-   goto disable;
-   }
-
-   memblock_reserve(start, size);
-   /* Now convert initrd to virtual addresses */
-   initrd_start = (unsigned long)__va(phys_initrd_start);
-   initrd_end = initrd_start + phys_initrd_size;
-   initrd_below_start_ok = 1;
-
-   pr_info("Initial ramdisk at: 0x%p (%lu bytes)\n",
-   (void *)(initrd_start), size);
-   return;
-disable:
-   pr_cont(" - disabling initrd\n");
-   initrd_start = 0;
-   initrd_end = 0;
-}
-#endif /* CONFIG_BLK_DEV_INITRD */
-
 void __init setup_bootmem(void)
 {
phys_addr_t mem_start = 0;
@@ -186,10 +137,7 @@ void __init setup_bootmem(void)
dma32_phys_limit = min(4UL * SZ_1G, (unsigned 
long)PFN_PHYS(max_low_pfn));
set_max_mapnr(max_low_pfn);
 
-#ifdef CONFIG_BLK_DEV_INITRD
-   setup_initrd();
-#endif /* CONFIG_BLK_DEV_INITRD */
-
+   reserve_initrd_mem();
/*
 * Avoid using early_init_fdt_reserve_self() since __pa() does
 * not work for DTB pointers that are fixmap addresses
-- 
2.26.2



[PATCH v3 3/4] ARM: Covert to reserve_initrd_mem()

2021-01-14 Thread Kefeng Wang
Covert to the generic reserve_initrd_mem() function.

Signed-off-by: Kefeng Wang 
---
 arch/arm/mm/init.c | 43 +--
 1 file changed, 1 insertion(+), 42 deletions(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 828a2561b229..a29e14cd626c 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -153,47 +153,6 @@ phys_addr_t __init arm_memblock_steal(phys_addr_t size, 
phys_addr_t align)
return phys;
 }
 
-static void __init arm_initrd_init(void)
-{
-#ifdef CONFIG_BLK_DEV_INITRD
-   phys_addr_t start;
-   unsigned long size;
-
-   initrd_start = initrd_end = 0;
-
-   if (!phys_initrd_size)
-   return;
-
-   /*
-* Round the memory region to page boundaries as per free_initrd_mem()
-* This allows us to detect whether the pages overlapping the initrd
-* are in use, but more importantly, reserves the entire set of pages
-* as we don't want these pages allocated for other purposes.
-*/
-   start = round_down(phys_initrd_start, PAGE_SIZE);
-   size = phys_initrd_size + (phys_initrd_start - start);
-   size = round_up(size, PAGE_SIZE);
-
-   if (!memblock_is_region_memory(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region - 
disabling initrd\n",
-  (u64)start, size);
-   return;
-   }
-
-   if (memblock_is_region_reserved(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx overlaps in-use memory region 
- disabling initrd\n",
-  (u64)start, size);
-   return;
-   }
-
-   memblock_reserve(start, size);
-
-   /* Now convert initrd to virtual addresses */
-   initrd_start = __phys_to_virt(phys_initrd_start);
-   initrd_end = initrd_start + phys_initrd_size;
-#endif
-}
-
 #ifdef CONFIG_CPU_ICACHE_MISMATCH_WORKAROUND
 void check_cpu_icache_size(int cpuid)
 {
@@ -215,7 +174,7 @@ void __init arm_memblock_init(const struct machine_desc 
*mdesc)
/* Register the kernel text, kernel data and initrd with memblock. */
memblock_reserve(__pa(KERNEL_START), KERNEL_END - KERNEL_START);
 
-   arm_initrd_init();
+   reserve_initrd_mem();
 
arm_mm_memblock_reserve();
 
-- 
2.26.2



[PATCH v3 1/4] initrd: Add the preprocessor guard in initrd.h

2021-01-14 Thread Kefeng Wang
Add the preprocessor guard in initrd.h to prevent possible
build error from the multiple inclusion of same header file
multiple time.

Signed-off-by: Kefeng Wang 
---
 include/linux/initrd.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/linux/initrd.h b/include/linux/initrd.h
index 8db6f8c8030b..fc30ac30e10e 100644
--- a/include/linux/initrd.h
+++ b/include/linux/initrd.h
@@ -1,5 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 
+#ifndef __LINUX_INITRD_H
+#define __LINUX_INITRD_H
+
 #define INITRD_MINOR 250 /* shouldn't collide with /dev/ram* too soon ... */
 
 /* starting block # of image */
@@ -24,3 +27,5 @@ extern char __initramfs_start[];
 extern unsigned long __initramfs_size;
 
 void console_on_rootfs(void);
+
+#endif /* __LINUX_INITRD_H */
-- 
2.26.2



[PATCH v3 0/4] initrd: Use unified initrd reserve function in ARM/RISCV

2021-01-14 Thread Kefeng Wang
Use the same implementation of initrd reserve to avoid duplication.

v3:
- split into four patches, suggested-by Palmer Dabbelt
v2:
- fix build error found by kernel test robot

Kefeng Wang (4):
  initrd: Add the preprocessor guard in initrd.h
  initramfs: Provide a common initrd reserve function
  ARM: Covert to reserve_initrd_mem()
  riscv: Covert to reserve_initrd_mem()

 arch/arm/mm/init.c | 43 +
 arch/riscv/mm/init.c   | 54 +-
 include/linux/initrd.h | 11 +
 init/initramfs.c   | 45 +++
 4 files changed, 58 insertions(+), 95 deletions(-)

-- 
2.26.2



[PATCH v2] initramfs: Provide a common initrd reserve function

2021-01-13 Thread Kefeng Wang
The ARM and riscv have same logic to check and reserve
the memory of initrd, let's provide a common function to
reduce duplicated code.

Add __LINUX_INITRD_H define in initrd.h to prevent build error
(found by kernel test robot ) from the multiple
inclusion of same header file multiple time.

Signed-off-by: Kefeng Wang 
---
v2: fix build err

 arch/arm/mm/init.c | 43 +-
 arch/riscv/mm/init.c   | 53 +-
 include/linux/initrd.h | 11 +
 init/initramfs.c   | 45 +++
 4 files changed, 58 insertions(+), 94 deletions(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 828a2561b229..a29e14cd626c 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -153,47 +153,6 @@ phys_addr_t __init arm_memblock_steal(phys_addr_t size, 
phys_addr_t align)
return phys;
 }
 
-static void __init arm_initrd_init(void)
-{
-#ifdef CONFIG_BLK_DEV_INITRD
-   phys_addr_t start;
-   unsigned long size;
-
-   initrd_start = initrd_end = 0;
-
-   if (!phys_initrd_size)
-   return;
-
-   /*
-* Round the memory region to page boundaries as per free_initrd_mem()
-* This allows us to detect whether the pages overlapping the initrd
-* are in use, but more importantly, reserves the entire set of pages
-* as we don't want these pages allocated for other purposes.
-*/
-   start = round_down(phys_initrd_start, PAGE_SIZE);
-   size = phys_initrd_size + (phys_initrd_start - start);
-   size = round_up(size, PAGE_SIZE);
-
-   if (!memblock_is_region_memory(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region - 
disabling initrd\n",
-  (u64)start, size);
-   return;
-   }
-
-   if (memblock_is_region_reserved(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx overlaps in-use memory region 
- disabling initrd\n",
-  (u64)start, size);
-   return;
-   }
-
-   memblock_reserve(start, size);
-
-   /* Now convert initrd to virtual addresses */
-   initrd_start = __phys_to_virt(phys_initrd_start);
-   initrd_end = initrd_start + phys_initrd_size;
-#endif
-}
-
 #ifdef CONFIG_CPU_ICACHE_MISMATCH_WORKAROUND
 void check_cpu_icache_size(int cpuid)
 {
@@ -215,7 +174,7 @@ void __init arm_memblock_init(const struct machine_desc 
*mdesc)
/* Register the kernel text, kernel data and initrd with memblock. */
memblock_reserve(__pa(KERNEL_START), KERNEL_END - KERNEL_START);
 
-   arm_initrd_init();
+   reserve_initrd_mem();
 
arm_mm_memblock_reserve();
 
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index da53902ef0fc..93cba0d3f43f 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -105,55 +105,6 @@ void __init mem_init(void)
print_vm_layout();
 }
 
-#ifdef CONFIG_BLK_DEV_INITRD
-static void __init setup_initrd(void)
-{
-   phys_addr_t start;
-   unsigned long size;
-
-   /* Ignore the virtul address computed during device tree parsing */
-   initrd_start = initrd_end = 0;
-
-   if (!phys_initrd_size)
-   return;
-   /*
-* Round the memory region to page boundaries as per free_initrd_mem()
-* This allows us to detect whether the pages overlapping the initrd
-* are in use, but more importantly, reserves the entire set of pages
-* as we don't want these pages allocated for other purposes.
-*/
-   start = round_down(phys_initrd_start, PAGE_SIZE);
-   size = phys_initrd_size + (phys_initrd_start - start);
-   size = round_up(size, PAGE_SIZE);
-
-   if (!memblock_is_region_memory(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region",
-  (u64)start, size);
-   goto disable;
-   }
-
-   if (memblock_is_region_reserved(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx overlaps in-use memory 
region\n",
-  (u64)start, size);
-   goto disable;
-   }
-
-   memblock_reserve(start, size);
-   /* Now convert initrd to virtual addresses */
-   initrd_start = (unsigned long)__va(phys_initrd_start);
-   initrd_end = initrd_start + phys_initrd_size;
-   initrd_below_start_ok = 1;
-
-   pr_info("Initial ramdisk at: 0x%p (%lu bytes)\n",
-   (void *)(initrd_start), size);
-   return;
-disable:
-   pr_cont(" - disabling initrd\n");
-   initrd_start = 0;
-   initrd_end = 0;
-}
-#endif /* CONFIG_BLK_DEV_INITRD */
-
 void __init setup_bootmem(void)
 {
phys_addr_t mem_start = 0;
@@ -198,9 +149,7 @@ void __init setup_bootmem(void)
dma32_phys_limit = min(4UL * SZ_1G, (unsigned 
long)PFN_PHYS(max_low_pfn));
   

[PATCH] initramfs: Provide a common initrd reserve function

2021-01-13 Thread Kefeng Wang
The arm and riscv have same logic to check and reserve
the memory of initrd, let's provide a common function
to reduce duplicated code.

Signed-off-by: Kefeng Wang 
---
PS: 
- Other architecture may use this function too, eg, csky,
  could guoren check it? thanks.

 arch/arm/mm/init.c | 43 +-
 arch/riscv/mm/init.c   | 53 +-
 include/linux/initrd.h |  6 +
 init/initramfs.c   | 45 +++
 4 files changed, 53 insertions(+), 94 deletions(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 828a2561b229..a29e14cd626c 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -153,47 +153,6 @@ phys_addr_t __init arm_memblock_steal(phys_addr_t size, 
phys_addr_t align)
return phys;
 }
 
-static void __init arm_initrd_init(void)
-{
-#ifdef CONFIG_BLK_DEV_INITRD
-   phys_addr_t start;
-   unsigned long size;
-
-   initrd_start = initrd_end = 0;
-
-   if (!phys_initrd_size)
-   return;
-
-   /*
-* Round the memory region to page boundaries as per free_initrd_mem()
-* This allows us to detect whether the pages overlapping the initrd
-* are in use, but more importantly, reserves the entire set of pages
-* as we don't want these pages allocated for other purposes.
-*/
-   start = round_down(phys_initrd_start, PAGE_SIZE);
-   size = phys_initrd_size + (phys_initrd_start - start);
-   size = round_up(size, PAGE_SIZE);
-
-   if (!memblock_is_region_memory(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region - 
disabling initrd\n",
-  (u64)start, size);
-   return;
-   }
-
-   if (memblock_is_region_reserved(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx overlaps in-use memory region 
- disabling initrd\n",
-  (u64)start, size);
-   return;
-   }
-
-   memblock_reserve(start, size);
-
-   /* Now convert initrd to virtual addresses */
-   initrd_start = __phys_to_virt(phys_initrd_start);
-   initrd_end = initrd_start + phys_initrd_size;
-#endif
-}
-
 #ifdef CONFIG_CPU_ICACHE_MISMATCH_WORKAROUND
 void check_cpu_icache_size(int cpuid)
 {
@@ -215,7 +174,7 @@ void __init arm_memblock_init(const struct machine_desc 
*mdesc)
/* Register the kernel text, kernel data and initrd with memblock. */
memblock_reserve(__pa(KERNEL_START), KERNEL_END - KERNEL_START);
 
-   arm_initrd_init();
+   reserve_initrd_mem();
 
arm_mm_memblock_reserve();
 
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index da53902ef0fc..93cba0d3f43f 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -105,55 +105,6 @@ void __init mem_init(void)
print_vm_layout();
 }
 
-#ifdef CONFIG_BLK_DEV_INITRD
-static void __init setup_initrd(void)
-{
-   phys_addr_t start;
-   unsigned long size;
-
-   /* Ignore the virtul address computed during device tree parsing */
-   initrd_start = initrd_end = 0;
-
-   if (!phys_initrd_size)
-   return;
-   /*
-* Round the memory region to page boundaries as per free_initrd_mem()
-* This allows us to detect whether the pages overlapping the initrd
-* are in use, but more importantly, reserves the entire set of pages
-* as we don't want these pages allocated for other purposes.
-*/
-   start = round_down(phys_initrd_start, PAGE_SIZE);
-   size = phys_initrd_size + (phys_initrd_start - start);
-   size = round_up(size, PAGE_SIZE);
-
-   if (!memblock_is_region_memory(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region",
-  (u64)start, size);
-   goto disable;
-   }
-
-   if (memblock_is_region_reserved(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx overlaps in-use memory 
region\n",
-  (u64)start, size);
-   goto disable;
-   }
-
-   memblock_reserve(start, size);
-   /* Now convert initrd to virtual addresses */
-   initrd_start = (unsigned long)__va(phys_initrd_start);
-   initrd_end = initrd_start + phys_initrd_size;
-   initrd_below_start_ok = 1;
-
-   pr_info("Initial ramdisk at: 0x%p (%lu bytes)\n",
-   (void *)(initrd_start), size);
-   return;
-disable:
-   pr_cont(" - disabling initrd\n");
-   initrd_start = 0;
-   initrd_end = 0;
-}
-#endif /* CONFIG_BLK_DEV_INITRD */
-
 void __init setup_bootmem(void)
 {
phys_addr_t mem_start = 0;
@@ -198,9 +149,7 @@ void __init setup_bootmem(void)
dma32_phys_limit = min(4UL * SZ_1G, (unsigned 
long)PFN_PHYS(max_low_pfn));
set_max_mapnr(max_low_pfn);
 
-#ifdef CONFIG_BLK_DEV_INITRD
-   setup_initrd();
-#

Re: linux-next: manual merge of the akpm-current tree with the risc-v tree

2020-12-16 Thread Kefeng Wang



On 2020/12/17 9:26, Stephen Rothwell wrote:

Hi all,

On Fri, 27 Nov 2020 18:34:41 +1100 Stephen Rothwell  
wrote:

Today's linux-next merge of the akpm-current tree got a conflict in:

   arch/riscv/Kconfig

between commit:

   5cb0080f1bfd ("riscv: Enable ARCH_STACKWALK")

from the risc-v tree and commit:

   46b9b00649f6 ("arch, mm: restore dependency of __kernel_map_pages() on 
DEBUG_PAGEALLOC")

from the akpm-current tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.


diff --cc arch/riscv/Kconfig
index 8a2a0523a9a3,9283c6f9ae2a..
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@@ -14,7 -14,7 +14,8 @@@ config RISC
def_bool y
select ARCH_CLOCKSOURCE_INIT
select ARCH_SUPPORTS_ATOMIC_RMW
  + select ARCH_STACKWALK
+   select ARCH_SUPPORTS_DEBUG_PAGEALLOC if MMU
select ARCH_HAS_BINFMT_FLAT
select ARCH_HAS_DEBUG_VM_PGTABLE
select ARCH_HAS_DEBUG_VIRTUAL if MMU

This is now a conflict between the risc-v tree and Linus' tree.


Could it be fixed in alphabetical order when merging riscv tree?







[tip: timers/core] clocksource/drivers/sp804: Use clk_prepare_enable and clk_disable_unprepare

2020-12-03 Thread tip-bot2 for Kefeng Wang
The following commit has been merged into the timers/core branch of tip:

Commit-ID: 9d4965eb438f0c9f93e91ce6bfec72bbb8def988
Gitweb:
https://git.kernel.org/tip/9d4965eb438f0c9f93e91ce6bfec72bbb8def988
Author:Kefeng Wang 
AuthorDate:Thu, 29 Oct 2020 20:33:15 +08:00
Committer: Daniel Lezcano 
CommitterDate: Thu, 03 Dec 2020 19:16:17 +01:00

clocksource/drivers/sp804: Use clk_prepare_enable and clk_disable_unprepare

Directly use clk_prepare_enable and clk_disable_unprepare.

Signed-off-by: Kefeng Wang 
Signed-off-by: Daniel Lezcano 
Link: 
https://lore.kernel.org/r/20201029123317.90286-3-wangkefeng.w...@huawei.com
---
 drivers/clocksource/timer-sp804.c | 13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/clocksource/timer-sp804.c 
b/drivers/clocksource/timer-sp804.c
index 22a68cb..d74788b 100644
--- a/drivers/clocksource/timer-sp804.c
+++ b/drivers/clocksource/timer-sp804.c
@@ -68,17 +68,9 @@ static long __init sp804_get_clock_rate(struct clk *clk, 
const char *name)
return PTR_ERR(clk);
}
 
-   err = clk_prepare(clk);
-   if (err) {
-   pr_err("sp804: clock failed to prepare: %d\n", err);
-   clk_put(clk);
-   return err;
-   }
-
-   err = clk_enable(clk);
+   err = clk_prepare_enable(clk);
if (err) {
pr_err("sp804: clock failed to enable: %d\n", err);
-   clk_unprepare(clk);
clk_put(clk);
return err;
}
@@ -86,8 +78,7 @@ static long __init sp804_get_clock_rate(struct clk *clk, 
const char *name)
rate = clk_get_rate(clk);
if (rate < 0) {
pr_err("sp804: clock failed to get rate: %ld\n", rate);
-   clk_disable(clk);
-   clk_unprepare(clk);
+   clk_disable_unprepare(clk);
clk_put(clk);
}
 


[tip: timers/core] clocksource/drivers/sp804: Make some symbol static

2020-12-03 Thread tip-bot2 for Kefeng Wang
The following commit has been merged into the timers/core branch of tip:

Commit-ID: 3c07bf0fc3558f680374f8ac6d148b0082aa08c6
Gitweb:
https://git.kernel.org/tip/3c07bf0fc3558f680374f8ac6d148b0082aa08c6
Author:Kefeng Wang 
AuthorDate:Thu, 29 Oct 2020 20:33:14 +08:00
Committer: Daniel Lezcano 
CommitterDate: Thu, 03 Dec 2020 19:16:17 +01:00

clocksource/drivers/sp804: Make some symbol static

drivers/clocksource/timer-sp804.c:38:31: warning: symbol 'arm_sp804_timer' was 
not declared. Should it be static?
drivers/clocksource/timer-sp804.c:47:31: warning: symbol 'hisi_sp804_timer' was 
not declared. Should it be static?
drivers/clocksource/timer-sp804.c:120:12: warning: symbol 
'sp804_clocksource_and_sched_clock_init' was not declared. Should it be static?
drivers/clocksource/timer-sp804.c:219:12: warning: symbol 
'sp804_clockevents_init' was not declared. Should it be static?

And move __initdata after the variables.

Signed-off-by: Kefeng Wang 
Signed-off-by: Daniel Lezcano 
Link: 
https://lore.kernel.org/r/20201029123317.90286-2-wangkefeng.w...@huawei.com
---
 drivers/clocksource/timer-sp804.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/clocksource/timer-sp804.c 
b/drivers/clocksource/timer-sp804.c
index db5330c..22a68cb 100644
--- a/drivers/clocksource/timer-sp804.c
+++ b/drivers/clocksource/timer-sp804.c
@@ -34,8 +34,7 @@
 #define HISI_TIMER_BGLOAD  0x20
 #define HISI_TIMER_BGLOAD_H0x24
 
-
-struct sp804_timer __initdata arm_sp804_timer = {
+static struct sp804_timer arm_sp804_timer __initdata = {
.load   = TIMER_LOAD,
.value  = TIMER_VALUE,
.ctrl   = TIMER_CTRL,
@@ -44,7 +43,7 @@ struct sp804_timer __initdata arm_sp804_timer = {
.width  = 32,
 };
 
-struct sp804_timer __initdata hisi_sp804_timer = {
+static struct sp804_timer hisi_sp804_timer __initdata = {
.load   = HISI_TIMER_LOAD,
.load_h = HISI_TIMER_LOAD_H,
.value  = HISI_TIMER_VALUE,


[tip: timers/core] clocksource/drivers/sp804: Correct clk_get_rate handle

2020-12-03 Thread tip-bot2 for Kefeng Wang
The following commit has been merged into the timers/core branch of tip:

Commit-ID: dca54f8ce1c3c979caf06cfdcdf8eab05a00f5ff
Gitweb:
https://git.kernel.org/tip/dca54f8ce1c3c979caf06cfdcdf8eab05a00f5ff
Author:Kefeng Wang 
AuthorDate:Thu, 29 Oct 2020 20:33:16 +08:00
Committer: Daniel Lezcano 
CommitterDate: Thu, 03 Dec 2020 19:16:17 +01:00

clocksource/drivers/sp804: Correct clk_get_rate handle

clk_get_rate won't return negative value, correct clk_get_rate handle.

Signed-off-by: Kefeng Wang 
Signed-off-by: Daniel Lezcano 
Link: 
https://lore.kernel.org/r/20201029123317.90286-4-wangkefeng.w...@huawei.com
---
 drivers/clocksource/timer-sp804.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/clocksource/timer-sp804.c 
b/drivers/clocksource/timer-sp804.c
index d74788b..fcce839 100644
--- a/drivers/clocksource/timer-sp804.c
+++ b/drivers/clocksource/timer-sp804.c
@@ -58,7 +58,6 @@ static struct sp804_clkevt sp804_clkevt[NR_TIMERS];
 
 static long __init sp804_get_clock_rate(struct clk *clk, const char *name)
 {
-   long rate;
int err;
 
if (!clk)
@@ -75,14 +74,7 @@ static long __init sp804_get_clock_rate(struct clk *clk, 
const char *name)
return err;
}
 
-   rate = clk_get_rate(clk);
-   if (rate < 0) {
-   pr_err("sp804: clock failed to get rate: %ld\n", rate);
-   clk_disable_unprepare(clk);
-   clk_put(clk);
-   }
-
-   return rate;
+   return clk_get_rate(clk);
 }
 
 static struct sp804_clkevt * __init sp804_clkevt_get(void __iomem *base)


[tip: timers/core] clocksource/drivers/sp804: Use pr_fmt

2020-12-03 Thread tip-bot2 for Kefeng Wang
The following commit has been merged into the timers/core branch of tip:

Commit-ID: 19f7ce8e36c09f4a2491b065dabd9162018309b6
Gitweb:
https://git.kernel.org/tip/19f7ce8e36c09f4a2491b065dabd9162018309b6
Author:Kefeng Wang 
AuthorDate:Thu, 29 Oct 2020 20:33:17 +08:00
Committer: Daniel Lezcano 
CommitterDate: Thu, 03 Dec 2020 19:16:18 +01:00

clocksource/drivers/sp804: Use pr_fmt

Add pr_fmt to prefix pr_ output.

Signed-off-by: Kefeng Wang 
Signed-off-by: Daniel Lezcano 
Link: 
https://lore.kernel.org/r/20201029123317.90286-5-wangkefeng.w...@huawei.com
---
 drivers/clocksource/timer-sp804.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/timer-sp804.c 
b/drivers/clocksource/timer-sp804.c
index fcce839..401d592 100644
--- a/drivers/clocksource/timer-sp804.c
+++ b/drivers/clocksource/timer-sp804.c
@@ -5,6 +5,9 @@
  *  Copyright (C) 1999 - 2003 ARM Limited
  *  Copyright (C) 2000 Deep Blue Solutions Ltd
  */
+
+#define pr_fmt(fmt)KBUILD_MODNAME ": " fmt
+
 #include 
 #include 
 #include 
@@ -63,13 +66,13 @@ static long __init sp804_get_clock_rate(struct clk *clk, 
const char *name)
if (!clk)
clk = clk_get_sys("sp804", name);
if (IS_ERR(clk)) {
-   pr_err("sp804: %s clock not found: %ld\n", name, PTR_ERR(clk));
+   pr_err("%s clock not found: %ld\n", name, PTR_ERR(clk));
return PTR_ERR(clk);
}
 
err = clk_prepare_enable(clk);
if (err) {
-   pr_err("sp804: clock failed to enable: %d\n", err);
+   pr_err("clock failed to enable: %d\n", err);
clk_put(clk);
return err;
}
@@ -218,7 +221,7 @@ static int __init sp804_clockevents_init(void __iomem 
*base, unsigned int irq,
 
if (request_irq(irq, sp804_timer_interrupt, IRQF_TIMER | IRQF_IRQPOLL,
"timer", _clockevent))
-   pr_err("%s: request_irq() failed\n", "timer");
+   pr_err("request_irq() failed\n");
clockevents_config_and_register(evt, rate, 0xf, 0x);
 
return 0;
@@ -280,7 +283,7 @@ static int __init sp804_of_init(struct device_node *np, 
struct sp804_timer *time
if (of_clk_get_parent_count(np) == 3) {
clk2 = of_clk_get(np, 1);
if (IS_ERR(clk2)) {
-   pr_err("sp804: %pOFn clock not found: %d\n", np,
+   pr_err("%pOFn clock not found: %d\n", np,
(int)PTR_ERR(clk2));
clk2 = NULL;
}


[tip: timers/core] clocksource/drivers/riscv: Make RISCV_TIMER depends on RISCV_SBI

2020-12-03 Thread tip-bot2 for Kefeng Wang
The following commit has been merged into the timers/core branch of tip:

Commit-ID: ab3105446f1ec4e98fadfc998ee24feec271c16c
Gitweb:
https://git.kernel.org/tip/ab3105446f1ec4e98fadfc998ee24feec271c16c
Author:Kefeng Wang 
AuthorDate:Wed, 28 Oct 2020 21:12:30 +08:00
Committer: Daniel Lezcano 
CommitterDate: Thu, 03 Dec 2020 19:16:26 +01:00

clocksource/drivers/riscv: Make RISCV_TIMER depends on RISCV_SBI

The riscv timer is set via SBI timer call, let's make RISCV_TIMER
depends on RISCV_SBI, and it also fixes some build issue.

Fixes: d5be89a8d118 ("RISC-V: Resurrect the MMIO timer implementation for 
M-mode systems")
Signed-off-by: Kefeng Wang 
Reviewed-by: Palmer Dabbelt 
Acked-by: Palmer Dabbelt 
Signed-off-by: Daniel Lezcano 
Link: 
https://lore.kernel.org/r/20201028131230.72907-1-wangkefeng.w...@huawei.com
---
 drivers/clocksource/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 390c27c..9f00b83 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -644,7 +644,7 @@ config ATCPIT100_TIMER
 
 config RISCV_TIMER
bool "Timer for the RISC-V platform" if COMPILE_TEST
-   depends on GENERIC_SCHED_CLOCK && RISCV
+   depends on GENERIC_SCHED_CLOCK && RISCV && RISCV_SBI
select TIMER_PROBE
select TIMER_OF
help


Re: [PATCH] riscv/stacktrace: fix stackframe without ra on the top

2020-11-27 Thread Kefeng Wang



On 2020/11/27 16:45, Chen Huang wrote:

When a function doesn't have a callee, then it will not push ra
into the stack, such as lkdtm_BUG() function:

addisp,sp,-16
sd  s0,8(sp)
addis0,sp,16
ebreak

Then we use pt_regs as a parameter to walk_stackframe(), for the
struct stackframe use {fp,ra} to get information from stack, it
will get the wrong value. And the call trace will be:

[] lkdtm_BUG+0x6/0x8
---[ end trace 18da3fbdf08e25d5 ]---

It should be that:
[] lkdtm_BUG+0x6/0x8
[] lkdtm_do_action+0x14/0x1c
[] direct_entry+0xc0/0x10a
[] full_proxy_write+0x42/0x6a
[] vfs_write+0x7e/0x214
[] ksys_write+0x98/0xc0
[] sys_write+0xe/0x16
[] ret_from_syscall+0x0/0x2
---[ end trace 61917f3d9a9fadcd ]---

Signed-off-by: Chen Huang 
---
  arch/riscv/kernel/stacktrace.c | 9 -
  1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c
index 595342910c3f..d1d4c18335c4 100644
--- a/arch/riscv/kernel/stacktrace.c
+++ b/arch/riscv/kernel/stacktrace.c
@@ -57,7 +57,14 @@ void notrace walk_stackframe(struct task_struct *task, 
struct pt_regs *regs,
/* Unwind stack frame */
frame = (struct stackframe *)fp - 1;
sp = fp;
-   fp = frame->fp;
+   if (regs && (frame->fp & 0x7) && (pc == regs->epc)) {
+   fp = frame->ra;
+   pc = regs->ra;
+   continue;
+   } else {
+   fp = frame->fp;
+   }
+
pc = ftrace_graph_ret_addr(current, NULL, frame->ra,
   (unsigned long *)(fp - 8));


Better to move above code into else branch


}


Re: [PATCH] printk: finalize records with trailing newlines

2020-11-26 Thread Kefeng Wang



On 2020/11/26 19:48, John Ogness wrote:

Any record with a trailing newline (LOG_NEWLINE flag) cannot
be continued because the newline has been stripped and will
not be visible if the message is appended. This was already
handled correctly when committing in log_output() but was
not handled correctly when committing in log_store().

Fixes: f5f022e53b87 ("printk: reimplement log_cont using record extension")
Signed-off-by: John Ogness 
---
  This is an important bugfix for continuous messages and should
  be part of the 5.10 release.

  If not applied, newlines will vanish when concatenating
  continuous with trailing newlines.

Thanks for you quick fix.

Reported-and-tested-by:  Kefeng Wang 


  kernel/printk/printk.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index fe64a49344bf..bc1e3b5a97bd 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -528,8 +528,8 @@ static int log_store(u32 caller_id, int facility, int level,
if (dev_info)
memcpy(>dev_info, dev_info, sizeof(r.info->dev_info));
  
-	/* insert message */

-   if ((flags & LOG_CONT) || !(flags & LOG_NEWLINE))
+   /* A message without a trailing newline can be continued. */
+   if (!(flags & LOG_NEWLINE))
prb_commit();
else
prb_final_commit();


Re: [PATCH] drivers: clocksource: timer-riscv: Depend on the SBI

2020-11-25 Thread Kefeng Wang

Hi Palmer,  I send a same patch and have been acked from you : )

https://patchwork.kernel.org/project/linux-riscv/patch/20201028131230.72907-1-wangkefeng.w...@huawei.com/

On 2020/11/26 3:58, Palmer Dabbelt wrote:

From: Palmer Dabbelt 

Fundamentally this is an SBI timer driver, so it cannot be enabled without
support for the RISC-V SBI.

Fixes: d5be89a8d118 ("RISC-V: Resurrect the MMIO timer implementation for M-mode 
systems")
Signed-off-by: Palmer Dabbelt 
---
  drivers/clocksource/Kconfig | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 68b087bff59c..3eeaf0efba8f 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -655,6 +655,7 @@ config ATCPIT100_TIMER
  config RISCV_TIMER
bool "Timer for the RISC-V platform" if COMPILE_TEST
depends on GENERIC_SCHED_CLOCK && RISCV
+   depends on RISCV_SBI
select TIMER_PROBE
select TIMER_OF
help


[PATCH] scsi: fnic: Fix error return in fnic_probe

2020-11-15 Thread Kefeng Wang
If mempool_create_slab_pool fails, return -ENOMEM.

Reported-by: Hulk Robot 
Signed-off-by: Kefeng Wang 
---
 drivers/scsi/fnic/fnic_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
index 5f8a7ef8f6a8..4f7befb43d60 100644
--- a/drivers/scsi/fnic/fnic_main.c
+++ b/drivers/scsi/fnic/fnic_main.c
@@ -740,6 +740,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
for (i = 0; i < FNIC_IO_LOCKS; i++)
spin_lock_init(>io_req_lock[i]);
 
+   err = -ENOMEM;
fnic->io_req_pool = mempool_create_slab_pool(2, fnic_io_req_cache);
if (!fnic->io_req_pool)
goto err_out_free_resources;
-- 
2.26.2



Re: [PATCH] panic: Avoid dump_stack() twice

2020-11-12 Thread Kefeng Wang



On 2020/11/13 14:39, Alexey Kardashevskiy wrote:

Fixed already

https://ozlabs.org/~akpm/mmots/broken-out/panic-dont-dump-stack-twice-on-warn.patch 



Sorry for breaking this :(


OK.


[PATCH] panic: Avoid dump_stack() twice

2020-11-12 Thread Kefeng Wang
stacktrace will be dumped twice on ARM64 after commit 3f388f28639f
("panic: dump registers on panic_on_warn"), will not dump_stack
when no regs as before.

Fixes: 3f388f28639f ("panic: dump registers on panic_on_warn")
Signed-off-by: Kefeng Wang 
---
 kernel/panic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/panic.c b/kernel/panic.c
index 396142ee43fd..332736a72a58 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -605,7 +605,8 @@ void __warn(const char *file, int line, void *caller, 
unsigned taint,
panic("panic_on_warn set ...\n");
}
 
-   dump_stack();
+   if (!regs)
+   dump_stack();
 
print_irqtrace_events(current);
 
-- 
2.26.2



Re: [PATCH] regmap: Properly free allocated name for regmap_config of syscon

2020-11-11 Thread Kefeng Wang



On 2020/11/10 16:47, Marc Zyngier wrote:

On 2020-11-10 01:35, Kefeng Wang wrote:

On 2020/11/10 1:23, Mark Brown wrote:

On Mon, Nov 09, 2020 at 07:58:16PM +0800, Kefeng Wang wrote:

Hi Marc,  the regmap debugfs will duplicate a name in 
regmap_set_name(), and


syscon_config.name won't be used in syscon,  so your following patch
doesn't seem

to be necessary,  right ? Please correct me if I'm wrong, thanks.


It was certainly necessary at the time when I wrote the patch, as it
was fixing some obvious memory corruption (use after free).

It is very possible that the flow has been reorganised since, as the
following commit hints at:

commit e15d7f2b81d2e7d93115d46fa931b366c1cdebc2
Author: Suman Anna 
Date:   Mon Jul 27 16:10:08 2020 -0500

    mfd: syscon: Use a unique name with regmap_config

    The DT node full name is currently being used in regmap_config
    which in turn is used to create the regmap debugfs directories.
    This name however is not guaranteed to be unique and the regmap
    debugfs registration can fail in the cases where the syscon nodes
    have the same unit-address but are present in different DT node
    hierarchies. Replace this logic using the syscon reg resource
    address instead (inspired from logic used while creating platform
    devices) to ensure a unique name is given for each syscon.

    Signed-off-by: Suman Anna 
    Reviewed-by: Arnd Bergmann 
    Signed-off-by: Lee Jones 

I suggest you come up with a more complete analysis of the problem
and how it came to be.


I check the history of above patch[1],

"The regmap name is expected to be managed by the caller and should be
live as long as the regmap is live, it is almost always static data."

so keep it as your patch said, thanks.

[1] 
https://patchwork.kernel.org/project/linux-arm-kernel/patch/20200727211008.24225-1-s-a...@ti.com/#23575471





    M.


Re: [PATCH] regmap: Properly free allocated name for regmap_config of syscon

2020-11-09 Thread Kefeng Wang



On 2020/11/10 1:23, Mark Brown wrote:

On Mon, Nov 09, 2020 at 07:58:16PM +0800, Kefeng Wang wrote:


syscon_config.name in of_syscon_register is allocated using kasprintf,
which should be freed when it is not used after regmap_set_name, fix
the following memory leak.
unreferenced object 0xffe07fe8c150 (size 16):
   comm "swapper/0", pid 1, jiffies 4294892540 (age 68.168s)
   hex dump (first 16 bytes):
 74 65 73 74 40 31 30 30 30 30 30 00 e0 ff ff ff  test@10.
   backtrace:
 [<23d86736>] create_object+0xe8/0x348
 [<fe9d1b17>] kmemleak_alloc+0x20/0x2a

Please think hard before including complete backtraces in upstream
reports, they are very large and contain almost no useful information
relative to their size so often obscure the relevant content in your
message. If part of the backtrace is usefully illustrative (it often is
for search engines if nothing else) then it's usually better to pull out
the relevant sections.


2899872b627e   "regmap: debugfs: Fix memory leak in regmap_debugfs_init" 
add a similar


backtrack, but the address of the trace is useless, will be careful next 
time.



@@ -601,6 +601,7 @@ static int regmap_set_name(struct regmap *map, const struct 
regmap_config *confi
if (!name)
return -ENOMEM;
  
+		kfree_const(config->name);

kfree_const(map->name);
map->name = name;
}

Why would we free the passed in name here?  The name wes passed in from
outside regmap in a const configuration struct, we've no idea within
regmap if it was dynamically allocted or not and it seems very
surprising that we'd go off and free it.  The whole reason we're
duplicating it in regmap_set_name() is that we don't know how long it's
going to be around so we don't want to reference it after having
returned to the caller.  If the caller has dynamically allocated it then
the caller should deal with freeing it.


Yes, after check it again, this patch is wrong.

Hi Marc,  the regmap debugfs will duplicate a name in regmap_set_name(), 
and


syscon_config.name won't be used in syscon,  so your following patch 
doesn't seem


to be necessary,  right ? Please correct me if I'm wrong, thanks.


commit 529a1101212a785c5df92c314b0e718287150c3b
Author: Marc Zyngier 
Date:   Thu Sep 3 17:02:37 2020 +0100

    mfd: syscon: Don't free allocated name for regmap_config

    The name allocated for the regmap_config structure is freed
    pretty early, right after the registration of the MMIO region.

    Unfortunately, that doesn't follow the life cycle that debugfs
    expects, as it can access the name field long after the free
    has occurred.

    Move the free on the error path, and keep it forever otherwise.




[PATCH] regmap: Properly free allocated name for regmap_config of syscon

2020-11-09 Thread Kefeng Wang
syscon_config.name in of_syscon_register is allocated using kasprintf,
which should be freed when it is not used after regmap_set_name, fix
the following memory leak.

unreferenced object 0xffe07fe8c150 (size 16):
  comm "swapper/0", pid 1, jiffies 4294892540 (age 68.168s)
  hex dump (first 16 bytes):
74 65 73 74 40 31 30 30 30 30 30 00 e0 ff ff ff  test@10.
  backtrace:
[<23d86736>] create_object+0xe8/0x348
[<fe9d1b17>] kmemleak_alloc+0x20/0x2a
[<6bba3c96>] __kmalloc_track_caller+0x174/0x272
[<8bbb1565>] kvasprintf+0x42/0x86
[<0e566920>] kasprintf+0x34/0x50
[<809602dd>] of_syscon_register+0x11c/0x2a8
[<711191ee>] device_node_get_regmap+0x6a/0x98
[<83dd951c>] syscon_node_to_regmap+0x2e/0x38
[<cbe0596d>] syscon_regmap_lookup_by_phandle+0x1e/0x26
[<9d9c679f>] syscon_reboot_probe+0x58/0x1aa
[<7b610fab>] platform_drv_probe+0x30/0x64
[<31597f78>] really_probe+0x9c/0x274
[<4d1de808>] driver_probe_device+0x2c/0x68
[<8a998a90>] device_driver_attach+0x4c/0x50
[<2ea43ad9>] __driver_attach+0x66/0xa0
[<18505756>] bus_for_each_dev+0x5a/0x98

Fixes: 529a1101212a ("mfd: syscon: Don't free allocated name for regmap_config")
Signed-off-by: Kefeng Wang 
---
 drivers/base/regmap/regmap.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 5db536ccfcd6..c1c1e53d46ac 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -601,6 +601,7 @@ static int regmap_set_name(struct regmap *map, const struct 
regmap_config *confi
if (!name)
return -ENOMEM;
 
+   kfree_const(config->name);
kfree_const(map->name);
map->name = name;
}
-- 
2.26.2



[PATCH 1/4] clocksource/drivers/sp804: Make some symbol static

2020-10-29 Thread Kefeng Wang
drivers/clocksource/timer-sp804.c:38:31: warning: symbol 'arm_sp804_timer' was 
not declared. Should it be static?
drivers/clocksource/timer-sp804.c:47:31: warning: symbol 'hisi_sp804_timer' was 
not declared. Should it be static?
drivers/clocksource/timer-sp804.c:120:12: warning: symbol 
'sp804_clocksource_and_sched_clock_init' was not declared. Should it be static?
drivers/clocksource/timer-sp804.c:219:12: warning: symbol 
'sp804_clockevents_init' was not declared. Should it be static?

And move __initdata after the variables.

Signed-off-by: Kefeng Wang 
---
 drivers/clocksource/timer-sp804.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/clocksource/timer-sp804.c 
b/drivers/clocksource/timer-sp804.c
index 6e8ad4a4ea3c..43d31bf09a18 100644
--- a/drivers/clocksource/timer-sp804.c
+++ b/drivers/clocksource/timer-sp804.c
@@ -34,8 +34,7 @@
 #define HISI_TIMER_BGLOAD  0x20
 #define HISI_TIMER_BGLOAD_H0x24
 
-
-struct sp804_timer __initdata arm_sp804_timer = {
+static struct sp804_timer arm_sp804_timer __initdata = {
.load   = TIMER_LOAD,
.value  = TIMER_VALUE,
.ctrl   = TIMER_CTRL,
@@ -44,7 +43,7 @@ struct sp804_timer __initdata arm_sp804_timer = {
.width  = 32,
 };
 
-struct sp804_timer __initdata hisi_sp804_timer = {
+static struct sp804_timer hisi_sp804_timer __initdata = {
.load   = HISI_TIMER_LOAD,
.load_h = HISI_TIMER_LOAD_H,
.value  = HISI_TIMER_VALUE,
@@ -117,7 +116,7 @@ static u64 notrace sp804_read(void)
return ~readl_relaxed(sched_clkevt->value);
 }
 
-int __init sp804_clocksource_and_sched_clock_init(void __iomem *base,
+static int __init sp804_clocksource_and_sched_clock_init(void __iomem *base,
  const char *name,
  struct clk *clk,
  int use_sched_clock)
@@ -216,7 +215,7 @@ static struct clock_event_device sp804_clockevent = {
.rating = 300,
 };
 
-int __init sp804_clockevents_init(void __iomem *base, unsigned int irq,
+static int __init sp804_clockevents_init(void __iomem *base, unsigned int irq,
  struct clk *clk, const char *name)
 {
struct clock_event_device *evt = _clockevent;
-- 
2.26.2



[PATCH 3/4] clocksource/drivers/sp804: Correct clk_get_rate handle

2020-10-29 Thread Kefeng Wang
clk_get_rate won't return negative value, correct clk_get_rate handle.

Signed-off-by: Kefeng Wang 
---
 drivers/clocksource/timer-sp804.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/clocksource/timer-sp804.c 
b/drivers/clocksource/timer-sp804.c
index 9e0cc029b06a..e0b48ecf20ab 100644
--- a/drivers/clocksource/timer-sp804.c
+++ b/drivers/clocksource/timer-sp804.c
@@ -58,7 +58,6 @@ static struct sp804_clkevt sp804_clkevt[NR_TIMERS];
 
 static long __init sp804_get_clock_rate(struct clk *clk, const char *name)
 {
-   long rate;
int err;
 
if (!clk)
@@ -75,14 +74,7 @@ static long __init sp804_get_clock_rate(struct clk *clk, 
const char *name)
return err;
}
 
-   rate = clk_get_rate(clk);
-   if (rate < 0) {
-   pr_err("sp804: clock failed to get rate: %ld\n", rate);
-   clk_disable_unprepare(clk);
-   clk_put(clk);
-   }
-
-   return rate;
+   return clk_get_rate(clk);
 }
 
 static struct sp804_clkevt * __init sp804_clkevt_get(void __iomem *base)
-- 
2.26.2



[PATCH 2/4] clocksource/drivers/sp804: Use clk_prepare_enable and clk_disable_unprepare

2020-10-29 Thread Kefeng Wang
Directly use clk_prepare_enable and clk_disable_unprepare.

Signed-off-by: Kefeng Wang 
---
 drivers/clocksource/timer-sp804.c | 13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/clocksource/timer-sp804.c 
b/drivers/clocksource/timer-sp804.c
index 43d31bf09a18..9e0cc029b06a 100644
--- a/drivers/clocksource/timer-sp804.c
+++ b/drivers/clocksource/timer-sp804.c
@@ -68,17 +68,9 @@ static long __init sp804_get_clock_rate(struct clk *clk, 
const char *name)
return PTR_ERR(clk);
}
 
-   err = clk_prepare(clk);
-   if (err) {
-   pr_err("sp804: clock failed to prepare: %d\n", err);
-   clk_put(clk);
-   return err;
-   }
-
-   err = clk_enable(clk);
+   err = clk_prepare_enable(clk);
if (err) {
pr_err("sp804: clock failed to enable: %d\n", err);
-   clk_unprepare(clk);
clk_put(clk);
return err;
}
@@ -86,8 +78,7 @@ static long __init sp804_get_clock_rate(struct clk *clk, 
const char *name)
rate = clk_get_rate(clk);
if (rate < 0) {
pr_err("sp804: clock failed to get rate: %ld\n", rate);
-   clk_disable(clk);
-   clk_unprepare(clk);
+   clk_disable_unprepare(clk);
clk_put(clk);
}
 
-- 
2.26.2



[PATCH 4/4] clocksource/drivers/sp804: Use pr_fmt

2020-10-29 Thread Kefeng Wang
Add pr_fmt to prefix pr_ output.

Signed-off-by: Kefeng Wang 
---
 drivers/clocksource/timer-sp804.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/timer-sp804.c 
b/drivers/clocksource/timer-sp804.c
index e0b48ecf20ab..778ad71a77ac 100644
--- a/drivers/clocksource/timer-sp804.c
+++ b/drivers/clocksource/timer-sp804.c
@@ -5,6 +5,9 @@
  *  Copyright (C) 1999 - 2003 ARM Limited
  *  Copyright (C) 2000 Deep Blue Solutions Ltd
  */
+
+#define pr_fmt(fmt)KBUILD_MODNAME ": " fmt
+
 #include 
 #include 
 #include 
@@ -63,13 +66,13 @@ static long __init sp804_get_clock_rate(struct clk *clk, 
const char *name)
if (!clk)
clk = clk_get_sys("sp804", name);
if (IS_ERR(clk)) {
-   pr_err("sp804: %s clock not found: %ld\n", name, PTR_ERR(clk));
+   pr_err("%s clock not found: %ld\n", name, PTR_ERR(clk));
return PTR_ERR(clk);
}
 
err = clk_prepare_enable(clk);
if (err) {
-   pr_err("sp804: clock failed to enable: %d\n", err);
+   pr_err("clock failed to enable: %d\n", err);
clk_put(clk);
return err;
}
@@ -218,7 +221,7 @@ static int __init sp804_clockevents_init(void __iomem 
*base, unsigned int irq,
 
if (request_irq(irq, sp804_timer_interrupt, IRQF_TIMER | IRQF_IRQPOLL,
"timer", _clockevent))
-   pr_err("%s: request_irq() failed\n", "timer");
+   pr_err("request_irq() failed\n");
clockevents_config_and_register(evt, rate, 0xf, 0x);
 
return 0;
@@ -280,7 +283,7 @@ static int __init sp804_of_init(struct device_node *np, 
struct sp804_timer *time
if (of_clk_get_parent_count(np) == 3) {
clk2 = of_clk_get(np, 1);
if (IS_ERR(clk2)) {
-   pr_err("sp804: %pOFn clock not found: %d\n", np,
+   pr_err("%pOFn clock not found: %d\n", np,
(int)PTR_ERR(clk2));
clk2 = NULL;
}
-- 
2.26.2



[PATCH 0/4] clocksource/drivers/sp804: misc cleanup

2020-10-29 Thread Kefeng Wang
Kefeng Wang (4):
  clocksource/drivers/sp804: Make some symbol static
  clocksource/drivers/sp804: Use clk_prepare_enable and
clk_disable_unprepare
  clocksource/drivers/sp804: Correct clk_get_rate handle
  clocksource/drivers/sp804: Use pr_fmt

 drivers/clocksource/timer-sp804.c | 41 ++-
 1 file changed, 13 insertions(+), 28 deletions(-)

-- 
2.26.2



[PATCH -next] mm/vmscan: Drop duplicated code in drop_slab_node

2020-09-29 Thread Kefeng Wang
The following patches fix same issue and both add fatal
signal check in drop_slab_node, kill a duplicated check.

  "mm/vmscan: add a fatal signals check in drop_slab_node"
  "mm/vmscan: fix infinite loop in drop_slab_node"

Cc: Chunxin Zang 
Signed-off-by: Kefeng Wang 
---
 mm/vmscan.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index eae57d092931..980155e257bf 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -699,9 +699,6 @@ void drop_slab_node(int nid)
do {
struct mem_cgroup *memcg = NULL;
 
-   if (fatal_signal_pending(current))
-   return;
-
if (fatal_signal_pending(current))
return;
 
-- 
2.26.2



[tip: timers/core] clocksource/drivers/sp804: Cleanup clk_get_sys()

2020-09-27 Thread tip-bot2 for Kefeng Wang
The following commit has been merged into the timers/core branch of tip:

Commit-ID: 7d19d521a034a8c58586814e0320463d1299a3a9
Gitweb:
https://git.kernel.org/tip/7d19d521a034a8c58586814e0320463d1299a3a9
Author:Kefeng Wang 
AuthorDate:Fri, 18 Sep 2020 21:22:29 +08:00
Committer: Daniel Lezcano 
CommitterDate: Thu, 24 Sep 2020 10:51:04 +02:00

clocksource/drivers/sp804: Cleanup clk_get_sys()

Move the clk_get_sys() part into sp804_get_clock_rate(), cleanup the same
code.

Signed-off-by: Kefeng Wang 
Signed-off-by: Zhen Lei 
Signed-off-by: Daniel Lezcano 
Link: https://lore.kernel.org/r/20200918132237.3552-2-thunder.leiz...@huawei.com
---
 drivers/clocksource/timer-sp804.c | 30 ++
 1 file changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/clocksource/timer-sp804.c 
b/drivers/clocksource/timer-sp804.c
index 5cd0abf..bec2d37 100644
--- a/drivers/clocksource/timer-sp804.c
+++ b/drivers/clocksource/timer-sp804.c
@@ -22,11 +22,18 @@
 
 #include "timer-sp.h"
 
-static long __init sp804_get_clock_rate(struct clk *clk)
+static long __init sp804_get_clock_rate(struct clk *clk, const char *name)
 {
long rate;
int err;
 
+   if (!clk)
+   clk = clk_get_sys("sp804", name);
+   if (IS_ERR(clk)) {
+   pr_err("sp804: %s clock not found: %ld\n", name, PTR_ERR(clk));
+   return PTR_ERR(clk);
+   }
+
err = clk_prepare(clk);
if (err) {
pr_err("sp804: clock failed to prepare: %d\n", err);
@@ -72,16 +79,7 @@ int  __init __sp804_clocksource_and_sched_clock_init(void 
__iomem *base,
 {
long rate;
 
-   if (!clk) {
-   clk = clk_get_sys("sp804", name);
-   if (IS_ERR(clk)) {
-   pr_err("sp804: clock not found: %d\n",
-  (int)PTR_ERR(clk));
-   return PTR_ERR(clk);
-   }
-   }
-
-   rate = sp804_get_clock_rate(clk);
+   rate = sp804_get_clock_rate(clk, name);
if (rate < 0)
return -EINVAL;
 
@@ -173,15 +171,7 @@ int __init __sp804_clockevents_init(void __iomem *base, 
unsigned int irq, struct
struct clock_event_device *evt = _clockevent;
long rate;
 
-   if (!clk)
-   clk = clk_get_sys("sp804", name);
-   if (IS_ERR(clk)) {
-   pr_err("sp804: %s clock not found: %d\n", name,
-   (int)PTR_ERR(clk));
-   return PTR_ERR(clk);
-   }
-
-   rate = sp804_get_clock_rate(clk);
+   rate = sp804_get_clock_rate(clk, name);
if (rate < 0)
return -EINVAL;
 


Re: [PATCH -next] arm64: Export __cpu_logical_map

2020-07-24 Thread Kefeng Wang



On 2020/7/24 21:10, Sudeep Holla wrote:

On Fri, Jul 24, 2020 at 11:08:03AM +0800, Kefeng Wang wrote:

+maillist

On 2020/7/24 11:04, Kefeng Wang wrote:

ERROR: modpost: "__cpu_logical_map" [drivers/cpufreq/tegra194-cpufreq.ko] 
undefined!

ARM64 tegra194-cpufreq driver use cpu_logical_map, export
__cpu_logical_map to fix build issue.


I wonder why like other instances in the drivers, the mpidr is not get
directly from the cpu. The cpufreq_driver->init call happens when the cpu
is being brought online and is executed on the required cpu IIUC.

read_cpuid_mpidr() is inline and avoids having to export the logical_cpu_map.
Though we may not add physical hotplug anytime soon, less dependency
on this cpu_logical_map is better given that we can resolve this without
the need to access the map.


Hi all,  thanks for all comments.

As Sudeep said, I will using read_cpuid_mpidr() directly in 
tegra194-cpufreq to


fix the build issue,  and later we also would turn cpu_logical_map() 
into a C wrapper.


If that's ok, I will send a new build-fix patch firstly, thanks.








Re: [PATCH -next] arm64: Export __cpu_logical_map

2020-07-24 Thread Kefeng Wang



On 2020/7/24 16:16, Anshuman Khandual wrote:

On 07/24/2020 08:38 AM, Kefeng Wang wrote:

+maillist

This does not seem to be a correct method of posting any patch.

sorry, forget to cc mailist when git send-email

On 2020/7/24 11:04, Kefeng Wang wrote:

ERROR: modpost: "__cpu_logical_map" [drivers/cpufreq/tegra194-cpufreq.ko] 
undefined!



ARM64 tegra194-cpufreq driver use cpu_logical_map, export
__cpu_logical_map to fix build issue.

Commit 887d5fc82cb4 ("cpufreq: Add Tegra194 cpufreq driver") which adds
this particular driver is present just on linux-next. But as expected,
the driver does not use __cpu_logical_map directly but instead accesses
it via cpu_logical_map() wrapper. Wondering, how did you even trigger
the modpost error ?


arch/arm64/include/asm/smp.h:#define cpu_logical_map(cpu) 
__cpu_logical_map[cpu]


Will see the error when using allmodconfig to build.




Reported-by: Hulk Robot 
Signed-off-by: Kefeng Wang 
---
   arch/arm64/kernel/setup.c | 1 +
   1 file changed, 1 insertion(+)

diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index c793276ec7ad9..3aea05fbb9998 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -275,6 +275,7 @@ static int __init reserve_memblock_reserved_regions(void)
   arch_initcall(reserve_memblock_reserved_regions);
     u64 __cpu_logical_map[NR_CPUS] = { [0 ... NR_CPUS-1] = INVALID_HWID };
+EXPORT_SYMBOL(__cpu_logical_map);
     void __init setup_arch(char **cmdline_p)
   {


___
linux-arm-kernel mailing list
linux-arm-ker...@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel


.





Re: [PATCH -next] arm64: Export __cpu_logical_map

2020-07-23 Thread Kefeng Wang

+maillist

On 2020/7/24 11:04, Kefeng Wang wrote:

ERROR: modpost: "__cpu_logical_map" [drivers/cpufreq/tegra194-cpufreq.ko] 
undefined!

ARM64 tegra194-cpufreq driver use cpu_logical_map, export
__cpu_logical_map to fix build issue.

Reported-by: Hulk Robot 
Signed-off-by: Kefeng Wang 
---
  arch/arm64/kernel/setup.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index c793276ec7ad9..3aea05fbb9998 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -275,6 +275,7 @@ static int __init reserve_memblock_reserved_regions(void)
  arch_initcall(reserve_memblock_reserved_regions);
  
  u64 __cpu_logical_map[NR_CPUS] = { [0 ... NR_CPUS-1] = INVALID_HWID };

+EXPORT_SYMBOL(__cpu_logical_map);
  
  void __init setup_arch(char **cmdline_p)

  {




[PATCH -next] remoteproc: qcom: Add missing slab.h

2020-07-12 Thread Kefeng Wang
drivers/remoteproc/qcom_common.c: In function ‘qcom_ssr_get_subsys’:
drivers/remoteproc/qcom_common.c:210:9: error: implicit declaration of function 
‘kzalloc’; did you mean ‘vzalloc’?
[-Werror=implicit-function-declaration]
  info = kzalloc(sizeof(*info), GFP_KERNEL);
 ^~~
 vzalloc

kzalloc() is declared in linux/slab.h, add include to fix build issue.

Reported-by: Hulk Robot 
Signed-off-by: Kefeng Wang 
---
 drivers/remoteproc/qcom_common.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c
index 2f45f0c79914e..085fd73fa23ae 100644
--- a/drivers/remoteproc/qcom_common.c
+++ b/drivers/remoteproc/qcom_common.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "remoteproc_internal.h"
-- 
2.26.2



[PATCH v3] sample-trace-array: Fix sleeping function called from invalid context

2020-06-09 Thread Kefeng Wang
 BUG: sleeping function called from invalid context at 
kernel/locking/mutex.c:935
 in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 0, name: swapper/5
 1 lock held by swapper/5/0:
  #0: 80001002bd90 (samples/ftrace/sample-trace-array.c:38){+.-.}-{0:0}, 
at: call_timer_fn+0x8/0x3e0
 CPU: 5 PID: 0 Comm: swapper/5 Not tainted 5.7.0+ #8
 Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015
 Call trace:
  dump_backtrace+0x0/0x1a0
  show_stack+0x20/0x30
  dump_stack+0xe4/0x150
  ___might_sleep+0x160/0x200
  __might_sleep+0x58/0x90
  __mutex_lock+0x64/0x948
  mutex_lock_nested+0x3c/0x58
  __ftrace_set_clr_event+0x44/0x88
  trace_array_set_clr_event+0x24/0x38
  mytimer_handler+0x34/0x40 [sample_trace_array]

mutex_lock() will be called in interrupt context, using workqueue to fix it.

Fixes: 89ed42495ef4 ("tracing: Sample module to demonstrate kernel access to 
Ftrace instances.")
Signed-off-by: Kefeng Wang 
Reviewed-by: Divya Indi 
---
V3:
- add Fixes and RB
v2:
- add include of linux/workqueue.h
- add missing cancel_work_sync() suggested by Divya Indi

 samples/ftrace/sample-trace-array.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/samples/ftrace/sample-trace-array.c 
b/samples/ftrace/sample-trace-array.c
index d523450d73eb..9e437f930280 100644
--- a/samples/ftrace/sample-trace-array.c
+++ b/samples/ftrace/sample-trace-array.c
@@ -6,6 +6,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * Any file that uses trace points, must include the header.
@@ -20,6 +21,16 @@ struct trace_array *tr;
 static void mytimer_handler(struct timer_list *unused);
 static struct task_struct *simple_tsk;
 
+static void trace_work_fn(struct work_struct *work)
+{
+   /*
+* Disable tracing for event "sample_event".
+*/
+   trace_array_set_clr_event(tr, "sample-subsystem", "sample_event",
+   false);
+}
+static DECLARE_WORK(trace_work, trace_work_fn);
+
 /*
  * mytimer: Timer setup to disable tracing for event "sample_event". This
  * timer is only for the purposes of the sample module to demonstrate access of
@@ -29,11 +40,7 @@ static DEFINE_TIMER(mytimer, mytimer_handler);
 
 static void mytimer_handler(struct timer_list *unused)
 {
-   /*
-* Disable tracing for event "sample_event".
-*/
-   trace_array_set_clr_event(tr, "sample-subsystem", "sample_event",
-   false);
+   schedule_work(_work);
 }
 
 static void simple_thread_func(int count)
@@ -76,6 +83,7 @@ static int simple_thread(void *arg)
simple_thread_func(count++);
 
del_timer();
+   cancel_work_sync(_work);
 
/*
 * trace_array_put() decrements the reference counter associated with
-- 
2.27.0



Re: [PATCH v2] sample-trace-array: Fix sleeping function called from invalid context

2020-06-09 Thread Kefeng Wang



On 2020/6/10 0:29, Divya Indi wrote:

On 6/9/20 6:51 AM, Kefeng Wang wrote:

  BUG: sleeping function called from invalid context at 
kernel/locking/mutex.c:935
  in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 0, name: swapper/5
  1 lock held by swapper/5/0:
   #0: 80001002bd90 (samples/ftrace/sample-trace-array.c:38){+.-.}-{0:0}, 
at: call_timer_fn+0x8/0x3e0
  CPU: 5 PID: 0 Comm: swapper/5 Not tainted 5.7.0+ #8
  Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015
  Call trace:
   dump_backtrace+0x0/0x1a0
   show_stack+0x20/0x30
   dump_stack+0xe4/0x150
   ___might_sleep+0x160/0x200
   __might_sleep+0x58/0x90
   __mutex_lock+0x64/0x948
   mutex_lock_nested+0x3c/0x58
   __ftrace_set_clr_event+0x44/0x88
   trace_array_set_clr_event+0x24/0x38
   mytimer_handler+0x34/0x40 [sample_trace_array]

mutex_lock() will be called in interrupt context, using workqueue to fix it.

Fixes:

Missing it, will send v3, thanks.

Signed-off-by: Kefeng Wang 

Reviewed-by: Divya Indi 






[PATCH] sample-trace-array: Remove trace_array 'sample-instance'

2020-06-09 Thread Kefeng Wang
Remove trace_array 'sample-instance' if kthread_run fails
in sample_trace_array_init().

Signed-off-by: Kefeng Wang 
---
 samples/ftrace/sample-trace-array.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/samples/ftrace/sample-trace-array.c 
b/samples/ftrace/sample-trace-array.c
index 9e437f930280..6aba02a31c96 100644
--- a/samples/ftrace/sample-trace-array.c
+++ b/samples/ftrace/sample-trace-array.c
@@ -115,8 +115,12 @@ static int __init sample_trace_array_init(void)
trace_printk_init_buffers();
 
simple_tsk = kthread_run(simple_thread, NULL, "sample-instance");
-   if (IS_ERR(simple_tsk))
+   if (IS_ERR(simple_tsk)) {
+   trace_array_put(tr);
+   trace_array_destroy(tr);
return -1;
+   }
+
return 0;
 }
 
-- 
2.27.0



[PATCH v2] sample-trace-array: Fix sleeping function called from invalid context

2020-06-09 Thread Kefeng Wang
 BUG: sleeping function called from invalid context at 
kernel/locking/mutex.c:935
 in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 0, name: swapper/5
 1 lock held by swapper/5/0:
  #0: 80001002bd90 (samples/ftrace/sample-trace-array.c:38){+.-.}-{0:0}, 
at: call_timer_fn+0x8/0x3e0
 CPU: 5 PID: 0 Comm: swapper/5 Not tainted 5.7.0+ #8
 Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015
 Call trace:
  dump_backtrace+0x0/0x1a0
  show_stack+0x20/0x30
  dump_stack+0xe4/0x150
  ___might_sleep+0x160/0x200
  __might_sleep+0x58/0x90
  __mutex_lock+0x64/0x948
  mutex_lock_nested+0x3c/0x58
  __ftrace_set_clr_event+0x44/0x88
  trace_array_set_clr_event+0x24/0x38
  mytimer_handler+0x34/0x40 [sample_trace_array]

mutex_lock() will be called in interrupt context, using workqueue to fix it.

Signed-off-by: Kefeng Wang 
---
v2:
- add include of linux/workqueue.h
- add missing cancel_work_sync() suggested by Divya Indi

 samples/ftrace/sample-trace-array.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/samples/ftrace/sample-trace-array.c 
b/samples/ftrace/sample-trace-array.c
index d523450d73eb..9e437f930280 100644
--- a/samples/ftrace/sample-trace-array.c
+++ b/samples/ftrace/sample-trace-array.c
@@ -6,6 +6,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * Any file that uses trace points, must include the header.
@@ -20,6 +21,16 @@ struct trace_array *tr;
 static void mytimer_handler(struct timer_list *unused);
 static struct task_struct *simple_tsk;
 
+static void trace_work_fn(struct work_struct *work)
+{
+   /*
+* Disable tracing for event "sample_event".
+*/
+   trace_array_set_clr_event(tr, "sample-subsystem", "sample_event",
+   false);
+}
+static DECLARE_WORK(trace_work, trace_work_fn);
+
 /*
  * mytimer: Timer setup to disable tracing for event "sample_event". This
  * timer is only for the purposes of the sample module to demonstrate access of
@@ -29,11 +40,7 @@ static DEFINE_TIMER(mytimer, mytimer_handler);
 
 static void mytimer_handler(struct timer_list *unused)
 {
-   /*
-* Disable tracing for event "sample_event".
-*/
-   trace_array_set_clr_event(tr, "sample-subsystem", "sample_event",
-   false);
+   schedule_work(_work);
 }
 
 static void simple_thread_func(int count)
@@ -76,6 +83,7 @@ static int simple_thread(void *arg)
simple_thread_func(count++);
 
del_timer();
+   cancel_work_sync(_work);
 
/*
 * trace_array_put() decrements the reference counter associated with
-- 
2.27.0



[PATCH] sample-trace-array: Fix sleeping function called from invalid context

2020-06-08 Thread Kefeng Wang
 BUG: sleeping function called from invalid context at 
kernel/locking/mutex.c:935
 in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 0, name: swapper/5
 1 lock held by swapper/5/0:
  #0: 80001002bd90 (samples/ftrace/sample-trace-array.c:38){+.-.}-{0:0}, 
at: call_timer_fn+0x8/0x3e0
 CPU: 5 PID: 0 Comm: swapper/5 Not tainted 5.7.0+ #8
 Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015
 Call trace:
  dump_backtrace+0x0/0x1a0
  show_stack+0x20/0x30
  dump_stack+0xe4/0x150
  ___might_sleep+0x160/0x200
  __might_sleep+0x58/0x90
  __mutex_lock+0x64/0x948
  mutex_lock_nested+0x3c/0x58
  __ftrace_set_clr_event+0x44/0x88
  trace_array_set_clr_event+0x24/0x38
  mytimer_handler+0x34/0x40 [sample_trace_array]

mutex_lock() will be called in interrupt context, using workqueueu to fix it.

Signed-off-by: Kefeng Wang 
---
 samples/ftrace/sample-trace-array.c | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/samples/ftrace/sample-trace-array.c 
b/samples/ftrace/sample-trace-array.c
index d523450d73eb..41684c7dbd7b 100644
--- a/samples/ftrace/sample-trace-array.c
+++ b/samples/ftrace/sample-trace-array.c
@@ -20,6 +20,16 @@ struct trace_array *tr;
 static void mytimer_handler(struct timer_list *unused);
 static struct task_struct *simple_tsk;
 
+static void trace_work_fn(struct work_struct *work)
+{
+   /*
+* Disable tracing for event "sample_event".
+*/
+   trace_array_set_clr_event(tr, "sample-subsystem", "sample_event",
+   false);
+}
+static DECLARE_WORK(trace_work, trace_work_fn);
+
 /*
  * mytimer: Timer setup to disable tracing for event "sample_event". This
  * timer is only for the purposes of the sample module to demonstrate access of
@@ -29,11 +39,7 @@ static DEFINE_TIMER(mytimer, mytimer_handler);
 
 static void mytimer_handler(struct timer_list *unused)
 {
-   /*
-* Disable tracing for event "sample_event".
-*/
-   trace_array_set_clr_event(tr, "sample-subsystem", "sample_event",
-   false);
+   schedule_work(_work);
 }
 
 static void simple_thread_func(int count)
-- 
2.27.0



[tip: core/urgent] rcuperf: Fix printk format warning

2020-06-03 Thread tip-bot2 for Kefeng Wang
The following commit has been merged into the core/urgent branch of tip:

Commit-ID: b3e2d20973db3ec87a6dd2fee0c88d3c2e7c2f61
Gitweb:
https://git.kernel.org/tip/b3e2d20973db3ec87a6dd2fee0c88d3c2e7c2f61
Author:Kefeng Wang 
AuthorDate:Fri, 17 Apr 2020 12:02:45 +08:00
Committer: Paul E. McKenney 
CommitterDate: Tue, 02 Jun 2020 08:41:37 -07:00

rcuperf: Fix printk format warning

Using "%zu" to fix following warning,
kernel/rcu/rcuperf.c: In function ‘kfree_perf_init’:
include/linux/kern_levels.h:5:18: warning: format ‘%lu’ expects argument of 
type ‘long unsigned int’, but argument 2 has type ‘unsigned int’ [-Wformat=]

Signed-off-by: Kefeng Wang 
Signed-off-by: Paul E. McKenney 
---
 kernel/rcu/rcuperf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/rcu/rcuperf.c b/kernel/rcu/rcuperf.c
index 16dd1e6..9eb39c2 100644
--- a/kernel/rcu/rcuperf.c
+++ b/kernel/rcu/rcuperf.c
@@ -723,7 +723,7 @@ kfree_perf_init(void)
schedule_timeout_uninterruptible(1);
}
 
-   pr_alert("kfree object size=%lu\n", kfree_mult * sizeof(struct 
kfree_obj));
+   pr_alert("kfree object size=%zu\n", kfree_mult * sizeof(struct 
kfree_obj));
 
kfree_reader_tasks = kcalloc(kfree_nrealthreads, 
sizeof(kfree_reader_tasks[0]),
   GFP_KERNEL);


Re: [PATCH 09/10] timer-riscv: Fix undefined riscv_time_val

2020-05-19 Thread Kefeng Wang



On 2020/5/20 9:14, Anup Patel wrote:

On Tue, May 19, 2020 at 7:21 PM Daniel Lezcano
 wrote:

On 19/05/2020 14:39, Kefeng Wang wrote:

On 2020/5/19 4:23, Daniel Lezcano wrote:

Hi Kefeng,

On 18/05/2020 17:40, Kefeng Wang wrote:

On 2020/5/18 22:09, Daniel Lezcano wrote:

On 13/05/2020 23:14, Palmer Dabbelt wrote:

On Sun, 10 May 2020 19:20:00 PDT (-0700), wangkefeng.w...@huawei.com
wrote:

ERROR: modpost: "riscv_time_val" [crypto/tcrypt.ko] undefined!

Reported-by: Hulk Robot 
Signed-off-by: Kefeng Wang 
---
drivers/clocksource/timer-riscv.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/clocksource/timer-riscv.c
b/drivers/clocksource/timer-riscv.c
index c4f15c4068c0..071b8c144027 100644
--- a/drivers/clocksource/timer-riscv.c
+++ b/drivers/clocksource/timer-riscv.c
@@ -19,6 +19,7 @@

u64 __iomem *riscv_time_cmp;
u64 __iomem *riscv_time_val;
+EXPORT_SYMBOL(riscv_time_val);

static inline void mmio_set_timer(u64 val)
{

Reviewed-by: Palmer Dabbelt 
Acked-by: Palmer Dabbelt 

Adding the clocksource maintainers.  Let me know if you want this
through my
tree, I'm assuming you want it through your tree.

How can we end up by an export symbol here ?!

Hi Danile,

s/Danile/Daniel/

Sorry for typing error.

Found this build error when CONFIG_RISCV_M_MODE=y and CONFIG_RISCV_SBI
is not,

see patch "4f9bbcefa142 riscv: add support for MMIO access to the timer
registers"

Thanks for the pointer.

The question still remains, how do we end up with this EXPORT_SYMBOL?

There is something wrong if the fix is an EXPORT_SYMBOL for a global
variable.

Not very clear, there are some global variable( eg, acpi_disabled,
memstart_addr in arm64,) is exported by EXPORT_SYMBOL,  do you mean that
export riscv_time_val is wrong way?

I do not maintain acpi neither arm64.mm.

AFAICT, riscv_time_val is globally declared in
drivers/clocksource/timer-riscv.c

The driver does not use this variable at all. Then there is a readl on
it in the header file arch/riscv/include/asm/timex.h

And finally it is initialized in arch/riscv/kernel/clint.c

Same thing for riscv_time_cmp.

The correct fix is to initialize the variables in the place where they
belong to (drivers/clocksource/timer-riscv.c), create a function to read
their content and export-symbol-gpl the function.


ok, it's better.  thanks for your explanation.



I agree with Daniel. Exporting riscv_time_val is a temporary fix.


yes.  it's only for build,  let's wait for Anup's patch.



The problem is timer-riscv.c is pretty convoluted right now. It is
implementing two different clocksources and clockevents in one-place.

I think we need two separate drivers for RISC-V world.

1. timer-riscv: This for regular S-mode kernel with MMU. The clocksource
will use TIME CSR and the clockevent device will use SBI calls.

2. timer-clint: This for M-mode kernel without MMU (or NoMMU kernel).
The clocksource will use MMIO counter for clocksource and the
clockevent device will use MMIO compare registers.

I will send a patch to have a separate timer-clint driver under
drivers/clocksource. (@Daniel, I hope you will be fine with this?)
Regards,
Anup



--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

.





Re: [PATCH 09/10] timer-riscv: Fix undefined riscv_time_val

2020-05-19 Thread Kefeng Wang



On 2020/5/19 4:23, Daniel Lezcano wrote:

Hi Kefeng,

On 18/05/2020 17:40, Kefeng Wang wrote:

On 2020/5/18 22:09, Daniel Lezcano wrote:

On 13/05/2020 23:14, Palmer Dabbelt wrote:

On Sun, 10 May 2020 19:20:00 PDT (-0700), wangkefeng.w...@huawei.com
wrote:

ERROR: modpost: "riscv_time_val" [crypto/tcrypt.ko] undefined!

Reported-by: Hulk Robot 
Signed-off-by: Kefeng Wang 
---
   drivers/clocksource/timer-riscv.c | 1 +
   1 file changed, 1 insertion(+)

diff --git a/drivers/clocksource/timer-riscv.c
b/drivers/clocksource/timer-riscv.c
index c4f15c4068c0..071b8c144027 100644
--- a/drivers/clocksource/timer-riscv.c
+++ b/drivers/clocksource/timer-riscv.c
@@ -19,6 +19,7 @@

   u64 __iomem *riscv_time_cmp;
   u64 __iomem *riscv_time_val;
+EXPORT_SYMBOL(riscv_time_val);

   static inline void mmio_set_timer(u64 val)
   {

Reviewed-by: Palmer Dabbelt 
Acked-by: Palmer Dabbelt 

Adding the clocksource maintainers.  Let me know if you want this
through my
tree, I'm assuming you want it through your tree.

How can we end up by an export symbol here ?!

Hi Danile,

s/Danile/Daniel/

Sorry for typing error.



Found this build error when CONFIG_RISCV_M_MODE=y and CONFIG_RISCV_SBI
is not,

see patch "4f9bbcefa142 riscv: add support for MMIO access to the timer
registers"

Thanks for the pointer.

The question still remains, how do we end up with this EXPORT_SYMBOL?

There is something wrong if the fix is an EXPORT_SYMBOL for a global
variable.


Not very clear, there are some global variable( eg, acpi_disabled, 
memstart_addr in arm64,) is exported by EXPORT_SYMBOL,  do you mean that 
export riscv_time_val is wrong way?












Re: [PATCH 09/10] timer-riscv: Fix undefined riscv_time_val

2020-05-18 Thread Kefeng Wang



On 2020/5/18 22:09, Daniel Lezcano wrote:

On 13/05/2020 23:14, Palmer Dabbelt wrote:

On Sun, 10 May 2020 19:20:00 PDT (-0700), wangkefeng.w...@huawei.com wrote:

ERROR: modpost: "riscv_time_val" [crypto/tcrypt.ko] undefined!

Reported-by: Hulk Robot 
Signed-off-by: Kefeng Wang 
---
  drivers/clocksource/timer-riscv.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/clocksource/timer-riscv.c
b/drivers/clocksource/timer-riscv.c
index c4f15c4068c0..071b8c144027 100644
--- a/drivers/clocksource/timer-riscv.c
+++ b/drivers/clocksource/timer-riscv.c
@@ -19,6 +19,7 @@

  u64 __iomem *riscv_time_cmp;
  u64 __iomem *riscv_time_val;
+EXPORT_SYMBOL(riscv_time_val);

  static inline void mmio_set_timer(u64 val)
  {

Reviewed-by: Palmer Dabbelt 
Acked-by: Palmer Dabbelt 

Adding the clocksource maintainers.  Let me know if you want this
through my
tree, I'm assuming you want it through your tree.

How can we end up by an export symbol here ?!


Hi Danile,

Found this build error when CONFIG_RISCV_M_MODE=y and CONFIG_RISCV_SBI 
is not,


see patch "4f9bbcefa142 riscv: add support for MMIO access to the timer 
registers"


thanks.








[PATCH v2] riscv: Fix print_vm_layout build error if NOMMU

2020-05-14 Thread Kefeng Wang
arch/riscv/mm/init.c: In function ‘print_vm_layout’:
arch/riscv/mm/init.c:68:37: error: ‘FIXADDR_START’ undeclared (first use in 
this function);
arch/riscv/mm/init.c:69:20: error: ‘FIXADDR_TOP’ undeclared
arch/riscv/mm/init.c:70:37: error: ‘PCI_IO_START’ undeclared
arch/riscv/mm/init.c:71:20: error: ‘PCI_IO_END’ undeclared
arch/riscv/mm/init.c:72:38: error: ‘VMEMMAP_START’ undeclared
arch/riscv/mm/init.c:73:20: error: ‘VMEMMAP_END’ undeclared (first use in this 
function);

Reported-by: Hulk Robot 
Signed-off-by: Kefeng Wang 
---
v2: 
- Should CONFIG_DEBUG_VM instead of DEBUG_VM
- Based on riscv fixes branch

 arch/riscv/mm/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 27a334106708..736de6c8739f 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -47,7 +47,7 @@ static void setup_zero_page(void)
memset((void *)empty_zero_page, 0, PAGE_SIZE);
 }
 
-#ifdef CONFIG_DEBUG_VM
+#if defined(CONFIG_MMU) && defined(CONFIG_DEBUG_VM)
 static inline void print_mlk(char *name, unsigned long b, unsigned long t)
 {
pr_notice("%12s : 0x%08lx - 0x%08lx   (%4ld kB)\n", name, b, t,
-- 
2.26.2



Re: [PATCH 04/10] riscv: Fix print_vm_layout build error if NOMMU

2020-05-14 Thread Kefeng Wang



On 2020/5/14 18:10, Alex Ghiti wrote:

Hi,

On 5/10/20 10:19 PM, Kefeng Wang wrote:

arch/riscv/mm/init.c: In function ‘print_vm_layout’:
arch/riscv/mm/init.c:68:37: error: ‘FIXADDR_START’ undeclared (first 
use in this function);

arch/riscv/mm/init.c:69:20: error: ‘FIXADDR_TOP’ undeclared
arch/riscv/mm/init.c:70:37: error: ‘PCI_IO_START’ undeclared
arch/riscv/mm/init.c:71:20: error: ‘PCI_IO_END’ undeclared
arch/riscv/mm/init.c:72:38: error: ‘VMEMMAP_START’ undeclared
arch/riscv/mm/init.c:73:20: error: ‘VMEMMAP_END’ undeclared (first 
use in this function);


Reported-by: Hulk Robot 
Signed-off-by: Kefeng Wang 
---
  arch/riscv/mm/init.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index dfcaebc3928f..58c39c44b9c9 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -49,7 +49,7 @@ static void setup_zero_page(void)
  memset((void *)empty_zero_page, 0, PAGE_SIZE);
  }
  -#ifdef CONFIG_DEBUG_VM
+#if defined(CONFIG_MMU) && defined(DEBUG_VM)



Shouldn't it be CONFIG_DEBUG_VM ?

oops, should be CONFIG_DEBUG_VM, will send v2, thanks.



  static inline void print_mlk(char *name, unsigned long b, unsigned 
long t)

  {
  pr_notice("%12s : 0x%08lx - 0x%08lx   (%4ld kB)\n", name, b, t,



Alex


.





Re: [PATCH 05/10] riscv: Disable ARCH_HAS_DEBUG_WX if NOMMU

2020-05-14 Thread Kefeng Wang



On 2020/5/14 5:14, Palmer Dabbelt wrote:
On Sun, 10 May 2020 19:19:56 PDT (-0700), wangkefeng.w...@huawei.com 
wrote:

DEBUG_WX is only useful when MMU enabled, diable it if nommu
and fix the build error.

Reported-by: Hulk Robot 
Signed-off-by: Kefeng Wang 
---
 arch/riscv/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 78f30f2fdd51..7da0a36a8df0 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -69,7 +69,7 @@ config RISCV
 select HAVE_ARCH_KASAN if MMU && 64BIT
 select HAVE_ARCH_KGDB
 select HAVE_ARCH_KGDB_QXFER_PKT
-    select ARCH_HAS_DEBUG_WX
+    select ARCH_HAS_DEBUG_WX if MMU

 config ARCH_MMAP_RND_BITS_MIN
 default 18 if 64BIT


Looks like this depends on something that isn't in any of my trees yet.
as said in cover letter, the patch is based on linux-next, tag 
next-20200508 :)







[PATCH 07/10] riscv: Make SYS_SUPPORTS_HUGETLBFS depends on MMU

2020-05-10 Thread Kefeng Wang
HUGETLBFS only used when MMU enabled, add the dependence.

Reported-by: Hulk Robot 
Signed-off-by: Kefeng Wang 
---
 arch/riscv/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 494e670520ae..d0010ed8e0f4 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -138,6 +138,7 @@ config ARCH_SUPPORTS_DEBUG_PAGEALLOC
def_bool y
 
 config SYS_SUPPORTS_HUGETLBFS
+   depends on MMU
def_bool y
 
 config STACKTRACE_SUPPORT
-- 
2.26.2



[PATCH 06/10] riscv: Disable ARCH_HAS_DEBUG_VIRTUAL if NOMMU

2020-05-10 Thread Kefeng Wang
DEBUG_VIRTUAL should only used when MMU enabled, add the dependence.

Signed-off-by: Kefeng Wang 
---
 arch/riscv/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 7da0a36a8df0..494e670520ae 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -53,7 +53,7 @@ config RISCV
select GENERIC_ARCH_TOPOLOGY if SMP
select ARCH_HAS_PTE_SPECIAL
select ARCH_HAS_MMIOWB
-   select ARCH_HAS_DEBUG_VIRTUAL
+   select ARCH_HAS_DEBUG_VIRTUAL if MMU
select HAVE_EBPF_JIT if MMU
select EDAC_SUPPORT
select ARCH_HAS_GIGANTIC_PAGE
-- 
2.26.2



[PATCH 10/10] riscv: mmiowb: Fix implicit declaration of function 'smp_processor_id'

2020-05-10 Thread Kefeng Wang
In file included from ./../include/linux/compiler_types.h:68,
 from :
../include/asm-generic/mmiowb.h: In function ‘mmiowb_set_pending’:
../include/asm-generic/percpu.h:34:38: error: implicit declaration of function 
‘smp_processor_id’; did you mean ‘raw_smp_processor_id’? 
[-Werror=implicit-function-declaration]
 #define my_cpu_offset per_cpu_offset(smp_processor_id())
  ^~~~
../include/linux/compiler-gcc.h:58:26: note: in definition of macro ‘RELOC_HIDE’
  (typeof(ptr)) (__ptr + (off)); \
  ^~~
../include/linux/percpu-defs.h:249:2: note: in expansion of macro 
‘SHIFT_PERCPU_PTR’
  SHIFT_PERCPU_PTR(ptr, my_cpu_offset);\
  ^~~~
../include/asm-generic/percpu.h:34:23: note: in expansion of macro 
‘per_cpu_offset’
 #define my_cpu_offset per_cpu_offset(smp_processor_id())
   ^~
../include/linux/percpu-defs.h:249:24: note: in expansion of macro 
‘my_cpu_offset’
  SHIFT_PERCPU_PTR(ptr, my_cpu_offset);\
^
../include/asm-generic/mmiowb.h:30:26: note: in expansion of macro 
‘this_cpu_ptr’
 #define __mmiowb_state() this_cpu_ptr(&__mmiowb_state)
  ^~~~
../include/asm-generic/mmiowb.h:37:28: note: in expansion of macro 
‘__mmiowb_state’
  struct mmiowb_state *ms = __mmiowb_state();
^~

Reported-by: Hulk Robot 
Signed-off-by: Kefeng Wang 
---
 arch/riscv/include/asm/mmiowb.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/riscv/include/asm/mmiowb.h b/arch/riscv/include/asm/mmiowb.h
index bb4091ff4a21..0b2333e71fdc 100644
--- a/arch/riscv/include/asm/mmiowb.h
+++ b/arch/riscv/include/asm/mmiowb.h
@@ -9,6 +9,7 @@
  */
 #define mmiowb()   __asm__ __volatile__ ("fence o,w" : : : "memory");
 
+#include 
 #include 
 
 #endif /* _ASM_RISCV_MMIOWB_H */
-- 
2.26.2



[PATCH 04/10] riscv: Fix print_vm_layout build error if NOMMU

2020-05-10 Thread Kefeng Wang
arch/riscv/mm/init.c: In function ‘print_vm_layout’:
arch/riscv/mm/init.c:68:37: error: ‘FIXADDR_START’ undeclared (first use in 
this function);
arch/riscv/mm/init.c:69:20: error: ‘FIXADDR_TOP’ undeclared
arch/riscv/mm/init.c:70:37: error: ‘PCI_IO_START’ undeclared
arch/riscv/mm/init.c:71:20: error: ‘PCI_IO_END’ undeclared
arch/riscv/mm/init.c:72:38: error: ‘VMEMMAP_START’ undeclared
arch/riscv/mm/init.c:73:20: error: ‘VMEMMAP_END’ undeclared (first use in this 
function);

Reported-by: Hulk Robot 
Signed-off-by: Kefeng Wang 
---
 arch/riscv/mm/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index dfcaebc3928f..58c39c44b9c9 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -49,7 +49,7 @@ static void setup_zero_page(void)
memset((void *)empty_zero_page, 0, PAGE_SIZE);
 }
 
-#ifdef CONFIG_DEBUG_VM
+#if defined(CONFIG_MMU) && defined(DEBUG_VM)
 static inline void print_mlk(char *name, unsigned long b, unsigned long t)
 {
pr_notice("%12s : 0x%08lx - 0x%08lx   (%4ld kB)\n", name, b, t,
-- 
2.26.2



[PATCH 09/10] timer-riscv: Fix undefined riscv_time_val

2020-05-10 Thread Kefeng Wang
ERROR: modpost: "riscv_time_val" [crypto/tcrypt.ko] undefined!

Reported-by: Hulk Robot 
Signed-off-by: Kefeng Wang 
---
 drivers/clocksource/timer-riscv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/clocksource/timer-riscv.c 
b/drivers/clocksource/timer-riscv.c
index c4f15c4068c0..071b8c144027 100644
--- a/drivers/clocksource/timer-riscv.c
+++ b/drivers/clocksource/timer-riscv.c
@@ -19,6 +19,7 @@
 
 u64 __iomem *riscv_time_cmp;
 u64 __iomem *riscv_time_val;
+EXPORT_SYMBOL(riscv_time_val);
 
 static inline void mmio_set_timer(u64 val)
 {
-- 
2.26.2



[PATCH 00/10] riscv: make riscv build happier

2020-05-10 Thread Kefeng Wang
When add RISCV arch to huawei build test, there are some build
issue, let's fix them to make riscv build happier :) 

Those patches is rebased on next-20200508.

Kefeng Wang (10):
  riscv: Fix unmet direct dependencies built based on SOC_VIRT
  riscv: stacktrace: Fix undefined reference to `walk_stackframe'
  riscv: Add pgprot_writecombine/device and PAGE_SHARED defination if
NOMMU
  riscv: Fix print_vm_layout build error if NOMMU
  riscv: Disable ARCH_HAS_DEBUG_WX if NOMMU
  riscv: Disable ARCH_HAS_DEBUG_VIRTUAL if NOMMU
  riscv: Make SYS_SUPPORTS_HUGETLBFS depends on MMU
  riscv: pgtable: Fix __kernel_map_pages build error if NOMMU
  timer-riscv: Fix undefined riscv_time_val
  riscv: mmiowb: Fix implicit declaration of function 'smp_processor_id'

 arch/riscv/Kconfig|  5 +++--
 arch/riscv/Kconfig.socs   | 17 +
 arch/riscv/include/asm/mmio.h |  2 ++
 arch/riscv/include/asm/mmiowb.h   |  1 +
 arch/riscv/include/asm/pgtable.h  |  3 +++
 arch/riscv/kernel/stacktrace.c|  2 +-
 arch/riscv/mm/init.c  |  2 +-
 drivers/clocksource/timer-riscv.c |  1 +
 8 files changed, 21 insertions(+), 12 deletions(-)

-- 
2.26.2



[PATCH 03/10] riscv: Add pgprot_writecombine/device and PAGE_SHARED defination if NOMMU

2020-05-10 Thread Kefeng Wang
Some drivers use PAGE_SHARED, pgprot_writecombine()/pgprot_device(),
add the defination to fix build error if NOMMU.

Reported-by: Hulk Robot 
Signed-off-by: Kefeng Wang 
---
 arch/riscv/include/asm/mmio.h| 2 ++
 arch/riscv/include/asm/pgtable.h | 1 +
 2 files changed, 3 insertions(+)

diff --git a/arch/riscv/include/asm/mmio.h b/arch/riscv/include/asm/mmio.h
index a2c809df2733..56053c9838b2 100644
--- a/arch/riscv/include/asm/mmio.h
+++ b/arch/riscv/include/asm/mmio.h
@@ -16,6 +16,8 @@
 
 #ifndef CONFIG_MMU
 #define pgprot_noncached(x)(x)
+#define pgprot_writecombine(x) (x)
+#define pgprot_device(x)   (x)
 #endif /* CONFIG_MMU */
 
 /* Generic IO read/write.  These perform native-endian accesses. */
diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
index 780dd1d4f720..a12d343e080a 100644
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -470,6 +470,7 @@ static inline int ptep_clear_flush_young(struct 
vm_area_struct *vma,
 
 #else /* CONFIG_MMU */
 
+#define PAGE_SHARED__pgprot(0)
 #define PAGE_KERNEL__pgprot(0)
 #define swapper_pg_dir NULL
 #define TASK_SIZE  0xUL
-- 
2.26.2



[PATCH 02/10] riscv: stacktrace: Fix undefined reference to `walk_stackframe'

2020-05-10 Thread Kefeng Wang
Drop static declaration to fix following build error if FRAME_POINTER disabled,
  riscv64-linux-ld: arch/riscv/kernel/perf_callchain.o: in function `.L0':
  perf_callchain.c:(.text+0x2b8): undefined reference to `walk_stackframe'

Reported-by: Hulk Robot 
Signed-off-by: Kefeng Wang 
---
 arch/riscv/kernel/stacktrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c
index 38141a3c70f7..595342910c3f 100644
--- a/arch/riscv/kernel/stacktrace.c
+++ b/arch/riscv/kernel/stacktrace.c
@@ -65,7 +65,7 @@ void notrace walk_stackframe(struct task_struct *task, struct 
pt_regs *regs,
 
 #else /* !CONFIG_FRAME_POINTER */
 
-static void notrace walk_stackframe(struct task_struct *task,
+void notrace walk_stackframe(struct task_struct *task,
struct pt_regs *regs, bool (*fn)(unsigned long, void *), void *arg)
 {
unsigned long sp, pc;
-- 
2.26.2



[PATCH 08/10] riscv: pgtable: Fix __kernel_map_pages build error if NOMMU

2020-05-10 Thread Kefeng Wang
riscv64-none-linux-gnu-ld: mm/page_alloc.o: in function `.L0 ':
page_alloc.c:(.text+0xd34): undefined reference to `__kernel_map_pages'
riscv64-none-linux-gnu-ld: page_alloc.c:(.text+0x104a): undefined reference to 
`__kernel_map_pages'
riscv64-none-linux-gnu-ld: mm/page_alloc.o: in function 
`__pageblock_pfn_to_page':
page_alloc.c:(.text+0x145e): undefined reference to `__kernel_map_pages'

Reported-by: Hulk Robot 
Signed-off-by: Kefeng Wang 
---
 arch/riscv/include/asm/pgtable.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
index a12d343e080a..d50706ea1c94 100644
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -477,6 +477,8 @@ static inline int ptep_clear_flush_young(struct 
vm_area_struct *vma,
 #define VMALLOC_START  0
 #define VMALLOC_ENDTASK_SIZE
 
+static inline void __kernel_map_pages(struct page *page, int numpages, int 
enable) {}
+
 #endif /* !CONFIG_MMU */
 
 #define kern_addr_valid(addr)   (1) /* FIXME */
-- 
2.26.2



[PATCH 01/10] riscv: Fix unmet direct dependencies built based on SOC_VIRT

2020-05-10 Thread Kefeng Wang
Fix unmet direct dependencies Warning and fix Kconfig indent.

WARNING: unmet direct dependencies detected for POWER_RESET_SYSCON
  Depends on [n]: POWER_RESET [=n] && OF [=y] && HAS_IOMEM [=y]
  Selected by [y]:
  - SOC_VIRT [=y]

WARNING: unmet direct dependencies detected for POWER_RESET_SYSCON_POWEROFF
  Depends on [n]: POWER_RESET [=n] && OF [=y] && HAS_IOMEM [=y]
  Selected by [y]:
  - SOC_VIRT [=y]

WARNING: unmet direct dependencies detected for RTC_DRV_GOLDFISH
  Depends on [n]: RTC_CLASS [=n] && OF [=y] && HAS_IOMEM [=y] && (GOLDFISH [=y] 
|| COMPILE_TEST [=n])
  Selected by [y]:
  - SOC_VIRT [=y]

Reported-by: Hulk Robot 
Signed-off-by: Kefeng Wang 
---
 arch/riscv/Kconfig.socs | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/arch/riscv/Kconfig.socs b/arch/riscv/Kconfig.socs
index 4b2303ca20b9..6c88148f1b9b 100644
--- a/arch/riscv/Kconfig.socs
+++ b/arch/riscv/Kconfig.socs
@@ -11,14 +11,15 @@ config SOC_SIFIVE
  This enables support for SiFive SoC platform hardware.
 
 config SOC_VIRT
-   bool "QEMU Virt Machine"
-   select POWER_RESET_SYSCON
-   select POWER_RESET_SYSCON_POWEROFF
-   select GOLDFISH
-   select RTC_DRV_GOLDFISH
-   select SIFIVE_PLIC
-   help
- This enables support for QEMU Virt Machine.
+   bool "QEMU Virt Machine"
+   select POWER_RESET
+   select POWER_RESET_SYSCON
+   select POWER_RESET_SYSCON_POWEROFF
+   select GOLDFISH
+   select RTC_DRV_GOLDFISH if RTC_CLASS
+   select SIFIVE_PLIC
+   help
+ This enables support for QEMU Virt Machine.
 
 config SOC_KENDRYTE
bool "Kendryte K210 SoC"
-- 
2.26.2



[PATCH 05/10] riscv: Disable ARCH_HAS_DEBUG_WX if NOMMU

2020-05-10 Thread Kefeng Wang
DEBUG_WX is only useful when MMU enabled, diable it if nommu
and fix the build error.

Reported-by: Hulk Robot 
Signed-off-by: Kefeng Wang 
---
 arch/riscv/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 78f30f2fdd51..7da0a36a8df0 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -69,7 +69,7 @@ config RISCV
select HAVE_ARCH_KASAN if MMU && 64BIT
select HAVE_ARCH_KGDB
select HAVE_ARCH_KGDB_QXFER_PKT
-   select ARCH_HAS_DEBUG_WX
+   select ARCH_HAS_DEBUG_WX if MMU
 
 config ARCH_MMAP_RND_BITS_MIN
default 18 if 64BIT
-- 
2.26.2



Re: [PATCH -next] riscv: perf_event: Make some funciton static

2020-05-10 Thread Kefeng Wang



On 2020/5/9 1:13, Palmer Dabbelt wrote:
What's the "-next" for?  This seems appropriate for an RC to me, as 
it's a

build fix.


Thanks for your review, this patch and "[PATCH -next] riscv: perf: 
RISCV_BASE_PMU


should be closeable", I fix the issue based on linux-next, so add the 
next prefix ; )


and we also found some another build issue when add RISCV arch to huawei 
build robot,


will send out the patches later.




On Thu, 07 May 2020 08:04:44 PDT (-0700), wangkefeng.w...@huawei.com 
wrote:

Fixes the following warning detected when running make with W=1,
../arch/riscv/kernel/perf_event.c:150:5: warning: no previous 
prototype for ‘riscv_map_cache_decode’ [-Wmissing-prototypes]

 int riscv_map_cache_decode(u64 config, unsigned int *type,
 ^~
../arch/riscv/kernel/perf_event.c:345:13: warning: no previous 
prototype for ‘riscv_base_pmu_handle_irq’ [-Wmissing-prototypes]

 irqreturn_t riscv_base_pmu_handle_irq(int irq_num, void *dev)
 ^
../arch/riscv/kernel/perf_event.c:364:6: warning: no previous 
prototype for ‘release_pmc_hardware’ [-Wmissing-prototypes]

 void release_pmc_hardware(void)
  ^~~~
../arch/riscv/kernel/perf_event.c:467:12: warning: no previous 
prototype for ‘init_hw_perf_events’ [-Wmissing-prototypes]

 int __init init_hw_perf_events(void)
    ^~~

Cc: Alan Kao 
Signed-off-by: Kefeng Wang 
---
 arch/riscv/kernel/perf_event.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/riscv/kernel/perf_event.c 
b/arch/riscv/kernel/perf_event.c

index 91626d9ae5f2..c835f0362d94 100644
--- a/arch/riscv/kernel/perf_event.c
+++ b/arch/riscv/kernel/perf_event.c
@@ -147,7 +147,7 @@ static int riscv_map_hw_event(u64 config)
 return riscv_pmu->hw_events[config];
 }

-int riscv_map_cache_decode(u64 config, unsigned int *type,
+static int riscv_map_cache_decode(u64 config, unsigned int *type,
    unsigned int *op, unsigned int *result)
 {
 return -ENOENT;
@@ -342,7 +342,7 @@ static void riscv_pmu_del(struct perf_event 
*event, int flags)


 static DEFINE_MUTEX(pmc_reserve_mutex);

-irqreturn_t riscv_base_pmu_handle_irq(int irq_num, void *dev)
+static irqreturn_t riscv_base_pmu_handle_irq(int irq_num, void *dev)
 {
 return IRQ_NONE;
 }
@@ -361,7 +361,7 @@ static int reserve_pmc_hardware(void)
 return err;
 }

-void release_pmc_hardware(void)
+static void release_pmc_hardware(void)
 {
 mutex_lock(_reserve_mutex);
 if (riscv_pmu->irq >= 0)
@@ -464,7 +464,7 @@ static const struct of_device_id 
riscv_pmu_of_ids[] = {

 { /* sentinel value */ }
 };

-int __init init_hw_perf_events(void)
+static int __init init_hw_perf_events(void)
 {
 struct device_node *node = of_find_node_by_type(NULL, "pmu");
 const struct of_device_id *of_id;


Reviewed-by: Palmer Dabbelt 

.





[PATCH 2/3] mm: vmstat: Convert to use DEFINE_SEQ_ATTRIBUTE macro

2020-05-09 Thread Kefeng Wang
Use DEFINE_SEQ_ATTRIBUTE macro to simplify the code.

Signed-off-by: Kefeng Wang 
---
 mm/vmstat.c | 32 ++--
 1 file changed, 6 insertions(+), 26 deletions(-)

diff --git a/mm/vmstat.c b/mm/vmstat.c
index 7f2e87cb7049..35219271796f 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -2055,24 +2055,14 @@ static int unusable_show(struct seq_file *m, void *arg)
return 0;
 }
 
-static const struct seq_operations unusable_op = {
+static const struct seq_operations unusable_sops = {
.start  = frag_start,
.next   = frag_next,
.stop   = frag_stop,
.show   = unusable_show,
 };
 
-static int unusable_open(struct inode *inode, struct file *file)
-{
-   return seq_open(file, _op);
-}
-
-static const struct file_operations unusable_file_ops = {
-   .open   = unusable_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release,
-};
+DEFINE_SEQ_ATTRIBUTE(unusable);
 
 static void extfrag_show_print(struct seq_file *m,
pg_data_t *pgdat, struct zone *zone)
@@ -2107,24 +2097,14 @@ static int extfrag_show(struct seq_file *m, void *arg)
return 0;
 }
 
-static const struct seq_operations extfrag_op = {
+static const struct seq_operations extfrag_sops = {
.start  = frag_start,
.next   = frag_next,
.stop   = frag_stop,
.show   = extfrag_show,
 };
 
-static int extfrag_open(struct inode *inode, struct file *file)
-{
-   return seq_open(file, _op);
-}
-
-static const struct file_operations extfrag_file_ops = {
-   .open   = extfrag_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release,
-};
+DEFINE_SEQ_ATTRIBUTE(extfrag);
 
 static int __init extfrag_debug_init(void)
 {
@@ -2133,10 +2113,10 @@ static int __init extfrag_debug_init(void)
extfrag_debug_root = debugfs_create_dir("extfrag", NULL);
 
debugfs_create_file("unusable_index", 0444, extfrag_debug_root, NULL,
-   _file_ops);
+   _fops);
 
debugfs_create_file("extfrag_index", 0444, extfrag_debug_root, NULL,
-   _file_ops);
+   _fops);
 
return 0;
 }
-- 
2.26.2



[PATCH 0/3] seq_file: Introduce DEFINE_SEQ_ATTRIBUTE() helper macro

2020-05-09 Thread Kefeng Wang
As discussion in 
https://lore.kernel.org/lkml/20191129222310.ga3712...@kroah.com/,
we could introduce a new helper macro to reduce losts of boilerplate
code, vmstat and kprobes is the example which covert to use it, if
this is accepted, I will send out more clean ups.

Kefeng Wang (3):
  seq_file: Introduce DEFINE_SEQ_ATTRIBUTE() helper macro
  mm: vmstat: Convert to use DEFINE_SEQ_ATTRIBUTE macro
  kernel: kprobes: Convert to use DEFINE_SEQ_ATTRIBUTE macro

 include/linux/seq_file.h | 19 +++
 kernel/kprobes.c | 33 ++---
 mm/vmstat.c  | 32 ++--
 3 files changed, 31 insertions(+), 53 deletions(-)

-- 
2.26.2



[PATCH 3/3] kernel: kprobes: Convert to use DEFINE_SEQ_ATTRIBUTE macro

2020-05-09 Thread Kefeng Wang
Use DEFINE_SEQ_ATTRIBUTE macro to simplify the code.

Cc: Anil S Keshavamurthy 
Cc: "David S. Miller" 
Cc: Masami Hiramatsu 
Signed-off-by: Kefeng Wang 
---
 kernel/kprobes.c | 33 ++---
 1 file changed, 6 insertions(+), 27 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index ffbe03a45c16..f961f5b13f43 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -2398,24 +2398,14 @@ static int show_kprobe_addr(struct seq_file *pi, void 
*v)
return 0;
 }
 
-static const struct seq_operations kprobes_seq_ops = {
+static const struct seq_operations kprobes_sops = {
.start = kprobe_seq_start,
.next  = kprobe_seq_next,
.stop  = kprobe_seq_stop,
.show  = show_kprobe_addr
 };
 
-static int kprobes_open(struct inode *inode, struct file *filp)
-{
-   return seq_open(filp, _seq_ops);
-}
-
-static const struct file_operations debugfs_kprobes_operations = {
-   .open   = kprobes_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release,
-};
+DEFINE_SEQ_ATTRIBUTE(kprobes);
 
 /* kprobes/blacklist -- shows which functions can not be probed */
 static void *kprobe_blacklist_seq_start(struct seq_file *m, loff_t *pos)
@@ -2446,24 +2436,14 @@ static int kprobe_blacklist_seq_show(struct seq_file 
*m, void *v)
return 0;
 }
 
-static const struct seq_operations kprobe_blacklist_seq_ops = {
+static const struct seq_operations kprobe_blacklist_sops = {
.start = kprobe_blacklist_seq_start,
.next  = kprobe_blacklist_seq_next,
.stop  = kprobe_seq_stop,   /* Reuse void function */
.show  = kprobe_blacklist_seq_show,
 };
 
-static int kprobe_blacklist_open(struct inode *inode, struct file *filp)
-{
-   return seq_open(filp, _blacklist_seq_ops);
-}
-
-static const struct file_operations debugfs_kprobe_blacklist_ops = {
-   .open   = kprobe_blacklist_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release,
-};
+DEFINE_SEQ_ATTRIBUTE(kprobe_blacklist);
 
 static int arm_all_kprobes(void)
 {
@@ -2622,13 +2602,12 @@ static int __init debugfs_kprobe_init(void)
 
dir = debugfs_create_dir("kprobes", NULL);
 
-   debugfs_create_file("list", 0400, dir, NULL,
-   _kprobes_operations);
+   debugfs_create_file("list", 0400, dir, NULL, _fops);
 
debugfs_create_file("enabled", 0600, dir, , _kp);
 
debugfs_create_file("blacklist", 0400, dir, NULL,
-   _kprobe_blacklist_ops);
+   _blacklist_fops);
 
return 0;
 }
-- 
2.26.2



[PATCH 1/3] seq_file: Introduce DEFINE_SEQ_ATTRIBUTE() helper macro

2020-05-09 Thread Kefeng Wang
Introduce DEFINE_SEQ_ATTRIBUTE() helper macro to decrease code duplication.

Signed-off-by: Kefeng Wang 
---
 include/linux/seq_file.h | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 1672cf6f7614..c77869cf7d10 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -145,6 +145,25 @@ void *__seq_open_private(struct file *, const struct 
seq_operations *, int);
 int seq_open_private(struct file *, const struct seq_operations *, int);
 int seq_release_private(struct inode *, struct file *);
 
+#define DEFINE_SEQ_ATTRIBUTE(__name)   \
+static int __name ## _open(struct inode *inode, struct file *file) \
+{  \
+   int ret = seq_open(file, &__name ## _sops); \
+   if (!ret && inode->i_private) { \
+   struct seq_file *seq_f = file->private_data;\
+   seq_f->private = inode->i_private;  \
+   }   \
+   return ret; \
+}  \
+   \
+static const struct file_operations __name ## _fops = {
\
+   .owner  = THIS_MODULE,  \
+   .open   = __name ## _open,  \
+   .read   = seq_read, \
+   .llseek = seq_lseek,\
+   .release= seq_release,  \
+}
+
 #define DEFINE_SHOW_ATTRIBUTE(__name)  \
 static int __name ## _open(struct inode *inode, struct file *file) \
 {  \
-- 
2.26.2



[PATCH -next] riscv: perf: RISCV_BASE_PMU should be closeable

2020-05-07 Thread Kefeng Wang
As 178e9fc47aae("perf: riscv: preliminary RISC-V support") said,
For RISCV_BASE_PMU, 'this option can also be disable to reduce kernel size',
but it could not work well, we need diable both RISCV_BASE_PMU and
PERF_EVENTS manually, or build error will occur when only disable
RISCV_BASE_PMU.

Cc: Alan Kao 
Signed-off-by: Kefeng Wang 
---
 arch/riscv/include/asm/perf_event.h | 8 ++--
 arch/riscv/kernel/Makefile  | 2 +-
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/arch/riscv/include/asm/perf_event.h 
b/arch/riscv/include/asm/perf_event.h
index 0234048b12bc..062efd3a1d5d 100644
--- a/arch/riscv/include/asm/perf_event.h
+++ b/arch/riscv/include/asm/perf_event.h
@@ -12,19 +12,14 @@
 #include 
 #include 
 
+#ifdef CONFIG_RISCV_BASE_PMU
 #define RISCV_BASE_COUNTERS2
 
 /*
  * The RISCV_MAX_COUNTERS parameter should be specified.
  */
 
-#ifdef CONFIG_RISCV_BASE_PMU
 #define RISCV_MAX_COUNTERS 2
-#endif
-
-#ifndef RISCV_MAX_COUNTERS
-#error "Please provide a valid RISCV_MAX_COUNTERS for the PMU."
-#endif
 
 /*
  * These are the indexes of bits in counteren register *minus* 1,
@@ -82,6 +77,7 @@ struct riscv_pmu {
int irq;
 };
 
+#endif
 #ifdef CONFIG_PERF_EVENTS
 #define perf_arch_bpf_user_pt_regs(regs) (struct user_regs_struct *)regs
 #endif
diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile
index 1f5736e996fd..b355cf485671 100644
--- a/arch/riscv/kernel/Makefile
+++ b/arch/riscv/kernel/Makefile
@@ -43,7 +43,7 @@ obj-$(CONFIG_MODULE_SECTIONS) += module-sections.o
 obj-$(CONFIG_FUNCTION_TRACER)  += mcount.o ftrace.o
 obj-$(CONFIG_DYNAMIC_FTRACE)   += mcount-dyn.o
 
-obj-$(CONFIG_PERF_EVENTS)  += perf_event.o
+obj-$(CONFIG_RISCV_BASE_PMU)   += perf_event.o
 obj-$(CONFIG_PERF_EVENTS)  += perf_callchain.o
 obj-$(CONFIG_HAVE_PERF_REGS)   += perf_regs.o
 obj-$(CONFIG_RISCV_SBI)+= sbi.o
-- 
2.26.2



[PATCH -next] riscv: perf_event: Make some funciton static

2020-05-07 Thread Kefeng Wang
Fixes the following warning detected when running make with W=1,
../arch/riscv/kernel/perf_event.c:150:5: warning: no previous prototype for 
‘riscv_map_cache_decode’ [-Wmissing-prototypes]
 int riscv_map_cache_decode(u64 config, unsigned int *type,
 ^~
../arch/riscv/kernel/perf_event.c:345:13: warning: no previous prototype for 
‘riscv_base_pmu_handle_irq’ [-Wmissing-prototypes]
 irqreturn_t riscv_base_pmu_handle_irq(int irq_num, void *dev)
 ^
../arch/riscv/kernel/perf_event.c:364:6: warning: no previous prototype for 
‘release_pmc_hardware’ [-Wmissing-prototypes]
 void release_pmc_hardware(void)
  ^~~~
../arch/riscv/kernel/perf_event.c:467:12: warning: no previous prototype for 
‘init_hw_perf_events’ [-Wmissing-prototypes]
 int __init init_hw_perf_events(void)
^~~

Cc: Alan Kao 
Signed-off-by: Kefeng Wang 
---
 arch/riscv/kernel/perf_event.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/riscv/kernel/perf_event.c b/arch/riscv/kernel/perf_event.c
index 91626d9ae5f2..c835f0362d94 100644
--- a/arch/riscv/kernel/perf_event.c
+++ b/arch/riscv/kernel/perf_event.c
@@ -147,7 +147,7 @@ static int riscv_map_hw_event(u64 config)
return riscv_pmu->hw_events[config];
 }
 
-int riscv_map_cache_decode(u64 config, unsigned int *type,
+static int riscv_map_cache_decode(u64 config, unsigned int *type,
   unsigned int *op, unsigned int *result)
 {
return -ENOENT;
@@ -342,7 +342,7 @@ static void riscv_pmu_del(struct perf_event *event, int 
flags)
 
 static DEFINE_MUTEX(pmc_reserve_mutex);
 
-irqreturn_t riscv_base_pmu_handle_irq(int irq_num, void *dev)
+static irqreturn_t riscv_base_pmu_handle_irq(int irq_num, void *dev)
 {
return IRQ_NONE;
 }
@@ -361,7 +361,7 @@ static int reserve_pmc_hardware(void)
return err;
 }
 
-void release_pmc_hardware(void)
+static void release_pmc_hardware(void)
 {
mutex_lock(_reserve_mutex);
if (riscv_pmu->irq >= 0)
@@ -464,7 +464,7 @@ static const struct of_device_id riscv_pmu_of_ids[] = {
{ /* sentinel value */ }
 };
 
-int __init init_hw_perf_events(void)
+static int __init init_hw_perf_events(void)
 {
struct device_node *node = of_find_node_by_type(NULL, "pmu");
const struct of_device_id *of_id;
-- 
2.26.2



[bpf-next] tools lib bpf: Renaming pr_warning to pr_warn

2019-10-20 Thread Kefeng Wang
For kernel logging macro, pr_warning is completely removed and
replaced by pr_warn, using pr_warn in tools lib bpf for symmetry
to kernel logging macro, then we could drop pr_warning in the
whole linux code.

Cc: Alexei Starovoitov 
Cc: Daniel Borkmann 
Cc: Martin KaFai Lau 
Cc: Song Liu 
Cc: Yonghong Song 
Cc: b...@vger.kernel.org
Acked-by: Andrii Nakryiko 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---

Based on git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git

 tools/lib/bpf/btf.c |  56 +--
 tools/lib/bpf/btf_dump.c|  18 +-
 tools/lib/bpf/libbpf.c  | 693 
 tools/lib/bpf/libbpf_internal.h |   8 +-
 tools/lib/bpf/xsk.c |   4 +-
 5 files changed, 386 insertions(+), 393 deletions(-)

diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index 3eae8d1addfa..d72e9a79dce1 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -390,14 +390,14 @@ struct btf *btf__parse_elf(const char *path, struct 
btf_ext **btf_ext)
GElf_Ehdr ehdr;
 
if (elf_version(EV_CURRENT) == EV_NONE) {
-   pr_warning("failed to init libelf for %s\n", path);
+   pr_warn("failed to init libelf for %s\n", path);
return ERR_PTR(-LIBBPF_ERRNO__LIBELF);
}
 
fd = open(path, O_RDONLY);
if (fd < 0) {
err = -errno;
-   pr_warning("failed to open %s: %s\n", path, strerror(errno));
+   pr_warn("failed to open %s: %s\n", path, strerror(errno));
return ERR_PTR(err);
}
 
@@ -405,19 +405,19 @@ struct btf *btf__parse_elf(const char *path, struct 
btf_ext **btf_ext)
 
elf = elf_begin(fd, ELF_C_READ, NULL);
if (!elf) {
-   pr_warning("failed to open %s as ELF file\n", path);
+   pr_warn("failed to open %s as ELF file\n", path);
goto done;
}
if (!gelf_getehdr(elf, )) {
-   pr_warning("failed to get EHDR from %s\n", path);
+   pr_warn("failed to get EHDR from %s\n", path);
goto done;
}
if (!btf_check_endianness()) {
-   pr_warning("non-native ELF endianness is not supported\n");
+   pr_warn("non-native ELF endianness is not supported\n");
goto done;
}
if (!elf_rawdata(elf_getscn(elf, ehdr.e_shstrndx), NULL)) {
-   pr_warning("failed to get e_shstrndx from %s\n", path);
+   pr_warn("failed to get e_shstrndx from %s\n", path);
goto done;
}
 
@@ -427,29 +427,29 @@ struct btf *btf__parse_elf(const char *path, struct 
btf_ext **btf_ext)
 
idx++;
if (gelf_getshdr(scn, ) != ) {
-   pr_warning("failed to get section(%d) header from %s\n",
-  idx, path);
+   pr_warn("failed to get section(%d) header from %s\n",
+   idx, path);
goto done;
}
name = elf_strptr(elf, ehdr.e_shstrndx, sh.sh_name);
if (!name) {
-   pr_warning("failed to get section(%d) name from %s\n",
-  idx, path);
+   pr_warn("failed to get section(%d) name from %s\n",
+   idx, path);
goto done;
}
if (strcmp(name, BTF_ELF_SEC) == 0) {
btf_data = elf_getdata(scn, 0);
if (!btf_data) {
-   pr_warning("failed to get section(%d, %s) data 
from %s\n",
-  idx, name, path);
+   pr_warn("failed to get section(%d, %s) data 
from %s\n",
+   idx, name, path);
goto done;
}
continue;
} else if (btf_ext && strcmp(name, BTF_EXT_ELF_SEC) == 0) {
btf_ext_data = elf_getdata(scn, 0);
if (!btf_ext_data) {
-   pr_warning("failed to get section(%d, %s) data 
from %s\n",
-  idx, name, path);
+   pr_warn("failed to get section(%d, %s) data 
from %s\n",
+   idx, name, path);
goto done;
}
continue;
@@ -600,9 +600,9 @@ int btf__load(struct btf *btf)
   log_buf, log_buf_size, false);
if (btf->fd < 0) {
 

[PATCH v2 22/33] sh/intc: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Yoshinori Sato 
Cc: Rich Felker 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 drivers/sh/intc/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/sh/intc/core.c b/drivers/sh/intc/core.c
index 46f0f322d4d8..8485e812d9b2 100644
--- a/drivers/sh/intc/core.c
+++ b/drivers/sh/intc/core.c
@@ -100,8 +100,8 @@ static void __init intc_register_irq(struct intc_desc *desc,
primary = 1;
 
if (!data[0] && !data[1])
-   pr_warning("missing unique irq mask for irq %d (vect 0x%04x)\n",
-  irq, irq2evt(irq));
+   pr_warn("missing unique irq mask for irq %d (vect 0x%04x)\n",
+   irq, irq2evt(irq));
 
data[0] = data[0] ? data[0] : intc_get_mask_handle(desc, d, enum_id, 1);
data[1] = data[1] ? data[1] : intc_get_prio_handle(desc, d, enum_id, 1);
-- 
2.20.1



[PATCH v2 11/33] clocksource: samsung_pwm_timer: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Daniel Lezcano 
Acked-by: Daniel Lezcano 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 drivers/clocksource/samsung_pwm_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/samsung_pwm_timer.c 
b/drivers/clocksource/samsung_pwm_timer.c
index 895f53eb5771..0274219e1720 100644
--- a/drivers/clocksource/samsung_pwm_timer.c
+++ b/drivers/clocksource/samsung_pwm_timer.c
@@ -430,7 +430,7 @@ static int __init samsung_pwm_alloc(struct device_node *np,
 
of_property_for_each_u32(np, "samsung,pwm-outputs", prop, cur, val) {
if (val >= SAMSUNG_PWM_NUM) {
-   pr_warning("%s: invalid channel index in 
samsung,pwm-outputs property\n",
+   pr_warn("%s: invalid channel index in 
samsung,pwm-outputs property\n",
__func__);
continue;
}
-- 
2.20.1



[PATCH v2 17/33] oprofile: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Robert Richter 
Acked-by: Robert Richter 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 drivers/oprofile/oprofile_perf.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/oprofile/oprofile_perf.c b/drivers/oprofile/oprofile_perf.c
index 4b150a754890..98a63a5f8763 100644
--- a/drivers/oprofile/oprofile_perf.c
+++ b/drivers/oprofile/oprofile_perf.c
@@ -46,8 +46,8 @@ static void op_overflow_handler(struct perf_event *event,
if (id != num_counters)
oprofile_add_sample(regs, id);
else
-   pr_warning("oprofile: ignoring spurious overflow "
-   "on cpu %u\n", cpu);
+   pr_warn("oprofile: ignoring spurious overflow on cpu %u\n",
+   cpu);
 }
 
 /*
@@ -88,8 +88,8 @@ static int op_create_counter(int cpu, int event)
 
if (pevent->state != PERF_EVENT_STATE_ACTIVE) {
perf_event_release_kernel(pevent);
-   pr_warning("oprofile: failed to enable event %d "
-   "on CPU %d\n", event, cpu);
+   pr_warn("oprofile: failed to enable event %d on CPU %d\n",
+   event, cpu);
return -EBUSY;
}
 
-- 
2.20.1



[PATCH v2 21/33] scsi: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: "James E.J. Bottomley" 
Cc: "Martin K. Petersen" 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 drivers/scsi/a3000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/a3000.c b/drivers/scsi/a3000.c
index 222c77c9621f..b6a0432f305a 100644
--- a/drivers/scsi/a3000.c
+++ b/drivers/scsi/a3000.c
@@ -39,7 +39,7 @@ static irqreturn_t a3000_intr(int irq, void *data)
spin_unlock_irqrestore(instance->host_lock, flags);
return IRQ_HANDLED;
}
-   pr_warning("Non-serviced A3000 SCSI-interrupt? ISTR = %02x\n", status);
+   pr_warn("Non-serviced A3000 SCSI-interrupt? ISTR = %02x\n", status);
return IRQ_NONE;
 }
 
-- 
2.20.1



[PATCH v2 04/33] riscv: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Paul Walmsley 
Cc: Palmer Dabbelt 
Cc: Albert Ou 
Acked-by: Palmer Dabbelt 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 arch/riscv/kernel/module.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c
index 70bb94ae61c5..b7401858d872 100644
--- a/arch/riscv/kernel/module.c
+++ b/arch/riscv/kernel/module.c
@@ -315,8 +315,8 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char 
*strtab,
/* Ignore unresolved weak symbol */
if (ELF_ST_BIND(sym->st_info) == STB_WEAK)
continue;
-   pr_warning("%s: Unknown symbol %s\n",
-  me->name, strtab + sym->st_name);
+   pr_warn("%s: Unknown symbol %s\n",
+   me->name, strtab + sym->st_name);
return -ENOENT;
}
 
-- 
2.20.1



[PATCH v2 06/33] sparc: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: "David S. Miller" 
Cc: Andrew Morton 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 arch/sparc/kernel/smp_64.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index a8275fea4b70..9b4506373353 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -1673,9 +1673,9 @@ void __init setup_per_cpu_areas(void)
pcpu_alloc_bootmem,
pcpu_free_bootmem);
if (rc)
-   pr_warning("PERCPU: %s allocator failed (%d), "
-  "falling back to page size\n",
-  pcpu_fc_names[pcpu_chosen_fc], rc);
+   pr_warn("PERCPU: %s allocator failed (%d), "
+   "falling back to page size\n",
+   pcpu_fc_names[pcpu_chosen_fc], rc);
}
if (rc < 0)
rc = pcpu_page_first_chunk(PERCPU_MODULE_RESERVE,
-- 
2.20.1



[PATCH v2 05/33] sh: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Stephen Rothwell 
Cc: Yoshinori Sato 
Cc: Rich Felker 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 arch/sh/boards/mach-sdk7786/nmi.c| 2 +-
 arch/sh/drivers/pci/fixups-sdk7786.c | 2 +-
 arch/sh/kernel/io_trapped.c  | 2 +-
 arch/sh/kernel/setup.c   | 2 +-
 arch/sh/mm/consistent.c  | 5 ++---
 5 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/arch/sh/boards/mach-sdk7786/nmi.c 
b/arch/sh/boards/mach-sdk7786/nmi.c
index c2e09d798537..afba49679a12 100644
--- a/arch/sh/boards/mach-sdk7786/nmi.c
+++ b/arch/sh/boards/mach-sdk7786/nmi.c
@@ -37,7 +37,7 @@ static int __init nmi_mode_setup(char *str)
nmi_mode = NMI_MODE_ANY;
else {
nmi_mode = NMI_MODE_UNKNOWN;
-   pr_warning("Unknown NMI mode %s\n", str);
+   pr_warn("Unknown NMI mode %s\n", str);
}
 
printk("Set NMI mode to %d\n", nmi_mode);
diff --git a/arch/sh/drivers/pci/fixups-sdk7786.c 
b/arch/sh/drivers/pci/fixups-sdk7786.c
index 8cbfa5310a4b..6972af7b4e93 100644
--- a/arch/sh/drivers/pci/fixups-sdk7786.c
+++ b/arch/sh/drivers/pci/fixups-sdk7786.c
@@ -53,7 +53,7 @@ static int __init sdk7786_pci_init(void)
 
/* Warn about forced rerouting if slot#3 is occupied */
if ((data & PCIECR_PRST3) == 0) {
-   pr_warning("Unreachable card detected in slot#3\n");
+   pr_warn("Unreachable card detected in slot#3\n");
return -EBUSY;
}
} else
diff --git a/arch/sh/kernel/io_trapped.c b/arch/sh/kernel/io_trapped.c
index bacad6da4fe4..60c828a2b8a2 100644
--- a/arch/sh/kernel/io_trapped.c
+++ b/arch/sh/kernel/io_trapped.c
@@ -99,7 +99,7 @@ int register_trapped_io(struct trapped_io *tiop)
 
return 0;
  bad:
-   pr_warning("unable to install trapped io filter\n");
+   pr_warn("unable to install trapped io filter\n");
return -1;
 }
 EXPORT_SYMBOL_GPL(register_trapped_io);
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 914174a125a4..d232cfa01877 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -355,7 +355,7 @@ void __init setup_arch(char **cmdline_p)
 /* processor boot mode configuration */
 int generic_mode_pins(void)
 {
-   pr_warning("generic_mode_pins(): missing mode pin configuration\n");
+   pr_warn("generic_mode_pins(): missing mode pin configuration\n");
return 0;
 }
 
diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c
index 792f36129062..3169a343a5ab 100644
--- a/arch/sh/mm/consistent.c
+++ b/arch/sh/mm/consistent.c
@@ -43,8 +43,7 @@ int __init platform_resource_setup_memory(struct 
platform_device *pdev,
 
r = pdev->resource + pdev->num_resources - 1;
if (r->flags) {
-   pr_warning("%s: unable to find empty space for resource\n",
-   name);
+   pr_warn("%s: unable to find empty space for resource\n", name);
return -EINVAL;
}
 
@@ -54,7 +53,7 @@ int __init platform_resource_setup_memory(struct 
platform_device *pdev,
 
buf = dma_alloc_coherent(>dev, memsize, _handle, GFP_KERNEL);
if (!buf) {
-   pr_warning("%s: unable to allocate memory\n", name);
+   pr_warn("%s: unable to allocate memory\n", name);
return -ENOMEM;
}
 
-- 
2.20.1



[PATCH v2 31/33] tools lib bpf: Renaming pr_warning to pr_warn

2019-10-17 Thread Kefeng Wang
For kernel logging macro, pr_warning is completely removed and
replaced by pr_warn, using pr_warn in tools lib bpf for symmetry
to kernel logging macro, then we could drop pr_warning in the
whole linux code.

Cc: Alexei Starovoitov 
Cc: Daniel Borkmann 
Cc: Martin KaFai Lau 
Cc: Song Liu 
Cc: Yonghong Song 
Cc: b...@vger.kernel.org
Acked-by: Andrii Nakryiko 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 tools/lib/bpf/btf.c |  56 +--
 tools/lib/bpf/btf_dump.c|  18 +-
 tools/lib/bpf/libbpf.c  | 679 
 tools/lib/bpf/libbpf_internal.h |   8 +-
 tools/lib/bpf/xsk.c |   4 +-
 5 files changed, 379 insertions(+), 386 deletions(-)

diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index 3eae8d1addfa..d72e9a79dce1 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -390,14 +390,14 @@ struct btf *btf__parse_elf(const char *path, struct 
btf_ext **btf_ext)
GElf_Ehdr ehdr;
 
if (elf_version(EV_CURRENT) == EV_NONE) {
-   pr_warning("failed to init libelf for %s\n", path);
+   pr_warn("failed to init libelf for %s\n", path);
return ERR_PTR(-LIBBPF_ERRNO__LIBELF);
}
 
fd = open(path, O_RDONLY);
if (fd < 0) {
err = -errno;
-   pr_warning("failed to open %s: %s\n", path, strerror(errno));
+   pr_warn("failed to open %s: %s\n", path, strerror(errno));
return ERR_PTR(err);
}
 
@@ -405,19 +405,19 @@ struct btf *btf__parse_elf(const char *path, struct 
btf_ext **btf_ext)
 
elf = elf_begin(fd, ELF_C_READ, NULL);
if (!elf) {
-   pr_warning("failed to open %s as ELF file\n", path);
+   pr_warn("failed to open %s as ELF file\n", path);
goto done;
}
if (!gelf_getehdr(elf, )) {
-   pr_warning("failed to get EHDR from %s\n", path);
+   pr_warn("failed to get EHDR from %s\n", path);
goto done;
}
if (!btf_check_endianness()) {
-   pr_warning("non-native ELF endianness is not supported\n");
+   pr_warn("non-native ELF endianness is not supported\n");
goto done;
}
if (!elf_rawdata(elf_getscn(elf, ehdr.e_shstrndx), NULL)) {
-   pr_warning("failed to get e_shstrndx from %s\n", path);
+   pr_warn("failed to get e_shstrndx from %s\n", path);
goto done;
}
 
@@ -427,29 +427,29 @@ struct btf *btf__parse_elf(const char *path, struct 
btf_ext **btf_ext)
 
idx++;
if (gelf_getshdr(scn, ) != ) {
-   pr_warning("failed to get section(%d) header from %s\n",
-  idx, path);
+   pr_warn("failed to get section(%d) header from %s\n",
+   idx, path);
goto done;
}
name = elf_strptr(elf, ehdr.e_shstrndx, sh.sh_name);
if (!name) {
-   pr_warning("failed to get section(%d) name from %s\n",
-  idx, path);
+   pr_warn("failed to get section(%d) name from %s\n",
+   idx, path);
goto done;
}
if (strcmp(name, BTF_ELF_SEC) == 0) {
btf_data = elf_getdata(scn, 0);
if (!btf_data) {
-   pr_warning("failed to get section(%d, %s) data 
from %s\n",
-  idx, name, path);
+   pr_warn("failed to get section(%d, %s) data 
from %s\n",
+   idx, name, path);
goto done;
}
continue;
} else if (btf_ext && strcmp(name, BTF_EXT_ELF_SEC) == 0) {
btf_ext_data = elf_getdata(scn, 0);
if (!btf_ext_data) {
-   pr_warning("failed to get section(%d, %s) data 
from %s\n",
-  idx, name, path);
+   pr_warn("failed to get section(%d, %s) data 
from %s\n",
+   idx, name, path);
goto done;
}
continue;
@@ -600,9 +600,9 @@ int btf__load(struct btf *btf)
   log_buf, log_buf_size, false);
if (btf->fd < 0) {
err = -errno;
-   pr_warning("Error loading BTF: %s(%d)\n",

  1   2   3   4   5   6   7   8   9   >