Re: [PATCH] selftests/ftrace: fix spelling mistake: "tiggers" -> "triggers"

2018-04-01 Thread Masami Hiramatsu
On Thu, 29 Mar 2018 18:24:31 +0100
Colin King  wrote:

> From: Colin Ian King 
> 
> Trivial fix to spelling mistake in message text
> 
> Signed-off-by: Colin Ian King 

Oops, thanks!

Acked-by: Masami Hiramatsu 

> ---
>  tools/testing/selftests/ftrace/test.d/trigger/trigger-multihist.tc | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git 
> a/tools/testing/selftests/ftrace/test.d/trigger/trigger-multihist.tc 
> b/tools/testing/selftests/ftrace/test.d/trigger/trigger-multihist.tc
> index c5ef8b9d02b3..1b8faf4c318c 100644
> --- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-multihist.tc
> +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-multihist.tc
> @@ -35,7 +35,7 @@ do_reset
>  
>  reset_trigger
>  
> -echo "Test histogram multiple tiggers"
> +echo "Test histogram multiple triggers"
>  
>  echo 'hist:keys=parent_pid:vals=child_pid' > 
> events/sched/sched_process_fork/trigger
>  echo 'hist:keys=parent_comm:vals=child_pid' >> 
> events/sched/sched_process_fork/trigger
> -- 
> 2.15.1
> 


-- 
Masami Hiramatsu 


Re: [PATCH v5 4/5] arm64: introduce pfn_valid_region()

2018-04-01 Thread Ard Biesheuvel
On 2 April 2018 at 04:30, Jia He  wrote:
> This is the preparation for further optimizing in early_pfn_valid
> on arm and arm64.
>

Same as before
- please share the code between ARM and arm64. if necessary, you can
invent a new HAVE_ARCH_xxx symbol that is only defined by ARM and
arm64
- please explain what the patch does and more importantly, why

> Signed-off-by: Jia He 
> ---
>  arch/arm/include/asm/page.h   |  3 ++-
>  arch/arm/mm/init.c| 24 
>  arch/arm64/include/asm/page.h |  3 ++-
>  arch/arm64/mm/init.c  | 24 
>  4 files changed, 52 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
> index f38909c..3bd810e 100644
> --- a/arch/arm/include/asm/page.h
> +++ b/arch/arm/include/asm/page.h
> @@ -158,9 +158,10 @@ typedef struct page *pgtable_t;
>
>  #ifdef CONFIG_HAVE_ARCH_PFN_VALID
>  extern int early_region_idx;
> -extern int pfn_valid(unsigned long);
> +extern int pfn_valid(unsigned long pfn);
>  extern unsigned long memblock_next_valid_pfn(unsigned long pfn);
>  #define skip_to_last_invalid_pfn(pfn) (memblock_next_valid_pfn(pfn) - 1)
> +extern int pfn_valid_region(unsigned long pfn);
>  #endif
>
>  #include 
> diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
> index 06ed190..bdcbf58 100644
> --- a/arch/arm/mm/init.c
> +++ b/arch/arm/mm/init.c
> @@ -201,6 +201,30 @@ int pfn_valid(unsigned long pfn)
>  }
>  EXPORT_SYMBOL(pfn_valid);
>
> +int pfn_valid_region(unsigned long pfn)
> +{
> +   unsigned long start_pfn, end_pfn;
> +   struct memblock_type *type = &memblock.memory;
> +   struct memblock_region *regions = type->regions;
> +
> +   if (early_region_idx != -1) {
> +   start_pfn = PFN_DOWN(regions[early_region_idx].base);
> +   end_pfn = PFN_DOWN(regions[early_region_idx].base +
> +   regions[early_region_idx].size);
> +
> +   if (pfn >= start_pfn && pfn < end_pfn)
> +   return !memblock_is_nomap(
> +   ®ions[early_region_idx]);
> +   }
> +
> +   early_region_idx = memblock_search_pfn_regions(pfn);
> +   if (early_region_idx == -1)
> +   return false;
> +
> +   return !memblock_is_nomap(®ions[early_region_idx]);
> +}
> +EXPORT_SYMBOL(pfn_valid_region);
> +
>  /* HAVE_MEMBLOCK is always enabled on arm */
>  unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn)
>  {
> diff --git a/arch/arm64/include/asm/page.h b/arch/arm64/include/asm/page.h
> index f0d8c8e5..7087b63 100644
> --- a/arch/arm64/include/asm/page.h
> +++ b/arch/arm64/include/asm/page.h
> @@ -39,9 +39,10 @@ typedef struct page *pgtable_t;
>
>  #ifdef CONFIG_HAVE_ARCH_PFN_VALID
>  extern int early_region_idx;
> -extern int pfn_valid(unsigned long);
> +extern int pfn_valid(unsigned long pfn);
>  extern unsigned long memblock_next_valid_pfn(unsigned long pfn);
>  #define skip_to_last_invalid_pfn(pfn) (memblock_next_valid_pfn(pfn) - 1)
> +extern int pfn_valid_region(unsigned long pfn);
>  #endif
>
>  #include 
> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> index 342e4e2..a1646b6 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -293,6 +293,30 @@ int pfn_valid(unsigned long pfn)
>  }
>  EXPORT_SYMBOL(pfn_valid);
>
> +int pfn_valid_region(unsigned long pfn)
> +{
> +   unsigned long start_pfn, end_pfn;
> +   struct memblock_type *type = &memblock.memory;
> +   struct memblock_region *regions = type->regions;
> +
> +   if (early_region_idx != -1) {
> +   start_pfn = PFN_DOWN(regions[early_region_idx].base);
> +   end_pfn = PFN_DOWN(regions[early_region_idx].base +
> +   regions[early_region_idx].size);
> +
> +   if (pfn >= start_pfn && pfn < end_pfn)
> +   return !memblock_is_nomap(
> +   ®ions[early_region_idx]);
> +   }
> +
> +   early_region_idx = memblock_search_pfn_regions(pfn);
> +   if (early_region_idx == -1)
> +   return false;
> +
> +   return !memblock_is_nomap(®ions[early_region_idx]);
> +}
> +EXPORT_SYMBOL(pfn_valid_region);
> +
>  /* HAVE_MEMBLOCK is always enabled on arm64 */
>  unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn)
>  {
> --
> 2.7.4
>


Re: [PATCH v5 3/5] mm/memblock: introduce memblock_search_pfn_regions()

2018-04-01 Thread Ard Biesheuvel
On 2 April 2018 at 04:30, Jia He  wrote:
> This api is the preparation for further optimizing early_pfn_valid
>

Please add more explanatation here of what it is you are doing and why.


> Signed-off-by: Jia He 
> ---
>  include/linux/memblock.h | 2 ++
>  mm/memblock.c| 9 +
>  2 files changed, 11 insertions(+)
>
> diff --git a/include/linux/memblock.h b/include/linux/memblock.h
> index 0257aee..a0127b3 100644
> --- a/include/linux/memblock.h
> +++ b/include/linux/memblock.h
> @@ -203,6 +203,8 @@ void __next_mem_pfn_range(int *idx, int nid, unsigned 
> long *out_start_pfn,
>  i >= 0; __next_mem_pfn_range(&i, nid, p_start, p_end, p_nid))
>  #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
>
> +int memblock_search_pfn_regions(unsigned long pfn);
> +
>  /**
>   * for_each_free_mem_range - iterate through free memblock areas
>   * @i: u64 used as loop variable
> diff --git a/mm/memblock.c b/mm/memblock.c
> index ba7c878..0f4004c 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -1617,6 +1617,15 @@ static int __init_memblock memblock_search(struct 
> memblock_type *type, phys_addr
> return -1;
>  }
>
> +/* search memblock with the input pfn, return the region idx */
> +int __init_memblock memblock_search_pfn_regions(unsigned long pfn)
> +{
> +   struct memblock_type *type = &memblock.memory;
> +   int mid = memblock_search(type, PFN_PHYS(pfn));
> +
> +   return mid;
> +}
> +
>  bool __init memblock_is_reserved(phys_addr_t addr)
>  {
> return memblock_search(&memblock.reserved, addr) != -1;
> --
> 2.7.4
>


[GIT PULL] locking changes for v4.17

2018-04-01 Thread Ingo Molnar
Linus,

Please pull the latest locking-core-for-linus git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
locking-core-for-linus

   # HEAD: 19193bcad8dced863f2f720b1a76110bda07c970 locking/Kconfig: 
Restructure the lock debugging menu

The main changes in the locking subsystem in this cycle were:

 - Add the Linux Kernel Memory Consistency Model (LKMM) subsystem, which is an
   an array of tools in tools/memory-model/ that formally describe the Linux
   memory coherency model (a.k.a. Documentation/memory-barriers.txt), and also 
   produce 'litmus tests' in form of kernel code which can be directly executed 
   and tested.

   Here's a high level background article about an earlier version of this work 
on 
   LWN.net:

  https://lwn.net/Articles/718628/

   The design principles:

"There is some reason to believe that Documentation/memory-barriers.txt
 could use some help, and a major purpose of this patch is to provide
 that help in the form of a design-time tool that can produce all valid
 executions of a small fragment of concurrent Linux-kernel code, which is
 called a "litmus test".  This tool's functionality is roughly similar to
 a full state-space search.  Please note that this is a design-time tool,
 not useful for regression testing.  However, we hope that the underlying
 Linux-kernel memory model will be incorporated into other tools capable
 of analyzing large bodies of code for regression-testing purposes."

 [...]

"A second tool is klitmus7, which converts litmus tests to loadable
 kernel modules for direct testing.  As with herd7, the klitmus7
 code is freely available from http://diy.inria.fr/sources/index.html
 (and via "git" at https://github.com/herd/herdtools7)."

[...]

Credits go to:

"This patch was the result of a most excellent collaboration founded
 by Jade Alglave and also including Alan Stern, Andrea Parri, and Luc 
Maranget."

... and to the gents listed in the MAINTAINERS entry:

LINUX KERNEL MEMORY CONSISTENCY MODEL (LKMM)
M:  Alan Stern 
M:  Andrea Parri 
M:  Will Deacon 
M:  Peter Zijlstra 
M:  Boqun Feng 
M:  Nicholas Piggin 
M:  David Howells 
M:  Jade Alglave 
M:  Luc Maranget 
M:  "Paul E. McKenney" 

   The LKMM project already found several bugs in Linux locking primitives and 
   improved the understanding and the documentation of the Linux memory model 
all 
   around.

 - Add KASAN instrumentation to atomic APIs (Dmitry Vyukov)

 - Add RWSEM API debugging and reorganize the lock debugging Kconfig (Waiman 
Long)

 - ... misc cleanups and other smaller changes.

 Thanks,

Ingo

-->
Alan Stern (3):
  tools/memory-model: Add a S lock-based external-view litmus test
  tools/memory-model: Remove rb-dep, smp_read_barrier_depends, and 
lockless_dereference
  tools/memory-model: Finish the removal of rb-dep, 
smp_read_barrier_depends(), and lockless_dereference()

Andrea Parri (5):
  tools/memory-model: Clarify the origin/scope of the tool name
  MAINTAINERS: Add the Memory Consistency Model subsystem
  MAINTAINERS: List file memory-barriers.txt within the LKMM entry
  Documentation/memory-barriers.txt: Cross-reference "tools/memory-model/"
  locking/xchg/alpha: Remove superfluous memory barriers from the _local() 
variants

Borislav Petkov (1):
  locking/lockdep: Show unadorned pointers

Dmitry Vyukov (4):
  locking/atomic, asm-generic: Add asm-generic/atomic-instrumented.h
  locking/atomic/x86: Switch atomic.h to use atomic-instrumented.h
  locking/atomic, asm-generic: Add KASAN instrumentation to atomic 
operations
  locking/atomic, asm-generic, x86: Add comments for atomic instrumentation

Juri Lelli (2):
  Documentation/locking/lockdep: Update info about states
  Documentation/locking/lockdep: Add section about available annotations

Nikolay Borisov (1):
  memory-barriers: Fix description of data dependency barriers

Paul E. McKenney (9):
  Automate memory-barriers.txt; provide Linux-kernel memory model
  EXP litmus_tests: Add comments explaining tests' purposes
  README: Fix a couple of punctuation errors
  MAINTAINERS: Add Akira Yokosawa as an LKMM reviewer
  tools/memory-model: Add required herd7 version to README file
  tools/memory-model: Convert underscores to hyphens
  locking/memory-barriers: De-emphasize smp_read_barrier_depends() some more
  tools/memory-model: Remove mention of docker/gentoo image
  tools/memory-model: Add documentation of new litmus test

Peter Zijlstra (1):
  locking/rtmutex: Handle non enqueued waiters gracefully in remove_waiter()

Randy Dunlap (1):
  mutex: Drop linkage.h from mutex.h

Tetsuo Handa (1):
  lockdep: Make the lock debug output more useful

Waiman Long (3):

Re: [PATCH v5 2/5] arm: arm64: page_alloc: reduce unnecessary binary search in memblock_next_valid_pfn()

2018-04-01 Thread Ard Biesheuvel
On 2 April 2018 at 04:30, Jia He  wrote:
> Commit b92df1de5d28 ("mm: page_alloc: skip over regions of invalid pfns
> where possible") optimized the loop in memmap_init_zone(). But there is
> still some room for improvement. E.g. if pfn and pfn+1 are in the same
> memblock region, we can simply pfn++ instead of doing the binary search
> in memblock_next_valid_pfn.
>
> Signed-off-by: Jia He 
> ---
>  arch/arm/include/asm/page.h   |  1 +
>  arch/arm/mm/init.c| 28 ++--
>  arch/arm64/include/asm/page.h |  1 +
>  arch/arm64/mm/init.c  | 28 ++--
>  4 files changed, 46 insertions(+), 12 deletions(-)
>

Could we put this in a shared file somewhere? This is the second patch
where you put make identical changes to ARM and arm64.


> diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
> index 489875c..f38909c 100644
> --- a/arch/arm/include/asm/page.h
> +++ b/arch/arm/include/asm/page.h
> @@ -157,6 +157,7 @@ extern void copy_page(void *to, const void *from);
>  typedef struct page *pgtable_t;
>
>  #ifdef CONFIG_HAVE_ARCH_PFN_VALID
> +extern int early_region_idx;
>  extern int pfn_valid(unsigned long);
>  extern unsigned long memblock_next_valid_pfn(unsigned long pfn);
>  #define skip_to_last_invalid_pfn(pfn) (memblock_next_valid_pfn(pfn) - 1)
> diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
> index 0fb85ca..06ed190 100644
> --- a/arch/arm/mm/init.c
> +++ b/arch/arm/mm/init.c
> @@ -193,6 +193,8 @@ static void __init zone_sizes_init(unsigned long min, 
> unsigned long max_low,
>  }
>
>  #ifdef CONFIG_HAVE_ARCH_PFN_VALID
> +int early_region_idx __meminitdata = -1;
> +
>  int pfn_valid(unsigned long pfn)
>  {
> return memblock_is_map_memory(__pfn_to_phys(pfn));
> @@ -203,28 +205,42 @@ EXPORT_SYMBOL(pfn_valid);
>  unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn)
>  {
> struct memblock_type *type = &memblock.memory;
> +   struct memblock_region *regions = type->regions;
> unsigned int right = type->cnt;
> unsigned int mid, left = 0;
> +   unsigned long start_pfn, end_pfn;
> phys_addr_t addr = PFN_PHYS(++pfn);
>
> +   /* fast path, return pfn+1 if next pfn is in the same region */
> +   if (early_region_idx != -1) {
> +   start_pfn = PFN_DOWN(regions[early_region_idx].base);
> +   end_pfn = PFN_DOWN(regions[early_region_idx].base +
> +   regions[early_region_idx].size);
> +
> +   if (pfn >= start_pfn && pfn < end_pfn)
> +   return pfn;
> +   }
> +
> +   /* slow path, do the binary searching */
> do {
> mid = (right + left) / 2;
>
> -   if (addr < type->regions[mid].base)
> +   if (addr < regions[mid].base)
> right = mid;
> -   else if (addr >= (type->regions[mid].base +
> - type->regions[mid].size))
> +   else if (addr >= (regions[mid].base + regions[mid].size))
> left = mid + 1;
> else {
> -   /* addr is within the region, so pfn is valid */
> +   early_region_idx = mid;
> return pfn;
> }
> } while (left < right);
>
> if (right == type->cnt)
> return -1UL;
> -   else
> -   return PHYS_PFN(type->regions[right].base);
> +
> +   early_region_idx = right;
> +
> +   return PHYS_PFN(regions[early_region_idx].base);
>  }
>  EXPORT_SYMBOL(memblock_next_valid_pfn);
>  #endif /*CONFIG_HAVE_ARCH_PFN_VALID*/
> diff --git a/arch/arm64/include/asm/page.h b/arch/arm64/include/asm/page.h
> index e57d3f2..f0d8c8e5 100644
> --- a/arch/arm64/include/asm/page.h
> +++ b/arch/arm64/include/asm/page.h
> @@ -38,6 +38,7 @@ extern void clear_page(void *to);
>  typedef struct page *pgtable_t;
>
>  #ifdef CONFIG_HAVE_ARCH_PFN_VALID
> +extern int early_region_idx;
>  extern int pfn_valid(unsigned long);
>  extern unsigned long memblock_next_valid_pfn(unsigned long pfn);
>  #define skip_to_last_invalid_pfn(pfn) (memblock_next_valid_pfn(pfn) - 1)
> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> index 13e43ff..342e4e2 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -285,6 +285,8 @@ static void __init zone_sizes_init(unsigned long min, 
> unsigned long max)
>  #endif /* CONFIG_NUMA */
>
>  #ifdef CONFIG_HAVE_ARCH_PFN_VALID
> +int early_region_idx __meminitdata = -1;
> +
>  int pfn_valid(unsigned long pfn)
>  {
> return memblock_is_map_memory(pfn << PAGE_SHIFT);
> @@ -295,28 +297,42 @@ EXPORT_SYMBOL(pfn_valid);
>  unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn)
>  {
> struct memblock_type *type = &memblock.memory;
> +   struct memblock_region *regions = type->regions;
> unsigned int right = type->cnt;
> un

Re: [PATCH v5 1/5] mm: page_alloc: remain memblock_next_valid_pfn() on arm and arm64

2018-04-01 Thread Ard Biesheuvel
On 2 April 2018 at 04:30, Jia He  wrote:
> Commit b92df1de5d28 ("mm: page_alloc: skip over regions of invalid pfns
> where possible") optimized the loop in memmap_init_zone(). But it causes
> possible panic bug. So Daniel Vacek reverted it later.
>
> But as suggested by Daniel Vacek, it is fine to using memblock to skip
> gaps and finding next valid frame with CONFIG_HAVE_ARCH_PFN_VALID.
>
> On arm and arm64, memblock is used by default. But generic version of
> pfn_valid() is based on mem sections and memblock_next_valid_pfn() does
> not always return the next valid one but skips more resulting in some
> valid frames to be skipped (as if they were invalid). And that's why
> kernel was eventually crashing on some !arm machines.
>
> And as verified by Eugeniu Rosca, arm can benifit from commit
> b92df1de5d28. So remain the memblock_next_valid_pfn on arm{,64} and move
> the related codes to arm64 arch directory.
>
> Suggested-by: Daniel Vacek 
> Signed-off-by: Jia He 

Hello Jia,

Apologies for chiming in late.

If we are going to rearchitect this, I'd rather we change the loop in
memmap_init_zone() so that we skip to the next valid PFN directly
rather than skipping to the last invalid PFN so that the pfn++ in the
for () results in the next value. Can we replace the pfn++ there with
a function calls that defaults to 'return pfn + 1', but does the skip
for architectures that implement it?


> ---
>  arch/arm/include/asm/page.h   |  2 ++
>  arch/arm/mm/init.c| 31 ++-
>  arch/arm64/include/asm/page.h |  2 ++
>  arch/arm64/mm/init.c  | 31 ++-
>  include/linux/mmzone.h|  1 +
>  mm/page_alloc.c   |  4 +++-
>  6 files changed, 68 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
> index 4355f0e..489875c 100644
> --- a/arch/arm/include/asm/page.h
> +++ b/arch/arm/include/asm/page.h
> @@ -158,6 +158,8 @@ typedef struct page *pgtable_t;
>
>  #ifdef CONFIG_HAVE_ARCH_PFN_VALID
>  extern int pfn_valid(unsigned long);
> +extern unsigned long memblock_next_valid_pfn(unsigned long pfn);
> +#define skip_to_last_invalid_pfn(pfn) (memblock_next_valid_pfn(pfn) - 1)
>  #endif
>
>  #include 
> diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
> index a1f11a7..0fb85ca 100644
> --- a/arch/arm/mm/init.c
> +++ b/arch/arm/mm/init.c
> @@ -198,7 +198,36 @@ int pfn_valid(unsigned long pfn)
> return memblock_is_map_memory(__pfn_to_phys(pfn));
>  }
>  EXPORT_SYMBOL(pfn_valid);
> -#endif
> +
> +/* HAVE_MEMBLOCK is always enabled on arm */
> +unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn)
> +{
> +   struct memblock_type *type = &memblock.memory;
> +   unsigned int right = type->cnt;
> +   unsigned int mid, left = 0;
> +   phys_addr_t addr = PFN_PHYS(++pfn);
> +
> +   do {
> +   mid = (right + left) / 2;
> +
> +   if (addr < type->regions[mid].base)
> +   right = mid;
> +   else if (addr >= (type->regions[mid].base +
> + type->regions[mid].size))
> +   left = mid + 1;
> +   else {
> +   /* addr is within the region, so pfn is valid */
> +   return pfn;
> +   }
> +   } while (left < right);
> +
> +   if (right == type->cnt)
> +   return -1UL;
> +   else
> +   return PHYS_PFN(type->regions[right].base);
> +}
> +EXPORT_SYMBOL(memblock_next_valid_pfn);
> +#endif /*CONFIG_HAVE_ARCH_PFN_VALID*/
>
>  #ifndef CONFIG_SPARSEMEM
>  static void __init arm_memory_present(void)
> diff --git a/arch/arm64/include/asm/page.h b/arch/arm64/include/asm/page.h
> index 60d02c8..e57d3f2 100644
> --- a/arch/arm64/include/asm/page.h
> +++ b/arch/arm64/include/asm/page.h
> @@ -39,6 +39,8 @@ typedef struct page *pgtable_t;
>
>  #ifdef CONFIG_HAVE_ARCH_PFN_VALID
>  extern int pfn_valid(unsigned long);
> +extern unsigned long memblock_next_valid_pfn(unsigned long pfn);
> +#define skip_to_last_invalid_pfn(pfn) (memblock_next_valid_pfn(pfn) - 1)
>  #endif
>
>  #include 
> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> index 00e7b90..13e43ff 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -290,7 +290,36 @@ int pfn_valid(unsigned long pfn)
> return memblock_is_map_memory(pfn << PAGE_SHIFT);
>  }
>  EXPORT_SYMBOL(pfn_valid);
> -#endif
> +
> +/* HAVE_MEMBLOCK is always enabled on arm64 */
> +unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn)
> +{
> +   struct memblock_type *type = &memblock.memory;
> +   unsigned int right = type->cnt;
> +   unsigned int mid, left = 0;
> +   phys_addr_t addr = PFN_PHYS(++pfn);
> +
> +   do {
> +   mid = (right + left) / 2;
> +
> +   if (addr < type->regions[mid].base)
> +   right = mid;
> +   else 

Re: linux-next: Signed-off-by missing for commits in the net-next tree

2018-04-01 Thread Stephen Rothwell
Hi Johan,

On Mon, 2 Apr 2018 08:38:03 +0300 Johan Hedberg  wrote:
>
> On Mon, Apr 02, 2018, Stephen Rothwell wrote:
> >   45a42bc9cc65 ("Bluetooth: hci_bcm: Remove DMI quirk for the MINIX Z83-4")
> >   f9b95db0165a ("Bluetooth: btrsi: remove unused including 
> > ")
> >   96e58d368fa6 ("Bluetooth: Set HCI_QUIRK_SIMULTANEOUS_DISCOVERY for 
> > BTUSB_QCA_ROME")
> >   9ea471320e13 ("Bluetooth: Mark expected switch fall-throughs")
> > 
> > are missing a Signed-off-by from their committer.  
> 
> I think this is because I fixed up a missing author name in "Bluetooth:
> hci_bcm: Remove DMI quirk for the MINIX Z83-4" and did a push --force,
> whereas these patches were originally committed by Marcel. Should I be
> adding my signed-off-by to all affected patches when doing such rebases?

Yep, Ideally we should have a Signed-off-by from everyone who involved
in getting the patches into the final tree.  That definitely means that
the final committer needs to add one.

-- 
Cheers,
Stephen Rothwell


pgpN9zG8WPRJy.pgp
Description: OpenPGP digital signature


Re: [PATCH v2] PM / wakeup: use seq_open() to show wakeup stats

2018-04-01 Thread Geert Uytterhoeven
Hi Ganesh,

On Mon, Apr 2, 2018 at 3:33 AM, Ganesh Mahendran
 wrote:
> 2018-03-30 19:00 GMT+08:00 Geert Uytterhoeven :
>> On Fri, Mar 30, 2018 at 12:25 PM, Rafael J. Wysocki  
>> wrote:
>>> On Monday, March 5, 2018 9:47:46 AM CEST Ganesh Mahendran wrote:
 single_open() interface requires that the whole output must
 fit into a single buffer. This will lead to timeout when
 system memory is not in a good situation.

 This patch use seq_open() to show wakeup stats. This method
 need only one page, so timeout will not be observed.

 --- a/drivers/base/power/wakeup.c
 +++ b/drivers/base/power/wakeup.c
 @@ -1029,32 +1029,77 @@ static int print_wakeup_source_stats(struct 
 seq_file *m,
   return 0;
  }

 -/**
 - * wakeup_sources_stats_show - Print wakeup sources statistics 
 information.
 - * @m: seq_file to print the statistics into.
 - */
 -static int wakeup_sources_stats_show(struct seq_file *m, void *unused)
 +static void *wakeup_sources_stats_seq_start(struct seq_file *m,
 + loff_t *pos)
  {

 + list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
 + if (n-- > 0)
 + continue;
 + goto out;
 + }
 + ws = NULL;
 +out:
 + return ws;
 +}
>>>
>>> Please clean up the above at least.
>>>
>>> If I'm not mistaken, you don't need the label and the goto here.
>>
>> The continue is also not needed, if the test condition is inverted.
>
> Hi, Geert
>
> We need to locate to the last read item. What is your suggestion here?

I didn't mean to get rid of that logic, but to reorganize the code to make it
simpler:

list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
if (n-- <= 0)
return ws;
}

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [GIT PULL] Andes(nds32) Port for Linux 4.17

2018-04-01 Thread Arnd Bergmann
On Mon, Apr 2, 2018 at 8:01 AM, Greentime Hu  wrote:
> 
> This tag contains the core nds32 Linux port(including interrupt controller
> driver and timer driver), which has been through 7 rounds of review on mailing
> list.

Reviewed-by: Arnd Bergmann 


Re: [PATCH v5] ANDROID: binder: change down_write to down_read

2018-04-01 Thread Ganesh Mahendran
2018-04-02 14:34 GMT+08:00 Minchan Kim :
> On Fri, Mar 30, 2018 at 12:04:07PM +0200, Greg Kroah-Hartman wrote:
>> On Fri, Mar 30, 2018 at 10:29:21AM +0900, Minchan Kim wrote:
>> > Hi Ganesh,
>> >
>> > On Fri, Mar 30, 2018 at 09:21:55AM +0800, Ganesh Mahendran wrote:
>> > > 2018-03-29 14:54 GMT+08:00 Minchan Kim :
>> > > > binder_update_page_range needs down_write of mmap_sem because
>> > > > vm_insert_page need to change vma->vm_flags to VM_MIXEDMAP unless
>> > > > it is set. However, when I profile binder working, it seems
>> > > > every binder buffers should be mapped in advance by binder_mmap.
>> > > > It means we could set VM_MIXEDMAP in binder_mmap time which is
>> > > > already hold a mmap_sem as down_write so binder_update_page_range
>> > > > doesn't need to hold a mmap_sem as down_write.
>> > > >
>> > > > Android suffers from mmap_sem contention so let's reduce mmap_sem
>> > > > down_write.
>> > >
>> > > Hi, Minchan:
>> > >
>> > > It seems there is performance regression of this patch.
>> >
>> > You mean "This patch aims for solving performance regression" not "This 
>> > patch
>> > makes performance regression"?
>> >
>> > >
>> > > Do you have some test result of android app launch time or 
>> > > binderThroughput?
>> >
>> > Unfortunately, I don't have any number. The goal is to reduce the number of
>> > call mmap_sem as write-side lock because it makes priority inversion of 
>> > threads
>> > easily and that's one of clear part I spot that we don't need write-side 
>> > lock.
>>
>> Please always run the binderThroughput tests when making binder changes
>> (there is a binder test suite in the CTS Android tests), as that ensures
>> that you are not causing performance regressions as well as just normal
>> bug regressions :)
>
> Thanks for the information. I didn't notice that such kinds of tests for
> binder. I will keep it in mind.
>
> Today, I have setup the testing for my phone and found testing was very
> fluctuating even without my patch. It might be not good with my test
> skill. I emulated user's behavior with various touch event. With it, I open
> various apps and play with them several times. Before starting the test,
> I did "adb shell stop && adb shell start && echo 3 > /proc/sys/vm/drop_caches"
>
> Such 15% noise was very easy to make it.
>
> Ganesh, How did you measure? What's the stddev?

Hi, Minchan:

Sorry for the late response, a little busy these days. :)

We have our own test tools to measure app launch time, or you can use
android systrace to get the app launch time. We tested your V1 patch:
https://patchwork.kernel.org/patch/10312057/
and found app lunch time regression.

I will use binderThroghput tool to test the patch today or tomorrow.

Thanks.

> Please let me know how you measure without noise so I'd like to reproduce
> the result in my phone.
>
> I will do binderThroghput test, too.
>
>


Re: [PATCH 4.4 076/134] kprobes/x86: Set kprobes pages read-only

2018-04-01 Thread Masami Hiramatsu
On Sun, 01 Apr 2018 17:20:30 +0100
Ben Hutchings  wrote:

> On Mon, 2018-03-19 at 19:05 +0100, Greg Kroah-Hartman wrote:
> > 4.4-stable review patch.  If anyone has any objections, please let me know.
> > 
> > --
> > 
> > From: Masami Hiramatsu 
> > 
> > 
> > [ Upstream commit d0381c81c2f782fa2131178d11e0cfb23d50d631 ]
> 
> This caused a regression in mainline, fixed by:
> 
> commit c93f5cf571e7795f97d49ef51b766cf25e328545
> Author: Masami Hiramatsu 
> Date:   Thu May 25 19:38:17 2017 +0900
> 
> kprobes/x86: Fix to set RWX bits correctly before releasing trampoline

Thanks Ben,
Greg, could you please pick above patch too?

Thank you,

> 
> Ben.
> 
> > Set the pages which is used for kprobes' singlestep buffer
> > and optprobe's trampoline instruction buffer to readonly.
> > This can prevent unexpected (or unintended) instruction
> > modification.
> > 
> > This also passes rodata_test as below.
> > 
> > Without this patch, rodata_test shows a warning:
> > 
> >   WARNING: CPU: 0 PID: 1 at arch/x86/mm/dump_pagetables.c:235 
> > note_page+0x7a9/0xa20
> >   x86/mm: Found insecure W+X mapping at address 
> > a000/0xa000
> > 
> > With this fix, no W+X pages are found:
> > 
> >   x86/mm: Checked W+X mappings: passed, no W+X pages found.
> >   rodata_test: all tests were successful
> > 
> > Reported-by: Andrey Ryabinin 
> > Signed-off-by: Masami Hiramatsu 
> > Cc: Ananth N Mavinakayanahalli 
> > Cc: Anil S Keshavamurthy 
> > Cc: Borislav Petkov 
> > Cc: Brian Gerst 
> > Cc: David S . Miller 
> > Cc: Denys Vlasenko 
> > Cc: H. Peter Anvin 
> > Cc: Josh Poimboeuf 
> > Cc: Linus Torvalds 
> > Cc: Peter Zijlstra 
> > Cc: Thomas Gleixner 
> > Cc: Ye Xiaolong 
> > Link: 
> > http://lkml.kernel.org/r/149076375592.22469.14174394514338612247.stgit@devbox
> > Signed-off-by: Ingo Molnar 
> > Signed-off-by: Sasha Levin 
> > Signed-off-by: Greg Kroah-Hartman 
> > ---
> >  arch/x86/kernel/kprobes/core.c |4 
> >  arch/x86/kernel/kprobes/opt.c  |3 +++
> >  2 files changed, 7 insertions(+)
> > 
> > --- a/arch/x86/kernel/kprobes/core.c
> > +++ b/arch/x86/kernel/kprobes/core.c
> > @@ -406,6 +406,8 @@ static int arch_copy_kprobe(struct kprob
> >  {
> >     int ret;
> >  
> > +   set_memory_rw((unsigned long)p->ainsn.insn & PAGE_MASK, 1);
> > +
> >     /* Copy an instruction with recovering if other optprobe modifies it.*/
> >     ret = __copy_instruction(p->ainsn.insn, p->addr);
> >     if (!ret)
> > @@ -420,6 +422,8 @@ static int arch_copy_kprobe(struct kprob
> >     else
> >     p->ainsn.boostable = -1;
> >  
> > +   set_memory_ro((unsigned long)p->ainsn.insn & PAGE_MASK, 1);
> > +
> >     /* Check whether the instruction modifies Interrupt Flag or not */
> >     p->ainsn.if_modifier = is_IF_modifier(p->ainsn.insn);
> >  
> > --- a/arch/x86/kernel/kprobes/opt.c
> > +++ b/arch/x86/kernel/kprobes/opt.c
> > @@ -370,6 +370,7 @@ int arch_prepare_optimized_kprobe(struct
> >     }
> >  
> >     buf = (u8 *)op->optinsn.insn;
> > +   set_memory_rw((unsigned long)buf & PAGE_MASK, 1);
> >  
> >     /* Copy instructions into the out-of-line buffer */
> >     ret = copy_optimized_instructions(buf + TMPL_END_IDX, op->kp.addr);
> > @@ -392,6 +393,8 @@ int arch_prepare_optimized_kprobe(struct
> >     synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
> >        (u8 *)op->kp.addr + op->optinsn.size);
> >  
> > +   set_memory_ro((unsigned long)buf & PAGE_MASK, 1);
> > +
> >     flush_icache_range((unsigned long) buf,
> >        (unsigned long) buf + TMPL_END_IDX +
> >        op->optinsn.size + RELATIVEJUMP_SIZE);
> 
> -- 
> Ben Hutchings
> Software Developer, Codethink Ltd.
> 


-- 
Masami Hiramatsu 


Re: BUG: corrupted list in __dentry_kill

2018-04-01 Thread Al Viro
On Sun, Apr 01, 2018 at 02:48:54PM -0700, Eric Biggers wrote:
> [+Cc linux-nfs]
> > 
> > [   42.965515] net/sunrpc/rpc_pipe.c: __rpc_create_common failed to 
> > allocate inode for dentry blocklayout
> > [   42.967234] net/sunrpc/rpc_pipe.c: rpc_mkpipe_dentry() failed to create 
> > pipe nfs/blocklayout (errno = -12)

AFAICS, there's nothing to zero nn->bl_device_pipe->dentry after
nfs4blocklayout_unregister_sb(), is there?  If nothing else, what's
going to happen after mount/umount/mount with failing
nfs4blocklayout_register_sb()?  AFAICS, we'll have stale pointer to
dentry sitting in nn->bl_device_pipe->dentry, and call rpc_unlink()
on it while cleaning up after the failing mount.

I don't think that's all there is to it, but it does smell like
a bug.


Re: [PATCH 2/2] perf: add arm64 smmuv3 pmu driver

2018-04-01 Thread Yisheng Xie
Hi Neil,

On 2018/4/1 13:44, Neil Leeder wrote:
> Hi Yisheng Xie,
> 
> On 3/29/2018 03:03 AM, Yisheng Xie wrote:
>>
>> Hi Neil,
>>
>> On 2017/8/5 3:59, Neil Leeder wrote:
>>> +mem_resource_0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>> +mem_map_0 = devm_ioremap_resource(&pdev->dev, mem_resource_0);
>>> +
>> Can we use devm_ioremap instead? for the reg_base of smmu_pmu is
>> IMPLEMENTATION DEFINED. If the reg of smmu_pmu is inside smmu,
>> devm_ioremap_resource will failed and return -EBUSY, eg.:
>>
>>   smmu reg ranges:0x18000 ~ 0x1801f
>>   its smmu_pmu reg ranges:0x180001000 ~ 0x180001fff
>>
> Just to let you know that I no longer work at Qualcomm and I won't be able to 
> provide updates to this patchset. I expect that others from my former team at 
> Qualcomm will pick up ownership.

Thanks for this infomation.

hi Agustin and Timur,

Is there any new status about this patchset?

Thanks
Yisheng

> 
> Neil
> 
> .
> 



Re: [PATCH v5 13/13] ARM: dts: ipq8074: Enable few peripherals for hk01 board

2018-04-01 Thread Sricharan R
Hi Bjorn,


On 3/27/2018 11:19 PM, Bjorn Andersson wrote:
> On Fri 23 Mar 03:18 PDT 2018, Sricharan R wrote:
> 
>> Reviewed-by: Abhishek Sahu 
>> Signed-off-by: Sricharan R 
>> ---
>>  arch/arm64/boot/dts/qcom/ipq8074-hk01.dts | 103 
>> ++
>>  1 file changed, 103 insertions(+)
>>
>> diff --git a/arch/arm64/boot/dts/qcom/ipq8074-hk01.dts 
>> b/arch/arm64/boot/dts/qcom/ipq8074-hk01.dts
>> index 6a838b5..dbca7ec 100644
>> --- a/arch/arm64/boot/dts/qcom/ipq8074-hk01.dts
>> +++ b/arch/arm64/boot/dts/qcom/ipq8074-hk01.dts
>> @@ -21,6 +21,7 @@
>>  
>>  aliases {
>>  serial0 = &blsp1_uart5;
>> +serial1 = &serial_blsp2;
>>  };
>>  
>>  chosen {
>> @@ -41,6 +42,47 @@
>>  bias-disable;
>>  };
>>  };
>> +
>> + i2c_0_pins: i2c_0_pinmux {
>> +  mux {
>> +   pins = "gpio42", "gpio43";
>> +   function = "blsp1_i2c";
>> +   drive-strength = <8>;
>> +   bias-disable;
>> +  };
>> + };
>> +
>> + spi_0_pins: spi_0_pins {
>> +  mux {
>> +   pins = "gpio38", "gpio39", "gpio40", 
>> "gpio41";
>> +   function = "blsp0_spi";
>> +   drive-strength = <8>;
>> +   bias-disable;
>> +  };
>> + };
>> +
>> + hsuart_pins: hsuart_pins {
>> +  mux {
>> +   pins = "gpio46", "gpio47", "gpio48", 
>> "gpio49";
>> +   function = "blsp2_uart";
>> +   drive-strength = <8>;
>> +   bias-disable;
>> +  };
>> + };
>> +
>> + qpic_pins: qpic_pins {
>> +mux {
>> +   pins = "gpio1", "gpio3", "gpio4",
>> +  "gpio5", "gpio6", "gpio7",
>> +  "gpio8", "gpio10", "gpio11",
>> +  "gpio12", "gpio13", "gpio14",
>> +  "gpio15", "gpio16", "gpio17";
>> +   function = "qpic";
> 
> I would prefer that you move the pinmux part to the same dtsi that
> defines the nand and add the board specific pinconf (electrical
> properties) here. That way we limit the repetition between the board
> files.
> 

 sure. will do.

>> +   drive-strength = <8>;
>> +   bias-disable;
>> +  };
>> +};
>> +
>>  };
>>  
> 
> Other than that,
> 
> Acked-by: Bjorn Andersson 
> 

 Thanks. Again, thanks for your time and all the reviews.

Regards,
 Sricharan

-- 
"QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of 
Code Aurora Forum, hosted by The Linux Foundation


Re: [PATCH v5 12/13] ARM: dts: ipq8074: Add pcie nodes

2018-04-01 Thread Sricharan R


On 3/27/2018 11:16 PM, Bjorn Andersson wrote:
> On Fri 23 Mar 03:18 PDT 2018, Sricharan R wrote:
> 
>> The driver/phy support for ipq8074 is available now.
>> So enabling the nodes in DT.
>>
> 
> Acked-by: Bjorn Andersson 
> 

 Thanks.

Regards,
 Sricharan



> Regards,
> Bjorn
> 
>> Reviewed-by: Abhishek Sahu 
>> Signed-off-by: Sricharan R 
>> ---
>>  arch/arm64/boot/dts/qcom/ipq8074.dtsi | 157 
>> +-
>>  1 file changed, 156 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/boot/dts/qcom/ipq8074.dtsi 
>> b/arch/arm64/boot/dts/qcom/ipq8074.dtsi
>> index a8dbbf0..caf3485 100644
>> --- a/arch/arm64/boot/dts/qcom/ipq8074.dtsi
>> +++ b/arch/arm64/boot/dts/qcom/ipq8074.dtsi
>> @@ -24,7 +24,7 @@
>>  ranges = <0 0 0 0x>;
>>  compatible = "simple-bus";
>>  
>> -pinctrl@100 {
>> +tlmm: pinctrl@100 {
>>  compatible = "qcom,ipq8074-pinctrl";
>>  reg = <0x100 0x30>;
>>  interrupts = ;
>> @@ -229,6 +229,161 @@
>>  dma-names = "tx", "rx", "cmd";
>>  status = "disabled";
>>  };
>> +
>> +pcie_phy0: phy@86000 {
>> +compatible = "qcom,ipq8074-qmp-pcie-phy";
>> +reg = <0x86000 0x1000>;
>> +#phy-cells = <0>;
>> +clocks = <&gcc GCC_PCIE0_PIPE_CLK>;
>> +clock-names = "pipe_clk";
>> +clock-output-names = "pcie20_phy0_pipe_clk";
>> +
>> +resets = <&gcc GCC_PCIE0_PHY_BCR>,
>> +<&gcc GCC_PCIE0PHY_PHY_BCR>;
>> +reset-names = "phy",
>> +  "common";
>> +status = "disabled";
>> +};
>> +
>> +pcie0: pci@2000 {
>> +compatible = "qcom,pcie-ipq8074";
>> +reg =  <0x2000 0xf1d
>> +0x2f20 0xa8
>> +0x8 0x2000
>> +0x2010 0x1000>;
>> +reg-names = "dbi", "elbi", "parf", "config";
>> +device_type = "pci";
>> +linux,pci-domain = <0>;
>> +bus-range = <0x00 0xff>;
>> +num-lanes = <1>;
>> +#address-cells = <3>;
>> +#size-cells = <2>;
>> +
>> +phys = <&pcie_phy0>;
>> +phy-names = "pciephy";
>> +
>> +ranges = <0x8100 0 0x2020 0x2020
>> +  0 0x10   /* downstream I/O */
>> +  0x8200 0 0x2030 0x2030
>> +  0 0xd0>; /* non-prefetchable memory */
>> +
>> +interrupts = ;
>> +interrupt-names = "msi";
>> +#interrupt-cells = <1>;
>> +interrupt-map-mask = <0 0 0 0x7>;
>> +interrupt-map = <0 0 0 1 &intc 0 75
>> + IRQ_TYPE_LEVEL_HIGH>, /* int_a */
>> +<0 0 0 2 &intc 0 78
>> + IRQ_TYPE_LEVEL_HIGH>, /* int_b */
>> +<0 0 0 3 &intc 0 79
>> + IRQ_TYPE_LEVEL_HIGH>, /* int_c */
>> +<0 0 0 4 &intc 0 83
>> + IRQ_TYPE_LEVEL_HIGH>; /* int_d */
>> +
>> +clocks = <&gcc GCC_SYS_NOC_PCIE0_AXI_CLK>,
>> + <&gcc GCC_PCIE0_AXI_M_CLK>,
>> + <&gcc GCC_PCIE0_AXI_S_CLK>,
>> + <&gcc GCC_PCIE0_AHB_CLK>,
>> + <&gcc GCC_PCIE0_AUX_CLK>;
>> +
>> +clock-names = "iface",
>> +  "axi_m",
>> +  "axi_s",
>> +  "ahb",
>> +  "aux";
>> +resets = <&gcc GCC_PCIE0_PIPE_ARES>,
>> + <&gcc GCC_PCIE0_SLEEP_ARES>,
>> + <&gcc GCC_PCIE0_CORE_STICKY_ARES>,
>> + <&gcc GCC_PCIE0_AXI_MASTER_ARES>,
>> + <&gcc GCC_PCIE0_AXI_SLAVE_ARES>,
>> + <&gcc GCC_PCIE0_AHB_ARES>,
>> + <&gcc GCC_PCIE0_AXI_MASTER_STICKY_ARES>;
>> +reset-names = "pipe",
>> +  "sleep",
>> +  "sticky",
>> +  "axi_m",
>> +  "axi_s",
>> +  "ahb",
>> +  "axi_m_sticky";
>> +status 

Re: [PATCH v5 11/13] ARM: dts: ipq8074: Add peripheral nodes

2018-04-01 Thread Sricharan R


On 3/27/2018 11:15 PM, Bjorn Andersson wrote:
> On Fri 23 Mar 03:18 PDT 2018, Sricharan R wrote:
>> +serial_blsp0: serial@78af000 {
> 
> Please try to have a single scheme for how you name your labels; this is
> serial0 or blsp1_uart1.
> 
> [..]
>> +i2c_0: i2c@78b6000 {
> 
> As in the previous patches, this is the 2nd i2c master in the SoC,
> please label it accordingly.

 ok, sure. will correct the label names uniformly.

Regards,
 Sricharan

-- 
"QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of 
Code Aurora Forum, hosted by The Linux Foundation


Re: [PATCH v5] ANDROID: binder: change down_write to down_read

2018-04-01 Thread Minchan Kim
On Fri, Mar 30, 2018 at 12:04:07PM +0200, Greg Kroah-Hartman wrote:
> On Fri, Mar 30, 2018 at 10:29:21AM +0900, Minchan Kim wrote:
> > Hi Ganesh,
> > 
> > On Fri, Mar 30, 2018 at 09:21:55AM +0800, Ganesh Mahendran wrote:
> > > 2018-03-29 14:54 GMT+08:00 Minchan Kim :
> > > > binder_update_page_range needs down_write of mmap_sem because
> > > > vm_insert_page need to change vma->vm_flags to VM_MIXEDMAP unless
> > > > it is set. However, when I profile binder working, it seems
> > > > every binder buffers should be mapped in advance by binder_mmap.
> > > > It means we could set VM_MIXEDMAP in binder_mmap time which is
> > > > already hold a mmap_sem as down_write so binder_update_page_range
> > > > doesn't need to hold a mmap_sem as down_write.
> > > >
> > > > Android suffers from mmap_sem contention so let's reduce mmap_sem
> > > > down_write.
> > > 
> > > Hi, Minchan:
> > > 
> > > It seems there is performance regression of this patch.
> > 
> > You mean "This patch aims for solving performance regression" not "This 
> > patch
> > makes performance regression"?
> > 
> > > 
> > > Do you have some test result of android app launch time or 
> > > binderThroughput?
> > 
> > Unfortunately, I don't have any number. The goal is to reduce the number of
> > call mmap_sem as write-side lock because it makes priority inversion of 
> > threads
> > easily and that's one of clear part I spot that we don't need write-side 
> > lock.
> 
> Please always run the binderThroughput tests when making binder changes
> (there is a binder test suite in the CTS Android tests), as that ensures
> that you are not causing performance regressions as well as just normal
> bug regressions :)

Thanks for the information. I didn't notice that such kinds of tests for
binder. I will keep it in mind.

Today, I have setup the testing for my phone and found testing was very
fluctuating even without my patch. It might be not good with my test
skill. I emulated user's behavior with various touch event. With it, I open
various apps and play with them several times. Before starting the test,
I did "adb shell stop && adb shell start && echo 3 > /proc/sys/vm/drop_caches"

Such 15% noise was very easy to make it.

Ganesh, How did you measure? What's the stddev?
Please let me know how you measure without noise so I'd like to reproduce
the result in my phone.

I will do binderThroghput test, too.




Re: [PATCH] cpufreq: ti-cpufreq: Fix couple of minor issues in probe()

2018-04-01 Thread Viresh Kumar
On 26-03-18, 16:52, Suman Anna wrote:
> Commit 05829d9431df ("cpufreq: ti-cpufreq: kfree opp_data when
> failure") has fixed a memory leak in the failure path, however
> kmemleak still keeps reporting a leak even on successful probes.
> This is a false-positive and is mostly a result of the opp_data

I don't agree to this reasoning for this particular patch. The code is just fine
and kmemleak is something that requires a fix.

> variable not being stored anywhere in the probe function. The
> patch also returned a positive value on the get_cpu_device()
> failure instead of a negative value.

Maybe that could have been fixed in a separate patch, cc'ing stable kernels as
well.

> unreferenced object 0xecae4d80 (size 64):
>   comm "swapper/0", pid 1, jiffies 4294937673 (age 154.420s)
>   hex dump (first 32 bytes):
> 10 40 d9 ee 74 b7 db ee 00 24 ac ec 20 a3 ea c0  .@..t$.. ...
> 00 26 ac ec 00 00 00 00 00 00 00 00 00 00 00 00  .&..
>   backtrace:
> [] platform_drv_probe+0x50/0xac
> [] driver_probe_device+0x24c/0x330
> [] bus_for_each_drv+0x54/0xb8
> [<2c6f7021>] __device_attach+0xcc/0x13c
> [] bus_probe_device+0x88/0x90
> [] device_add+0x38c/0x5b4
> [<6f1af99b>] platform_device_add+0x100/0x220
> [] platform_device_register_full+0xf0/0x104
> [<4d492439>] ti_cpufreq_init+0x44/0x6c
> [<81222e89>] do_one_initcall+0x48/0x190
> [<3bebf42a>] kernel_init_freeable+0x1f4/0x2b8
> [<230ad7df>] kernel_init+0x8/0x110
> [<43a165c3>] ret_from_fork+0x14/0x20
> [<  (null)>]   (null)
> [<87288797>] 0x
> 
> Fix both issues by replacing the previous logic by using the devres
> managed API for allocating the opp_data variable, and simplifying
> the get_cpu_device() failure return path.
> 
> Fixes: 05829d9431df ("cpufreq: ti-cpufreq: kfree opp_data when failure")
> Cc: Zumeng Chen 
> Signed-off-by: Suman Anna 
> ---
>  drivers/cpufreq/ti-cpufreq.c | 7 ++-
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/cpufreq/ti-cpufreq.c b/drivers/cpufreq/ti-cpufreq.c
> index a099b7bf74cd..7d353a21935b 100644
> --- a/drivers/cpufreq/ti-cpufreq.c
> +++ b/drivers/cpufreq/ti-cpufreq.c
> @@ -217,7 +217,7 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
>   if (!match)
>   return -ENODEV;
>  
> - opp_data = kzalloc(sizeof(*opp_data), GFP_KERNEL);
> + opp_data = devm_kzalloc(&pdev->dev, sizeof(*opp_data), GFP_KERNEL);
>   if (!opp_data)
>   return -ENOMEM;
>  
> @@ -226,8 +226,7 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
>   opp_data->cpu_dev = get_cpu_device(0);
>   if (!opp_data->cpu_dev) {
>   pr_err("%s: Failed to get device for CPU0\n", __func__);
> - ret = ENODEV;
> - goto free_opp_data;
> + return -ENODEV;
>   }
>  
>   opp_data->opp_node = dev_pm_opp_of_get_opp_desc_node(opp_data->cpu_dev);
> @@ -285,8 +284,6 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
>  
>  fail_put_node:
>   of_node_put(opp_data->opp_node);
> -free_opp_data:
> - kfree(opp_data);
>  
>   return ret;
>  }

I am fine with the diff though, as that makes sense. So maybe do this ?

- send separate patch for ENODEV thing
- and another patch to move to devres with a different reason than fixing false
  positive.

-- 
viresh


Re: [PATCH v5 06/13] ARM: dts: ipq4019: Add ipq4019-ap.dk04.1-c1 board file

2018-04-01 Thread Varadarajan Narayanan
On Fri, Mar 23, 2018 at 03:48:49PM +0530, Sricharan R wrote:
> Reviewed-by: Abhishek Sahu 
> Signed-off-by: Sricharan R 
> ---
>  arch/arm/boot/dts/Makefile  |  1 +
>  arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1-c1.dts | 20 
>  2 files changed, 21 insertions(+)
>  create mode 100644 arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1-c1.dts
> 

NAND, BAM and SPI work fine.

Tested-by: Varadarajan Narayanan 

-Varada

> diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
> index ade7a38..b6c62c6 100644
> --- a/arch/arm/boot/dts/Makefile
> +++ b/arch/arm/boot/dts/Makefile
> @@ -747,6 +747,7 @@ dtb-$(CONFIG_ARCH_QCOM) += \
>   qcom-apq8084-ifc6540.dtb \
>   qcom-apq8084-mtp.dtb \
>   qcom-ipq4019-ap.dk01.1-c1.dtb \
> + qcom-ipq4019-ap.dk04.1-c1.dtb \
>   qcom-ipq8064-ap148.dtb \
>   qcom-msm8660-surf.dtb \
>   qcom-msm8960-cdp.dtb \
> diff --git a/arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1-c1.dts 
> b/arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1-c1.dts
> new file mode 100644
> index 000..526b7f8
> --- /dev/null
> +++ b/arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1-c1.dts
> @@ -0,0 +1,20 @@
> +// SPDX-License-Identifier: GPL-2.0
> +// Copyright (c) 2018, The Linux Foundation. All rights reserved.
> +
> +#include "qcom-ipq4019-ap.dk04.1.dtsi"
> +
> +/ {
> + model = "Qualcomm Technologies, Inc. IPQ4019/AP-DK04.1-C1";
> +
> + soc {
> + dma@7984000 {
> + status = "ok";
> + };
> +
> + qpic-nand@79b {
> + pinctrl-0 = <&nand_pins>;
> + pinctrl-names = "default";
> + status = "ok";
> + };
> + };
> +};
> -- 
> QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of 
> Code Aurora Forum, hosted by The Linux Foundation
> 
> 
> ___
> linux-arm-kernel mailing list
> linux-arm-ker...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of 
Code Aurora Forum, hosted by The Linux Foundation


[GIT PULL] RCU changes for v4.17

2018-04-01 Thread Ingo Molnar
Linus,

Please pull the latest core-rcu-for-linus git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-rcu-for-linus

   # HEAD: c4fb5f37001514c0004d17b79cf74a499b9bc320 Merge branch 'for-mingo' of 
git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu into core/rcu

The main RCU subsystem changes in this cycle were:

 - Miscellaneous fixes, perhaps most notably removing obsolete
   code whose only purpose in life was to gather information for
   the now-removed RCU debugfs facility.  Other notable changes
   include removing NO_HZ_FULL_ALL in favor of the nohz_full kernel
   boot parameter, minor optimizations for expedited grace periods,
   some added tracing, creating an RCU-specific workqueue using Tejun's
   new WQ_MEM_RECLAIM flag, and several cleanups to code and comments.

 - SRCU cleanups and optimizations.

 - Torture-test updates, perhaps most notably the adding of ARMv8
   support, but also including numerous cleanups and usability fixes.

 Thanks,

Ingo

-->
Byungchul Park (1):
  srcu: Remove dead code in srcu_gp_end()

Ildar Ismagilov (3):
  rcu: Fix misprint in srcu_funnel_exp_start
  srcu: Prevent sdp->srcu_gp_seq_needed_exp counter wrap
  srcu: Reduce scans of srcu_data in counter wrap check

Lihao Liang (4):
  rcu: Remove unnecessary spinlock in rcu_boot_init_percpu_data()
  doc: Fix typo in rcutorture documentation
  doc: Fix typo in rcu_head comments
  rcutorture: Add basic ARM64 support to run scripts

Liu, Changcheng (1):
  rcu: Remove redundant nxttail index macro define

Matthew Wilcox (1):
  rcu: Use wrapper for lockdep asserts

Paul E. McKenney (26):
  sched/isolation: Eliminate NO_HZ_FULL_ALL
  rcu: Fix CPU offload boot message when no CPUs are offloaded
  rcu: Remove obsolete boost statistics for debugfs
  rcu: Remove obsolete callback-invocation statistics for debugfs
  rcu: Remove obsolete __rcu_pending() statistics for debugfs
  rcu: Remove obsolete force-quiescent-state statistics for debugfs
  rcu: More clearly identify grace-period kthread stack dump
  rcu: Consolidate rcu.h #ifdefs
  rcu: Fix init_rcu_head() comment.
  rcu: Add more tracing of expedited grace periods
  rcu: Trace expedited GP delays due to transitioning CPUs
  rcu: Make expedited RCU CPU selection avoid unnecessary stores
  srcu: Abstract function name
  rcu: Remove SRCU throttling
  rcutorture: Replace multi-instance kzalloc() with kcalloc()
  rcutorture: Abstract function and module names
  rcutorture: Avoid fake-writer use of undefined primitives
  rcutorture: Re-enable testing of dynamic expediting
  rcutorture: Record which grace-period primitives are tested
  rcutorture: Update kvm.sh header comment
  torture: Specify qemu memory size with --memory argument
  torture: Default jitter off when running rcuperf
  torture: Adjust rcuperf trace processing to allow for workqueues
  torture: Grace periods do not piggyback off of themselves
  torture: Provide more sensible nreader/nwriter defaults for rcuperf
  rcu: Create RCU-specific workqueues with rescuers

Tejun Heo (1):
  rcu: Call touch_nmi_watchdog() while printing stall warnings


 Documentation/timers/NO_HZ.txt |  7 ---
 include/linux/rcupdate.h   | 10 +--
 include/linux/types.h  |  2 +-
 include/trace/events/rcu.h |  4 ++
 kernel/rcu/rcu.h   | 38 
 kernel/rcu/rcuperf.c   | 21 ++-
 kernel/rcu/rcutorture.c| 72 --
 kernel/rcu/srcutree.c  | 29 +
 kernel/rcu/tree.c  | 72 --
 kernel/rcu/tree.h  | 36 +--
 kernel/rcu/tree_exp.h  | 36 ---
 kernel/rcu/tree_plugin.h   | 34 ++
 kernel/time/Kconfig| 10 ---
 kernel/time/tick-sched.c   | 22 +--
 .../testing/selftests/rcutorture/bin/functions.sh  | 17 -
 .../rcutorture/bin/kvm-recheck-rcuperf-ftrace.sh   | 11 ++--
 .../selftests/rcutorture/bin/kvm-test-1-run.sh |  4 +-
 tools/testing/selftests/rcutorture/bin/kvm.sh  | 22 +--
 .../selftests/rcutorture/configs/rcu/TASKS03   |  1 -
 .../selftests/rcutorture/configs/rcu/TASKS03.boot  |  2 +-
 .../selftests/rcutorture/configs/rcu/TREE04|  1 -
 .../selftests/rcutorture/configs/rcu/TREE04.boot   |  2 +-
 .../selftests/rcutorture/configs/rcu/TREE07|  1 -
 .../rcutorture/configs/rcuperf/ver_functions.sh| 24 +---
 .../selftests/rcutorture/doc/rcu-test-image.txt|  2 +-
 25 files changed, 238 insertions(+), 242 deletions(-)



[GIT PULL] Reduce dependencies

2018-04-01 Thread Ingo Molnar
Linus,

Please pull the latest core-headers-for-linus git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
core-headers-for-linus

   # HEAD: 562c45d635ecd5c0648ceb4d4aff9bdc1ad91252 headers: Drop two #included 
headers from 

A single change that drops two #includes from a frequently used kernel header: 
.

 Thanks,

Ingo

-->
Randy Dunlap (1):
  headers: Drop two #included headers from 


 include/linux/interrupt.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 69c238210325..5426627f9c55 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -4,9 +4,7 @@
 #define _LINUX_INTERRUPT_H
 
 #include 
-#include 
 #include 
-#include 
 #include 
 #include 
 #include 


[GIT PULL] debugobjects changes for v4.17

2018-04-01 Thread Ingo Molnar
Linus,

Please pull the latest core-debugobjects-for-linus git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
core-debugobjects-for-linus

   # HEAD: 163cf842f5837334bc69aaf09ad38e11f4573914 debugobjects: Avoid another 
unused variable warning

Misc improvements:

 - add better instrumentation/debugging
 - optimize the freeing logic improve performance

 Thanks,

Ingo

-->
Arnd Bergmann (2):
  debugobjects: Fix debug_objects_freed accounting
  debugobjects: Avoid another unused variable warning

Yang Shi (4):
  debugobjects: Export max loops counter
  debugobjects: Add global free list and the counter
  debugobjects: Use global free list in free_object()
  debugobjects: Use global free list in __debug_check_no_obj_freed()


 lib/debugobjects.c | 141 ++---
 1 file changed, 92 insertions(+), 49 deletions(-)

diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index 2f5349c6e81a..994be4805cec 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -42,14 +42,18 @@ static struct debug_obj 
obj_static_pool[ODEBUG_POOL_SIZE] __initdata;
 static DEFINE_RAW_SPINLOCK(pool_lock);
 
 static HLIST_HEAD(obj_pool);
+static HLIST_HEAD(obj_to_free);
 
 static int obj_pool_min_free = ODEBUG_POOL_SIZE;
 static int obj_pool_free = ODEBUG_POOL_SIZE;
 static int obj_pool_used;
 static int obj_pool_max_used;
+/* The number of objs on the global free list */
+static int obj_nr_tofree;
 static struct kmem_cache   *obj_cache;
 
 static int debug_objects_maxchain __read_mostly;
+static int __maybe_unused  debug_objects_maxchecked __read_mostly;
 static int debug_objects_fixups __read_mostly;
 static int debug_objects_warnings __read_mostly;
 static int debug_objects_enabled __read_mostly
@@ -96,12 +100,32 @@ static const char *obj_states[ODEBUG_STATE_MAX] = {
 static void fill_pool(void)
 {
gfp_t gfp = GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN;
-   struct debug_obj *new;
+   struct debug_obj *new, *obj;
unsigned long flags;
 
if (likely(obj_pool_free >= debug_objects_pool_min_level))
return;
 
+   /*
+* Reuse objs from the global free list; they will be reinitialized
+* when allocating.
+*/
+   while (obj_nr_tofree && (obj_pool_free < obj_pool_min_free)) {
+   raw_spin_lock_irqsave(&pool_lock, flags);
+   /*
+* Recheck with the lock held as the worker thread might have
+* won the race and freed the global free list already.
+*/
+   if (obj_nr_tofree) {
+   obj = hlist_entry(obj_to_free.first, typeof(*obj), 
node);
+   hlist_del(&obj->node);
+   obj_nr_tofree--;
+   hlist_add_head(&obj->node, &obj_pool);
+   obj_pool_free++;
+   }
+   raw_spin_unlock_irqrestore(&pool_lock, flags);
+   }
+
if (unlikely(!obj_cache))
return;
 
@@ -177,62 +201,76 @@ alloc_object(void *addr, struct debug_bucket *b, struct 
debug_obj_descr *descr)
  * workqueue function to free objects.
  *
  * To reduce contention on the global pool_lock, the actual freeing of
- * debug objects will be delayed if the pool_lock is busy. We also free
- * the objects in a batch of 4 for each lock/unlock cycle.
+ * debug objects will be delayed if the pool_lock is busy.
  */
-#define ODEBUG_FREE_BATCH  4
-
 static void free_obj_work(struct work_struct *work)
 {
-   struct debug_obj *objs[ODEBUG_FREE_BATCH];
+   struct hlist_node *tmp;
+   struct debug_obj *obj;
unsigned long flags;
-   int i;
+   HLIST_HEAD(tofree);
 
if (!raw_spin_trylock_irqsave(&pool_lock, flags))
return;
-   while (obj_pool_free >= debug_objects_pool_size + ODEBUG_FREE_BATCH) {
-   for (i = 0; i < ODEBUG_FREE_BATCH; i++) {
-   objs[i] = hlist_entry(obj_pool.first,
- typeof(*objs[0]), node);
-   hlist_del(&objs[i]->node);
-   }
 
-   obj_pool_free -= ODEBUG_FREE_BATCH;
-   debug_objects_freed += ODEBUG_FREE_BATCH;
-   /*
-* We release pool_lock across kmem_cache_free() to
-* avoid contention on pool_lock.
-*/
-   raw_spin_unlock_irqrestore(&pool_lock, flags);
-   for (i = 0; i < ODEBUG_FREE_BATCH; i++)
-   kmem_cache_free(obj_cache, objs[i]);
-   if (!raw_spin_trylock_irqsave(&pool_lock, flags))
-   return;
+   /*
+* The objs on the pool li

[GIT PULL] misc core kernel changes

2018-04-01 Thread Ingo Molnar
Linus,

Please pull the latest core-core-for-linus git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-core-for-linus

   # HEAD: 5ad751053704df3f00d2bb2dc9345c697c212150 panic: Add closing panic 
marker parenthesis

Two changes:

 - add membarriers to Documentation/features/
 - fix a minor nit in panic printk formatting

 Thanks,

Ingo

-->
Borislav Petkov (1):
  panic: Add closing panic marker parenthesis

Mathieu Desnoyers (2):
  Documentation/features: Allow comments in arch features files
  Documentation/features, membarriers: Document membarrier-sync-core 
architecture support


 Documentation/features/list-arch.sh|  2 +-
 .../sched/membarrier-sync-core/arch-support.txt| 62 ++
 kernel/panic.c |  2 +-
 3 files changed, 64 insertions(+), 2 deletions(-)
 create mode 100644 
Documentation/features/sched/membarrier-sync-core/arch-support.txt

diff --git a/Documentation/features/list-arch.sh 
b/Documentation/features/list-arch.sh
index c16b5b595688..1ec47c3bb5fa 100755
--- a/Documentation/features/list-arch.sh
+++ b/Documentation/features/list-arch.sh
@@ -17,7 +17,7 @@ for F in */*/arch-support.txt; do
   N=$(grep -h "^# Feature name:"$F | cut -c25-)
   C=$(grep -h "^# Kconfig:" $F | cut -c25-)
   D=$(grep -h "^# description:" $F | cut -c25-)
-  S=$(grep -hw $ARCH $F | cut -d\| -f3)
+  S=$(grep -hv "^#" $F | grep -w $ARCH | cut -d\| -f3)
 
   printf "%10s/%-22s:%s| %35s # %s\n" "$SUBSYS" "$N" "$S" "$C" "$D"
 done
diff --git a/Documentation/features/sched/membarrier-sync-core/arch-support.txt 
b/Documentation/features/sched/membarrier-sync-core/arch-support.txt
new file mode 100644
index ..2c815a7f1ba7
--- /dev/null
+++ b/Documentation/features/sched/membarrier-sync-core/arch-support.txt
@@ -0,0 +1,62 @@
+#
+# Feature name:  membarrier-sync-core
+# Kconfig:   ARCH_HAS_MEMBARRIER_SYNC_CORE
+# description:   arch supports core serializing membarrier
+#
+# Architecture requirements
+#
+# * arm64
+#
+# Rely on eret context synchronization when returning from IPI handler, and
+# when returning to user-space.
+#
+# * x86
+#
+# x86-32 uses IRET as return from interrupt, which takes care of the IPI.
+# However, it uses both IRET and SYSEXIT to go back to user-space. The IRET
+# instruction is core serializing, but not SYSEXIT.
+#
+# x86-64 uses IRET as return from interrupt, which takes care of the IPI.
+# However, it can return to user-space through either SYSRETL (compat code),
+# SYSRETQ, or IRET.
+#
+# Given that neither SYSRET{L,Q}, nor SYSEXIT, are core serializing, we rely
+# instead on write_cr3() performed by switch_mm() to provide core serialization
+# after changing the current mm, and deal with the special case of kthread ->
+# uthread (temporarily keeping current mm into active_mm) by issuing a
+# sync_core_before_usermode() in that specific case.
+#
+---
+| arch |status|
+---
+|   alpha: | TODO |
+| arc: | TODO |
+| arm: | TODO |
+|   arm64: |  ok  |
+|blackfin: | TODO |
+| c6x: | TODO |
+|cris: | TODO |
+| frv: | TODO |
+|   h8300: | TODO |
+| hexagon: | TODO |
+|ia64: | TODO |
+|m32r: | TODO |
+|m68k: | TODO |
+|   metag: | TODO |
+|  microblaze: | TODO |
+|mips: | TODO |
+| mn10300: | TODO |
+|   nios2: | TODO |
+|openrisc: | TODO |
+|  parisc: | TODO |
+| powerpc: | TODO |
+|s390: | TODO |
+|   score: | TODO |
+|  sh: | TODO |
+|   sparc: | TODO |
+|tile: | TODO |
+|  um: | TODO |
+|   unicore32: | TODO |
+| x86: |  ok  |
+|  xtensa: | TODO |
+---
diff --git a/kernel/panic.c b/kernel/panic.c
index 2cfef408fec9..9fb023d0cae1 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -289,7 +289,7 @@ void panic(const char *fmt, ...)
disabled_wait(caller);
}
 #endif
-   pr_emerg("---[ end Kernel panic - not syncing: %s\n", buf);
+   pr_emerg("---[ end Kernel panic - not syncing: %s ]---\n", buf);
local_irq_enable();
for (i = 0; ; i += PANIC_TIMER_STEP) {
touch_softlockup_watchdog();


Re: [PATCH 05/45] C++: Set compilation as C++ for .c files

2018-04-01 Thread kbuild test robot
Hi David,

I love your patch! Yet something to improve:

[auto build test ERROR on v4.16-rc7]
[cannot apply to linus/master tip/x86/core tip/locking/core v4.16 next-20180329]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/David-Howells/C-Convert-the-kernel-to-C/20180402-120344
config: x86_64-randconfig-x014-201813 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

   scripts/Makefile.kasan:17: Cannot use CONFIG_KASAN: 
-fsanitize=kernel-address is not supported by compiler
   cc1: warning: command line option '-fno-rtti' is valid for C++/ObjC++ but 
not for C
   cc1: warning: command line option '-fpermissive' is valid for C++/ObjC++ but 
not for C
   In file included from include/linux/page-flags.h:9:0,
from kernel/bounds.c:10:
>> include/linux/types.h:6:2: error: #error not c++
#error not c++
 ^
   make[2]: *** [kernel/bounds.s] Error 1
   make[2]: Target '__build' not remade because of errors.
   make[1]: *** [prepare0] Error 2
   make[1]: Target 'prepare' not remade because of errors.
   make: *** [sub-make] Error 2

vim +6 include/linux/types.h

 4  
 5  #ifndef __cplusplus
   > 6  #error not c++
 7  #endif
 8  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [PATCH v5 10/13] ARM: dts: ipq4019: Add qcom-ipq4019-ap.dk07.1-c2 board file

2018-04-01 Thread Sricharan R
Hi Bjorn,

On 3/27/2018 10:59 PM, Bjorn Andersson wrote:
> On Fri 23 Mar 03:18 PDT 2018, Sricharan R wrote:
> 
>> Reviewed-by: Abhishek Sahu 
>> Signed-off-by: Sricharan R 
>> ---
>>  arch/arm/boot/dts/Makefile  |  1 +
>>  arch/arm/boot/dts/qcom-ipq4019-ap.dk07.1-c2.dts | 26 
>> +
>>  2 files changed, 27 insertions(+)
>>  create mode 100644 arch/arm/boot/dts/qcom-ipq4019-ap.dk07.1-c2.dts
>>
>> diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
>> index ae7f214..3b65e30 100644
>> --- a/arch/arm/boot/dts/Makefile
>> +++ b/arch/arm/boot/dts/Makefile
>> @@ -750,6 +750,7 @@ dtb-$(CONFIG_ARCH_QCOM) += \
>>  qcom-ipq4019-ap.dk04.1-c1.dtb \
>>  qcom-ipq4019-ap.dk04.1-c3.dtb \
>>  qcom-ipq4019-ap.dk07.1-c1.dtb \
>> +qcom-ipq4019-ap.dk07.1-c2.dtb \
>>  qcom-ipq8064-ap148.dtb \
>>  qcom-msm8660-surf.dtb \
>>  qcom-msm8960-cdp.dtb \
>> diff --git a/arch/arm/boot/dts/qcom-ipq4019-ap.dk07.1-c2.dts 
>> b/arch/arm/boot/dts/qcom-ipq4019-ap.dk07.1-c2.dts
>> new file mode 100644
>> index 000..c1e909c
>> --- /dev/null
>> +++ b/arch/arm/boot/dts/qcom-ipq4019-ap.dk07.1-c2.dts
>> @@ -0,0 +1,26 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +// Copyright (c) 2018, The Linux Foundation. All rights reserved.
>> +
>> +#include "qcom-ipq4019-ap.dk07.1.dtsi"
>> +
>> +/ {
>> +model = "Qualcomm Technologies, Inc. IPQ4019/AP-DK07.1-C2";
> 
> compatible
> 

 ok.

> Apart from that you have my
> 
> Acked-by: Bjorn Andersson 
> 

 Thanks.

Regards,
 Sricharan

-- 
"QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of 
Code Aurora Forum, hosted by The Linux Foundation


Re: [PATCH 05/45] C++: Set compilation as C++ for .c files

2018-04-01 Thread kbuild test robot
Hi David,

I love your patch! Yet something to improve:

[auto build test ERROR on v4.16-rc7]
[cannot apply to linus/master tip/x86/core tip/locking/core v4.16 next-20180329]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/David-Howells/C-Convert-the-kernel-to-C/20180402-120344
config: i386-randconfig-x073-201813 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All error/warnings (new ones prefixed by >>):

   CONFIG_CC_STACKPROTECTOR_AUTO: Compiler does not support any known 
stack-protector
>> cc1: warning: command line option '-fno-rtti' is valid for C++/ObjC++ but 
>> not for C
>> cc1: warning: command line option '-fpermissive' is valid for C++/ObjC++ but 
>> not for C
>> cc1: error: CPU you selected does not support x86-64 instruction set
   make[2]: *** [kernel/bounds.s] Error 1
   make[2]: Target '__build' not remade because of errors.
   make[1]: *** [prepare0] Error 2
   make[1]: Target 'prepare' not remade because of errors.
   make: *** [sub-make] Error 2

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [PATCH 06/45] C++: Do some basic C++ type definition

2018-04-01 Thread kbuild test robot
Hi David,

I love your patch! Yet something to improve:

[auto build test ERROR on v4.16-rc7]
[cannot apply to linus/master tip/x86/core tip/locking/core v4.16 next-20180329]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/David-Howells/C-Convert-the-kernel-to-C/20180402-120344
config: x86_64-randconfig-x006-201813 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

^~~~
   include/linux/types.h:115:17: error: storage class specified for parameter 
'u_int64_t'
typedef  __u64  u_int64_t;
^
   include/linux/types.h:116:17: error: storage class specified for parameter 
'int64_t'
typedef  __s64  int64_t;
^~~
   include/linux/types.h:136:23: error: storage class specified for parameter 
'sector_t'
typedef unsigned long sector_t;
  ^~~~
   include/linux/types.h:137:23: error: storage class specified for parameter 
'blkcnt_t'
typedef unsigned long blkcnt_t;
  ^~~~
   include/linux/types.h:155:13: error: storage class specified for parameter 
'dma_addr_t'
typedef u64 dma_addr_t;
^~
   include/linux/types.h:160:28: error: storage class specified for parameter 
'gfp_t'
typedef unsigned __bitwise gfp_t;
   ^
   include/linux/types.h:161:28: error: storage class specified for parameter 
'slab_flags_t'
typedef unsigned __bitwise slab_flags_t;
   ^~~~
   include/linux/types.h:162:28: error: storage class specified for parameter 
'fmode_t'
typedef unsigned __bitwise fmode_t;
   ^~~
   include/linux/types.h:165:13: error: storage class specified for parameter 
'phys_addr_t'
typedef u64 phys_addr_t;
^~~
   include/linux/types.h:170:21: error: expected '=', ',', ';', 'asm' or 
'__attribute__' before 'resource_size_t'
typedef phys_addr_t resource_size_t;
^~~
   include/linux/types.h:176:23: error: storage class specified for parameter 
'irq_hw_number_t'
typedef unsigned long irq_hw_number_t;
  ^~~
   include/linux/types.h:180:3: error: storage class specified for parameter 
'atomic_t'
} atomic_t;
  ^~~~
   include/linux/types.h:185:3: error: storage class specified for parameter 
'atomic64_t'
} atomic64_t;
  ^~
   include/linux/types.h:188:1: warning: empty declaration
struct list_head {
^~
   include/linux/types.h:192:1: warning: empty declaration
struct hlist_head {
^~
   include/linux/types.h:196:1: warning: empty declaration
struct hlist_node {
^~
   include/linux/types.h:201:2: error: expected specifier-qualifier-list before 
'__kernel_daddr_t'
 __kernel_daddr_t f_tfree;
 ^~~~
   include/linux/types.h:200:1: warning: empty declaration
struct ustat {
^~
   include/linux/types.h:226:1: warning: empty declaration
struct callback_head {
^~
   include/linux/types.h:232:16: error: storage class specified for parameter 
'rcu_callback_t'
typedef void (*rcu_callback_t)(struct rcu_head *head);
   ^~
   include/linux/types.h:233:56: error: expected declaration specifiers or 
'...' before 'rcu_callback_t'
typedef void (*call_rcu_func_t)(struct rcu_head *head, rcu_callback_t func);
   ^~
   In file included from include/asm-generic/bug.h:5:0,
from arch/x86/include/asm/bug.h:83,
from include/linux/bug.h:5,
from include/linux/page-flags.h:10,
from kernel/bounds.c:10:
   include/linux/compiler.h:187:1: error: expected '=', ',', ';', 'asm' or 
'__attribute__' before '{' token
{
^
   include/linux/compiler.h:205:1: error: expected '=', ',', ';', 'asm' or 
'__attribute__' before '{' token
{
^
   include/linux/compiler.h:210:1: error: expected '=', ',', ';', 'asm' or 
'__attribute__' before '{' token
{
^
   In file included from arch/x86/include/asm/barrier.h:5:0,
from include/linux/compiler.h:245,
from include/asm-generic/bug.h:5,
from arch/x86/include/asm/bug.h:83,
from include/linux/bug.h:5,
from include/linux/page-flags.h:10,
from kernel/bounds.c:10:
   arch/x86/include/asm/alternative.h:48:1: warning: empty declaration
struct alt_instr {
^~
   arch/x86/include/asm/alternative.h:61:12: error: storage class specified for 
parameter 'alternatives_patched'
extern int

Re: [PATCH 41/45] C++: Cast in bitops

2018-04-01 Thread kbuild test robot
Hi David,

I love your patch! Yet something to improve:

[auto build test ERROR on v4.16-rc7]
[cannot apply to linus/master tip/x86/core tip/locking/core v4.16 next-20180329]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/David-Howells/C-Convert-the-kernel-to-C/20180402-120344
config: x86_64-randconfig-x016-201813 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

   include/linux/printk.h:183:12: error: storage class specified for parameter 
'__printk_ratelimit'
extern int __printk_ratelimit(const char *func);
   ^~
   include/linux/printk.h:185:8: error: unknown type name 'bool'
extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
   ^~~~
   include/linux/printk.h:185:13: error: storage class specified for parameter 
'printk_timed_ratelimit'
extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
^~
   include/linux/printk.h:188:12: error: storage class specified for parameter 
'printk_delay_msec'
extern int printk_delay_msec;
   ^
   include/linux/printk.h:189:12: error: storage class specified for parameter 
'dmesg_restrict'
extern int dmesg_restrict;
   ^~
   include/linux/printk.h:193:6: error: expected declaration specifiers or 
'...' before 'size_t'
 size_t *lenp, loff_t *ppos);
 ^~
   include/linux/printk.h:193:20: error: unknown type name 'loff_t'; did you 
mean 'pgoff_t'?
 size_t *lenp, loff_t *ppos);
   ^~
   pgoff_t
   include/linux/printk.h:195:13: error: storage class specified for parameter 
'wake_up_klogd'
extern void wake_up_klogd(void);
^
   include/linux/printk.h:200:13: error: section attribute not allowed for 
'setup_log_buf'
void __init setup_log_buf(int early);
^
   include/linux/printk.h:200:1: warning: '__cold__' attribute ignored 
[-Wattributes]
void __init setup_log_buf(int early);
^~~~
   In file included from include/linux/compiler_types.h:58:0,
from include/linux/kconfig.h:74,
from :0:
   include/linux/compiler-gcc.h:130:25: error: expected declaration specifiers 
before '__attribute__'
#define __printf(a, b)  __attribute__((format(printf, a, b)))
^
   include/linux/printk.h:201:1: note: in expansion of macro '__printf'
__printf(1, 2) void dump_stack_set_arch_desc(const char *fmt, ...);
^~~~
   In file included from include/linux/kernel.h:15:0,
from include/asm-generic/bug.h:18,
from arch/x86/include/asm/bug.h:83,
from include/linux/bug.h:5,
from include/linux/page-flags.h:10,
from kernel/bounds.c:10:
   include/linux/printk.h:204:13: error: storage class specified for parameter 
'printk_safe_init'
extern void printk_safe_init(void);
^~~~
   include/linux/printk.h:205:13: error: storage class specified for parameter 
'printk_safe_flush'
extern void printk_safe_flush(void);
^
   include/linux/printk.h:206:13: error: storage class specified for parameter 
'printk_safe_flush_on_panic'
extern void printk_safe_flush_on_panic(void);
^~
   include/linux/printk.h:280:12: error: storage class specified for parameter 
'kptr_restrict'
extern int kptr_restrict;
   ^
   include/linux/printk.h:282:1: warning: '__cold__' attribute ignored 
[-Wattributes]
asmlinkage void dump_stack(void) __cold;
^~
   include/linux/printk.h:474:37: error: storage class specified for parameter 
'kmsg_fops'
extern const struct file_operations kmsg_fops;
^
   include/linux/printk.h:476:1: warning: empty declaration
enum {
^~~~
   include/linux/printk.h:481:48: error: expected declaration specifiers or 
'...' before 'size_t'
extern int hex_dump_to_buffer(const void *buf, size_t len, int rowsize,
   ^~
   include/linux/printk.h:482:40: error: expected declaration specifiers or 
'...' before 'size_t'
 int groupsize, char *linebuf, size_t linebuflen,
   ^~
   include/linux/printk.h:483:10: error: unknown type name 'bool'; did you mean 
'_Bool'?
 bool ascii);
 ^~~~
 _Bool
   include/linux/printk.h:487:24: error: expected declaration specifiers or 
'...' before 'size_t'
  const void *buf, size_t len, bool ascii);
   

Re: [PATCH v5 09/13] ARM: dts: ipq4019: Add qcom-ipq4019-ap.dk07.1-c1 board file

2018-04-01 Thread Sricharan R


On 3/27/2018 10:52 PM, Bjorn Andersson wrote:
> On Fri 23 Mar 03:18 PDT 2018, Sricharan R wrote:
>> +#include "qcom-ipq4019-ap.dk07.1.dtsi"
>> +
>> +/ {
>> +model = "Qualcomm Technologies, Inc. IPQ4019/AP-DK07.1-C1";
> 
> Add compatible for the board.
> 

 ok.

Regards,
 Sricharan

-- 
"QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of 
Code Aurora Forum, hosted by The Linux Foundation


Re: [PATCH v5 08/13] ARM: dts: ipq4019: Add ipq4019-ap.dk07.1 common data

2018-04-01 Thread Sricharan R


On 3/27/2018 10:50 PM, Bjorn Andersson wrote:
> On Fri 23 Mar 03:18 PDT 2018, Sricharan R wrote:
>> +#include "qcom-ipq4019.dtsi"
>> +#include 
>> +#include 
>> +
>> +/ {
>> +model = "Qualcomm Technologies, Inc. IPQ4019/AP-DK07.1";
>> +compatible = "qcom,ipq4019";
> 
> The board should set these, so you shouldn't need to specify them here.
> And you should be able to find a more specific compatible for the board.
> 

 ok. agree. As mentioned earlier, will correct the compatible in all boards.

>> +
> [..]
>> +qpic-nand@79b {
>> +status = "ok";
> 
> No pinmux for the qpic on these boards?
> 
 clearly missed it and was lucky that bootloader was doing it in this case.
 Will add it.

Regards,
 Sricharan

-- 
"QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of 
Code Aurora Forum, hosted by The Linux Foundation


Re: [PATCH 0/1] cover-letter/lz4: Implement lz4 with dynamic offset length.

2018-04-01 Thread Maninder Singh

 Hello,

>> (Added cover letter to avoid much text in patch description)
>> 
>> LZ4 specification defines 2 byte offset length for 64 KB data.
>> But in case of ZRAM we compress data per page and in most of
>> architecture PAGE_SIZE is 4KB. So we can decide offset length based
>> on actual offset value. For this we can reserve 1 bit to decide offset
>> length (1 byte or 2 byte). 2 byte required only if ofsset is greater than 
>> 127,
>> else 1 byte is enough.
> 
>So what happens if I compress the data on a system with no dyn
>offset and then send it over the network to a machine which has
>dyn offset? Or, say, I have a USB stick with a compression enabled
>FS, store files on a dyn offset enabled PC and then mount that USB
>stick on a machine with no dyn offset support. And vice versa.


lz4_dyn is not an extension of LZ4 so there is no backward compatibility.
Consider this as a different algorithm adapted from LZ4 for better compression 
ratio.

Thanks
Maninder Singh


Re: 答复: Re: [PATCH v2] scsi: Introduce sdev_printk_ratelimited to throttlefrequent printk

2018-04-01 Thread Jason Yan



On 2018/4/2 13:29, Sergey Senozhatsky wrote:

On (04/02/18 13:14), wen.yan...@zte.com.cn wrote:


> It's true that this print for the same device is useless. But it's
> useful for different devices. Is it possible to limit the print only
> for the same device?

In our scene, it's  just for the same device (q->queuedata), Thanks.


Yes, what Jason meant was that rate limit struct is shared by different call
sites - including scsi_request_fn() from different devices.

If device1->scsi_request_fn()->sdev_printk_ratelimited() causes printk rate
limit, then messages from device2->scsi_request_fn()->sdev_printk_ratelimited()
may be lost entirely, unless you have enough of them.

-ss



Yes, that's exactly what I mean.

Thanks,

Jason


.





Re: [PATCH v5 07/13] ARM: dts: ipq4019: Add qcom-ipq4019-ap.dk04.1-c3 board file

2018-04-01 Thread Sricharan R


On 3/27/2018 10:44 PM, Bjorn Andersson wrote:
> On Fri 23 Mar 03:18 PDT 2018, Sricharan R wrote:
>> +#include "qcom-ipq4019-ap.dk04.1.dtsi"
>> +
>> +/ {
>> +model = "Qualcomm Technologies, Inc. IPQ4019/AP-DK04.1-C3";
> 
> Add a compatible to the board file.
> 

 ok.

> Also, things like alias would make sense to put in the board unless
> there's some restriction making every board having the same layout.
> 
>> +};

 hmm. i also thought of having them in board specific files initially.
 In this case, at-least the aliases for serial nodes seems to match across
 dk-01/04/07 base variants. But might be if we add something else in future
 it might not be common. Yeah, would move it to board specific files.

Regards,
 Sricharan

-- 
"QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of 
Code Aurora Forum, hosted by The Linux Foundation


Re: [PATCH 1/1] lz4: Implement lz4 with dynamic offset length.

2018-04-01 Thread Maninder Singh
Hi,

>> diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c
>> index 4ed0a78..5bc5aab 100644
>> --- a/drivers/block/zram/zcomp.c
>> +++ b/drivers/block/zram/zcomp.c
>> @@ -17,11 +17,15 @@
>>  #include 
>>  
>>  #include "zcomp.h"
>> +#define KB(1 << 10)
>>  
>>  static const char * const backends[] = {
>>  "lzo",
>>  #if IS_ENABLED(CONFIG_CRYPTO_LZ4)
>>  "lz4",
>> +#if (PAGE_SIZE < (32 * KB))
>> +"lz4_dyn",
>> +#endif
> 
>This is not the list of supported algorithms. It's the list of
>recommended algorithms. You can configure zram to use any of
>available and known to Crypto API algorithms. Including lz4_dyn
>on PAGE_SIZE > 32K systems.
> 
>-ss
 
Yes, we want to integrate new compression(lz4_dyn) for ZRAM 
only if PAGE_SIZE is less than 32KB to get maximum benefit. 
so we added lz4_dyn to available list of ZRAM compression alhorithms.

Thanks,
Manider Singh


Re: 答复: Re: [PATCH v2] scsi: Introduce sdev_printk_ratelimited to throttlefrequent printk

2018-04-01 Thread Jason Yan



On 2018/4/2 13:14, wen.yan...@zte.com.cn wrote:

Hello,

 > It's true that this print for the same device is useless. But it's

 > useful for different devices. Is it possible to limit the print only

 > for the same device?


In our scene, it's  just for the same device (q->queuedata), Thanks.



I mean the print limit you add will affect all devices. One device's 
print *may* cause another device's print limited even if it only printed 
one message.




[GIT PULL] Andes(nds32) Port for Linux 4.17

2018-04-01 Thread Greentime Hu
The following changes since commit 7928b2cbe55b2a410a0f5c1f154610059c57b1b2:

  Linux 4.16-rc1 (2018-02-11 15:04:29 -0800)

are available in the Git repository at:

  ssh://g...@gitolite.kernel.org/pub/scm/linux/kernel/git/greentime/linux.git 
tags/nds32-for-linus-4.17

for you to fetch changes up to 6fc61ee69433e7e0433cabd36f78bb5fb3b26524:

  nds32: To use the generic dump_stack() (2018-03-16 15:45:23 +0800)


This tag contains the core nds32 Linux port(including interrupt controller
driver and timer driver), which has been through 7 rounds of review on mailing
list.

It is able to boot to shell and passes most LTP-2017 testsuites in nds32 AE3XX
platform.
Total Tests: 1901
Total Skipped Tests: 618
Total Failures: 78

Copied below is the ChangeLog that contains the history of this patch set:
Changes in v7:
 - Update cpu binding document to add "andestech,nds32v3" as fallback
 - Remove unnecessary configs of arch/nds32/Kconfig
 - Use GENERIC_CALIBRATE_DELAY
 - Add more help texts for minimum CPU type config
 - Update defconfig because of Kconfig changed and bug fixed
 - Move early_trap_init() declaration to nds32.h
 - Refine dma.c
 - Remove apply_relocate() in module.c and include  to 
catch it
 - Add do_kernel_restart() in machine_restart()
 - Clean up setup.c to remove CONFIG_VGA_CONSOLE and some extern declaration 
functions
 - Add negative dependency for VGA_CONSOLE on nds32
 - Refine ptrace.c and arch/nds32/include/asm/ptrace.h
 - Refine syscall restart flow and arch/nds32/kernel/signal.c
 - Fix a bug in VDSO
 - Remove the handling for kernel code unaligned accessing
 - Add a description for unaligned access handling in git commit message.
 - Rebase to v4.16-rc1
 - Replace ACCESS_ONCE with READ_ONCE
 - Replace atomic_long_dec(&mm->nr_ptes) with mm_dec_nr_ptes(mm)
 - Remove print_symbol(%s) with printk(%pS)
 - Add bpf_perf_event.h
 - Remove init_stack and init_thread_info

Changes in v6:
 - Refine naming for atl2c
 - Refine ae3xx.dts
 - Remove CONFIG_TIMER_ATCPIT100 in defconfig
 - Refine elf.h
 - Fix a vdso bug
 - Separate arch patchset and timer patchset
 - To select TIMER_OF in drivers/clocksource/Kconfig instead of 
arch/nds32/Kconfig

Changes in v5:
 - Remove __NR__llseek  and sys_mmap()
 - Add a comment to explain that we don't have clocksource cycle counter in the 
CPU
 - Add volatile in iounmap()
 - Fix typo Featuretures to Features
 - Replace CPU_CACHE_NONALIASING with !CPU_CACHE_ALIASING
 - Fix a endian bug when we try to get val = 
of_get_property(cpu,"clock-frequency", NULL)
 - Add screen_info to fix the building error when CONFIG_ VGA_CONSOLE is enabled
 - Remove unnecessary msync()
 - Add depends on !64BIT || BROKEN for faraday Kconfig because the descriptor 
only supports 32bit
 - Add atl2c binding document
 - Remove unnecessary include headers
 - Fix a vector table bug. It placed wrong vector handlers for 2 exceptions.
 - Fix a vdso bug. It may encounter TLB multi-hit exception because we 
accidently set it as a global page.
 - Add proper isb and barrier after some cache operations
 - Fix a bug in system call restart flow. $r0 ~ $r5 does not be recovered 
before restarting system call
 - Fix the build errors for OpenRISC and SPARC because io.h changed.
 - Update ae3xx.dts to support atl2c.

Changes in v4:
 - Add atcpit100 timer driver due to it include vdso implementations and sent
   them together with nds32 may help reviewer to review.
 - Update ae3xx.dts for atcpit100 clock setting and remove vdso settings.
 - To get cycle counter register by timer driver instead of dts.
 - Use "depends on NDS32 || COMPILE_TEST" in atcpit100 driver because it is 
needed for nds32 vdso
 - Update defconfig becasue kconfig rename from CONFIG_CLKSRC_ATCPIT100 to 
CONFIG_TIMER_ATCPIT100
 - Remove ag101p.dts because we are not yet ready for ag101p platform.
 - Update copyright style to SPDX-License-Identifier
 - Include  instead of 
 - Add local_irq_save()/local_irq_restore() to protect SR_TLB_VPN in 
update_mmu_cache().
 - Update cpu_dcache_inval_all implementation to make sure all level cache are 
writeback.

Changes in v3:
 - Use arch's io.h instead of generic one
 - Add andestech-boards binding document
 - Update nds32/cpus.txt binding document
 - Remove atcpit100 timer drivers
 - Select NO_BOOTMEM and delete HAVE_MEMBLOCK_NODE_MAP
 - make CPU_BIG_ENDIAN and CPU_LITTLE_ENDIAN are dependent
 - Add cpu type to select HWZOL/CPU_CACHE_ALIASING
 - Change CPU_CACHE_NONALIASING to CPU_CACHE_ALIASING
 - Remove bootarg from device tree script
 - Update ag101p.dts and ae3xx.dts for correct board name.
 - Clear and simplify defconfig
 - Implement L2C_R_REG/ L2C_W_REG with readl/writel instead of 
__raw_readl/__raw_writel for endian save
 - Remove early_init_dt_add_memory_arch/early_init_dt_alloc_memory_arch to use 
the generic ones
 - Refine devicetree.c
 - Fix bug https://lkml.kernel.org/r/1499782590-31366-1-git-send-ema...
 - Refine irqchip/irq-ati

general protection fault in tipc_nametbl_unsubscribe

2018-04-01 Thread syzbot

Hello,

syzbot hit the following crash on upstream commit
10b84daddbec72c6b440216a69de9a9605127f7a (Sat Mar 31 17:59:00 2018 +)
Merge branch 'perf-urgent-for-linus' of  
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
syzbot dashboard link:  
https://syzkaller.appspot.com/bug?extid=4859fe19555ea87c42f3


So far this crash happened 3 times on upstream.
C reproducer: https://syzkaller.appspot.com/x/repro.c?id=4775372465897472
syzkaller reproducer:  
https://syzkaller.appspot.com/x/repro.syz?id=4868734988582912
Raw console output:  
https://syzkaller.appspot.com/x/log.txt?id=507380209544
Kernel config:  
https://syzkaller.appspot.com/x/.config?id=-2760467897697295172

compiler: gcc (GCC) 7.1.1 20170620

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+4859fe19555ea87c4...@syzkaller.appspotmail.com
It will help syzbot understand when the bug is fixed. See footer for  
details.

If you forward the report, please keep this part and the footer.

R13:  R14:  R15: 
Name sequence creation failed, no memory
Failed to create subscription for {24576,0,4294967295}
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault:  [#1] SMP KASAN
Dumping ftrace buffer:
   (ftrace buffer empty)
Modules linked in:
CPU: 1 PID: 4447 Comm: syzkaller851181 Not tainted 4.16.0-rc7+ #374
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

RIP: 0010:__list_del_entry_valid+0x7e/0x150 lib/list_debug.c:51
RSP: 0018:8801ae1aef48 EFLAGS: 00010246
RAX: dc00 RBX:  RCX: 
RDX:  RSI: 8801cf54c760 RDI: 8801cf54c768
RBP: 8801ae1aef60 R08: 110035c35cff R09: 89956150
R10: 8801ae1aee28 R11: 168a R12: 87745ea0
R13: 8801ae1af100 R14: 8801cf54c760 R15: 8801cf4c8cc0
FS:  () GS:8801db10() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 55dce15c3090 CR3: 0846a002 CR4: 001606e0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
Call Trace:
 __list_del_entry include/linux/list.h:117 [inline]
 list_del_init include/linux/list.h:159 [inline]
 tipc_nametbl_unsubscribe+0x318/0x990 net/tipc/name_table.c:848
 tipc_subscrb_subscrp_delete+0x1e9/0x460 net/tipc/subscr.c:212
 tipc_subscrb_delete net/tipc/subscr.c:242 [inline]
 tipc_subscrb_release_cb+0x17/0x30 net/tipc/subscr.c:321
 tipc_topsrv_kern_unsubscr+0x2c3/0x430 net/tipc/server.c:535
 tipc_group_delete+0x2c0/0x3d0 net/tipc/group.c:231
 tipc_sk_leave+0x10b/0x200 net/tipc/socket.c:2795
 tipc_release+0x154/0xff0 net/tipc/socket.c:577
 sock_release+0x8d/0x1e0 net/socket.c:595
 sock_close+0x16/0x20 net/socket.c:1149
 __fput+0x327/0x7e0 fs/file_table.c:209
 fput+0x15/0x20 fs/file_table.c:243
 task_work_run+0x199/0x270 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0x9bb/0x1ad0 kernel/exit.c:865
 do_group_exit+0x149/0x400 kernel/exit.c:968
 SYSC_exit_group kernel/exit.c:979 [inline]
 SyS_exit_group+0x1d/0x20 kernel/exit.c:977
 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x43f228
RSP: 002b:7ffde31217e8 EFLAGS: 0246 ORIG_RAX: 00e7
RAX: ffda RBX:  RCX: 0043f228
RDX:  RSI: 003c RDI: 
RBP: 004bf308 R08: 00e7 R09: ffd0
R10: 204ee000 R11: 0246 R12: 0001
R13: 006d1180 R14:  R15: 
Code: 00 00 00 00 ad de 49 39 c4 74 66 48 b8 00 02 00 00 00 00 ad de 48 89  
da 48 39 c3 74 65 48 c1 ea 03 48 b8 00 00 00 00 00 fc ff df <80> 3c 02 00  
75 7b 48 8b 13 48 39 f2 75 57 49 8d 7c 24 08 48 b8
RIP: __list_del_entry_valid+0x7e/0x150 lib/list_debug.c:51 RSP:  
8801ae1aef48

---[ end trace ba18c1598e2d5535 ]---


---
This bug is generated by a dumb bot. It may contain errors.
See https://goo.gl/tpsmEJ for details.
Direct all questions to syzkal...@googlegroups.com.

syzbot will keep track of this bug report.
If you forgot to add the Reported-by tag, once the fix for this bug is  
merged

into any tree, please reply to this email with:
#syz fix: exact-commit-title
If you want to test a patch for this bug, please reply with:
#syz test: git://repo/address.git branch
and provide the patch inline or as an attachment.
To mark this as a duplicate of another syzbot report, please reply with:
#syz dup: exact-subject-of-another-report
If it's a one-off invalid bug report, please reply with:
#syz invalid
Note: if the crash happens again, it will cause creation of a new bug  
report.

Note: all commands must start from beginning of the line in the em

KASAN: stack-out-of-bounds Read in xfrm_state_find (5)

2018-04-01 Thread syzbot

Hello,

syzbot hit the following crash on upstream commit
10b84daddbec72c6b440216a69de9a9605127f7a (Sat Mar 31 17:59:00 2018 +)
Merge branch 'perf-urgent-for-linus' of  
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
syzbot dashboard link:  
https://syzkaller.appspot.com/bug?extid=d90468452f685a0b28eb


So far this crash happened 4 times on net-next, upstream.
C reproducer: https://syzkaller.appspot.com/x/repro.c?id=6686969799114752
syzkaller reproducer:  
https://syzkaller.appspot.com/x/repro.syz?id=5121263362113536
Raw console output:  
https://syzkaller.appspot.com/x/log.txt?id=5897355362566144
Kernel config:  
https://syzkaller.appspot.com/x/.config?id=-2760467897697295172

compiler: gcc (GCC) 7.1.1 20170620

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+d90468452f685a0b2...@syzkaller.appspotmail.com
It will help syzbot understand when the bug is fixed. See footer for  
details.

If you forward the report, please keep this part and the footer.

==
BUG: KASAN: stack-out-of-bounds in xfrm_state_find+0x30de/0x3210  
net/xfrm/xfrm_state.c:1051

Read of size 4 at addr 8801b25ef480 by task syzkaller538986/4480

CPU: 0 PID: 4480 Comm: syzkaller538986 Not tainted 4.16.0-rc7+ #9
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x194/0x24d lib/dump_stack.c:53
 print_address_description+0x73/0x250 mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report+0x23c/0x360 mm/kasan/report.c:412
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:432
 xfrm_state_find+0x30de/0x3210 net/xfrm/xfrm_state.c:1051
 xfrm_tmpl_resolve_one net/xfrm/xfrm_policy.c:1393 [inline]
 xfrm_tmpl_resolve+0x2ee/0xc40 net/xfrm/xfrm_policy.c:1437
 xfrm_resolve_and_create_bundle+0x184/0x28d0 net/xfrm/xfrm_policy.c:1833
 xfrm_lookup+0xfcb/0x25c0 net/xfrm/xfrm_policy.c:2163
 xfrm_lookup_route+0x39/0x1a0 net/xfrm/xfrm_policy.c:2283
 ip_route_output_flow+0x7c/0xa0 net/ipv4/route.c:2583
 udp_sendmsg+0x19bd/0x2f70 net/ipv4/udp.c:1012
 udpv6_sendmsg+0x757/0x3400 net/ipv6/udp.c:1156
 inet_sendmsg+0x11f/0x5e0 net/ipv4/af_inet.c:764
 sock_sendmsg_nosec net/socket.c:630 [inline]
 sock_sendmsg+0xca/0x110 net/socket.c:640
 ___sys_sendmsg+0x767/0x8b0 net/socket.c:2046
 __sys_sendmsg+0xe5/0x210 net/socket.c:2080
 SYSC_sendmsg net/socket.c:2091 [inline]
 SyS_sendmsg+0x2d/0x50 net/socket.c:2087
 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x440139
RSP: 002b:7fffa14c36e8 EFLAGS: 0217 ORIG_RAX: 002e
RAX: ffda RBX: 004002c8 RCX: 00440139
RDX:  RSI: 2580 RDI: 0003
RBP: 006ca018 R08: 004002c8 R09: 004002c8
R10: 00e8 R11: 0217 R12: 00401a60
R13: 00401af0 R14:  R15: 

The buggy address belongs to the page:
page:ea0006c97bc0 count:0 mapcount:0 mapping: index:0x0
flags: 0x2fffc00()
raw: 02fffc00   
raw:  ea0006c90101  
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 8801b25ef380: f2 00 f2 f2 f2 f2 f2 f2 f2 f8 f2 f2 f2 f2 f2 f2
 8801b25ef400: f2 00 00 00 00 f2 f2 f2 f2 00 00 00 00 00 00 00

8801b25ef480: f2 f2 f2 f2 f2 00 00 00 00 00 00 00 00 00 f2 f2

   ^
 8801b25ef500: f2 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 8801b25ef580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1
==


---
This bug is generated by a dumb bot. It may contain errors.
See https://goo.gl/tpsmEJ for details.
Direct all questions to syzkal...@googlegroups.com.

syzbot will keep track of this bug report.
If you forgot to add the Reported-by tag, once the fix for this bug is  
merged

into any tree, please reply to this email with:
#syz fix: exact-commit-title
If you want to test a patch for this bug, please reply with:
#syz test: git://repo/address.git branch
and provide the patch inline or as an attachment.
To mark this as a duplicate of another syzbot report, please reply with:
#syz dup: exact-subject-of-another-report
If it's a one-off invalid bug report, please reply with:
#syz invalid
Note: if the crash happens again, it will cause creation of a new bug  
report.

Note: all commands must start from beginning of the line in the email body.


WARNING in add_uevent_var

2018-04-01 Thread syzbot

Hello,

syzbot hit the following crash on upstream commit
10b84daddbec72c6b440216a69de9a9605127f7a (Sat Mar 31 17:59:00 2018 +)
Merge branch 'perf-urgent-for-linus' of  
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
syzbot dashboard link:  
https://syzkaller.appspot.com/bug?extid=230d9e642a85d3fec29c


So far this crash happened 5 times on net-next, upstream.
C reproducer: https://syzkaller.appspot.com/x/repro.c?id=6614377067184128
syzkaller reproducer:  
https://syzkaller.appspot.com/x/repro.syz?id=6535492073947136
Raw console output:  
https://syzkaller.appspot.com/x/log.txt?id=6339348970602496
Kernel config:  
https://syzkaller.appspot.com/x/.config?id=-2760467897697295172

compiler: gcc (GCC) 7.1.1 20170620

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+230d9e642a85d3fec...@syzkaller.appspotmail.com
It will help syzbot understand when the bug is fixed. See footer for  
details.

If you forward the report, please keep this part and the footer.

[ cut here ]
add_uevent_var: buffer size too small
WARNING: CPU: 0 PID: 4431 at lib/kobject_uevent.c:594  
add_uevent_var+0x2aa/0x2d0 lib/kobject_uevent.c:594

Kernel panic - not syncing: panic_on_warn set ...

CPU: 0 PID: 4431 Comm: syzkaller678536 Not tainted 4.16.0-rc7+ #374
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x194/0x24d lib/dump_stack.c:53
 panic+0x1e4/0x41c kernel/panic.c:183
 __warn+0x1dc/0x200 kernel/panic.c:547
 report_bug+0x1f4/0x2b0 lib/bug.c:186
 fixup_bug.part.10+0x37/0x80 arch/x86/kernel/traps.c:178
 fixup_bug arch/x86/kernel/traps.c:247 [inline]
 do_error_trap+0x2d7/0x3e0 arch/x86/kernel/traps.c:296
 do_invalid_op+0x1b/0x20 arch/x86/kernel/traps.c:315
 invalid_op+0x1b/0x40 arch/x86/entry/entry_64.S:986
RIP: 0010:add_uevent_var+0x2aa/0x2d0 lib/kobject_uevent.c:594
RSP: 0018:8801adba6810 EFLAGS: 00010286
RAX: dc08 RBX: 8801ad7a6d40 RCX: 815b193e
RDX:  RSI: 110035b74cb2 RDI: 110035b74c87
RBP: 8801adba68d8 R08: 110035b74c49 R09: 
R10: 0002 R11:  R12: 110035b74d03
R13: 8801ad7a6e58 R14: 03e6 R15: 0438
 rfkill_dev_uevent+0x31/0x170 net/rfkill/core.c:813
 dev_uevent+0x2b6/0x7e0 drivers/base/core.c:913
 kobject_uevent_env+0x3fe/0xd30 lib/kobject_uevent.c:476
 kobject_uevent+0x1f/0x30 lib/kobject_uevent.c:565
 device_add+0xd04/0x1650 drivers/base/core.c:1834
 rfkill_register+0x254/0xd60 net/rfkill/core.c:1019
 wiphy_register+0x19d1/0x2050 net/wireless/core.c:872
 ieee80211_register_hw+0x1162/0x3100 net/mac80211/main.c:1041
 mac80211_hwsim_new_radio+0x1d06/0x2fb0  
drivers/net/wireless/mac80211_hwsim.c:2757

 hwsim_new_radio_nl+0x67a/0x8c0 drivers/net/wireless/mac80211_hwsim.c:3214
 genl_family_rcv_msg+0x7b7/0xfb0 net/netlink/genetlink.c:599
 genl_rcv_msg+0xb2/0x140 net/netlink/genetlink.c:624
 netlink_rcv_skb+0x14b/0x380 net/netlink/af_netlink.c:2447
 genl_rcv+0x28/0x40 net/netlink/genetlink.c:635
 netlink_unicast_kernel net/netlink/af_netlink.c:1311 [inline]
 netlink_unicast+0x4c4/0x6b0 net/netlink/af_netlink.c:1337
 netlink_sendmsg+0xa4a/0xe60 net/netlink/af_netlink.c:1900
 sock_sendmsg_nosec net/socket.c:630 [inline]
 sock_sendmsg+0xca/0x110 net/socket.c:640
 ___sys_sendmsg+0x767/0x8b0 net/socket.c:2046
 __sys_sendmsg+0xe5/0x210 net/socket.c:2080
 SYSC_sendmsg net/socket.c:2091 [inline]
 SyS_sendmsg+0x2d/0x50 net/socket.c:2087
 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x43fda9
RSP: 002b:7ffde548edb8 EFLAGS: 0213 ORIG_RAX: 002e
RAX: ffda RBX: 004002c8 RCX: 0043fda9
RDX:  RSI: 20b3dfc8 RDI: 0003
RBP: 006cb018 R08: 004002c8 R09: 004002c8
R10: 004002c8 R11: 0213 R12: 004016d0
R13: 00401760 R14:  R15: 
Dumping ftrace buffer:
   (ftrace buffer empty)
Kernel Offset: disabled
Rebooting in 86400 seconds..


---
This bug is generated by a dumb bot. It may contain errors.
See https://goo.gl/tpsmEJ for details.
Direct all questions to syzkal...@googlegroups.com.

syzbot will keep track of this bug report.
If you forgot to add the Reported-by tag, once the fix for this bug is  
merged

into any tree, please reply to this email with:
#syz fix: exact-commit-title
If you want to test a patch for this bug, please reply with:
#syz test: git://repo/address.git branch
and provide the patch inline or as an attachment.
To mark this as a duplicate of another syzbot report, please reply with:
#syz dup: exact-subject-of-another-report
If it's a one-off invalid bug report, please reply with:
#syz invalid
Note: if the crash happens again, it will cause creation of a new bug  
report.

Note: all commands m

KASAN: use-after-free Read in rdma_listen

2018-04-01 Thread syzbot

Hello,

syzbot hit the following crash on upstream commit
10b84daddbec72c6b440216a69de9a9605127f7a (Sat Mar 31 17:59:00 2018 +)
Merge branch 'perf-urgent-for-linus' of  
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
syzbot dashboard link:  
https://syzkaller.appspot.com/bug?extid=f3ce716af730c8f96637


So far this crash happened 4 times on upstream.
C reproducer: https://syzkaller.appspot.com/x/repro.c?id=6306348723601408
syzkaller reproducer:  
https://syzkaller.appspot.com/x/repro.syz?id=6405720039751680
Raw console output:  
https://syzkaller.appspot.com/x/log.txt?id=6416847360491520
Kernel config:  
https://syzkaller.appspot.com/x/.config?id=-2760467897697295172

compiler: gcc (GCC) 7.1.1 20170620

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+f3ce716af730c8f96...@syzkaller.appspotmail.com
It will help syzbot understand when the bug is fixed. See footer for  
details.

If you forward the report, please keep this part and the footer.

==
BUG: KASAN: use-after-free in __list_add_valid+0xc6/0xd0 lib/list_debug.c:26
Read of size 8 at addr 8801d7ba9cd8 by task syzkaller817651/5232

CPU: 1 PID: 5232 Comm: syzkaller817651 Not tainted 4.16.0-rc7+ #374
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x194/0x24d lib/dump_stack.c:53
 print_address_description+0x73/0x250 mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report+0x23c/0x360 mm/kasan/report.c:412
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
 __list_add_valid+0xc6/0xd0 lib/list_debug.c:26
 __list_add include/linux/list.h:60 [inline]
 list_add_tail include/linux/list.h:93 [inline]
 cma_listen_on_all drivers/infiniband/core/cma.c:2309 [inline]
 rdma_listen+0x581/0x8e0 drivers/infiniband/core/cma.c:
 ucma_listen+0x172/0x1f0 drivers/infiniband/core/ucma.c:1074
 ucma_write+0x2d6/0x3d0 drivers/infiniband/core/ucma.c:1656
 __vfs_write+0xef/0x970 fs/read_write.c:480
 vfs_write+0x189/0x510 fs/read_write.c:544
 SYSC_write fs/read_write.c:589 [inline]
 SyS_write+0xef/0x220 fs/read_write.c:581
 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x4415e9
RSP: 002b:7fffa7eaaf98 EFLAGS: 0207 ORIG_RAX: 0001
RAX: ffda RBX:  RCX: 004415e9
RDX: fd4e RSI: 28c0 RDI: 0003
RBP:  R08: a7eab118 R09: a7eab118
R10: a7eab118 R11: 0207 R12: 6463
R13: 006cd448 R14:  R15: 

Allocated by task 5230:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:552
 kmem_cache_alloc_trace+0x136/0x740 mm/slab.c:3608
 kmalloc include/linux/slab.h:512 [inline]
 kzalloc include/linux/slab.h:701 [inline]
 rdma_create_id+0xd0/0x630 drivers/infiniband/core/cma.c:787
 ucma_create_id+0x35f/0x920 drivers/infiniband/core/ucma.c:480
 ucma_write+0x2d6/0x3d0 drivers/infiniband/core/ucma.c:1656
 __vfs_write+0xef/0x970 fs/read_write.c:480
 vfs_write+0x189/0x510 fs/read_write.c:544
 SYSC_write fs/read_write.c:589 [inline]
 SyS_write+0xef/0x220 fs/read_write.c:581
 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 5230:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 __kasan_slab_free+0x11a/0x170 mm/kasan/kasan.c:520
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:527
 __cache_free mm/slab.c:3486 [inline]
 kfree+0xd9/0x260 mm/slab.c:3801
 rdma_destroy_id+0x821/0xda0 drivers/infiniband/core/cma.c:1691
 ucma_close+0x100/0x2f0 drivers/infiniband/core/ucma.c:1735
 __fput+0x327/0x7e0 fs/file_table.c:209
 fput+0x15/0x20 fs/file_table.c:243
 task_work_run+0x199/0x270 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0x9bb/0x1ad0 kernel/exit.c:865
 do_group_exit+0x149/0x400 kernel/exit.c:968
 SYSC_exit_group kernel/exit.c:979 [inline]
 SyS_exit_group+0x1d/0x20 kernel/exit.c:977
 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

The buggy address belongs to the object at 8801d7ba9b00
 which belongs to the cache kmalloc-1024 of size 1024
The buggy address is located 472 bytes inside of
 1024-byte region [8801d7ba9b00, 8801d7ba9f00)
The buggy address belongs to the page:
page:ea00075eea00 count:1 mapcount:0 mapping:8801d7ba8000 index:0x0  
compound_mapcount: 0

flags: 0x2fffc008100(slab|head)
raw: 02fffc008100 8801d7ba8000  00010007
raw: ea0006b2af20 ea00075f6520 8801dac00ac0 
page dumped because: kasan: bad access detected

Memory state around the buggy addr

[PATCH] genirq: only scan the present CPUs

2018-04-01 Thread Li RongQing
lots of application will read /proc/stat, like ps and vmstat, but we
find the reading time are spreading on Purley platform which has lots
of possible CPUs and interrupt.

To reduce the reading time, only scan the present CPUs, not all possible
CPUs, which speeds the reading of /proc/stat 20 times on Purley platform
which has 56 present CPUs, and 224 possible CPUs

Signed-off-by: Li RongQing 
---
 kernel/irq/irqdesc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 49b54e9979cc..8f489b73733e 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -902,7 +902,7 @@ unsigned int kstat_irqs(unsigned int irq)
 
if (!desc || !desc->kstat_irqs)
return 0;
-   for_each_possible_cpu(cpu)
+   for_each_present_cpu(cpu)
sum += *per_cpu_ptr(desc->kstat_irqs, cpu);
return sum;
 }
-- 
2.11.0



Re: linux-next: Signed-off-by missing for commits in the net-next tree

2018-04-01 Thread Johan Hedberg
Hi,

On Mon, Apr 02, 2018, Stephen Rothwell wrote:
>   45a42bc9cc65 ("Bluetooth: hci_bcm: Remove DMI quirk for the MINIX Z83-4")
>   f9b95db0165a ("Bluetooth: btrsi: remove unused including ")
>   96e58d368fa6 ("Bluetooth: Set HCI_QUIRK_SIMULTANEOUS_DISCOVERY for 
> BTUSB_QCA_ROME")
>   9ea471320e13 ("Bluetooth: Mark expected switch fall-throughs")
> 
> are missing a Signed-off-by from their committer.

I think this is because I fixed up a missing author name in "Bluetooth:
hci_bcm: Remove DMI quirk for the MINIX Z83-4" and did a push --force,
whereas these patches were originally committed by Marcel. Should I be
adding my signed-off-by to all affected patches when doing such rebases?

Johan


Re: [PATCH 4/8] misc: pci_endpoint_test: Add designware EP entry

2018-04-01 Thread Kishon Vijay Abraham I
Hi,

On Wednesday 28 March 2018 05:08 PM, Gustavo Pimentel wrote:
> Adds the designware EP device ID entry to pci_endpoint_test driver table
> to allow this device to be recognize and handle by the pci_endpoint_test
> driver.
> 
> Signed-off-by: Gustavo Pimentel 
> ---
>  drivers/misc/pci_endpoint_test.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/misc/pci_endpoint_test.c 
> b/drivers/misc/pci_endpoint_test.c
> index 320276f..e80c533 100644
> --- a/drivers/misc/pci_endpoint_test.c
> +++ b/drivers/misc/pci_endpoint_test.c
> @@ -632,6 +632,7 @@ static void pci_endpoint_test_remove(struct pci_dev *pdev)
>  static const struct pci_device_id pci_endpoint_test_tbl[] = {
>   { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA74x) },
>   { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA72x) },
> + { PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS, 0xedda) },

Add device ids to include/linux/pci_ids.h and use the macro here.

Thanks
Kishon


Re: [PATCH 3/8] bindings: PCI: designware: Add support for the EP in designware driver

2018-04-01 Thread Kishon Vijay Abraham I


On Wednesday 28 March 2018 05:08 PM, Gustavo Pimentel wrote:
> Signed-off-by: Gustavo Pimentel 

Please add a commit message.
> ---
>  Documentation/devicetree/bindings/pci/designware-pcie.txt | 13 +
>  1 file changed, 13 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/pci/designware-pcie.txt 
> b/Documentation/devicetree/bindings/pci/designware-pcie.txt
> index 6300762..4bb2e08 100644
> --- a/Documentation/devicetree/bindings/pci/designware-pcie.txt
> +++ b/Documentation/devicetree/bindings/pci/designware-pcie.txt
> @@ -3,6 +3,7 @@
>  Required properties:
>  - compatible:
>   "snps,dw-pcie" for RC mode;
> + "snps,dw-pcie-ep" for EP mode;
>  - reg: Should contain the configuration address space.
>  - reg-names: Must be "config" for the PCIe configuration space.
>  (The old way of getting the configuration address space from "ranges"
> @@ -56,3 +57,15 @@ Example configuration:
>   #interrupt-cells = <1>;
>   num-lanes = <1>;
>   };
> +or
> + pcie_ep: pcie_ep@dfc0 {
> + compatible = "snps,dw-pcie-ep";
> + reg = <0xdfc0 0x0001000>, /* IP registers 1 */
> +   <0xdfc01000 0x0001000>, /* IP registers 2 */

Doesn't this have iATU unroll space?

Thanks
Kishon


Re: [PATCH v5 06/13] ARM: dts: ipq4019: Add ipq4019-ap.dk04.1-c1 board file

2018-04-01 Thread Sricharan R
Hi Bjorn,

On 3/27/2018 10:42 PM, Bjorn Andersson wrote:
> On Fri 23 Mar 03:18 PDT 2018, Sricharan R wrote:
>> +#include "qcom-ipq4019-ap.dk04.1.dtsi"
>> +
>> +/ {
>> +model = "Qualcomm Technologies, Inc. IPQ4019/AP-DK04.1-C1";
>> +
> 
> If this is the board and qcom-ipq4019-ap.dk04.1.dtsi is the platform
> file then the compatible should be here and not there. Also qcom,ipq4019
> is not an awesome compatible for a board file.
> 

 ok, agree. Will correct the compatible and move it here.

>> +soc {
>> +dma@7984000 {
>> +status = "ok";
>> +};
>> +
>> +qpic-nand@79b {
>> +pinctrl-0 = <&nand_pins>;
>> +pinctrl-names = "default";
>> +status = "ok";
>> +};
> 
> nand_pins defines the muxing and is defined in the other dtsi. So please
> move these pinctrl-* properties to the dtsi.
> 
> As long as the node is disabled the pinctrl state won't be applied
> anyways.
> 
> 
> If there are electrical properties that needs to be specified you can
> override the pinctrl state in the board specific file.
> 

 ok, understood. Will follow these conventions in rest of the places as well.

Regards,
 Sricharan

-- 
"QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of 
Code Aurora Forum, hosted by The Linux Foundation


Re: [PATCH 2/8] PCI: dwc: designware: Add support for endpoint mode

2018-04-01 Thread Kishon Vijay Abraham I
Hi,

On Wednesday 28 March 2018 05:08 PM, Gustavo Pimentel wrote:
> The PCIe controller dual mode is capable of operating in host mode as well
> as endpoint mode by configuration, therefore this patch aims to add
> endpoint mode support to the designware driver.
> 
> Signed-off-by: Gustavo Pimentel 
> ---
>  drivers/pci/dwc/Kconfig   |  45 ++--
>  drivers/pci/dwc/pcie-designware-plat.c| 157 
> --
>  drivers/pci/endpoint/functions/pci-epf-test.c |   5 +
>  3 files changed, 187 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/pci/dwc/Kconfig b/drivers/pci/dwc/Kconfig
> index 2f3f5c5..3fd7daf 100644
> --- a/drivers/pci/dwc/Kconfig
> +++ b/drivers/pci/dwc/Kconfig
> @@ -7,8 +7,7 @@ config PCIE_DW
>  
>  config PCIE_DW_HOST
>  bool
> - depends on PCI
> - depends on PCI_MSI_IRQ_DOMAIN
> + depends on PCI && PCI_MSI_IRQ_DOMAIN
>  select PCIE_DW
>  
>  config PCIE_DW_EP
> @@ -52,16 +51,42 @@ config PCI_DRA7XX_EP
>  
>  config PCIE_DW_PLAT
>   bool "Platform bus based DesignWare PCIe Controller"
> - depends on PCI
> - depends on PCI_MSI_IRQ_DOMAIN
> - select PCIE_DW_HOST
> - ---help---
> -  This selects the DesignWare PCIe controller support. Select this if
> -  you have a PCIe controller on Platform bus.
> + help
> +   There are two instances of PCIe controller in Designware IP.
> +   This controller can work either as EP or RC. In order to enable
> +   host-specific features PCIE_DW_PLAT_HOST must be selected and in
> +   order to enable device-specific features PCIE_DW_PLAT_EP must be
> +   selected.
>  
> -  If you have a controller with this interface, say Y or M here.
> +config PCIE_DW_PLAT_HOST
> + bool "Platform bus based DesignWare PCIe Controller - Host mode"
> + depends on PCI && PCI_MSI_IRQ_DOMAIN
> + select PCIE_DW_HOST
> + select PCIE_DW_PLAT
> + default y
> + help
> +   Enables support for the PCIe controller in the Designware IP to
> +   work in host mode. There are two instances of PCIe controller in
> +   Designware IP.
> +   This controller can work either as EP or RC. In order to enable
> +   host-specific features PCIE_DW_PLAT_HOST must be selected and in
> +   order to enable device-specific features PCI_DW_PLAT_EP must be
> +   selected.
>  
> -  If unsure, say N.
> +config PCIE_DW_PLAT_EP
> + bool "Platform bus based DesignWare PCIe Controller - Endpoint mode"
> + depends on PCI && PCI_MSI_IRQ_DOMAIN
> + depends on PCI_ENDPOINT
> + select PCIE_DW_EP
> + select PCIE_DW_PLAT
> + help
> +   Enables support for the PCIe controller in the Designware IP to
> +   work in endpoint mode. There are two instances of PCIe controller
> +   in Designware IP.
> +   This controller can work either as EP or RC. In order to enable
> +   host-specific features PCIE_DW_PLAT_HOST must be selected and in
> +   order to enable device-specific features PCI_DW_PLAT_EP must be
> +   selected.
>  
>  config PCI_EXYNOS
>   bool "Samsung Exynos PCIe controller"
> diff --git a/drivers/pci/dwc/pcie-designware-plat.c 
> b/drivers/pci/dwc/pcie-designware-plat.c
> index 5416aa8..921ab07 100644
> --- a/drivers/pci/dwc/pcie-designware-plat.c
> +++ b/drivers/pci/dwc/pcie-designware-plat.c
> @@ -12,19 +12,29 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include "pcie-designware.h"
>  
>  struct dw_plat_pcie {
> - struct dw_pcie  *pci;
> + struct dw_pcie  *pci;
> + struct regmap   *regmap;
> + enum dw_pcie_device_modemode;
>  };
>  
> +struct dw_plat_pcie_of_data {
> + enum dw_pcie_device_modemode;
> +};
> +
> +static const struct of_device_id dw_plat_pcie_of_match[];
> +
>  static int dw_plat_pcie_host_init(struct pcie_port *pp)
>  {
>   struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
> @@ -42,9 +52,61 @@ static const struct dw_pcie_host_ops dw_plat_pcie_host_ops 
> = {
>   .host_init = dw_plat_pcie_host_init,
>  };
>  
> -static int dw_plat_add_pcie_port(struct pcie_port *pp,
> +static int dw_plat_pcie_establish_link(struct dw_pcie *pci)
> +{
> + dw_pcie_ep_linkup(&pci->ep);

.start_link ops is used incorrectly here. .start_link is used when all the
endpoint side configuration is done and "is ready" to establish a link with the
host. But dw_pcie_ep_linkup is used to inform the function devices that the
link "has been" established.
> +
> + return 0;
> +}
> +
> +static void dw_plat_pcie_stop_link(struct dw_pcie *pci)
> +{
> +
> +}

Not necessary to have empty function here. pci-epc-core will not try to invoke
ops which are not populated.
> +
> +static const struct dw_pcie_ops dw_pcie_ops = {
> + .start_link = dw_plat_pcie_establish_link,
> + .stop_link = dw_plat_pcie_stop_li

[PATCH 1/2] Move kfree_call_rcu() to slab_common.c

2018-04-01 Thread rao . shoaib
From: Rao Shoaib 

kfree_call_rcu does not belong in linux/rcupdate.h and should be moved to
slab_common.c

Signed-off-by: Rao Shoaib 
---
 include/linux/rcupdate.h | 43 +++
 include/linux/rcutree.h  |  2 --
 include/linux/slab.h | 42 ++
 kernel/rcu/tree.c| 24 ++--
 mm/slab_common.c | 10 ++
 5 files changed, 65 insertions(+), 56 deletions(-)

diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 043d047..6338fb6 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -55,6 +55,9 @@ void call_rcu(struct rcu_head *head, rcu_callback_t func);
 #definecall_rcucall_rcu_sched
 #endif /* #else #ifdef CONFIG_PREEMPT_RCU */
 
+/* only for use by kfree_call_rcu() */
+void call_rcu_lazy(struct rcu_head *head, rcu_callback_t func);
+
 void call_rcu_bh(struct rcu_head *head, rcu_callback_t func);
 void call_rcu_sched(struct rcu_head *head, rcu_callback_t func);
 void synchronize_sched(void);
@@ -837,45 +840,6 @@ static inline notrace void 
rcu_read_unlock_sched_notrace(void)
 #define __is_kfree_rcu_offset(offset) ((offset) < 4096)
 
 /*
- * Helper macro for kfree_rcu() to prevent argument-expansion eyestrain.
- */
-#define __kfree_rcu(head, offset) \
-   do { \
-   BUILD_BUG_ON(!__is_kfree_rcu_offset(offset)); \
-   kfree_call_rcu(head, (rcu_callback_t)(unsigned long)(offset)); \
-   } while (0)
-
-/**
- * kfree_rcu() - kfree an object after a grace period.
- * @ptr:   pointer to kfree
- * @rcu_head:  the name of the struct rcu_head within the type of @ptr.
- *
- * Many rcu callbacks functions just call kfree() on the base structure.
- * These functions are trivial, but their size adds up, and furthermore
- * when they are used in a kernel module, that module must invoke the
- * high-latency rcu_barrier() function at module-unload time.
- *
- * The kfree_rcu() function handles this issue.  Rather than encoding a
- * function address in the embedded rcu_head structure, kfree_rcu() instead
- * encodes the offset of the rcu_head structure within the base structure.
- * Because the functions are not allowed in the low-order 4096 bytes of
- * kernel virtual memory, offsets up to 4095 bytes can be accommodated.
- * If the offset is larger than 4095 bytes, a compile-time error will
- * be generated in __kfree_rcu().  If this error is triggered, you can
- * either fall back to use of call_rcu() or rearrange the structure to
- * position the rcu_head structure into the first 4096 bytes.
- *
- * Note that the allowable offset might decrease in the future, for example,
- * to allow something like kmem_cache_free_rcu().
- *
- * The BUILD_BUG_ON check must not involve any function calls, hence the
- * checks are done in macros here.
- */
-#define kfree_rcu(ptr, rcu_head)   \
-   __kfree_rcu(&((ptr)->rcu_head), offsetof(typeof(*(ptr)), rcu_head))
-
-
-/*
  * Place this after a lock-acquisition primitive to guarantee that
  * an UNLOCK+LOCK pair acts as a full barrier.  This guarantee applies
  * if the UNLOCK and LOCK are executed by the same CPU or if the
@@ -887,5 +851,4 @@ static inline notrace void 
rcu_read_unlock_sched_notrace(void)
 #define smp_mb__after_unlock_lock()do { } while (0)
 #endif /* #else #ifdef CONFIG_ARCH_WEAK_RELEASE_ACQUIRE */
 
-
 #endif /* __LINUX_RCUPDATE_H */
diff --git a/include/linux/rcutree.h b/include/linux/rcutree.h
index fd996cd..567ef58 100644
--- a/include/linux/rcutree.h
+++ b/include/linux/rcutree.h
@@ -48,8 +48,6 @@ void synchronize_rcu_bh(void);
 void synchronize_sched_expedited(void);
 void synchronize_rcu_expedited(void);
 
-void kfree_call_rcu(struct rcu_head *head, rcu_callback_t func);
-
 /**
  * synchronize_rcu_bh_expedited - Brute-force RCU-bh grace period
  *
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 231abc8..116e870 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -355,6 +355,48 @@ void *__kmalloc(size_t size, gfp_t flags) 
__assume_kmalloc_alignment __malloc;
 void *kmem_cache_alloc(struct kmem_cache *, gfp_t flags) 
__assume_slab_alignment __malloc;
 void kmem_cache_free(struct kmem_cache *, void *);
 
+void kfree_call_rcu(struct rcu_head *head, rcu_callback_t func);
+
+/* Helper macro for kfree_rcu() to prevent argument-expansion eyestrain. */
+#define __kfree_rcu(head, offset) \
+   do { \
+   unsigned long __of = (unsigned long)offset; \
+   BUILD_BUG_ON(!__is_kfree_rcu_offset(__of)); \
+   kfree_call_rcu(head, (rcu_callback_t)(__of));   \
+   } while (0)
+
+/**
+ * kfree_rcu() - kfree an object after a grace period.
+ * @ptr:   pointer to kfree
+ * @rcu_name:  the name of the struct rcu_head within the type of @ptr.
+ *
+ * Many rcu callbacks functions just call kfree() on the base structure.
+ * These functions are trivial, but their size a

[PATCH 2/2] kfree_rcu() should use kfree_bulk() interface

2018-04-01 Thread rao . shoaib
From: Rao Shoaib 

kfree_rcu() should use the new kfree_bulk() interface for freeing
rcu structures as it is more efficient.

Signed-off-by: Rao Shoaib 
---
 include/linux/mm.h  |   5 ++
 include/linux/rcutiny.h |   8 ++-
 kernel/sysctl.c |  40 
 mm/slab.h   |  23 +++
 mm/slab_common.c| 164 +++-
 5 files changed, 238 insertions(+), 2 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index ad06d42..fb1e54c 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2673,5 +2673,10 @@ void __init setup_nr_node_ids(void);
 static inline void setup_nr_node_ids(void) {}
 #endif
 
+extern int sysctl_kfree_rcu_drain_limit;
+extern int sysctl_kfree_rcu_poll_limit;
+extern int sysctl_kfree_rcu_empty_limit;
+extern int sysctl_kfree_rcu_caching_allowed;
+
 #endif /* __KERNEL__ */
 #endif /* _LINUX_MM_H */
diff --git a/include/linux/rcutiny.h b/include/linux/rcutiny.h
index ce9beec..b9e9025 100644
--- a/include/linux/rcutiny.h
+++ b/include/linux/rcutiny.h
@@ -84,10 +84,16 @@ static inline void synchronize_sched_expedited(void)
synchronize_sched();
 }
 
+static inline void call_rcu_lazy(struct rcu_head *head,
+rcu_callback_t func)
+{
+   call_rcu(head, func);
+}
+
 static inline void kfree_call_rcu(struct rcu_head *head,
  rcu_callback_t func)
 {
-   call_rcu(head, func);
+   call_rcu_lazy(head, func);
 }
 
 #define rcu_note_context_switch(preempt) \
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index f98f28c..ab70c99 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1650,6 +1650,46 @@ static struct ctl_table vm_table[] = {
.extra2 = (void *)&mmap_rnd_compat_bits_max,
},
 #endif
+   {
+   .procname   = "kfree_rcu_drain_limit",
+   .data   = &sysctl_kfree_rcu_drain_limit,
+   .maxlen = sizeof(sysctl_kfree_rcu_drain_limit),
+   .mode   = 0644,
+   .proc_handler   = proc_dointvec_minmax,
+   .extra1 = &one,
+   .extra2 = &one_hundred,
+   },
+
+   {
+   .procname   = "kfree_rcu_poll_limit",
+   .data   = &sysctl_kfree_rcu_poll_limit,
+   .maxlen = sizeof(sysctl_kfree_rcu_poll_limit),
+   .mode   = 0644,
+   .proc_handler   = proc_dointvec_minmax,
+   .extra1 = &one,
+   .extra2 = &one_hundred,
+   },
+
+   {
+   .procname   = "kfree_rcu_empty_limit",
+   .data   = &sysctl_kfree_rcu_empty_limit,
+   .maxlen = sizeof(sysctl_kfree_rcu_empty_limit),
+   .mode   = 0644,
+   .proc_handler   = proc_dointvec_minmax,
+   .extra1 = &zero,
+   .extra2 = &four,
+   },
+
+   {
+   .procname   = "kfree_rcu_caching_allowed",
+   .data   = &sysctl_kfree_rcu_caching_allowed,
+   .maxlen = sizeof(sysctl_kfree_rcu_caching_allowed),
+   .mode   = 0644,
+   .proc_handler   = proc_dointvec_minmax,
+   .extra1 = &zero,
+   .extra2 = &one,
+   },
+
{ }
 };
 
diff --git a/mm/slab.h b/mm/slab.h
index 5181323..a332ea6 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -80,6 +80,29 @@ extern const struct kmalloc_info_struct {
unsigned long size;
 } kmalloc_info[];
 
+#defineRCU_MAX_ACCUMULATE_SIZE 25
+
+struct rcu_bulk_free_container {
+   struct  rcu_head rbfc_rcu;
+   int rbfc_entries;
+   void*rbfc_data[RCU_MAX_ACCUMULATE_SIZE];
+   struct  rcu_bulk_free *rbfc_rbf;
+};
+
+struct rcu_bulk_free {
+   struct  rcu_head rbf_rcu; /* used to schedule monitor process */
+   spinlock_t  rbf_lock;
+   struct  rcu_bulk_free_container *rbf_container;
+   struct  rcu_bulk_free_container *rbf_cached_container;
+   struct  rcu_head *rbf_list_head;
+   int rbf_list_size;
+   int rbf_cpu;
+   int rbf_empty;
+   int rbf_polled;
+   boolrbf_init;
+   boolrbf_monitor;
+};
+
 #ifndef CONFIG_SLOB
 /* Kmalloc array related functions */
 void setup_kmalloc_cache_index_table(void);
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 2ea9866..6e8afff 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define CREATE_TRACE_POINTS
 #include 
@@ -1525,13 +1526,174 @@ void kzfree(const void *p)
 }
 EXPORT_SYMBOL(kzfree);
 
+static DEFINE_PER_CPU(struct rcu_bulk_free, cpu_rbf);
+
+/* drain if atleast these many objects */
+int sysctl_kfree_rcu_drain_limit __read_mostl

[PATCH 0/2] Move kfree_rcu out of rcu code and use kfree_bulk

2018-04-01 Thread rao . shoaib
From: Rao Shoaib 

This patch moves kfree_call_rcu() out of rcu related code to
mm/slab_common and updates kfree_rcu() to use new bulk memory free
functions as they are more efficient.

This is a resubmission of the previous patch.

Changes:

1) checkpatch.pl has been fixed, so kfree_rcu macro is much simpler

2) To handle preemption, preempt_enable()/preempt_disable() statements
   have been added to __rcu_bulk_free().


Rao Shoaib (2):
  Move kfree_call_rcu() to slab_common.c
  kfree_rcu() should use kfree_bulk() interface

 include/linux/mm.h   |   5 ++
 include/linux/rcupdate.h |  43 +---
 include/linux/rcutiny.h  |   8 ++-
 include/linux/rcutree.h  |   2 -
 include/linux/slab.h |  42 
 kernel/rcu/tree.c|  24 +++
 kernel/sysctl.c  |  40 +++
 mm/slab.h|  23 +++
 mm/slab_common.c | 172 +++
 9 files changed, 302 insertions(+), 57 deletions(-)

-- 
2.7.4



Re: 答复: Re: [PATCH v2] scsi: Introduce sdev_printk_ratelimited to throttlefrequent printk

2018-04-01 Thread Sergey Senozhatsky
On (04/02/18 13:14), wen.yan...@zte.com.cn wrote:
> 
>> It's true that this print for the same device is useless. But it's
>> useful for different devices. Is it possible to limit the print only
>> for the same device?
> 
>In our scene, it's  just for the same device (q->queuedata), Thanks.

Yes, what Jason meant was that rate limit struct is shared by different call
sites - including scsi_request_fn() from different devices.

If device1->scsi_request_fn()->sdev_printk_ratelimited() causes printk rate
limit, then messages from device2->scsi_request_fn()->sdev_printk_ratelimited()
may be lost entirely, unless you have enough of them.

-ss


Re: [PATCH v5 05/13] ARM: dts: ipq4019: Add ipq4019-ap.dk04.dtsi

2018-04-01 Thread Sricharan R


On 3/27/2018 10:34 PM, Bjorn Andersson wrote:
> On Fri 23 Mar 03:18 PDT 2018, Sricharan R wrote:
>> +soc {
>> +pinctrl@100 {
>> +serial_0_pins: serial0_pinmux {
> 
> Please, no underscores in the node name.

 ok.

> 
>> +mux {
> 
> Fyi, you can put the pinctrl properties directly into the state node,
> omitting the "mux" level.
> 

 ok, will change.

>> +pins = "gpio16", "gpio17";
>> +function = "blsp_uart0";
>> +bias-disable;
>> +};
>> +};
>> +
> 
> Apart from this the patch looks good.
 Thanks.

Regards,
 Sricharan

-- 
"QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of 
Code Aurora Forum, hosted by The Linux Foundation


Re: [PATCH v5 03/13] ARM: dts: ipq4019: Add a few peripheral nodes

2018-04-01 Thread Sricharan R
Hi Bjorn,
  Thanks a lot for all the reviews.

On 3/27/2018 10:20 PM, Bjorn Andersson wrote:
> On Fri 23 Mar 03:18 PDT 2018, Sricharan R wrote:
>> @@ -172,6 +180,22 @@
>>  clock-names = "core", "iface";
>>  #address-cells = <1>;
>>  #size-cells = <0>;
>> +dmas = <&blsp_dma 5>, <&blsp_dma 4>;
>> +dma-names = "rx", "tx";
>> +status = "disabled";
>> +};
>> +
>> +spi_1: spi@78b6000 { /* BLSP1 QUP2 */
>> +compatible = "qcom,spi-qup-v2.2.1";
>> +reg = <0x78b6000 0x600>;
>> +interrupts = ;
>> +clocks = <&gcc GCC_BLSP1_QUP2_SPI_APPS_CLK>,
>> +<&gcc GCC_BLSP1_AHB_CLK>;
>> +clock-names = "core", "iface";
>> +#address-cells = <1>;
>> +#size-cells = <0>;
>> +dmas = <&blsp_dma 7>, <&blsp_dma 6>;
>> +dma-names = "rx", "tx";
>>  status = "disabled";
>>  };
>>  
>> @@ -184,9 +208,24 @@
>>  clock-names = "iface", "core";
>>  #address-cells = <1>;
>>  #size-cells = <0>;
>> +dmas = <&blsp_dma 9>, <&blsp_dma 8>;
>> +dma-names = "rx", "tx";
>>  status = "disabled";
>>  };
>>  
>> +i2c_1: i2c@78b8000 { /* BLSP1 QUP4 */
> 
> The label, comment and the core clock disagrees on which qup this is.
> 
> Label your nodes based on the SoC naming, not your board - as this will
> prevent a future board from using e.g. blsp1 qup2 as i2c (as you already
> used the label for that).

Sure. will fix. Infact this is QUP3.

> 
>> +compatible = "qcom,i2c-qup-v2.2.1";
>> +reg = <0x78b8000 0x600>;
>> +interrupts = ;
>> +clocks = <&gcc GCC_BLSP1_AHB_CLK>,
>> + <&gcc GCC_BLSP1_QUP2_I2C_APPS_CLK>;
> 
> QUP4?

 QUP3

> 
>> +clock-names = "iface", "core";
>> +#address-cells = <1>;
>> +#size-cells = <0>;
>> +dmas = <&blsp_dma 11>, <&blsp_dma 10>;
>> +dma-names = "rx", "tx";
>> +status = "disabled";
>> +};
> 
> Apart from this the patch looks good.

 Thanks.

Regards,
  Sricharan

-- 
"QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of 
Code Aurora Forum, hosted by The Linux Foundation



Re: [PATCH 1/8] bindings: PCI: designware: Example update

2018-04-01 Thread Kishon Vijay Abraham I
Hi,

On Wednesday 28 March 2018 05:08 PM, Gustavo Pimentel wrote:
> Changes the IP registers size to accommodate the ATU unroll space.
> 
> Replaces "ctrlreg" reg-name by "dbi" to be coherent with similar drivers.
> 
> Replaces the pcie base address example by a real pcie base address in use.
> 
> Signed-off-by: Gustavo Pimentel 
> ---
>  Documentation/devicetree/bindings/pci/designware-pcie.txt | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/pci/designware-pcie.txt 
> b/Documentation/devicetree/bindings/pci/designware-pcie.txt
> index 1da7ade..6300762 100644
> --- a/Documentation/devicetree/bindings/pci/designware-pcie.txt
> +++ b/Documentation/devicetree/bindings/pci/designware-pcie.txt
> @@ -1,7 +1,8 @@
>  * Synopsys DesignWare PCIe interface
>  
>  Required properties:
> -- compatible: should contain "snps,dw-pcie" to identify the core.
> +- compatible:
> + "snps,dw-pcie" for RC mode;

I think irrespective of RC mode or EP mode, "snps,dw-pcie" can be used to
identify the pcie core?
>  - reg: Should contain the configuration address space.
>  - reg-names: Must be "config" for the PCIe configuration space.
>  (The old way of getting the configuration address space from "ranges"
> @@ -41,11 +42,11 @@ EP mode:
>  
>  Example configuration:
>  
> - pcie: pcie@d000 {
> + pcie: pcie@dfc0 {
>   compatible = "snps,dw-pcie";
> - reg = <0xd000 0x1000>, /* Controller registers */
> -   <0xd000 0x2000>; /* PCI config space */
> - reg-names = "ctrlreg", "config";
> + reg = <0xdfc0 0x302000>, /* IP registers */

which version of synopsys IP is this. I think the ideal thing to do here is to
have a separate register space for iATU.

Thanks
Kishon


Re: [PATCH v2 4/6] drm/msm: Issue queued events when disabling crtc

2018-04-01 Thread Archit Taneja



On Thursday 29 March 2018 12:36 AM, Sean Paul wrote:

Ensure that any queued events are issued when disabling the crtc. This
avoids timeouts when we come back and wait for dependencies (like the
previous frame's flip_done).


Reviewed-by: Archit Taneja 



Changes in v2:
- None

Signed-off-by: Sean Paul 
---
  drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c | 9 +
  1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c 
b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
index 76b96081916f..10271359789e 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
@@ -430,6 +430,7 @@ static void mdp5_crtc_atomic_disable(struct drm_crtc *crtc,
struct mdp5_crtc_state *mdp5_cstate = to_mdp5_crtc_state(crtc->state);
struct mdp5_kms *mdp5_kms = get_kms(crtc);
struct device *dev = &mdp5_kms->pdev->dev;
+   unsigned long flags;
  
  	DBG("%s", crtc->name);
  
@@ -445,6 +446,14 @@ static void mdp5_crtc_atomic_disable(struct drm_crtc *crtc,

mdp_irq_unregister(&mdp5_kms->base, &mdp5_crtc->err);
pm_runtime_put_sync(dev);
  
+	if (crtc->state->event && !crtc->state->active) {

+   WARN_ON(mdp5_crtc->event);
+   spin_lock_irqsave(&mdp5_kms->dev->event_lock, flags);
+   drm_crtc_send_vblank_event(crtc, crtc->state->event);
+   crtc->state->event = NULL;
+   spin_unlock_irqrestore(&mdp5_kms->dev->event_lock, flags);
+   }
+
mdp5_crtc->enabled = false;
  }
  



Re: [PATCH v2 3/6] drm/msm: Mark the crtc->state->event consumed

2018-04-01 Thread Archit Taneja



On Thursday 29 March 2018 12:36 AM, Sean Paul wrote:

Don't leave the event != NULL once it's consumed, this is used a signal

s/used a/used as a ?

to the atomic helpers that the event will be handled by the driver.



Reviewed-by: Archit Taneja 


Changes in v2:
- None

Cc: Jeykumar Sankaran 
Signed-off-by: Sean Paul 
---
  drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c | 1 +
  drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c | 1 +
  2 files changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c 
b/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
index 6e5e1aa54ce1..b001699297c4 100644
--- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
+++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
@@ -351,6 +351,7 @@ static void mdp4_crtc_atomic_flush(struct drm_crtc *crtc,
  
  	spin_lock_irqsave(&dev->event_lock, flags);

mdp4_crtc->event = crtc->state->event;
+   crtc->state->event = NULL;
spin_unlock_irqrestore(&dev->event_lock, flags);
  
  	blend_setup(crtc);

diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c 
b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
index 9893e43ba6c5..76b96081916f 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
@@ -708,6 +708,7 @@ static void mdp5_crtc_atomic_flush(struct drm_crtc *crtc,
  
  	spin_lock_irqsave(&dev->event_lock, flags);

mdp5_crtc->event = crtc->state->event;
+   crtc->state->event = NULL;
spin_unlock_irqrestore(&dev->event_lock, flags);
  
  	/*




Re: [PATCH v2 2/6] drm/msm: Refactor complete_commit() to look more the helpers

2018-04-01 Thread Archit Taneja



On Thursday 29 March 2018 12:36 AM, Sean Paul wrote:

Factor out the commit_tail() portions of complete_commit() into a
separate function to facilitate moving to the atomic helpers in future
patches.



Reviewed-by: Archit Taneja 


Changes in v2:
- None

Cc: Jeykumar Sankaran 
Signed-off-by: Sean Paul 
---
  drivers/gpu/drm/msm/msm_atomic.c | 25 -
  1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_atomic.c b/drivers/gpu/drm/msm/msm_atomic.c
index e792158676aa..671a18ee977d 100644
--- a/drivers/gpu/drm/msm/msm_atomic.c
+++ b/drivers/gpu/drm/msm/msm_atomic.c
@@ -97,18 +97,12 @@ static void msm_atomic_wait_for_commit_done(struct 
drm_device *dev,
}
  }
  
-/* The (potentially) asynchronous part of the commit.  At this point

- * nothing can fail short of armageddon.
- */
-static void complete_commit(struct msm_commit *c, bool async)
+static void msm_atomic_commit_tail(struct drm_atomic_state *state)
  {
-   struct drm_atomic_state *state = c->state;
struct drm_device *dev = state->dev;
struct msm_drm_private *priv = dev->dev_private;
struct msm_kms *kms = priv->kms;
  
-	drm_atomic_helper_wait_for_fences(dev, state, false);

-
kms->funcs->prepare_commit(kms, state);
  
  	drm_atomic_helper_commit_modeset_disables(dev, state);

@@ -135,6 +129,19 @@ static void complete_commit(struct msm_commit *c, bool 
async)
drm_atomic_helper_cleanup_planes(dev, state);
  
  	kms->funcs->complete_commit(kms, state);

+}
+
+/* The (potentially) asynchronous part of the commit.  At this point
+ * nothing can fail short of armageddon.
+ */
+static void complete_commit(struct msm_commit *c)
+{
+   struct drm_atomic_state *state = c->state;
+   struct drm_device *dev = state->dev;
+
+   drm_atomic_helper_wait_for_fences(dev, state, false);
+
+   msm_atomic_commit_tail(state);
  
  	drm_atomic_state_put(state);
  
@@ -143,7 +150,7 @@ static void complete_commit(struct msm_commit *c, bool async)
  
  static void commit_worker(struct work_struct *work)

  {
-   complete_commit(container_of(work, struct msm_commit, work), true);
+   complete_commit(container_of(work, struct msm_commit, work));
  }
  
  /**

@@ -242,7 +249,7 @@ int msm_atomic_commit(struct drm_device *dev,
return 0;
}
  
-	complete_commit(c, false);

+   complete_commit(c);
  
  	return 0;
  



Re: [PATCH v2 1/6] drm/msm: Use drm_private_obj/state instead of subclassing

2018-04-01 Thread Archit Taneja



On Thursday 29 March 2018 12:36 AM, Sean Paul wrote:

Now that we have private state handled by the core, we can use those
instead of rolling our own swap_state for private data.

Originally posted here: https://patchwork.freedesktop.org/patch/211361/

Changes in v2:
  - Use state->state in disp duplicate_state callback (Jeykumar)
Changes in v3:
  - Update comment describing msm_kms_state (Jeykumar)
Changes in v4:
  - Rebased on msm-next
  - Don't always use private state from atomic state (Archit)
  - Renamed some of the state accessors
  - Tested on mdp5 db410c
Changes in v5:
  - None

Cc: Jeykumar Sankaran 
Cc: Archit Taneja 
Signed-off-by: Sean Paul 
---
  drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c   | 77 ++-
  drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.h   | 11 +--
  drivers/gpu/drm/msm/disp/mdp5/mdp5_mixer.c | 12 ++-
  drivers/gpu/drm/msm/disp/mdp5/mdp5_pipe.c  | 28 ---
  drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c   | 19 +++--
  drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.h   |  4 +-
  drivers/gpu/drm/msm/msm_atomic.c   | 37 -
  drivers/gpu/drm/msm/msm_drv.c  | 87 +-
  drivers/gpu/drm/msm/msm_drv.h  |  3 -
  drivers/gpu/drm/msm/msm_kms.h  | 21 --
  10 files changed, 183 insertions(+), 116 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c 
b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
index 6d8e3a9a6fc0..366670043190 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
@@ -70,60 +70,62 @@ static int mdp5_hw_init(struct msm_kms *kms)
return 0;
  }
  
-struct mdp5_state *mdp5_get_state(struct drm_atomic_state *s)

+struct mdp5_state *mdp5_state_from_atomic(struct drm_atomic_state *state)
  {
-   struct msm_drm_private *priv = s->dev->dev_private;
-   struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(priv->kms));
-   struct msm_kms_state *state = to_kms_state(s);
-   struct mdp5_state *new_state;
-   int ret;
+   struct msm_kms_state *kms_state = msm_kms_state_from_atomic(state);
  
-	if (state->state)

-   return state->state;
+   if (IS_ERR_OR_NULL(kms_state))
+   return (struct mdp5_state *)kms_state; /* casting ERR_PTR */
  
-	ret = drm_modeset_lock(&mdp5_kms->state_lock, s->acquire_ctx);

-   if (ret)
-   return ERR_PTR(ret);
+   return kms_state->state;
+}
  
-	new_state = kmalloc(sizeof(*mdp5_kms->state), GFP_KERNEL);

-   if (!new_state)
-   return ERR_PTR(-ENOMEM);
+struct mdp5_state *mdp5_state_from_dev(struct drm_device *dev)
+{
+   struct msm_kms_state *kms_state = msm_kms_state_from_dev(dev);
  
-	/* Copy state: */

-   new_state->hwpipe = mdp5_kms->state->hwpipe;
-   new_state->hwmixer = mdp5_kms->state->hwmixer;
-   if (mdp5_kms->smp)
-   new_state->smp = mdp5_kms->state->smp;
+   if (IS_ERR_OR_NULL(kms_state))
+   return (struct mdp5_state *)kms_state; /* casting ERR_PTR */
  
-	state->state = new_state;

+   return kms_state->state;
+}
+
+static void *mdp5_duplicate_state(void *state)
+{
+   if (!state)
+   return kzalloc(sizeof(struct mdp5_state), GFP_KERNEL);
  
-	return new_state;

+   return kmemdup(state, sizeof(struct mdp5_state), GFP_KERNEL);
  }
  
-static void mdp5_swap_state(struct msm_kms *kms, struct drm_atomic_state *state)

+static void mdp5_destroy_state(void *state)
  {
-   struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
-   swap(to_kms_state(state)->state, mdp5_kms->state);
+   struct mdp5_state *mdp_state = (struct mdp5_state *)state;
+   kfree(mdp_state);
  }
  
-static void mdp5_prepare_commit(struct msm_kms *kms, struct drm_atomic_state *state)

+static void mdp5_prepare_commit(struct msm_kms *kms,
+   struct drm_atomic_state *old_state)
  {
struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
+   struct mdp5_state *mdp5_state = mdp5_state_from_dev(mdp5_kms->dev);
struct device *dev = &mdp5_kms->pdev->dev;
  
  	pm_runtime_get_sync(dev);
  
  	if (mdp5_kms->smp)

-   mdp5_smp_prepare_commit(mdp5_kms->smp, &mdp5_kms->state->smp);
+   mdp5_smp_prepare_commit(mdp5_kms->smp, &mdp5_state->smp);
  }
  
-static void mdp5_complete_commit(struct msm_kms *kms, struct drm_atomic_state *state)

+static void mdp5_complete_commit(struct msm_kms *kms,
+struct drm_atomic_state *old_state)
  {
struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
+   struct mdp5_state *mdp5_state = mdp5_state_from_dev(mdp5_kms->dev);
struct device *dev = &mdp5_kms->pdev->dev;
  
  	if (mdp5_kms->smp)

-   mdp5_smp_complete_commit(mdp5_kms->smp, &mdp5_kms->state->smp);
+   mdp5_smp_complete_commit(mdp5_kms->smp, &mdp5_state->smp);
  
  	pm_runtime_put_sync(dev);

  }
@@ -229,7 +231,8 @@ static const struct mdp_kms

Re: [PATCH] net: improve ipv4 performances

2018-04-01 Thread Eric Dumazet


On 04/01/2018 11:31 AM, Anton Gary Ceph wrote:
> As the Linux networking stack is growing, more and more protocols are
> added, increasing the complexity of stack itself.
> Modern processors, contrary to common belief, are very bad in branch
> prediction, so it's our task to give hints to the compiler when possible.
> 
> After a few profiling and analysis, turned out that the ethertype field
> of the packets has the following distribution:
> 
> 92.1% ETH_P_IP
>  3.2% ETH_P_ARP
>  2.7% ETH_P_8021Q
>  1.4% ETH_P_PPP_SES
>  0.6% don't know/no opinion
> 
> From a projection on statistics collected by Google about IPv6 adoption[1],
> IPv6 should peak at 25% usage at the beginning of 2030. Hence, we should
> give proper hints to the compiler about the low IPv6 usage.
> 
> Here is an iperf3 run before and after the patch:
> 
> Before:
> [ ID]  Interval   TransferBandwidth   Retr
> [  4]  0.00-100.00 sec100 GBytes  8.60 Gbits/sec  0   sender
> [  4]  0.00-100.00 sec100 GBytes  8.60 Gbits/sec  receiver
> 
> After
> [ ID]  Interval   TransferBandwidth   Retr
> [  4]  0.00-100.00 sec109 GBytes  9.35 Gbits/sec  0   sender
> [  4]  0.00-100.00 sec109 GBytes  9.35 Gbits/sec  receiver
>

These iperf3 numbers are simply telling something is wrong in your measures or 
your hardware.

By the time linux kernels with this patch reach hosts, they will likely use 
IPv6 anyway.

Please do not tell the compiler that IPv6 should be slowed down in favor of 
IPv4.

Instead, work on removing IPv4 stack from linux kernel (making it a module)





Re: [PATCH 06/45] C++: Do some basic C++ type definition

2018-04-01 Thread kbuild test robot
Hi David,

I love your patch! Yet something to improve:

[auto build test ERROR on v4.16-rc7]
[cannot apply to linus/master tip/x86/core tip/locking/core v4.16 next-20180329]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/David-Howells/C-Convert-the-kernel-to-C/20180402-120344
config: x86_64-randconfig-x002-201813 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

   include/linux/types.h:188:1: warning: empty declaration
struct list_head {
^~
   include/linux/types.h:192:1: warning: empty declaration
struct hlist_head {
^~
   include/linux/types.h:196:1: warning: empty declaration
struct hlist_node {
^~
   include/linux/types.h:201:2: error: expected specifier-qualifier-list before 
'__kernel_daddr_t'
 __kernel_daddr_t f_tfree;
 ^~~~
   include/linux/types.h:200:1: warning: empty declaration
struct ustat {
^~
   include/linux/types.h:226:1: warning: empty declaration
struct callback_head {
^~
   include/linux/types.h:232:16: error: storage class specified for parameter 
'rcu_callback_t'
typedef void (*rcu_callback_t)(struct rcu_head *head);
   ^~
   include/linux/types.h:233:56: error: expected declaration specifiers or 
'...' before 'rcu_callback_t'
typedef void (*call_rcu_func_t)(struct rcu_head *head, rcu_callback_t func);
   ^~
   In file included from include/asm-generic/bug.h:5:0,
from arch/x86/include/asm/bug.h:83,
from include/linux/bug.h:5,
from include/linux/page-flags.h:10,
from kernel/bounds.c:10:
   include/linux/compiler.h:187:1: error: expected '=', ',', ';', 'asm' or 
'__attribute__' before '{' token
{
^
   include/linux/compiler.h:205:1: error: expected '=', ',', ';', 'asm' or 
'__attribute__' before '{' token
{
^
   include/linux/compiler.h:210:1: error: expected '=', ',', ';', 'asm' or 
'__attribute__' before '{' token
{
^
   In file included from arch/x86/include/asm/barrier.h:5:0,
from include/linux/compiler.h:245,
from include/asm-generic/bug.h:5,
from arch/x86/include/asm/bug.h:83,
from include/linux/bug.h:5,
from include/linux/page-flags.h:10,
from kernel/bounds.c:10:
   arch/x86/include/asm/alternative.h:48:1: warning: empty declaration
struct alt_instr {
^~
   arch/x86/include/asm/alternative.h:61:12: error: storage class specified for 
parameter 'alternatives_patched'
extern int alternatives_patched;
   ^~~~
   arch/x86/include/asm/alternative.h:63:13: error: storage class specified for 
parameter 'alternative_instructions'
extern void alternative_instructions(void);
^~~~
   arch/x86/include/asm/alternative.h:64:13: error: storage class specified for 
parameter 'apply_alternatives'
extern void apply_alternatives(struct alt_instr *start, struct alt_instr 
*end);
^~
   arch/x86/include/asm/alternative.h:66:1: warning: empty declaration
struct module;
^~
   arch/x86/include/asm/alternative.h:79:41: error: expected '=', ',', ';', 
'asm' or '__attribute__' before '{' token
void *text, void *text_end) {}
^
   arch/x86/include/asm/alternative.h:80:68: error: expected '=', ',', ';', 
'asm' or '__attribute__' before '{' token
static inline void alternatives_smp_module_del(struct module *mod) {}
   ^
   arch/x86/include/asm/alternative.h:81:50: error: expected '=', ',', ';', 
'asm' or '__attribute__' before '{' token
static inline void alternatives_enable_smp(void) {}
 ^
   arch/x86/include/asm/alternative.h:83:1: error: expected '=', ',', ';', 
'asm' or '__attribute__' before '{' token
{
^
   In file included from arch/x86/include/asm/barrier.h:6:0,
from include/linux/compiler.h:245,
from include/asm-generic/bug.h:5,
from arch/x86/include/asm/bug.h:83,
from include/linux/bug.h:5,
from include/linux/page-flags.h:10,
from kernel/bounds.c:10:
   arch/x86/include/asm/nops.h:143:37: error: storage class specified for 
parameter 'ideal_nops'
extern const unsigned char * const *ideal_nops;
^~
   arch/x86/include/asm/nops.h:144:13: error: storage class specified 

Re: [PATCH v4 04/24] fpga: add device feature list support

2018-04-01 Thread Wu Hao
On Thu, Mar 29, 2018 at 04:57:22PM -0500, Alan Tull wrote:
> On Mon, Mar 26, 2018 at 9:35 PM, Wu Hao  wrote:
> 
> Hi Hao,
> 
> Currently there is one set of functions that handles port enable,
> disable, and reset and it's in dfl.c and dfl.h, so that's not in any
> driver module that can be switched out if necessary for a different
> implementation of the port.  Finding a way for this patchset to be
> structured for DFL to control what low level manager/port drivers are
> used is the current challenge that I've got a lot of my attention on.
> 
> Thanks for the explanations on how virtualization affects how this can
> be implemented.
> 
> > On Mon, Mar 26, 2018 at 12:21:23PM -0500, Alan Tull wrote:
> >> On Thu, Mar 22, 2018 at 11:33 PM, Wu Hao  wrote:
> >>
> >> >> > +
> >> >> > +/*
> >> >> > + * This function resets the FPGA Port and its accelerator (AFU) by 
> >> >> > function
> >> >> > + * __fpga_port_disable and __fpga_port_enable (set port soft reset 
> >> >> > bit and
> >> >> > + * then clear it). Userspace can do Port reset at any time, e.g 
> >> >> > during DMA
> >> >> > + * or Partial Reconfiguration. But it should never cause any system 
> >> >> > level
> >> >> > + * issue, only functional failure (e.g DMA or PR operation failure) 
> >> >> > and be
> >> >> > + * recoverable from the failure.
> >> >> > + *
> >> >> > + * Note: the accelerator (AFU) is not accessible when its port is in 
> >> >> > reset
> >> >> > + * (disabled). Any attempts on MMIO access to AFU while in reset, 
> >> >> > will
> >> >> > + * result errors reported via port error reporting sub feature (if 
> >> >> > present).
> >> >> > + */
> >> >> > +static inline int __fpga_port_reset(struct platform_device *pdev)
> >> >> > +{
> >> >> > +   int ret;
> >> >> > +
> >> >> > +   ret = __fpga_port_disable(pdev);
> >> >> > +   if (ret)
> >> >> > +   return ret;
> >> >> > +
> >> >> > +   __fpga_port_enable(pdev);
> >> >> > +
> >> >> > +   return 0;
> >> >> > +}
> >> >> > +
> >> >> > +static inline int fpga_port_reset(struct platform_device *pdev)
> >> >> > +{
> >> >> > +   struct feature_platform_data *pdata = 
> >> >> > dev_get_platdata(&pdev->dev);
> >> >> > +   int ret;
> >> >> > +
> >> >> > +   mutex_lock(&pdata->lock);
> >> >> > +   ret = __fpga_port_reset(pdev);
> >> >> > +   mutex_unlock(&pdata->lock);
> >> >> > +
> >> >> > +   return ret;
> >> >> > +}
> >> >>
> >> >> I'm still scratching my head about how the enumeration code also has
> >> >> code that handles resetting the PL in a FPGA region and
> >> >> enabling/disabling the bridge.  We've discussed this before [1] and I
> >> >> know you've looked into it, I'm still trying to figure out how this
> >> >> can be made modular, so when someone needs to support a different port
> >> >> in the future, it isn't a complete rewrite.
> >> >>
> >> >> Speaking of resets, one way forward would be to create a reset
> >> >> controller for the port (and if possible move the port code to the
> >> >> bridge platform driver).  The current linux-next repo adds support for
> >> >> reset lookups, so that reset controllers are supported for non-DT
> >> >> platforms [2].
> >> >>
> >> >> So the bridge driver would implement the enable/disable functions and
> >> >> create a reset controller, the fpga-region (or whoever else needs it)
> >> >> could look the reset controller and use the reset.  By using the
> >> >> kernel reset framework, we don't have to have that piece of code
> >> >> shared around by having a reset function in a .h file.  And it avoids
> >> >> adding extra dependencies between modules.  Also, where necessary, I'd
> >> >> rather add functionality to the existing bridge/mgr/region frameworks,
> >> >> adding common interfaces at that level to allow reuse (like adding
> >> >> status to fpga-mgr).  Ideally, this DFL framework would sit on top of
> >> >> mgr and bridge and allow those to be swapped out for reuse of the DFL
> >> >> framework on other devices.  Also it will save future headaches as mgr
> >> >> or port implementations evolve.
> >> >
> >> > Thanks a lot for the suggestion. I really really appreciate this.
> >>
> >> Yes, this is a good discussion, thanks.
> >>
> >> >
> >> > Actually if we consider the virutalization case as I mentioned in [1] 
> >> > below,
> >> > that means AFU and its Port will be turned into a PCI VF and assigned 
> >> > (passed
> >> > through) to a virtual machine. There is no FME block on that PCI VF 
> >> > device,
> >> > (the FME is always kept in PCI PF device in the host) and currently the 
> >> > bridge
> >> > is created by FME module for PR functionatily. So in the guest virtual 
> >> > machine,
> >> > nobody creates the reset controller actually.
> >> >
> >> > As I mentioned in [1], one possible method is, put these port reset 
> >> > functions to
> >> > AFU (Port) module, and share those functions with FME bridge module.
> >>
> >> Yes, the port reset functions could move into an AFU driver, and th

Re: [PATCH V4 1/2] mmc: sdhci-msm: Add support to store supported vdd-io voltages

2018-04-01 Thread Vijay Viswanath



On 3/29/2018 4:22 AM, Doug Anderson wrote:

Hi,

On Wed, Mar 28, 2018 at 6:08 AM, Vijay Viswanath
 wrote:

During probe check whether the vdd-io regulator of sdhc platform device
can support 1.8V and 3V and store this information as a capability of
platform device.

Signed-off-by: Vijay Viswanath 
---
  drivers/mmc/host/sdhci-msm.c | 35 ++-
  1 file changed, 34 insertions(+), 1 deletion(-)


Since I commented on v2, please copy me for this series going forward.  Thanks.




Will do. Sorry I missed.


diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index c283291..2fcd9010 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -21,6 +21,7 @@
  #include 
  #include 
  #include 
+#include 

  #include "sdhci-pltfm.h"

@@ -81,6 +82,9 @@
  #define CORE_HC_SELECT_IN_HS400(6 << 19)
  #define CORE_HC_SELECT_IN_MASK (7 << 19)

+#define CORE_3_0V_SUPPORT  (1 << 25)
+#define CORE_1_8V_SUPPORT  (1 << 26)
+
  #define CORE_CSR_CDC_CTLR_CFG0 0x130
  #define CORE_SW_TRIG_FULL_CALIBBIT(16)
  #define CORE_HW_AUTOCAL_ENABIT(17)
@@ -148,6 +152,7 @@ struct sdhci_msm_host {
 u32 curr_io_level;
 wait_queue_head_t pwr_irq_wait;
 bool pwr_irq_flag;
+   u32 caps_0;
  };

  static unsigned int msm_get_clock_rate_for_bus_mode(struct sdhci_host *host,
@@ -1103,7 +1108,7 @@ static void sdhci_msm_handle_pwr_irq(struct sdhci_host 
*host, int irq)
 struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
 u32 irq_status, irq_ack = 0;
 int retry = 10;
-   int pwr_state = 0, io_level = 0;
+   u32 pwr_state = 0, io_level = 0;


 irq_status = readl_relaxed(msm_host->core_mem + CORE_PWRCTL_STATUS);
@@ -1313,6 +1318,30 @@ static void sdhci_msm_writeb(struct sdhci_host *host, u8 
val, int reg)
 sdhci_msm_check_power_status(host, req_type);
  }

+static int sdhci_msm_set_regulator_caps(struct sdhci_msm_host *msm_host)


This function always returns 0.  Make it void.



+{
+   struct mmc_host *mmc = msm_host->mmc;
+   struct regulator *supply = mmc->supply.vqmmc;
+   u32 caps = 0;
+
+   if (!IS_ERR(mmc->supply.vqmmc)) {
+   if (regulator_is_supported_voltage(supply, 170, 195))
+   caps |= CORE_1_8V_SUPPORT;
+   if (regulator_is_supported_voltage(supply, 270, 360))
+   caps |= CORE_3_0V_SUPPORT;
+
+   if (!caps)
+   pr_warn("%s: %s: 1.8/3V not supported for vqmmc\n",
+   mmc_hostname(mmc), __func__);


Please remove __func__.  You already have the unique thing to find the
right driver (AKA mmc_hostname(mmc)) and the string itself should be
enough from there.



+   }
+
+   msm_host->caps_0 |= caps;
+   pr_debug("%s: %s: supported caps: 0x%08x\n", mmc_hostname(mmc),
+   __func__, caps);


Same, no need for __func__.




will remove all unnecessary __func__ references.


+
+   return 0;
+}
+
  static const struct of_device_id sdhci_msm_dt_match[] = {
 { .compatible = "qcom,sdhci-msm-v4" },
 {},
@@ -1530,6 +1559,10 @@ static int sdhci_msm_probe(struct platform_device *pdev)
 ret = sdhci_add_host(host);
 if (ret)
 goto pm_runtime_disable;
+   ret = sdhci_msm_set_regulator_caps(msm_host);
+   if (ret)
+   dev_err(&pdev->dev, "Failed to set regulator caps: %d\n",
+   ret);


If you find some reason _not_ to make sdhci_msm_set_regulator_caps()
return "void" as per above, you should actually do something about
this error.  You've used "dev_err" which makes me feel like you
consider this a serious error.  Presumably it should cause the probe
to fail?
>
-Doug



yeah, we don't need to print anything here as a warning is printed in 
sdhci_msm_set_regulator_caps() anyway.


Re: [PATCH 3/3] clk: uniphier: add additional ethernet clock lines for Pro4

2018-04-01 Thread Masahiro Yamada
2018-03-30 18:44 GMT+09:00 Kunihiko Hayashi :
> Pro4 SoC has clock lines for Giga-bit feature and ethernet phy,
> and these are mandatory to activate the ethernet controller. This adds
> support for the clock lines.
>
> Signed-off-by: Kunihiko Hayashi 
> ---


Acked-by: Masahiro Yamada 





-- 
Best Regards
Masahiro Yamada


Re: [PATCH 2/3] clk: uniphier: add SATA clock control support

2018-04-01 Thread Masahiro Yamada
2018-03-30 18:44 GMT+09:00 Kunihiko Hayashi :
> Add clock control for SATA controller on UniPhier SoCs. This adds
> support for PXs2, LD20 and PXs3.
>
> Signed-off-by: Kunihiko Hayashi 
> ---

Acked-by: Masahiro Yamada 





-- 
Best Regards
Masahiro Yamada


Re: [PATCH v2] staging: mt7621-eth: Fix sparse warning in ethtool.c

2018-04-01 Thread NeilBrown
On Mon, Apr 02 2018, Sean Wang wrote:

> On Mon, 2018-04-02 at 09:34 +1000, NeilBrown wrote:
>> On Thu, Mar 29 2018, Chris Coffey wrote:
>> 
>> > This fixes the following sparse warning:
>> >
>> > drivers/staging/mt7621-eth/ethtool.c:213:6: warning: symbol
>> > 'mtk_set_ethtool_ops' was not declared. Should it be static?
>> >
>> > Signed-off-by: Chris Coffey 
>> 
>> Reviewed-by: NeilBrown 
>> 
>> Thanks,
>> NeilBrown
>> 
> Hi, Neil
>
> Forgive me I cannot find the cover letter in the original series in my
> mailbox to make a reply, so I rudely made here just letting you know
> something good to the growth of mt7621 support in upstream.
>
> do you have maintained an out-of-tree branch to boot the mt7621 machine
> with those staging patches?

I can boot v4.16 plus staging-next on my mt7621 with no other patches.
An important fix (a63d706ea71919) landed in 4.16-rc7.

It do have
  https://github.com/neilbrown/linux/commits/gnubee/v4.15

which was part of preparation for this, but now that very nearly all I
need is in mainline or on its way, I won't be doing much more in that
tree.

>
> If so, it would become a bit easier for me that maybe I could give a
> hand for migrating these staging driver for mt7621 to mainline. I
> thought mmc, pci, ethernet, gsw and hsdma all could probably reuse the
> current mainline code.

I agree that it is quite likely that several of these drivers could and
should reuse current mainline code.  I would love to have some help
sorting this out.  I won't have much time myself to dig into it for
several weeks, but I'll make time to review and test any code that is
contributed.

Thanks,
NeilBrown


signature.asc
Description: PGP signature


Re: [PATCH 2/2] reset: uniphier: add SATA reset control support and change SATA-PHY ID

2018-04-01 Thread Masahiro Yamada
2018-03-30 18:44 GMT+09:00 Kunihiko Hayashi :
> Add reset lines for SATA controller on UniPhier SoCs.
> This adds support for Pro4 and PXs3 in addition to PXs2.
>
> And this changes the ID of the reset line for SATA-PHY on PXs2.
> Since some SoCs have two controller instances with a common PHY, this moves
> the ID of SATA-PHY for consistency.
>
> Signed-off-by: Kunihiko Hayashi 
> ---

Acked-by: Masahiro Yamada 






-- 
Best Regards
Masahiro Yamada


Re: [PATCH 1/3] clk: uniphier: add PCIe clock control support

2018-04-01 Thread Masahiro Yamada
2018-03-30 18:44 GMT+09:00 Kunihiko Hayashi :
> Add clock control for PCIe controller on UniPhier SoCs. This adds
> support for Pro5, LD20 and PXs3.
>
> Signed-off-by: Kunihiko Hayashi 
> ---


Acked-by: Masahiro Yamada 






-- 
Best Regards
Masahiro Yamada


Re: [PATCH 1/2] reset: uniphier: add PCIe reset control support

2018-04-01 Thread Masahiro Yamada
2018-03-30 18:44 GMT+09:00 Kunihiko Hayashi :
> Add reset lines for PCIe controller on UniPhier SoCs. This adds support for
> Pro5, LD20 and PXs3.
>
> Signed-off-by: Kunihiko Hayashi 
> ---



Acked-by: Masahiro Yamada 



-- 
Best Regards
Masahiro Yamada


[PATCH v2 2/2] x86/mce: add CMCI support for centaur CPUs

2018-04-01 Thread David Wang
This patch is used to tell the kernel that newer Centaur CPU support CMCI.

Signed-off-by: David Wang 
---
 arch/x86/kernel/cpu/mcheck/mce.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index c3db7ce..361d95e 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -1751,6 +1751,7 @@ static void __mcheck_cpu_init_vendor(struct cpuinfo_x86 
*c)
 {
switch (c->x86_vendor) {
case X86_VENDOR_INTEL:
+   case X86_VENDOR_CENTAUR:
mce_intel_feature_init(c);
mce_adjust_timer = cmci_intel_adjust_timer;
break;
-- 
1.9.1



[PATCH v2 0/2] MCA support on Centaur CPU

2018-04-01 Thread David Wang
This patch set is to provide MCA support on new Centaur CPU.

The first patch is used to tell the kernel that newer Centaur CPU
support MCE broadcasting.

The second patch is used to tell the kernel that newer Centaur
CPU support CMCI.

Changes from v1 to v2:
* Capatilize 'Centaur' in the comments

David Wang (2):
  x86/mce: new Centaur CPUs support MCE broadcasting
  x86/mce: add CMCI support for centaur CPUs

 arch/x86/kernel/cpu/mcheck/mce.c | 12 
 1 file changed, 12 insertions(+)

-- 
1.9.1



[PATCH v2 1/2] x86/mce: new Centaur CPUs support MCE broadcasting

2018-04-01 Thread David Wang
This patch is used to tell the kernel that newer Centaur CPU support
MCE broadcasting.

Signed-off-by: David Wang 
---
 arch/x86/kernel/cpu/mcheck/mce.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 7065846..c3db7ce 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -1688,6 +1688,17 @@ static int __mcheck_cpu_apply_quirks(struct cpuinfo_x86 
*c)
if (c->x86 == 6 && c->x86_model == 45)
quirk_no_way_out = quirk_sandybridge_ifu;
}
+
+   if (c->x86_vendor == X86_VENDOR_CENTAUR) {
+   /*
+* All newer Centaur CPUs support MCE broadcasting. Enable
+* synchronization with a one second timeout.
+*/
+   if ((c->x86 > 6 || (c->x86 == 6 && c->x86_model == 0xf && 
c->x86_mask >=0xe)) &&
+   cfg->monarch_timeout < 0)
+   cfg->monarch_timeout = USEC_PER_SEC;
+   }
+
if (cfg->monarch_timeout < 0)
cfg->monarch_timeout = 0;
if (cfg->bootlog != 0)
-- 
1.9.1



[PATCH v3 2/2] net: mvneta: improve suspend/resume

2018-04-01 Thread Jisheng Zhang
Current suspend/resume implementation reuses the mvneta_open() and
mvneta_close(), but it could be optimized to take only necessary
actions during suspend/resume.

One obvious problem of current implementation is: after hundreds of
system suspend/resume cycles, the resume of mvneta could fail due to
fragmented dma coherent memory. After this patch, the non-necessary
memory alloc/free is optimized out.

Signed-off-by: Jisheng Zhang 
---
 drivers/net/ethernet/marvell/mvneta.c | 69 +++
 1 file changed, 62 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c 
b/drivers/net/ethernet/marvell/mvneta.c
index f96815853108..8999a9a52ca2 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -4586,16 +4586,45 @@ static int mvneta_remove(struct platform_device *pdev)
 #ifdef CONFIG_PM_SLEEP
 static int mvneta_suspend(struct device *device)
 {
+   int queue;
struct net_device *dev = dev_get_drvdata(device);
struct mvneta_port *pp = netdev_priv(dev);
 
+   if (!netif_running(dev))
+   goto clean_exit;
+
+   if (!pp->neta_armada3700) {
+   spin_lock(&pp->lock);
+   pp->is_stopped = true;
+   spin_unlock(&pp->lock);
+
+   cpuhp_state_remove_instance_nocalls(online_hpstate,
+   &pp->node_online);
+   cpuhp_state_remove_instance_nocalls(CPUHP_NET_MVNETA_DEAD,
+   &pp->node_dead);
+   }
+
rtnl_lock();
-   if (netif_running(dev))
-   mvneta_stop(dev);
+   mvneta_stop_dev(pp);
rtnl_unlock();
+
+   for (queue = 0; queue < rxq_number; queue++) {
+   struct mvneta_rx_queue *rxq = &pp->rxqs[queue];
+
+   mvneta_rxq_drop_pkts(pp, rxq);
+   }
+
+   for (queue = 0; queue < txq_number; queue++) {
+   struct mvneta_tx_queue *txq = &pp->txqs[queue];
+
+   mvneta_txq_hw_deinit(pp, txq);
+   }
+
+clean_exit:
netif_device_detach(dev);
clk_disable_unprepare(pp->clk_bus);
clk_disable_unprepare(pp->clk);
+
return 0;
 }
 
@@ -4604,7 +4633,7 @@ static int mvneta_resume(struct device *device)
struct platform_device *pdev = to_platform_device(device);
struct net_device *dev = dev_get_drvdata(device);
struct mvneta_port *pp = netdev_priv(dev);
-   int err;
+   int err, queue;
 
clk_prepare_enable(pp->clk);
if (!IS_ERR(pp->clk_bus))
@@ -4626,12 +4655,38 @@ static int mvneta_resume(struct device *device)
}
 
netif_device_attach(dev);
-   rtnl_lock();
-   if (netif_running(dev)) {
-   mvneta_open(dev);
-   mvneta_set_rx_mode(dev);
+
+   if (!netif_running(dev))
+   return 0;
+
+   for (queue = 0; queue < rxq_number; queue++) {
+   struct mvneta_rx_queue *rxq = &pp->rxqs[queue];
+
+   rxq->next_desc_to_proc = 0;
+   mvneta_rxq_hw_init(pp, rxq);
+   }
+
+   for (queue = 0; queue < txq_number; queue++) {
+   struct mvneta_tx_queue *txq = &pp->txqs[queue];
+
+   txq->next_desc_to_proc = 0;
+   mvneta_txq_hw_init(pp, txq);
}
+
+   if (!pp->neta_armada3700) {
+   spin_lock(&pp->lock);
+   pp->is_stopped = false;
+   spin_unlock(&pp->lock);
+   cpuhp_state_add_instance_nocalls(online_hpstate,
+&pp->node_online);
+   cpuhp_state_add_instance_nocalls(CPUHP_NET_MVNETA_DEAD,
+&pp->node_dead);
+   }
+
+   rtnl_lock();
+   mvneta_start_dev(pp);
rtnl_unlock();
+   mvneta_set_rx_mode(dev);
 
return 0;
 }
-- 
2.16.3



[PATCH v3 1/2] net: mvneta: split rxq/txq init and txq deinit into SW and HW parts

2018-04-01 Thread Jisheng Zhang
This is to prepare the suspend/resume improvement in next patch. The
SW parts can be optimized out during resume.

As for rxq handling during suspend, we'd like to drop packets by
calling mvneta_rxq_drop_pkts() which is both SW and HW operation,
so we don't split rxq deinit.

Signed-off-by: Jisheng Zhang 
---
 drivers/net/ethernet/marvell/mvneta.c | 85 +++
 1 file changed, 66 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c 
b/drivers/net/ethernet/marvell/mvneta.c
index 30aab9bf77cc..f96815853108 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -2796,10 +2796,8 @@ static void mvneta_rx_reset(struct mvneta_port *pp)
 
 /* Rx/Tx queue initialization/cleanup methods */
 
-/* Create a specified RX queue */
-static int mvneta_rxq_init(struct mvneta_port *pp,
-  struct mvneta_rx_queue *rxq)
-
+static int mvneta_rxq_sw_init(struct mvneta_port *pp,
+ struct mvneta_rx_queue *rxq)
 {
rxq->size = pp->rx_ring_size;
 
@@ -2812,6 +2810,12 @@ static int mvneta_rxq_init(struct mvneta_port *pp,
 
rxq->last_desc = rxq->size - 1;
 
+   return 0;
+}
+
+static void mvneta_rxq_hw_init(struct mvneta_port *pp,
+  struct mvneta_rx_queue *rxq)
+{
/* Set Rx descriptors queue starting address */
mvreg_write(pp, MVNETA_RXQ_BASE_ADDR_REG(rxq->id), rxq->descs_phys);
mvreg_write(pp, MVNETA_RXQ_SIZE_REG(rxq->id), rxq->size);
@@ -2835,6 +2839,20 @@ static int mvneta_rxq_init(struct mvneta_port *pp,
mvneta_rxq_short_pool_set(pp, rxq);
mvneta_rxq_non_occup_desc_add(pp, rxq, rxq->size);
}
+}
+
+/* Create a specified RX queue */
+static int mvneta_rxq_init(struct mvneta_port *pp,
+  struct mvneta_rx_queue *rxq)
+
+{
+   int ret;
+
+   ret = mvneta_rxq_sw_init(pp, rxq);
+   if (ret < 0)
+   return ret;
+
+   mvneta_rxq_hw_init(pp, rxq);
 
return 0;
 }
@@ -2857,9 +2875,8 @@ static void mvneta_rxq_deinit(struct mvneta_port *pp,
rxq->descs_phys= 0;
 }
 
-/* Create and initialize a tx queue */
-static int mvneta_txq_init(struct mvneta_port *pp,
-  struct mvneta_tx_queue *txq)
+static int mvneta_txq_sw_init(struct mvneta_port *pp,
+ struct mvneta_tx_queue *txq)
 {
int cpu;
 
@@ -2872,7 +2889,6 @@ static int mvneta_txq_init(struct mvneta_port *pp,
txq->tx_stop_threshold = txq->size - MVNETA_MAX_SKB_DESCS;
txq->tx_wake_threshold = txq->tx_stop_threshold / 2;
 
-
/* Allocate memory for TX descriptors */
txq->descs = dma_alloc_coherent(pp->dev->dev.parent,
txq->size * MVNETA_DESC_ALIGNED_SIZE,
@@ -2882,14 +2898,6 @@ static int mvneta_txq_init(struct mvneta_port *pp,
 
txq->last_desc = txq->size - 1;
 
-   /* Set maximum bandwidth for enabled TXQs */
-   mvreg_write(pp, MVETH_TXQ_TOKEN_CFG_REG(txq->id), 0x03ff);
-   mvreg_write(pp, MVETH_TXQ_TOKEN_COUNT_REG(txq->id), 0x3fff);
-
-   /* Set Tx descriptors queue starting address */
-   mvreg_write(pp, MVNETA_TXQ_BASE_ADDR_REG(txq->id), txq->descs_phys);
-   mvreg_write(pp, MVNETA_TXQ_SIZE_REG(txq->id), txq->size);
-
txq->tx_skb = kmalloc_array(txq->size, sizeof(*txq->tx_skb),
GFP_KERNEL);
if (!txq->tx_skb) {
@@ -2910,7 +2918,6 @@ static int mvneta_txq_init(struct mvneta_port *pp,
  txq->descs, txq->descs_phys);
return -ENOMEM;
}
-   mvneta_tx_done_pkts_coal_set(pp, txq, txq->done_pkts_coal);
 
/* Setup XPS mapping */
if (txq_number > 1)
@@ -2923,9 +2930,38 @@ static int mvneta_txq_init(struct mvneta_port *pp,
return 0;
 }
 
+static void mvneta_txq_hw_init(struct mvneta_port *pp,
+  struct mvneta_tx_queue *txq)
+{
+   /* Set maximum bandwidth for enabled TXQs */
+   mvreg_write(pp, MVETH_TXQ_TOKEN_CFG_REG(txq->id), 0x03ff);
+   mvreg_write(pp, MVETH_TXQ_TOKEN_COUNT_REG(txq->id), 0x3fff);
+
+   /* Set Tx descriptors queue starting address */
+   mvreg_write(pp, MVNETA_TXQ_BASE_ADDR_REG(txq->id), txq->descs_phys);
+   mvreg_write(pp, MVNETA_TXQ_SIZE_REG(txq->id), txq->size);
+
+   mvneta_tx_done_pkts_coal_set(pp, txq, txq->done_pkts_coal);
+}
+
+/* Create and initialize a tx queue */
+static int mvneta_txq_init(struct mvneta_port *pp,
+  struct mvneta_tx_queue *txq)
+{
+   int ret;
+
+   ret = mvneta_txq_sw_init(pp, txq);
+   if (ret < 0)
+   return ret;
+
+   mvneta_txq_hw_init(pp, txq);
+
+   return 0;
+}
+
 /* Free allocated resources when mvneta_txq_init() fails to allocate memory*/
-static void mvneta_txq_deinit(struct mvneta_port *pp,
-

[PATCH v3 0/2] net: mvneta: improve suspend/resume

2018-04-01 Thread Jisheng Zhang
This series tries to optimize the mvneta's suspend/resume
implementation by only taking necessary actions.

Since v2:
 - keep rtnl lock when calling mvneta_start_dev() and mvneta_stop_dev()
   Thank Russell for pointing this out

Since v1:
 - unify ret check
 - try best to keep the suspend/resume behavior
 - split txq deinit into sw/hw parts as well
 - adjust mvneta_stop_dev() location

I didn't add Thomas's Ack tag to patch1, because in v2, I add new code
to split the txq deinit into two parts.

Jisheng Zhang (2):
  net: mvneta: split rxq/txq init and txq deinit into SW and HW parts
  net: mvneta: improve suspend/resume

 drivers/net/ethernet/marvell/mvneta.c | 154 --
 1 file changed, 128 insertions(+), 26 deletions(-)

-- 
2.16.3



[lkp-robot] [list_lru] 42658d54ce: BUG:unable_to_handle_kernel

2018-04-01 Thread kernel test robot

FYI, we noticed the following commit (built with gcc-7):

commit: 42658d54ce4d9c25c8a286651c60cbc869f2f91e ("list_lru: Add memcg argument 
to list_lru_from_kmem()")
url: 
https://github.com/0day-ci/linux/commits/Kirill-Tkhai/Improve-shrink_slab-scalability-old-complexity-was-O-n-2-new-is-O-n/20180323-052754
base: git://git.cmpxchg.org/linux-mmotm.git master

in testcase: boot

on test machine: qemu-system-x86_64 -enable-kvm -cpu Haswell,+smep,+smap -smp 2 
-m 512M

caused below changes (please refer to attached dmesg/kmsg for entire 
log/backtrace):


+--+++
|  | 7f23acedf7 | 42658d54ce |
+--+++
| boot_successes   | 10 | 0  |
| boot_failures| 0  | 19 |
| BUG:unable_to_handle_kernel  | 0  | 19 |
| Oops:#[##]   | 0  | 19 |
| RIP:list_lru_add | 0  | 19 |
| Kernel_panic-not_syncing:Fatal_exception | 0  | 19 |
+--+++



[  465.702558] BUG: unable to handle kernel NULL pointer dereference at 

[  465.721123] PGD 80001740e067 P4D 80001740e067 PUD 1740f067 PMD 0 
[  465.737033] Oops: 0002 [#1] PTI
[  465.744456] CPU: 0 PID: 163 Comm: rc.local Not tainted 
4.16.0-rc5-mm1-00298-g42658d5 #1
[  465.760374] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.10.2-1 04/01/2014
[  465.773920] RIP: 0010:list_lru_add+0x1e/0x70
[  465.780850] RSP: 0018:c90001f0fe18 EFLAGS: 00010246
[  465.791551] RAX: 88001a1f16f0 RBX: 8801a508 RCX: 0001
[  465.806362] RDX:  RSI: 8801a520 RDI: 0246
[  465.821265] RBP: c90001f0fe28 R08:  R09: 0001
[  465.836206] R10: c90001f0fd88 R11: 0001 R12: 88001a1f16f0
[  465.850706] R13: 82c213d8 R14: 811aa4d5 R15: 88001a1f15f0
[  465.865285] FS:  7fccddf45700() GS:82e3f000() 
knlGS:
[  465.881839] CS:  0010 DS:  ES:  CR0: 80050033
[  465.893412] CR2:  CR3: 17868004 CR4: 000206f0
[  465.907019] Call Trace:
[  465.911369]  d_lru_add+0x37/0x40
[  465.917037]  dput+0x181/0x1d0
[  465.95]  __fput+0x1a7/0x1c0
[  465.928052]  fput+0x9/0x10
[  465.933601]  task_work_run+0x84/0xc0
[  465.940404]  exit_to_usermode_loop+0x4e/0x80
[  465.948013]  do_syscall_64+0x179/0x190
[  465.954817]  entry_SYSCALL_64_after_hwframe+0x42/0xb7
[  465.963476] RIP: 0033:0x7fccdd625040
[  465.969435] RSP: 002b:7fff689ff258 EFLAGS: 0246 ORIG_RAX: 
0003
[  465.981362] RAX:  RBX: 006f1c08 RCX: 7fccdd625040
[  465.993162] RDX: fbada408 RSI: 0001 RDI: 0003
[  466.005567] RBP:  R08: 0078 R09: 0100
[  466.018316] R10: 0008 R11: 0246 R12: 
[  466.030899] R13: 0046e150 R14: 04f0 R15: 0001
[  466.043602] Code: c3 66 90 66 2e 0f 1f 84 00 00 00 00 00 55 48 89 e5 41 54 
53 48 8b 1f 49 89 f4 48 89 df e8 db f6 f5 00 49 8b 04 24 49 39 c4 75 3d <48> c7 
04 25 00 00 00 00 00 00 00 00 48 8b 43 50 48 8d 53 48 4c 
[  466.077316] RIP: list_lru_add+0x1e/0x70 RSP: c90001f0fe18
[  466.087943] CR2: 
[  466.094137] ---[ end trace aeec590ab6dccbb2 ]---


To reproduce:

git clone https://github.com/intel/lkp-tests.git
cd lkp-tests
bin/lkp qemu -k  job-script  # job-script is attached in this 
email



Thanks,
Xiaolong
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86_64 4.16.0-rc5-mm1 Kernel Configuration
#
CONFIG_64BIT=y
CONFIG_X86_64=y
CONFIG_X86=y
CONFIG_INSTRUCTION_DECODER=y
CONFIG_OUTPUT_FORMAT="elf64-x86-64"
CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig"
CONFIG_LOCKDEP_SUPPORT=y
CONFIG_STACKTRACE_SUPPORT=y
CONFIG_MMU=y
CONFIG_ARCH_MMAP_RND_BITS_MIN=28
CONFIG_ARCH_MMAP_RND_BITS_MAX=32
CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=8
CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=16
CONFIG_NEED_DMA_MAP_STATE=y
CONFIG_NEED_SG_DMA_LENGTH=y
CONFIG_GENERIC_BUG=y
CONFIG_GENERIC_BUG_RELATIVE_POINTERS=y
CONFIG_GENERIC_HWEIGHT=y
CONFIG_RWSEM_XCHGADD_ALGORITHM=y
CONFIG_GENERIC_CALIBRATE_DELAY=y
CONFIG_ARCH_HAS_CPU_RELAX=y
CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y
CONFIG_HAVE_SETUP_PER_CPU_AREA=y
CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK=y
CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y
CONFIG_ARCH_HIBERNATION_POSSIBLE=y
CONFIG_ARCH_SUSPEND_POSSIBLE=y
CONFIG_ARCH_WANT_HUGE_PMD_SHARE=y
CONFIG_ARCH_WANT_GENERAL_HUGETLB=y
CONFIG_ZONE_DMA32=y
CONFIG_AUDIT_ARCH=y
CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y
CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
CONFIG_ARCH_SUPPORTS_UP

Re: [PATCH v2] staging: mt7621-eth: Fix sparse warning in ethtool.c

2018-04-01 Thread Sean Wang
On Mon, 2018-04-02 at 09:34 +1000, NeilBrown wrote:
> On Thu, Mar 29 2018, Chris Coffey wrote:
> 
> > This fixes the following sparse warning:
> >
> > drivers/staging/mt7621-eth/ethtool.c:213:6: warning: symbol
> > 'mtk_set_ethtool_ops' was not declared. Should it be static?
> >
> > Signed-off-by: Chris Coffey 
> 
> Reviewed-by: NeilBrown 
> 
> Thanks,
> NeilBrown
> 
Hi, Neil

Forgive me I cannot find the cover letter in the original series in my
mailbox to make a reply, so I rudely made here just letting you know
something good to the growth of mt7621 support in upstream.

do you have maintained an out-of-tree branch to boot the mt7621 machine
with those staging patches?

If so, it would become a bit easier for me that maybe I could give a
hand for migrating these staging driver for mt7621 to mainline. I
thought mmc, pci, ethernet, gsw and hsdma all could probably reuse the
current mainline code.

Sean
> 
> > ---
> > Changes in v2:
> >  - Per GregKH's feedback (thanks!), don't add unnecessary new .h file
> >  dependencies. This patch version reverts those changes and fixes the
> >  problem directly in ethtool.c (which is that it didn't include
> >  ethtool.h anywhere -- mtk_set_ethtool_ops is not static).
> >
> >  drivers/staging/mt7621-eth/ethtool.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/staging/mt7621-eth/ethtool.c 
> > b/drivers/staging/mt7621-eth/ethtool.c
> > index 38ba0c040a..5268c5ca09 100644
> > --- a/drivers/staging/mt7621-eth/ethtool.c
> > +++ b/drivers/staging/mt7621-eth/ethtool.c
> > @@ -13,6 +13,7 @@
> >   */
> >  
> >  #include "mtk_eth_soc.h"
> > +#include "ethtool.h"
> >  
> >  static const char mtk_gdma_str[][ETH_GSTRING_LEN] = {
> >  #define _FE(x...)  # x,
> > -- 
> > 2.11.0
> ___
> Linux-mediatek mailing list
> linux-media...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-mediatek




Re: [Qemu-devel] [RFC] About 9pfs support "O_DIRECT + aio"?

2018-04-01 Thread Paolo Bonzini
On 30/03/2018 10:53, jiangyiwen wrote:
> Currently, I found virtio-9p in VirtFS don't support "O_DIRECT + aio"
> mode, both v9fs and qemu. So when user use "O_DIRECT + aio" mode and
> increase iodepths, they can't get higher IOPS.
> 
> I want to know why v9fs don't implement this mode? And I will try to
> implement this mode from now on.

Can you explain?  I think 9p has support for direct I/O in Linux.  See
v9fs_direct_IO in fs/9p/vfs_addr.c.

Paolo


Re: [PATCH v2] scsi: Introduce sdev_printk_ratelimited to throttle frequent printk

2018-04-01 Thread Jason Yan

Hi, Yang,

On 2018/4/2 9:58, Wen Yang wrote:

There would be so many same lines printed by frequent printk if one
disk went wrong, like,
[  546.185242] sd 0:1:0:0: rejecting I/O to offline device
[  546.185258] sd 0:1:0:0: rejecting I/O to offline device
[  546.185280] sd 0:1:0:0: rejecting I/O to offline device
[  546.185307] sd 0:1:0:0: rejecting I/O to offline device
[  546.185334] sd 0:1:0:0: rejecting I/O to offline device
[  546.185364] sd 0:1:0:0: rejecting I/O to offline device
[  546.185390] sd 0:1:0:0: rejecting I/O to offline device
[  546.185410] sd 0:1:0:0: rejecting I/O to offline device
For slow serial console, the frequent printk may be blocked for a
long time, and if any spin_lock has been acquired before the printk
like in scsi_request_fn, watchdog could be triggered.

Related disscussion can be found here,
https://bugzilla.kernel.org/show_bug.cgi?id=199003
And Petr brought the idea to throttle the frequent printk, it's
useless to print the same lines frequently after all.



It's true that this print for the same device is useless. But it's
useful for different devices. Is it possible to limit the print only
for the same device?

Thanks,

Jason








[PATCH] mm/migrate: properly preserve write attribute in special migrate entry

2018-04-01 Thread jglisse
From: Ralph Campbell 

Use of pte_write(pte) is only valid for present pte, the common code
which set the migration entry can be reach for both valid present
pte and special swap entry (for device memory). Fix the code to use
the mpfn value which properly handle both cases.

On x86 this did not have any bad side effect because pte write bit
is below PAGE_BIT_GLOBAL and thus special swap entry have it set to
0 which in turn means we were always creating read only special
migration entry.

So once migration did finish we always write protected the CPU page
table entry (moreover this is only an issue when migrating from device
memory to system memory). End effect is that CPU write access would
fault again and restore write permission.

Signed-off-by: Ralph Campbell 
Signed-off-by: Jérôme Glisse 
---
 mm/migrate.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/migrate.c b/mm/migrate.c
index 5d0dc7b85f90..a5c559d8e0e7 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -2269,7 +2269,8 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp,
ptep_get_and_clear(mm, addr, ptep);
 
/* Setup special migration page table entry */
-   entry = make_migration_entry(page, pte_write(pte));
+   entry = make_migration_entry(page, mpfn &
+MIGRATE_PFN_WRITE);
swp_pte = swp_entry_to_pte(entry);
if (pte_soft_dirty(pte))
swp_pte = pte_swp_mksoft_dirty(swp_pte);
-- 
2.14.3



[PATCH v5 5/5] mm: page_alloc: reduce unnecessary binary search in early_pfn_valid()

2018-04-01 Thread Jia He
Commit b92df1de5d28 ("mm: page_alloc: skip over regions of invalid pfns
where possible") optimized the loop in memmap_init_zone(). But there is
still some room for improvement. E.g. in early_pfn_valid(), if pfn and
pfn+1 are in the same memblock region, we can record the last returned
memblock region index and check check pfn++ is still in the same region.

Currently it only improve the performance on arm64 and will have no
impact on other arches.

Signed-off-by: Jia He 
---
 include/linux/mmzone.h | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index f9c0c46..079f468 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1268,9 +1268,14 @@ static inline int pfn_present(unsigned long pfn)
 })
 #else
 #define pfn_to_nid(pfn)(0)
-#endif
+#endif /*CONFIG_NUMA*/
 
+#ifdef CONFIG_HAVE_ARCH_PFN_VALID
+#define early_pfn_valid(pfn) pfn_valid_region(pfn)
+#else
 #define early_pfn_valid(pfn)   pfn_valid(pfn)
+#endif /*CONFIG_HAVE_ARCH_PFN_VALID*/
+
 void sparse_init(void);
 #else
 #define sparse_init()  do {} while (0)
-- 
2.7.4



[PATCH v5 4/5] arm64: introduce pfn_valid_region()

2018-04-01 Thread Jia He
This is the preparation for further optimizing in early_pfn_valid
on arm and arm64.

Signed-off-by: Jia He 
---
 arch/arm/include/asm/page.h   |  3 ++-
 arch/arm/mm/init.c| 24 
 arch/arm64/include/asm/page.h |  3 ++-
 arch/arm64/mm/init.c  | 24 
 4 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
index f38909c..3bd810e 100644
--- a/arch/arm/include/asm/page.h
+++ b/arch/arm/include/asm/page.h
@@ -158,9 +158,10 @@ typedef struct page *pgtable_t;
 
 #ifdef CONFIG_HAVE_ARCH_PFN_VALID
 extern int early_region_idx;
-extern int pfn_valid(unsigned long);
+extern int pfn_valid(unsigned long pfn);
 extern unsigned long memblock_next_valid_pfn(unsigned long pfn);
 #define skip_to_last_invalid_pfn(pfn) (memblock_next_valid_pfn(pfn) - 1)
+extern int pfn_valid_region(unsigned long pfn);
 #endif
 
 #include 
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 06ed190..bdcbf58 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -201,6 +201,30 @@ int pfn_valid(unsigned long pfn)
 }
 EXPORT_SYMBOL(pfn_valid);
 
+int pfn_valid_region(unsigned long pfn)
+{
+   unsigned long start_pfn, end_pfn;
+   struct memblock_type *type = &memblock.memory;
+   struct memblock_region *regions = type->regions;
+
+   if (early_region_idx != -1) {
+   start_pfn = PFN_DOWN(regions[early_region_idx].base);
+   end_pfn = PFN_DOWN(regions[early_region_idx].base +
+   regions[early_region_idx].size);
+
+   if (pfn >= start_pfn && pfn < end_pfn)
+   return !memblock_is_nomap(
+   ®ions[early_region_idx]);
+   }
+
+   early_region_idx = memblock_search_pfn_regions(pfn);
+   if (early_region_idx == -1)
+   return false;
+
+   return !memblock_is_nomap(®ions[early_region_idx]);
+}
+EXPORT_SYMBOL(pfn_valid_region);
+
 /* HAVE_MEMBLOCK is always enabled on arm */
 unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn)
 {
diff --git a/arch/arm64/include/asm/page.h b/arch/arm64/include/asm/page.h
index f0d8c8e5..7087b63 100644
--- a/arch/arm64/include/asm/page.h
+++ b/arch/arm64/include/asm/page.h
@@ -39,9 +39,10 @@ typedef struct page *pgtable_t;
 
 #ifdef CONFIG_HAVE_ARCH_PFN_VALID
 extern int early_region_idx;
-extern int pfn_valid(unsigned long);
+extern int pfn_valid(unsigned long pfn);
 extern unsigned long memblock_next_valid_pfn(unsigned long pfn);
 #define skip_to_last_invalid_pfn(pfn) (memblock_next_valid_pfn(pfn) - 1)
+extern int pfn_valid_region(unsigned long pfn);
 #endif
 
 #include 
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 342e4e2..a1646b6 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -293,6 +293,30 @@ int pfn_valid(unsigned long pfn)
 }
 EXPORT_SYMBOL(pfn_valid);
 
+int pfn_valid_region(unsigned long pfn)
+{
+   unsigned long start_pfn, end_pfn;
+   struct memblock_type *type = &memblock.memory;
+   struct memblock_region *regions = type->regions;
+
+   if (early_region_idx != -1) {
+   start_pfn = PFN_DOWN(regions[early_region_idx].base);
+   end_pfn = PFN_DOWN(regions[early_region_idx].base +
+   regions[early_region_idx].size);
+
+   if (pfn >= start_pfn && pfn < end_pfn)
+   return !memblock_is_nomap(
+   ®ions[early_region_idx]);
+   }
+
+   early_region_idx = memblock_search_pfn_regions(pfn);
+   if (early_region_idx == -1)
+   return false;
+
+   return !memblock_is_nomap(®ions[early_region_idx]);
+}
+EXPORT_SYMBOL(pfn_valid_region);
+
 /* HAVE_MEMBLOCK is always enabled on arm64 */
 unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn)
 {
-- 
2.7.4



[PATCH v5 3/5] mm/memblock: introduce memblock_search_pfn_regions()

2018-04-01 Thread Jia He
This api is the preparation for further optimizing early_pfn_valid

Signed-off-by: Jia He 
---
 include/linux/memblock.h | 2 ++
 mm/memblock.c| 9 +
 2 files changed, 11 insertions(+)

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 0257aee..a0127b3 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -203,6 +203,8 @@ void __next_mem_pfn_range(int *idx, int nid, unsigned long 
*out_start_pfn,
 i >= 0; __next_mem_pfn_range(&i, nid, p_start, p_end, p_nid))
 #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
 
+int memblock_search_pfn_regions(unsigned long pfn);
+
 /**
  * for_each_free_mem_range - iterate through free memblock areas
  * @i: u64 used as loop variable
diff --git a/mm/memblock.c b/mm/memblock.c
index ba7c878..0f4004c 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -1617,6 +1617,15 @@ static int __init_memblock memblock_search(struct 
memblock_type *type, phys_addr
return -1;
 }
 
+/* search memblock with the input pfn, return the region idx */
+int __init_memblock memblock_search_pfn_regions(unsigned long pfn)
+{
+   struct memblock_type *type = &memblock.memory;
+   int mid = memblock_search(type, PFN_PHYS(pfn));
+
+   return mid;
+}
+
 bool __init memblock_is_reserved(phys_addr_t addr)
 {
return memblock_search(&memblock.reserved, addr) != -1;
-- 
2.7.4



[PATCH v5 0/5] optimize memblock_next_valid_pfn and early_pfn_valid on arm and arm64

2018-04-01 Thread Jia He
Commit b92df1de5d28 ("mm: page_alloc: skip over regions of invalid pfns
where possible") tried to optimize the loop in memmap_init_zone(). But
there is still some room for improvement.

Patch 1 remain the memblock_next_valid_pfn on arm and arm64
Patch 2 optimizes the memblock_next_valid_pfn()
Patch 3~5 optimizes the early_pfn_valid()

I tested the pfn loop process in memmap_init(), the same as before.
As for the performance improvement, after this set, I can see the time
overhead of memmap_init() is reduced from 41313 us to 24345 us in my
armv8a server(QDF2400 with 96G memory).

Attached the memblock region information in my server.
[   86.956758] Zone ranges:
[   86.959452]   DMA  [mem 0x0020-0x]
[   86.966041]   Normal   [mem 0x0001-0x0017]
[   86.972631] Movable zone start for each node
[   86.977179] Early memory node ranges
[   86.980985]   node   0: [mem 0x0020-0x0021]
[   86.987666]   node   0: [mem 0x0082-0x0307]
[   86.994348]   node   0: [mem 0x0308-0x0308]
[   87.001029]   node   0: [mem 0x0309-0x031f]
[   87.007710]   node   0: [mem 0x0320-0x033f]
[   87.014392]   node   0: [mem 0x0341-0x0563]
[   87.021073]   node   0: [mem 0x0564-0x0567]
[   87.027754]   node   0: [mem 0x0568-0x056d]
[   87.034435]   node   0: [mem 0x056e-0x086f]
[   87.041117]   node   0: [mem 0x0870-0x0871]
[   87.047798]   node   0: [mem 0x0872-0x0894]
[   87.054479]   node   0: [mem 0x0895-0x08ba]
[   87.061161]   node   0: [mem 0x08bb-0x08bc]
[   87.067842]   node   0: [mem 0x08bd-0x08c4]
[   87.074524]   node   0: [mem 0x08c5-0x08e2]
[   87.081205]   node   0: [mem 0x08e3-0x08e4]
[   87.087886]   node   0: [mem 0x08e5-0x08fc]
[   87.094568]   node   0: [mem 0x08fd-0x0910]
[   87.101249]   node   0: [mem 0x0911-0x092e]
[   87.107930]   node   0: [mem 0x092f-0x0930]
[   87.114612]   node   0: [mem 0x0931-0x0963]
[   87.121293]   node   0: [mem 0x0964-0x0e61]
[   87.127975]   node   0: [mem 0x0e62-0x0e64]
[   87.134657]   node   0: [mem 0x0e65-0x0fff]
[   87.141338]   node   0: [mem 0x1080-0x17fe]
[   87.148019]   node   0: [mem 0x1c00-0x1c00]
[   87.154701]   node   0: [mem 0x1c01-0x1c7f]
[   87.161383]   node   0: [mem 0x1c81-0x7efb]
[   87.168064]   node   0: [mem 0x7efc-0x7efd]
[   87.174746]   node   0: [mem 0x7efe-0x7efe]
[   87.181427]   node   0: [mem 0x7eff-0x7eff]
[   87.188108]   node   0: [mem 0x7f00-0x0017]
[   87.194791] Initmem setup node 0 [mem 0x0020-0x0017]

Without this patchset:
[  117.106153] Initmem setup node 0 [mem 0x0020-0x0017]
[  117.113677] before memmap_init
[  117.118195] after  memmap_init
>>> memmap_init takes 4518 us
[  117.121446] before memmap_init
[  117.154992] after  memmap_init
>>> memmap_init takes 33546 us
[  117.158241] before memmap_init
[  117.161490] after  memmap_init
>>> memmap_init takes 3249 us
>>> totally takes 41313 us

With this patchset:
[   87.194791] Initmem setup node 0 [mem 0x0020-0x0017]
[   87.202314] before memmap_init
[   87.206164] after  memmap_init
>>> memmap_init takes 3850 us
[   87.209416] before memmap_init
[   87.226662] after  memmap_init
>>> memmap_init takes 17246 us
[   87.229911] before memmap_init
[   87.233160] after  memmap_init
>>> memmap_init takes 3249 us
>>> totally takes 24345 us

Changelog:
V5: - further refining as suggested by Danial Vacek. Make codes
  arm/arm64 more arch specific
V4: - refine patches as suggested by Danial Vacek and Wei Yang
- optimized on arm besides arm64
V3: - fix 2 issues reported by kbuild test robot
V2: - rebase to mmotm latest
- remain memblock_next_valid_pfn on arm64
- refine memblock_search_pfn_regions and pfn_valid_region

Jia He (5):
  mm: page_alloc: remain memblock_next_valid_pfn() on arm and arm64
  arm: arm64: page_alloc: reduce unnecessary binary search in
memblock_next_valid_pfn()
  mm/memblock: introduce memblock_search_pfn_regions()
  arm64: introduce pfn_valid_region()
  mm: page_alloc: reduce unnecessary binary search in early_pfn_valid()

 arch/arm/include/asm/page.h   |  6 +++-
 arch/arm/mm/init.c| 71 ++-
 arch/arm64/include/asm/page.h |  6 +++-
 ar

[PATCH v5 2/5] arm: arm64: page_alloc: reduce unnecessary binary search in memblock_next_valid_pfn()

2018-04-01 Thread Jia He
Commit b92df1de5d28 ("mm: page_alloc: skip over regions of invalid pfns
where possible") optimized the loop in memmap_init_zone(). But there is
still some room for improvement. E.g. if pfn and pfn+1 are in the same
memblock region, we can simply pfn++ instead of doing the binary search
in memblock_next_valid_pfn.

Signed-off-by: Jia He 
---
 arch/arm/include/asm/page.h   |  1 +
 arch/arm/mm/init.c| 28 ++--
 arch/arm64/include/asm/page.h |  1 +
 arch/arm64/mm/init.c  | 28 ++--
 4 files changed, 46 insertions(+), 12 deletions(-)

diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
index 489875c..f38909c 100644
--- a/arch/arm/include/asm/page.h
+++ b/arch/arm/include/asm/page.h
@@ -157,6 +157,7 @@ extern void copy_page(void *to, const void *from);
 typedef struct page *pgtable_t;
 
 #ifdef CONFIG_HAVE_ARCH_PFN_VALID
+extern int early_region_idx;
 extern int pfn_valid(unsigned long);
 extern unsigned long memblock_next_valid_pfn(unsigned long pfn);
 #define skip_to_last_invalid_pfn(pfn) (memblock_next_valid_pfn(pfn) - 1)
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 0fb85ca..06ed190 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -193,6 +193,8 @@ static void __init zone_sizes_init(unsigned long min, 
unsigned long max_low,
 }
 
 #ifdef CONFIG_HAVE_ARCH_PFN_VALID
+int early_region_idx __meminitdata = -1;
+
 int pfn_valid(unsigned long pfn)
 {
return memblock_is_map_memory(__pfn_to_phys(pfn));
@@ -203,28 +205,42 @@ EXPORT_SYMBOL(pfn_valid);
 unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn)
 {
struct memblock_type *type = &memblock.memory;
+   struct memblock_region *regions = type->regions;
unsigned int right = type->cnt;
unsigned int mid, left = 0;
+   unsigned long start_pfn, end_pfn;
phys_addr_t addr = PFN_PHYS(++pfn);
 
+   /* fast path, return pfn+1 if next pfn is in the same region */
+   if (early_region_idx != -1) {
+   start_pfn = PFN_DOWN(regions[early_region_idx].base);
+   end_pfn = PFN_DOWN(regions[early_region_idx].base +
+   regions[early_region_idx].size);
+
+   if (pfn >= start_pfn && pfn < end_pfn)
+   return pfn;
+   }
+
+   /* slow path, do the binary searching */
do {
mid = (right + left) / 2;
 
-   if (addr < type->regions[mid].base)
+   if (addr < regions[mid].base)
right = mid;
-   else if (addr >= (type->regions[mid].base +
- type->regions[mid].size))
+   else if (addr >= (regions[mid].base + regions[mid].size))
left = mid + 1;
else {
-   /* addr is within the region, so pfn is valid */
+   early_region_idx = mid;
return pfn;
}
} while (left < right);
 
if (right == type->cnt)
return -1UL;
-   else
-   return PHYS_PFN(type->regions[right].base);
+
+   early_region_idx = right;
+
+   return PHYS_PFN(regions[early_region_idx].base);
 }
 EXPORT_SYMBOL(memblock_next_valid_pfn);
 #endif /*CONFIG_HAVE_ARCH_PFN_VALID*/
diff --git a/arch/arm64/include/asm/page.h b/arch/arm64/include/asm/page.h
index e57d3f2..f0d8c8e5 100644
--- a/arch/arm64/include/asm/page.h
+++ b/arch/arm64/include/asm/page.h
@@ -38,6 +38,7 @@ extern void clear_page(void *to);
 typedef struct page *pgtable_t;
 
 #ifdef CONFIG_HAVE_ARCH_PFN_VALID
+extern int early_region_idx;
 extern int pfn_valid(unsigned long);
 extern unsigned long memblock_next_valid_pfn(unsigned long pfn);
 #define skip_to_last_invalid_pfn(pfn) (memblock_next_valid_pfn(pfn) - 1)
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 13e43ff..342e4e2 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -285,6 +285,8 @@ static void __init zone_sizes_init(unsigned long min, 
unsigned long max)
 #endif /* CONFIG_NUMA */
 
 #ifdef CONFIG_HAVE_ARCH_PFN_VALID
+int early_region_idx __meminitdata = -1;
+
 int pfn_valid(unsigned long pfn)
 {
return memblock_is_map_memory(pfn << PAGE_SHIFT);
@@ -295,28 +297,42 @@ EXPORT_SYMBOL(pfn_valid);
 unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn)
 {
struct memblock_type *type = &memblock.memory;
+   struct memblock_region *regions = type->regions;
unsigned int right = type->cnt;
unsigned int mid, left = 0;
+   unsigned long start_pfn, end_pfn;
phys_addr_t addr = PFN_PHYS(++pfn);
 
+   /* fast path, return pfn+1 if next pfn is in the same region */
+   if (early_region_idx != -1) {
+   start_pfn = PFN_DOWN(regions[early_region_idx].base);
+   end_pfn = PFN_DOWN(regions[early_region_idx].base +
+   regi

[PATCH v5 1/5] mm: page_alloc: remain memblock_next_valid_pfn() on arm and arm64

2018-04-01 Thread Jia He
Commit b92df1de5d28 ("mm: page_alloc: skip over regions of invalid pfns
where possible") optimized the loop in memmap_init_zone(). But it causes
possible panic bug. So Daniel Vacek reverted it later.

But as suggested by Daniel Vacek, it is fine to using memblock to skip
gaps and finding next valid frame with CONFIG_HAVE_ARCH_PFN_VALID.

On arm and arm64, memblock is used by default. But generic version of
pfn_valid() is based on mem sections and memblock_next_valid_pfn() does
not always return the next valid one but skips more resulting in some
valid frames to be skipped (as if they were invalid). And that's why
kernel was eventually crashing on some !arm machines.

And as verified by Eugeniu Rosca, arm can benifit from commit
b92df1de5d28. So remain the memblock_next_valid_pfn on arm{,64} and move
the related codes to arm64 arch directory.

Suggested-by: Daniel Vacek 
Signed-off-by: Jia He 
---
 arch/arm/include/asm/page.h   |  2 ++
 arch/arm/mm/init.c| 31 ++-
 arch/arm64/include/asm/page.h |  2 ++
 arch/arm64/mm/init.c  | 31 ++-
 include/linux/mmzone.h|  1 +
 mm/page_alloc.c   |  4 +++-
 6 files changed, 68 insertions(+), 3 deletions(-)

diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
index 4355f0e..489875c 100644
--- a/arch/arm/include/asm/page.h
+++ b/arch/arm/include/asm/page.h
@@ -158,6 +158,8 @@ typedef struct page *pgtable_t;
 
 #ifdef CONFIG_HAVE_ARCH_PFN_VALID
 extern int pfn_valid(unsigned long);
+extern unsigned long memblock_next_valid_pfn(unsigned long pfn);
+#define skip_to_last_invalid_pfn(pfn) (memblock_next_valid_pfn(pfn) - 1)
 #endif
 
 #include 
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index a1f11a7..0fb85ca 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -198,7 +198,36 @@ int pfn_valid(unsigned long pfn)
return memblock_is_map_memory(__pfn_to_phys(pfn));
 }
 EXPORT_SYMBOL(pfn_valid);
-#endif
+
+/* HAVE_MEMBLOCK is always enabled on arm */
+unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn)
+{
+   struct memblock_type *type = &memblock.memory;
+   unsigned int right = type->cnt;
+   unsigned int mid, left = 0;
+   phys_addr_t addr = PFN_PHYS(++pfn);
+
+   do {
+   mid = (right + left) / 2;
+
+   if (addr < type->regions[mid].base)
+   right = mid;
+   else if (addr >= (type->regions[mid].base +
+ type->regions[mid].size))
+   left = mid + 1;
+   else {
+   /* addr is within the region, so pfn is valid */
+   return pfn;
+   }
+   } while (left < right);
+
+   if (right == type->cnt)
+   return -1UL;
+   else
+   return PHYS_PFN(type->regions[right].base);
+}
+EXPORT_SYMBOL(memblock_next_valid_pfn);
+#endif /*CONFIG_HAVE_ARCH_PFN_VALID*/
 
 #ifndef CONFIG_SPARSEMEM
 static void __init arm_memory_present(void)
diff --git a/arch/arm64/include/asm/page.h b/arch/arm64/include/asm/page.h
index 60d02c8..e57d3f2 100644
--- a/arch/arm64/include/asm/page.h
+++ b/arch/arm64/include/asm/page.h
@@ -39,6 +39,8 @@ typedef struct page *pgtable_t;
 
 #ifdef CONFIG_HAVE_ARCH_PFN_VALID
 extern int pfn_valid(unsigned long);
+extern unsigned long memblock_next_valid_pfn(unsigned long pfn);
+#define skip_to_last_invalid_pfn(pfn) (memblock_next_valid_pfn(pfn) - 1)
 #endif
 
 #include 
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 00e7b90..13e43ff 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -290,7 +290,36 @@ int pfn_valid(unsigned long pfn)
return memblock_is_map_memory(pfn << PAGE_SHIFT);
 }
 EXPORT_SYMBOL(pfn_valid);
-#endif
+
+/* HAVE_MEMBLOCK is always enabled on arm64 */
+unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn)
+{
+   struct memblock_type *type = &memblock.memory;
+   unsigned int right = type->cnt;
+   unsigned int mid, left = 0;
+   phys_addr_t addr = PFN_PHYS(++pfn);
+
+   do {
+   mid = (right + left) / 2;
+
+   if (addr < type->regions[mid].base)
+   right = mid;
+   else if (addr >= (type->regions[mid].base +
+ type->regions[mid].size))
+   left = mid + 1;
+   else {
+   /* addr is within the region, so pfn is valid */
+   return pfn;
+   }
+   } while (left < right);
+
+   if (right == type->cnt)
+   return -1UL;
+   else
+   return PHYS_PFN(type->regions[right].base);
+}
+EXPORT_SYMBOL(memblock_next_valid_pfn);
+#endif /*CONFIG_HAVE_ARCH_PFN_VALID*/
 
 #ifndef CONFIG_SPARSEMEM
 static void __init arm64_memory_present(void)
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index d797716..f9c0c

linux-next: Signed-off-by missing for commits in the net-next tree

2018-04-01 Thread Stephen Rothwell
Hi all,

Commits

  45a42bc9cc65 ("Bluetooth: hci_bcm: Remove DMI quirk for the MINIX Z83-4")
  f9b95db0165a ("Bluetooth: btrsi: remove unused including ")
  96e58d368fa6 ("Bluetooth: Set HCI_QUIRK_SIMULTANEOUS_DISCOVERY for 
BTUSB_QCA_ROME")
  9ea471320e13 ("Bluetooth: Mark expected switch fall-throughs")

are missing a Signed-off-by from their committer.

-- 
Cheers,
Stephen Rothwell


pgpThjDSvHOCK.pgp
Description: OpenPGP digital signature


Re: [PATCH v2] MAINTAINERS: update entry for ARM/berlin

2018-04-01 Thread Jisheng Zhang
On Fri, 30 Mar 2018 15:59:32 +0200 Andrew Lunn wrote:

> On Fri, Mar 30, 2018 at 11:02:11AM +0800, Jisheng Zhang wrote:
> > Synaptics has acquired the Multimedia Solutions Business of Marvell[1].
> > So change the berlin entry name and move it to its alphabetical
> > location. We move to ARM/Synaptics instead of ARM/Marvell.
> > 
> > This patch also updates my email address from marvell to synaptics.
> > 
> > [1] https://www.synaptics.com/company/news/conexant-marvell
> > 
> > Signed-off-by: Jisheng Zhang   
> 
> Thanks for the link
> 
> Reviewed-by: Andrew Lunn 
> 
> Do you still plan to move the DT files from the Marvell subdirectory?
> Are the locations of these files considered fixed?
> 

For new SoCs, the DT files will be put into synaptics sub-directory.
But for existing arm64 berlin DT files which currently sits in
arch/arm64/boot/dts/marvell, I dunno the proper solution. Could
you please give some suggestions? How do other vendors handle this
situation in the past?

Thanks in advance,
Jisheng



Get back to me//

2018-04-01 Thread Sgt. Sherri
Hey,
 
I am sorry to encroach into your privacy in this manner, I want to solicit your 
attention to assist me receive two (2) trunk boxes on my behalf.
 
I am an Army officer with the USA Military and currently in Baghdad with the 
Combat Support Squad, US Base Camp, Speicher - Baghdad, Iraq. I am on my 3rd 
deployment to combat war zones. I am also among the squad that will be 
re-deployed to Afghanistan in about a fortnight and in view of this, I
urgently need your help in assisting me receive for safe keeping the two (2) 
trunk boxes containing some monies.
 
The source:
You can visit this links for more details:
http://www.theguardian.com/world/2007/ feb/08/usa.iraq1
http://news.bbc.co.uk/2/hi/7444083.stm
 
If you can be trusted, I will explain further on the modalities on how we'll 
realize the safe shipment of the boxes to you for safe keeping without the 
breach of the law.when i get a response from you.

Sgt. Sherri Gallagher
U.S Army



Re: [PATCH net 0/2] net: bgmac: Couple of sparse warnings

2018-04-01 Thread David Miller
From: Florian Fainelli 
Date: Sun,  1 Apr 2018 10:26:28 -0700

> This patch series fixes a couple of warnings reported by sparse, should not
> cause any functional problems since bgmac is typically used on LE platforms
> anyway.

Series applied, thanks Florian.


Re: [PATCH v2] scsi: Introduce sdev_printk_ratelimited to throttle frequent printk

2018-04-01 Thread Sergey Senozhatsky
Hello,

On (04/02/18 09:58), Wen Yang wrote:
> There would be so many same lines printed by frequent printk if one 
> disk went wrong, like,
> [  546.185242] sd 0:1:0:0: rejecting I/O to offline device
> [  546.185258] sd 0:1:0:0: rejecting I/O to offline device
> [  546.185280] sd 0:1:0:0: rejecting I/O to offline device
> [  546.185307] sd 0:1:0:0: rejecting I/O to offline device
> [  546.185334] sd 0:1:0:0: rejecting I/O to offline device
> [  546.185364] sd 0:1:0:0: rejecting I/O to offline device
> [  546.185390] sd 0:1:0:0: rejecting I/O to offline device
> [  546.185410] sd 0:1:0:0: rejecting I/O to offline device
> For slow serial console, the frequent printk may be blocked for a 
> long time, and if any spin_lock has been acquired before the printk 
> like in scsi_request_fn, watchdog could be triggered.

Did you test the patch? Rate limiting does not completely remove
printk calls. printk is still there, in a loop under spin_lock.
A big enough I/O request queue can cause the same lockup problems.

-ss


Re: INFO: rcu detected stall in vprintk_func

2018-04-01 Thread Sergey Senozhatsky
On (04/02/18 10:54), Sergey Senozhatsky wrote:
> > > If you forward the report, please keep this part and the footer.
> > >
> > > llcp: nfc_llcp_send_ui_frame: Could not allocate PDU
> > > llcp: nfc_llcp_send_ui_frame: Could not allocate PDU
> > > llcp: nfc_llcp_send_ui_frame: Could not allocate PDU
> > > llcp: nfc_llcp_send_ui_frame: Could not allocate PDU

[..]

> diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c
> index ef4026a23e80..a309a27581da 100644
> --- a/net/nfc/llcp_core.c
> +++ b/net/nfc/llcp_core.c
> @@ -1386,7 +1386,7 @@ static void nfc_llcp_recv_agf(struct nfc_llcp_local 
> *local, struct sk_buff *skb)
>  
>   new_skb = nfc_alloc_recv_skb(pdu_len, GFP_KERNEL);
>   if (new_skb == NULL) {
> - pr_err("Could not allocate PDU\n");
> + pr_err_ratelimited("Could not allocate PDU\n");
>   return;
>   }

And of course I ended up patching the wrong function...
What I actually meant was:

---

diff --git a/net/nfc/llcp_commands.c b/net/nfc/llcp_commands.c
index 2ceefa183cee..2f3becb709b8 100644
--- a/net/nfc/llcp_commands.c
+++ b/net/nfc/llcp_commands.c
@@ -755,7 +755,7 @@ int nfc_llcp_send_ui_frame(struct nfc_llcp_sock *sock, u8 
ssap, u8 dsap,
pdu = nfc_alloc_send_skb(sock->dev, &sock->sk, MSG_DONTWAIT,
 frag_len + LLCP_HEADER_SIZE, &err);
if (pdu == NULL) {
-   pr_err("Could not allocate PDU\n");
+   pr_err_ratelimited("Could not allocate PDU\n");
continue;
}
 


[PATCH v2] scsi: Introduce sdev_printk_ratelimited to throttle frequent printk

2018-04-01 Thread Wen Yang
There would be so many same lines printed by frequent printk if one 
disk went wrong, like,
[  546.185242] sd 0:1:0:0: rejecting I/O to offline device
[  546.185258] sd 0:1:0:0: rejecting I/O to offline device
[  546.185280] sd 0:1:0:0: rejecting I/O to offline device
[  546.185307] sd 0:1:0:0: rejecting I/O to offline device
[  546.185334] sd 0:1:0:0: rejecting I/O to offline device
[  546.185364] sd 0:1:0:0: rejecting I/O to offline device
[  546.185390] sd 0:1:0:0: rejecting I/O to offline device
[  546.185410] sd 0:1:0:0: rejecting I/O to offline device
For slow serial console, the frequent printk may be blocked for a 
long time, and if any spin_lock has been acquired before the printk 
like in scsi_request_fn, watchdog could be triggered.

Related disscussion can be found here,
https://bugzilla.kernel.org/show_bug.cgi?id=199003
And Petr brought the idea to throttle the frequent printk, it's 
useless to print the same lines frequently after all.

v2->v1: fix some typos
 
Suggested-by: Petr Mladek 
Suggested-by: Sergey Senozhatsky 
Signed-off-by: Wen Yang 
Signed-off-by: Jiang Biao 
Signed-off-by: Tan Hu 
CC: BartVanAssche 
CC: Petr Mladek 
CC: Sergey Senozhatsky 
CC: Martin K. Petersen 
CC: "James E.J. Bottomley" 
CC: Tejun Heo 
---
 drivers/scsi/scsi_lib.c|  6 +++---
 include/scsi/scsi_device.h | 10 ++
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index c84f931..f77e801 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1301,7 +1301,7 @@ static int scsi_setup_cmnd(struct scsi_device *sdev, 
struct request *req)
 * commands.  The device must be brought online
 * before trying any recovery commands.
 */
-   sdev_printk(KERN_ERR, sdev,
+   sdev_printk_ratelimited(KERN_ERR, sdev,
"rejecting I/O to offline device\n");
ret = BLKPREP_KILL;
break;
@@ -1310,7 +1310,7 @@ static int scsi_setup_cmnd(struct scsi_device *sdev, 
struct request *req)
 * If the device is fully deleted, we refuse to
 * process any commands as well.
 */
-   sdev_printk(KERN_ERR, sdev,
+   sdev_printk_ratelimited(KERN_ERR, sdev,
"rejecting I/O to dead device\n");
ret = BLKPREP_KILL;
break;
@@ -1802,7 +1802,7 @@ static void scsi_request_fn(struct request_queue *q)
break;
 
if (unlikely(!scsi_device_online(sdev))) {
-   sdev_printk(KERN_ERR, sdev,
+   sdev_printk_ratelimited(KERN_ERR, sdev,
"rejecting I/O to offline device\n");
scsi_kill_request(req, q);
continue;
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 7ae177c..378d3f2 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -249,6 +249,16 @@ struct scsi_device {
 #define sdev_printk(l, sdev, fmt, a...)\
sdev_prefix_printk(l, sdev, NULL, fmt, ##a)
 
+#define sdev_printk_ratelimited(l, sdev, fmt, a...)\
+({ \
+   static DEFINE_RATELIMIT_STATE(_rs,  \
+ DEFAULT_RATELIMIT_INTERVAL,   \
+ DEFAULT_RATELIMIT_BURST); \
+   \
+   if (__ratelimit(&_rs))  \
+   sdev_prefix_printk(l, sdev, NULL, fmt, ##a);\
+})
+
 __printf(3, 4) void
 scmd_printk(const char *, const struct scsi_cmnd *, const char *, ...);
 
-- 
1.8.3.1



Re: [v2 PATCH] mm: introduce arg_lock to protect arg_start|end and env_start|end in mm_struct

2018-04-01 Thread Yang Shi



On 3/26/18 11:29 PM, Michal Hocko wrote:

On Tue 27-03-18 02:20:39, Yang Shi wrote:
[...]
The patch looks reasonable to me. Maybe it would be better to be more
explicit about the purpose of the patch. As others noticed, this alone
wouldn't solve the mmap_sem contention issues. I _think_ that if you
were more explicit about the mmap_sem abuse it would trigger less
questions.

I have just one more question. Now that you are touching this area,
would you be willing to remove the following ugliness?


diff --git a/kernel/sys.c b/kernel/sys.c
index f2289de..17bddd2 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1959,7 +1959,7 @@ static int prctl_set_mm_map(int opt, const void __user 
*addr, unsigned long data
return error;
}
  
-	down_write(&mm->mmap_sem);

+   down_read(&mm->mmap_sem);

Why do we need to hold mmap_sem here and call find_vma, when only
PR_SET_MM_ENV_END: is consuming it? I guess we can replace it wit the
new lock and take the mmap_sem only for PR_SET_MM_ENV_END.


Sorry for taking a little bit longer to get back since I was traveling. 
I think all the stuff can be protected by the new arg_lock except 
mm->brk since arg_lock can't prevent from concurrent writing from sys_brk().


We may use arg_lock to protect everything else other than mm->brk. The 
complexity sounds acceptable.


Of course, as Cyrill mentioned, he prefers to deprecating prctl_set_mm 
since C/R is the only user of it. We may wait until he is done?


Thanks,
Yang



Thanks!




Re: INFO: rcu detected stall in vprintk_default

2018-04-01 Thread Sergey Senozhatsky
On (04/01/18 12:52), Dmitry Vyukov wrote:
> 
> Seems to be the same as:
> 
> #syz dup: INFO: rcu detected stall in vprintk_func
> 
> +nfc maintainers

Yes, seems to be the same issue.

-ss


Re: [PATCH 0/2] cowsay support

2018-04-01 Thread Sergey Senozhatsky
On (04/01/18 10:56), Richard Weinberger wrote:
> As the printk subsystem gains more and more popularity it is time to add
> the final missing feature to make it perfect, namely cowsay output.
> Currently only one type of cow is supported and the only user is kmsg,
> but I can see more use cases for it and the need for different cow types.
> 
> Example of /dev/kmsg usage:
> [1.309561]   _
> [1.309561] < systemd[1]: Detected architecture x86-64. >
> [1.309561]   -
> [1.309561] \   ^__^
> [1.309561]  \  (oo)\___
> [1.309561] (__)\   )\/\
> [1.309561] ||w |
> [1.309561] || ||
> 
> Richard Weinberger (2):
>   lib: vsprintf: Implement %pCOW
>   printk: Use %pCOW for kmsg
> 

   ___
 < Acked-by: Sergey Senozhatsky  >
   ---
 \   ^__^
  \  (oo)\___
 (__)\   )\/\
 ||w |
 || ||

-ss


Re: INFO: rcu detected stall in vprintk_func

2018-04-01 Thread Sergey Senozhatsky
On (04/01/18 12:51), Dmitry Vyukov wrote:
[..]
> > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > Reported-by: syzbot+3f28bd18291266ec8...@syzkaller.appspotmail.com
> > It will help syzbot understand when the bug is fixed. See footer for
> > details.
> > If you forward the report, please keep this part and the footer.
> >
> > llcp: nfc_llcp_send_ui_frame: Could not allocate PDU
> > llcp: nfc_llcp_send_ui_frame: Could not allocate PDU
> > llcp: nfc_llcp_send_ui_frame: Could not allocate PDU
> > llcp: nfc_llcp_send_ui_frame: Could not allocate PDU

Yes, this thing

do {
remote_miu = sock->remote_miu > LLCP_MAX_MIU ?
local->remote_miu : sock->remote_miu;

frag_len = min_t(size_t, remote_miu, remaining_len);

pr_debug("Fragment %zd bytes remaining %zd",
 frag_len, remaining_len);

pdu = nfc_alloc_send_skb(sock->dev, &sock->sk, MSG_DONTWAIT,
 frag_len + LLCP_HEADER_SIZE, &err);
if (pdu == NULL) {
pr_err("Could not allocate PDU\n");
continue;

}

is basically

do {
pr_err("Could not allocate PDU\n");
} while (1)

Can cause problems sometimes. But this loop is a bit worrisome
even without the printk() call.

>From printk() side, we only can do rate limiting here. Would be
great if nfc maintainers could take a look and tweak the loop
maybe.

---

diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c
index ef4026a23e80..a309a27581da 100644
--- a/net/nfc/llcp_core.c
+++ b/net/nfc/llcp_core.c
@@ -1386,7 +1386,7 @@ static void nfc_llcp_recv_agf(struct nfc_llcp_local 
*local, struct sk_buff *skb)
 
new_skb = nfc_alloc_recv_skb(pdu_len, GFP_KERNEL);
if (new_skb == NULL) {
-   pr_err("Could not allocate PDU\n");
+   pr_err_ratelimited("Could not allocate PDU\n");
return;
}
 


Re: [PATCH v2] PM / wakeup: use seq_open() to show wakeup stats

2018-04-01 Thread Ganesh Mahendran
2018-03-30 19:00 GMT+08:00 Geert Uytterhoeven :
> On Fri, Mar 30, 2018 at 12:25 PM, Rafael J. Wysocki  
> wrote:
>> On Monday, March 5, 2018 9:47:46 AM CEST Ganesh Mahendran wrote:
>>> single_open() interface requires that the whole output must
>>> fit into a single buffer. This will lead to timeout when
>>> system memory is not in a good situation.
>>>
>>> This patch use seq_open() to show wakeup stats. This method
>>> need only one page, so timeout will not be observed.
>>>
>>> Signed-off-by: Ganesh Mahendran 
>>> 
>>> v2: use srcu_read_lock instead of rcu_read_lock
>>> ---
>>>  drivers/base/power/wakeup.c | 77 
>>> +++--
>>>  1 file changed, 61 insertions(+), 16 deletions(-)
>>>
>>> diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
>>> index ea01621..3bcab7d 100644
>>> --- a/drivers/base/power/wakeup.c
>>> +++ b/drivers/base/power/wakeup.c
>>> @@ -1029,32 +1029,77 @@ static int print_wakeup_source_stats(struct 
>>> seq_file *m,
>>>   return 0;
>>>  }
>>>
>>> -/**
>>> - * wakeup_sources_stats_show - Print wakeup sources statistics information.
>>> - * @m: seq_file to print the statistics into.
>>> - */
>>> -static int wakeup_sources_stats_show(struct seq_file *m, void *unused)
>>> +static void *wakeup_sources_stats_seq_start(struct seq_file *m,
>>> + loff_t *pos)
>>>  {
>>>   struct wakeup_source *ws;
>>> - int srcuidx;
>>> + loff_t n = *pos;
>>> + int *srcuidx = m->private;
>>>
>>> - seq_puts(m, "name\t\tactive_count\tevent_count\twakeup_count\t"
>>> - "expire_count\tactive_since\ttotal_time\tmax_time\t"
>>> - "last_change\tprevent_suspend_time\n");
>>> + if (n == 0) {
>>> + seq_puts(m, 
>>> "name\t\tactive_count\tevent_count\twakeup_count\t"
>>> + "expire_count\tactive_since\ttotal_time\tmax_time\t"
>>> + "last_change\tprevent_suspend_time\n");
>>> + }
>>>
>>> - srcuidx = srcu_read_lock(&wakeup_srcu);
>>> - list_for_each_entry_rcu(ws, &wakeup_sources, entry)
>>> - print_wakeup_source_stats(m, ws);
>>> - srcu_read_unlock(&wakeup_srcu, srcuidx);
>>> + *srcuidx = srcu_read_lock(&wakeup_srcu);
>>> + list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
>>> + if (n-- > 0)
>>> + continue;
>>> + goto out;
>>> + }
>>> + ws = NULL;
>>> +out:
>>> + return ws;
>>> +}
>>
>> Please clean up the above at least.
>>
>> If I'm not mistaken, you don't need the label and the goto here.
>
> The continue is also not needed, if the test condition is inverted.

Hi, Geert

We need to locate to the last read item. What is your suggestion here?

Thanks.

>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds


Re: [PATCH v2] PM / wakeup: use seq_open() to show wakeup stats

2018-04-01 Thread Ganesh Mahendran
2018-03-30 18:25 GMT+08:00 Rafael J. Wysocki :
> On Monday, March 5, 2018 9:47:46 AM CEST Ganesh Mahendran wrote:
>> single_open() interface requires that the whole output must
>> fit into a single buffer. This will lead to timeout when
>> system memory is not in a good situation.
>>
>> This patch use seq_open() to show wakeup stats. This method
>> need only one page, so timeout will not be observed.
>>
>> Signed-off-by: Ganesh Mahendran 
>> 
>> v2: use srcu_read_lock instead of rcu_read_lock
>> ---
>>  drivers/base/power/wakeup.c | 77 
>> +++--
>>  1 file changed, 61 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
>> index ea01621..3bcab7d 100644
>> --- a/drivers/base/power/wakeup.c
>> +++ b/drivers/base/power/wakeup.c
>> @@ -1029,32 +1029,77 @@ static int print_wakeup_source_stats(struct seq_file 
>> *m,
>>   return 0;
>>  }
>>
>> -/**
>> - * wakeup_sources_stats_show - Print wakeup sources statistics information.
>> - * @m: seq_file to print the statistics into.
>> - */
>> -static int wakeup_sources_stats_show(struct seq_file *m, void *unused)
>> +static void *wakeup_sources_stats_seq_start(struct seq_file *m,
>> + loff_t *pos)
>>  {
>>   struct wakeup_source *ws;
>> - int srcuidx;
>> + loff_t n = *pos;
>> + int *srcuidx = m->private;
>>
>> - seq_puts(m, "name\t\tactive_count\tevent_count\twakeup_count\t"
>> - "expire_count\tactive_since\ttotal_time\tmax_time\t"
>> - "last_change\tprevent_suspend_time\n");
>> + if (n == 0) {
>> + seq_puts(m, "name\t\tactive_count\tevent_count\twakeup_count\t"
>> + "expire_count\tactive_since\ttotal_time\tmax_time\t"
>> + "last_change\tprevent_suspend_time\n");
>> + }
>>
>> - srcuidx = srcu_read_lock(&wakeup_srcu);
>> - list_for_each_entry_rcu(ws, &wakeup_sources, entry)
>> - print_wakeup_source_stats(m, ws);
>> - srcu_read_unlock(&wakeup_srcu, srcuidx);
>> + *srcuidx = srcu_read_lock(&wakeup_srcu);
>> + list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
>> + if (n-- > 0)
>> + continue;
>> + goto out;
>> + }
>> + ws = NULL;
>> +out:
>> + return ws;
>> +}
>
> Please clean up the above at least.

Hi, Rafael

When length of file "wakeup_sources" is larger than 1 page,
wakeup_sources_stats_seq_start()
may be called more then 1 time if the user space wants to read all of the file.
So we need to locate to last read item, if it is not the first time to
read the file.

We can see the same logic in kmemleak_seq_start().

Thanks.

>
> If I'm not mistaken, you don't need the label and the goto here.
>


Re: [PATCH] sky2: Increase D3 delay to sky2 stops working after suspend

2018-04-01 Thread David Miller
From: Kai-Heng Feng 
Date: Sat, 31 Mar 2018 23:42:03 +0800

> The sky2 ethernet stops working after system resume from suspend:
> [ 582.852065] sky2 :04:00.0: Refused to change power state, currently in 
> D3
> 
> The current 150ms delay is not enough, change it to 200ms can solve the
> issue.
> 
> BugLink: https://bugs.launchpad.net/bugs/1758507
> Cc: Stable 
> Signed-off-by: Kai-Heng Feng 

Applied.


Re: [PATCH v1] kernel/trace:check the val against the available mem

2018-04-01 Thread Zhaoyang Huang
On Sat, Mar 31, 2018 at 5:42 AM, Steven Rostedt  wrote:
> On Fri, 30 Mar 2018 17:30:31 -0400
> Steven Rostedt  wrote:
>
>> I'll take a look at si_mem_available() that Joel suggested and see if
>> we can make that work.
>
> Wow, this appears to work great! Joel and Zhaoyang, can you test this?
>
> -- Steve
>
> diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> index a2fd3893cc02..32a803626ee2 100644
> --- a/kernel/trace/ring_buffer.c
> +++ b/kernel/trace/ring_buffer.c
> @@ -1164,6 +1164,11 @@ static int __rb_allocate_pages(long nr_pages, struct 
> list_head *pages, int cpu)
> struct buffer_page *bpage, *tmp;
> long i;
>
> +   /* Check if the available memory is there first */
> +   i = si_mem_available();
> +   if (i < nr_pages)
> +   return -ENOMEM;
> +
> for (i = 0; i < nr_pages; i++) {
> struct page *page;
> /*
Hi Steve, It works as my previous patch does.


Re: [PATCH] net: improve ipv4 performances

2018-04-01 Thread Md. Islam
Yes, I'm also seeing good performance improvement after adding
likely() and prefetch().

On Sun, Apr 1, 2018 at 2:50 PM, Stephen Hemminger
 wrote:
> On Sun,  1 Apr 2018 20:31:21 +0200
> Anton Gary Ceph  wrote:
>
>> As the Linux networking stack is growing, more and more protocols are
>> added, increasing the complexity of stack itself.
>> Modern processors, contrary to common belief, are very bad in branch
>> prediction, so it's our task to give hints to the compiler when possible.
>>
>> After a few profiling and analysis, turned out that the ethertype field
>> of the packets has the following distribution:
>>
>> 92.1% ETH_P_IP
>>  3.2% ETH_P_ARP
>>  2.7% ETH_P_8021Q
>>  1.4% ETH_P_PPP_SES
>>  0.6% don't know/no opinion
>>
>> From a projection on statistics collected by Google about IPv6 adoption[1],
>> IPv6 should peak at 25% usage at the beginning of 2030. Hence, we should
>> give proper hints to the compiler about the low IPv6 usage.
>>
>> Here is an iperf3 run before and after the patch:
>>
>> Before:
>> [ ID]  Interval   TransferBandwidth   Retr
>> [  4]  0.00-100.00 sec100 GBytes  8.60 Gbits/sec  0   sender
>> [  4]  0.00-100.00 sec100 GBytes  8.60 Gbits/sec  receiver
>>
>> After
>> [ ID]  Interval   TransferBandwidth   Retr
>> [  4]  0.00-100.00 sec109 GBytes  9.35 Gbits/sec  0   sender
>> [  4]  0.00-100.00 sec109 GBytes  9.35 Gbits/sec  receiver
>>
>> [1] https://www.google.com/intl/en/ipv6/statistics.html
>>
>> Signed-off-by: Anton Gary Ceph 
>
> I am surprised it makes that much of an impact.
>
> It would be easier to manage future bisection if the big patch
> was split into several pieces. Bridge,  bonding, netfilter, etc.
> There doesn't appear to be any direct cross dependencies.
>
>



-- 
Tamim
PhD Candidate,
Kent State University
http://web.cs.kent.edu/~mislam4/


  1   2   3   >