[PATCH] timer: use raw_spin_unlock_irqrestore and raw_spin_lock_irqsave instead of raw_spin_{lock|unlock}

2020-08-19 Thread Wang Long
The current code in function 
__mod_timer(https://github.com/torvalds/linux/blob/master/kernel/time/timer.c#L961):

994 base = lock_timer_base(timer, );   
--(1)
forward_timer_base(base);

if (timer_pending(timer) && (options & MOD_TIMER_REDUCE) &&
time_before_eq(timer->expires, expires)) {
ret = 1;
goto out_unlock;
}

clk = base->clk;
idx = calc_wheel_index(expires, clk, _expiry);

/*
 * Retrieve and compare the array index of the pending
 * timer. If it matches set the expiry to the new value so a
 * subsequent call will exit in the expires check above.
 */
if (idx == timer_get_idx(timer)) {
if (!(options & MOD_TIMER_REDUCE))
timer->expires = expires;
else if (time_after(timer->expires, expires))
timer->expires = expires;
ret = 1;
goto out_unlock;
}
} else {
1021base = lock_timer_base(timer, ); 
(2)
forward_timer_base(base);
}

ret = detach_if_pending(timer, base, false);
if (!ret && (options & MOD_TIMER_PENDING_ONLY))
goto out_unlock;

new_base = get_target_base(base, timer->flags);

if (base != new_base) {
/*
 * We are trying to schedule the timer on the new base.
 * However we can't change timer's base while it is running,
 * otherwise del_timer_sync() can't detect that the timer's
 * handler yet has not finished. This also guarantees that the
 * timer is serialized wrt itself.
 */
if (likely(base->running_timer != timer)) {
/* See the comment in lock_timer_base() */
timer->flags |= TIMER_MIGRATING;

1042raw_spin_unlock(>lock); ---(3)
base = new_base;
raw_spin_lock(>lock); -(4)
WRITE_ONCE(timer->flags,
   (timer->flags & ~TIMER_BASEMASK) | 
base->cpu);
forward_timer_base(base);
}
}

debug_timer_activate(timer);

timer->expires = expires;
/*
 * If 'idx' was calculated above and the base time did not advance
 * between calculating 'idx' and possibly switching the base, only
 * enqueue_timer() is required. Otherwise we need to (re)calculate
 * the wheel index via internal_add_timer().
 */
if (idx != UINT_MAX && clk == base->clk)
enqueue_timer(base, timer, idx, bucket_expiry);
else
internal_add_timer(base, timer);

out_unlock:
1066raw_spin_unlock_irqrestore(>lock, flags); -(5)

return ret;
}

The code in (1)(2) lock the base with raw_spin_lock_irqsave(>lock, flag),
if base != new_base,  the code in (3) unlock the old base, the code in (4) lock 
the
new base. at the end of the function(5), use 
raw_spin_unlock_irqrestore(>lock, flags);
to unlock the new_base.

Consider the following situation:

CPU0CPU1
base = lock_timer_base(timer, );  
(1)(2)
raw_spin_unlock(>lock);   
(3)
base = new_base;
raw_spin_lock(>lock); 
(4)
raw_spin_unlock_irqrestore(>lock, 
flags); (5)

The flags save from CPU0, and restore to CPU1. Is this wrong?

we encountered a kernel panic, and we suspect that it is the problem. How about 
the following patch to fix.

Signed-off-by: Wang Long 
---
 kernel/time/timer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index a16764b..4153766 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -1039,9 +1039,9 @@ static struct timer_base *lock_timer_base(struct 
timer_list *timer,
/* See the comment in lock_timer_base() */
timer->flags |= TIMER_MIGRATING;
 
-   raw_spin_unlock(>lock);
+   raw_spin_unlock_irqrestore(>lock, flags);
base = new_base;
-   raw_spin_lock(>lock);
+   raw_spin_lo

[PATCH] idr: Fix a typo in idr_alloc_cyclic()'s comment

2020-07-28 Thread Wang Long
This patch fix a typo in comment for function idr_alloc_cyclic().

Signed-off-by: Wang Long 
---
 lib/idr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/idr.c b/lib/idr.c
index c2cf2c5..47d203f 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -100,7 +100,7 @@ int idr_alloc(struct idr *idr, void *ptr, int start, int 
end, gfp_t gfp)
  * @end: The maximum ID (exclusive).
  * @gfp: Memory allocation flags.
  *
- * Allocates an unused ID in the range specified by @nextid and @end.  If
+ * Allocates an unused ID in the range specified by @start and @end.  If
  * @end is <= 0, it is treated as one larger than %INT_MAX.  This allows
  * callers to use @start + N as @end as long as N is within integer range.
  * The search for an unused ID will start at the last ID allocated and will
-- 
1.8.3.1






[PATCH] Documentation: driver-api: update kernel connector

2020-07-20 Thread Wang Long
This patch changes:
1) Fix typo in kernel connector documentation.
s/cn_netlink_send_multi/cn_netlink_send_mult/
2) update definition of struct cn_msg

Signed-off-by: Wang Long 
---
 Documentation/driver-api/connector.rst | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Documentation/driver-api/connector.rst 
b/Documentation/driver-api/connector.rst
index c100c74..23d06819 100644
--- a/Documentation/driver-api/connector.rst
+++ b/Documentation/driver-api/connector.rst
@@ -26,7 +26,7 @@ netlink based networking for inter-process communication in a 
significantly
 easier way::
 
   int cn_add_callback(struct cb_id *id, char *name, void (*callback) (struct 
cn_msg *, struct netlink_skb_parms *));
-  void cn_netlink_send_multi(struct cn_msg *msg, u16 len, u32 portid, u32 
__group, int gfp_mask);
+  void cn_netlink_send_mult(struct cn_msg *msg, u16 len, u32 portid, u32 
__group, int gfp_mask);
   void cn_netlink_send(struct cn_msg *msg, u32 portid, u32 __group, int 
gfp_mask);
 
   struct cb_id
@@ -48,7 +48,8 @@ be dereferenced to `struct cn_msg *`::
__u32   seq;
__u32   ack;
 
-   __u32   len;/* Length of the following data */
+   __u16   len;/* Length of the following data */
+   __u16   flags;
__u8data[0];
   };
 
-- 
1.8.3.1






[PATCH v1] xarray: update document for error space returned by xarray normal API

2020-07-19 Thread Wang Long
In the current xarray code, the negative value -1 and -4095 represented
as an error.

xa_is_err(xa_mk_internal(-4095)) and xa_is_err(xa_mk_internal(-1))
are all return true.

This patch update the document.

Signed-off-by: Wang Long 
---
 include/linux/xarray.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/xarray.h b/include/linux/xarray.h
index b4d70e7..0588fb9 100644
--- a/include/linux/xarray.h
+++ b/include/linux/xarray.h
@@ -36,7 +36,7 @@
  * 257: Zero entry
  *
  * Errors are also represented as internal entries, but use the negative
- * space (-4094 to -2).  They're never stored in the slots array; only
+ * space (-4095 to -1).  They're never stored in the slots array; only
  * returned by the normal API.
  */
 
-- 
1.8.3.1






[PATCH] xarray: update document for error space returned by xarray normal API

2020-07-19 Thread Wang Long
In the current xarray code, the negative value -1 and -4095 represented
as an error.

xa_is_error(xa_mk_internal(-4095)) and xa_is_error(xa_mk_internal(-1))
are all return true.

This patch update the document.

Signed-off-by: Wang Long 
---
 include/linux/xarray.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/xarray.h b/include/linux/xarray.h
index b4d70e7..0588fb9 100644
--- a/include/linux/xarray.h
+++ b/include/linux/xarray.h
@@ -36,7 +36,7 @@
  * 257: Zero entry
  *
  * Errors are also represented as internal entries, but use the negative
- * space (-4094 to -2).  They're never stored in the slots array; only
+ * space (-4095 to -1).  They're never stored in the slots array; only
  * returned by the normal API.
  */
 
-- 
1.8.3.1






[PATCH] xarray: update document for error space returned by xarray normal API

2020-07-19 Thread Wang Long
In the current xarray code, the negative value -1 and -4095 represented
as an error.

xa_is_error(xa_mk_internal(-4095)) and xa_is_error(xa_mk_internal(-1))
are all return true.

This patch update the document.

Signed-off-by: Wang Long 
---
 include/linux/xarray.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/xarray.h b/include/linux/xarray.h
index b4d70e7..0588fb9 100644
--- a/include/linux/xarray.h
+++ b/include/linux/xarray.h
@@ -36,7 +36,7 @@
  * 257: Zero entry
  *
  * Errors are also represented as internal entries, but use the negative
- * space (-4094 to -2).  They're never stored in the slots array; only
+ * space (-4095 to -1).  They're never stored in the slots array; only
  * returned by the normal API.
  */
 
-- 
1.8.3.1






[PATCH] radix-tree: optimization for radix_tree_init_maxnodes

2018-09-09 Thread Wang Long
if i == 0, height_to_maxnodes[i] = 0,
if i >= 1, height_to_maxnodes[i] = height_to_maxnodes[i-1]
+ __maxindex(i-1) + 1.

so delete height_to_maxindex and optimize the calculation of
height_to_maxnodes array.

Signed-off-by: Wang Long 
---
 lib/radix-tree.c | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index bc03ecc..af02b2c 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -2242,14 +2242,11 @@ static __init unsigned long __maxindex(unsigned int 
height)
 
 static __init void radix_tree_init_maxnodes(void)
 {
-   unsigned long height_to_maxindex[RADIX_TREE_MAX_PATH + 1];
-   unsigned int i, j;
-
-   for (i = 0; i < ARRAY_SIZE(height_to_maxindex); i++)
-   height_to_maxindex[i] = __maxindex(i);
-   for (i = 0; i < ARRAY_SIZE(height_to_maxnodes); i++) {
-   for (j = i; j > 0; j--)
-   height_to_maxnodes[i] += height_to_maxindex[j - 1] + 1;
+   unsigned int i;
+
+   for (i = 1; i < ARRAY_SIZE(height_to_maxnodes); i++) {
+   height_to_maxnodes[i] = height_to_maxnodes[i - 1]
+   +  __maxindex(i - 1) + 1;
}
 }
 
-- 
1.8.3.1



[PATCH] radix-tree: optimization for radix_tree_init_maxnodes

2018-09-09 Thread Wang Long
if i == 0, height_to_maxnodes[i] = 0,
if i >= 1, height_to_maxnodes[i] = height_to_maxnodes[i-1]
+ __maxindex(i-1) + 1.

so delete height_to_maxindex and optimize the calculation of
height_to_maxnodes array.

Signed-off-by: Wang Long 
---
 lib/radix-tree.c | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index bc03ecc..af02b2c 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -2242,14 +2242,11 @@ static __init unsigned long __maxindex(unsigned int 
height)
 
 static __init void radix_tree_init_maxnodes(void)
 {
-   unsigned long height_to_maxindex[RADIX_TREE_MAX_PATH + 1];
-   unsigned int i, j;
-
-   for (i = 0; i < ARRAY_SIZE(height_to_maxindex); i++)
-   height_to_maxindex[i] = __maxindex(i);
-   for (i = 0; i < ARRAY_SIZE(height_to_maxnodes); i++) {
-   for (j = i; j > 0; j--)
-   height_to_maxnodes[i] += height_to_maxindex[j - 1] + 1;
+   unsigned int i;
+
+   for (i = 1; i < ARRAY_SIZE(height_to_maxnodes); i++) {
+   height_to_maxnodes[i] = height_to_maxnodes[i - 1]
+   +  __maxindex(i - 1) + 1;
}
 }
 
-- 
1.8.3.1



[PATCH v2] memcg: writeback: use memcg->cgwb_list directly

2018-04-22 Thread Wang Long
mem_cgroup_cgwb_list is a very simple wrapper and it will
never be used outside of code under CONFIG_CGROUP_WRITEBACK.
so use memcg->cgwb_list directly.

Reviewed-by: Jan Kara <j...@suse.cz>
Signed-off-by: Wang Long <wanglon...@meituan.com>
---
 include/linux/memcontrol.h | 1 -
 mm/backing-dev.c   | 4 ++--
 mm/memcontrol.c| 5 -
 3 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index d99b71b..c0056e0 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -1093,7 +1093,6 @@ static inline void dec_lruvec_page_state(struct page 
*page,
 
 #ifdef CONFIG_CGROUP_WRITEBACK
 
-struct list_head *mem_cgroup_cgwb_list(struct mem_cgroup *memcg);
 struct wb_domain *mem_cgroup_wb_domain(struct bdi_writeback *wb);
 void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pfilepages,
 unsigned long *pheadroom, unsigned long *pdirty,
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 023190c..0a48e05 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -555,7 +555,7 @@ static int cgwb_create(struct backing_dev_info *bdi,
memcg = mem_cgroup_from_css(memcg_css);
blkcg_css = cgroup_get_e_css(memcg_css->cgroup, _cgrp_subsys);
blkcg = css_to_blkcg(blkcg_css);
-   memcg_cgwb_list = mem_cgroup_cgwb_list(memcg);
+   memcg_cgwb_list = >cgwb_list;
blkcg_cgwb_list = >cgwb_list;
 
/* look up again under lock and discard on blkcg mismatch */
@@ -734,7 +734,7 @@ static void cgwb_bdi_unregister(struct backing_dev_info 
*bdi)
  */
 void wb_memcg_offline(struct mem_cgroup *memcg)
 {
-   struct list_head *memcg_cgwb_list = mem_cgroup_cgwb_list(memcg);
+   struct list_head *memcg_cgwb_list = >cgwb_list;
struct bdi_writeback *wb, *next;
 
spin_lock_irq(_lock);
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index e074f7c..d1adb9c 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3562,11 +3562,6 @@ static int mem_cgroup_oom_control_write(struct 
cgroup_subsys_state *css,
 
 #ifdef CONFIG_CGROUP_WRITEBACK
 
-struct list_head *mem_cgroup_cgwb_list(struct mem_cgroup *memcg)
-{
-   return >cgwb_list;
-}
-
 static int memcg_wb_domain_init(struct mem_cgroup *memcg, gfp_t gfp)
 {
return wb_domain_init(>cgwb_domain, gfp);
-- 
1.8.3.1



[PATCH v2] memcg: writeback: use memcg->cgwb_list directly

2018-04-22 Thread Wang Long
mem_cgroup_cgwb_list is a very simple wrapper and it will
never be used outside of code under CONFIG_CGROUP_WRITEBACK.
so use memcg->cgwb_list directly.

Reviewed-by: Jan Kara 
Signed-off-by: Wang Long 
---
 include/linux/memcontrol.h | 1 -
 mm/backing-dev.c   | 4 ++--
 mm/memcontrol.c| 5 -
 3 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index d99b71b..c0056e0 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -1093,7 +1093,6 @@ static inline void dec_lruvec_page_state(struct page 
*page,
 
 #ifdef CONFIG_CGROUP_WRITEBACK
 
-struct list_head *mem_cgroup_cgwb_list(struct mem_cgroup *memcg);
 struct wb_domain *mem_cgroup_wb_domain(struct bdi_writeback *wb);
 void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pfilepages,
 unsigned long *pheadroom, unsigned long *pdirty,
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 023190c..0a48e05 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -555,7 +555,7 @@ static int cgwb_create(struct backing_dev_info *bdi,
memcg = mem_cgroup_from_css(memcg_css);
blkcg_css = cgroup_get_e_css(memcg_css->cgroup, _cgrp_subsys);
blkcg = css_to_blkcg(blkcg_css);
-   memcg_cgwb_list = mem_cgroup_cgwb_list(memcg);
+   memcg_cgwb_list = >cgwb_list;
blkcg_cgwb_list = >cgwb_list;
 
/* look up again under lock and discard on blkcg mismatch */
@@ -734,7 +734,7 @@ static void cgwb_bdi_unregister(struct backing_dev_info 
*bdi)
  */
 void wb_memcg_offline(struct mem_cgroup *memcg)
 {
-   struct list_head *memcg_cgwb_list = mem_cgroup_cgwb_list(memcg);
+   struct list_head *memcg_cgwb_list = >cgwb_list;
struct bdi_writeback *wb, *next;
 
spin_lock_irq(_lock);
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index e074f7c..d1adb9c 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3562,11 +3562,6 @@ static int mem_cgroup_oom_control_write(struct 
cgroup_subsys_state *css,
 
 #ifdef CONFIG_CGROUP_WRITEBACK
 
-struct list_head *mem_cgroup_cgwb_list(struct mem_cgroup *memcg)
-{
-   return >cgwb_list;
-}
-
 static int memcg_wb_domain_init(struct mem_cgroup *memcg, gfp_t gfp)
 {
return wb_domain_init(>cgwb_domain, gfp);
-- 
1.8.3.1



Re: [PATCH] memcg: writeback: use memcg->cgwb_list directly

2018-04-22 Thread Wang Long



On 22/4/2018 8:43 PM, Michal Hocko wrote:

On Sun 22-04-18 01:50:57, Jan Kara wrote:

On Sat 21-04-18 21:29:41, Wang Long wrote:

Signed-off-by: Wang Long <wanglon...@meituan.com>

Yeah, looks good. I guess it was originally intended to avoid compilation
errors if CONFIG_CGROUP_WRITEBACK was disabled. But it doesn't seem likely
we'll ever need that list outside of code under CONFIG_CGROUP_WRITEBACK. So
you can add:

Yeah. Trivial wrappers like these are usualy more harm than goot.  But
please add _some_ words in the changelog.

ok, I will send the v2 patch.

Reviewed-by: Jan Kara <j...@suse.cz>

Honza


---
  include/linux/memcontrol.h | 1 -
  mm/backing-dev.c   | 4 ++--
  mm/memcontrol.c| 5 -
  3 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index d99b71b..c0056e0 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -1093,7 +1093,6 @@ static inline void dec_lruvec_page_state(struct page 
*page,
  
  #ifdef CONFIG_CGROUP_WRITEBACK
  
-struct list_head *mem_cgroup_cgwb_list(struct mem_cgroup *memcg);

  struct wb_domain *mem_cgroup_wb_domain(struct bdi_writeback *wb);
  void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pfilepages,
 unsigned long *pheadroom, unsigned long *pdirty,
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 023190c..0a48e05 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -555,7 +555,7 @@ static int cgwb_create(struct backing_dev_info *bdi,
memcg = mem_cgroup_from_css(memcg_css);
blkcg_css = cgroup_get_e_css(memcg_css->cgroup, _cgrp_subsys);
blkcg = css_to_blkcg(blkcg_css);
-   memcg_cgwb_list = mem_cgroup_cgwb_list(memcg);
+   memcg_cgwb_list = >cgwb_list;
blkcg_cgwb_list = >cgwb_list;
  
  	/* look up again under lock and discard on blkcg mismatch */

@@ -734,7 +734,7 @@ static void cgwb_bdi_unregister(struct backing_dev_info 
*bdi)
   */
  void wb_memcg_offline(struct mem_cgroup *memcg)
  {
-   struct list_head *memcg_cgwb_list = mem_cgroup_cgwb_list(memcg);
+   struct list_head *memcg_cgwb_list = >cgwb_list;
struct bdi_writeback *wb, *next;
  
  	spin_lock_irq(_lock);

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index e074f7c..d1adb9c 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3562,11 +3562,6 @@ static int mem_cgroup_oom_control_write(struct 
cgroup_subsys_state *css,
  
  #ifdef CONFIG_CGROUP_WRITEBACK
  
-struct list_head *mem_cgroup_cgwb_list(struct mem_cgroup *memcg)

-{
-   return >cgwb_list;
-}
-
  static int memcg_wb_domain_init(struct mem_cgroup *memcg, gfp_t gfp)
  {
return wb_domain_init(>cgwb_domain, gfp);
--
1.8.3.1


--
Jan Kara <j...@suse.com>
SUSE Labs, CR




Re: [PATCH] memcg: writeback: use memcg->cgwb_list directly

2018-04-22 Thread Wang Long



On 22/4/2018 8:43 PM, Michal Hocko wrote:

On Sun 22-04-18 01:50:57, Jan Kara wrote:

On Sat 21-04-18 21:29:41, Wang Long wrote:

Signed-off-by: Wang Long 

Yeah, looks good. I guess it was originally intended to avoid compilation
errors if CONFIG_CGROUP_WRITEBACK was disabled. But it doesn't seem likely
we'll ever need that list outside of code under CONFIG_CGROUP_WRITEBACK. So
you can add:

Yeah. Trivial wrappers like these are usualy more harm than goot.  But
please add _some_ words in the changelog.

ok, I will send the v2 patch.

Reviewed-by: Jan Kara 

Honza


---
  include/linux/memcontrol.h | 1 -
  mm/backing-dev.c   | 4 ++--
  mm/memcontrol.c| 5 -
  3 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index d99b71b..c0056e0 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -1093,7 +1093,6 @@ static inline void dec_lruvec_page_state(struct page 
*page,
  
  #ifdef CONFIG_CGROUP_WRITEBACK
  
-struct list_head *mem_cgroup_cgwb_list(struct mem_cgroup *memcg);

  struct wb_domain *mem_cgroup_wb_domain(struct bdi_writeback *wb);
  void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pfilepages,
 unsigned long *pheadroom, unsigned long *pdirty,
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 023190c..0a48e05 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -555,7 +555,7 @@ static int cgwb_create(struct backing_dev_info *bdi,
memcg = mem_cgroup_from_css(memcg_css);
blkcg_css = cgroup_get_e_css(memcg_css->cgroup, _cgrp_subsys);
blkcg = css_to_blkcg(blkcg_css);
-   memcg_cgwb_list = mem_cgroup_cgwb_list(memcg);
+   memcg_cgwb_list = >cgwb_list;
blkcg_cgwb_list = >cgwb_list;
  
  	/* look up again under lock and discard on blkcg mismatch */

@@ -734,7 +734,7 @@ static void cgwb_bdi_unregister(struct backing_dev_info 
*bdi)
   */
  void wb_memcg_offline(struct mem_cgroup *memcg)
  {
-   struct list_head *memcg_cgwb_list = mem_cgroup_cgwb_list(memcg);
+   struct list_head *memcg_cgwb_list = >cgwb_list;
struct bdi_writeback *wb, *next;
  
  	spin_lock_irq(_lock);

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index e074f7c..d1adb9c 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3562,11 +3562,6 @@ static int mem_cgroup_oom_control_write(struct 
cgroup_subsys_state *css,
  
  #ifdef CONFIG_CGROUP_WRITEBACK
  
-struct list_head *mem_cgroup_cgwb_list(struct mem_cgroup *memcg)

-{
-   return >cgwb_list;
-}
-
  static int memcg_wb_domain_init(struct mem_cgroup *memcg, gfp_t gfp)
  {
return wb_domain_init(>cgwb_domain, gfp);
--
1.8.3.1


--
Jan Kara 
SUSE Labs, CR




[PATCH] memcg: writeback: use memcg->cgwb_list directly

2018-04-21 Thread Wang Long
Signed-off-by: Wang Long <wanglon...@meituan.com>
---
 include/linux/memcontrol.h | 1 -
 mm/backing-dev.c   | 4 ++--
 mm/memcontrol.c| 5 -
 3 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index d99b71b..c0056e0 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -1093,7 +1093,6 @@ static inline void dec_lruvec_page_state(struct page 
*page,
 
 #ifdef CONFIG_CGROUP_WRITEBACK
 
-struct list_head *mem_cgroup_cgwb_list(struct mem_cgroup *memcg);
 struct wb_domain *mem_cgroup_wb_domain(struct bdi_writeback *wb);
 void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pfilepages,
 unsigned long *pheadroom, unsigned long *pdirty,
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 023190c..0a48e05 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -555,7 +555,7 @@ static int cgwb_create(struct backing_dev_info *bdi,
memcg = mem_cgroup_from_css(memcg_css);
blkcg_css = cgroup_get_e_css(memcg_css->cgroup, _cgrp_subsys);
blkcg = css_to_blkcg(blkcg_css);
-   memcg_cgwb_list = mem_cgroup_cgwb_list(memcg);
+   memcg_cgwb_list = >cgwb_list;
blkcg_cgwb_list = >cgwb_list;
 
/* look up again under lock and discard on blkcg mismatch */
@@ -734,7 +734,7 @@ static void cgwb_bdi_unregister(struct backing_dev_info 
*bdi)
  */
 void wb_memcg_offline(struct mem_cgroup *memcg)
 {
-   struct list_head *memcg_cgwb_list = mem_cgroup_cgwb_list(memcg);
+   struct list_head *memcg_cgwb_list = >cgwb_list;
struct bdi_writeback *wb, *next;
 
spin_lock_irq(_lock);
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index e074f7c..d1adb9c 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3562,11 +3562,6 @@ static int mem_cgroup_oom_control_write(struct 
cgroup_subsys_state *css,
 
 #ifdef CONFIG_CGROUP_WRITEBACK
 
-struct list_head *mem_cgroup_cgwb_list(struct mem_cgroup *memcg)
-{
-   return >cgwb_list;
-}
-
 static int memcg_wb_domain_init(struct mem_cgroup *memcg, gfp_t gfp)
 {
return wb_domain_init(>cgwb_domain, gfp);
-- 
1.8.3.1



[PATCH] memcg: writeback: use memcg->cgwb_list directly

2018-04-21 Thread Wang Long
Signed-off-by: Wang Long 
---
 include/linux/memcontrol.h | 1 -
 mm/backing-dev.c   | 4 ++--
 mm/memcontrol.c| 5 -
 3 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index d99b71b..c0056e0 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -1093,7 +1093,6 @@ static inline void dec_lruvec_page_state(struct page 
*page,
 
 #ifdef CONFIG_CGROUP_WRITEBACK
 
-struct list_head *mem_cgroup_cgwb_list(struct mem_cgroup *memcg);
 struct wb_domain *mem_cgroup_wb_domain(struct bdi_writeback *wb);
 void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pfilepages,
 unsigned long *pheadroom, unsigned long *pdirty,
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 023190c..0a48e05 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -555,7 +555,7 @@ static int cgwb_create(struct backing_dev_info *bdi,
memcg = mem_cgroup_from_css(memcg_css);
blkcg_css = cgroup_get_e_css(memcg_css->cgroup, _cgrp_subsys);
blkcg = css_to_blkcg(blkcg_css);
-   memcg_cgwb_list = mem_cgroup_cgwb_list(memcg);
+   memcg_cgwb_list = >cgwb_list;
blkcg_cgwb_list = >cgwb_list;
 
/* look up again under lock and discard on blkcg mismatch */
@@ -734,7 +734,7 @@ static void cgwb_bdi_unregister(struct backing_dev_info 
*bdi)
  */
 void wb_memcg_offline(struct mem_cgroup *memcg)
 {
-   struct list_head *memcg_cgwb_list = mem_cgroup_cgwb_list(memcg);
+   struct list_head *memcg_cgwb_list = >cgwb_list;
struct bdi_writeback *wb, *next;
 
spin_lock_irq(_lock);
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index e074f7c..d1adb9c 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3562,11 +3562,6 @@ static int mem_cgroup_oom_control_write(struct 
cgroup_subsys_state *css,
 
 #ifdef CONFIG_CGROUP_WRITEBACK
 
-struct list_head *mem_cgroup_cgwb_list(struct mem_cgroup *memcg)
-{
-   return >cgwb_list;
-}
-
 static int memcg_wb_domain_init(struct mem_cgroup *memcg, gfp_t gfp)
 {
return wb_domain_init(>cgwb_domain, gfp);
-- 
1.8.3.1



Re: [PATCH] writeback: safer lock nesting

2018-04-10 Thread Wang Long



Hi,

[This is an automated email]

This commit has been processed by the -stable helper bot and determined
to be a high probability candidate for -stable trees. (score: 44.5575)

The bot has tested the following trees: v4.16.1, v4.15.16, v4.14.33, v4.9.93, 
v4.4.127.

v4.16.1: Build OK!
v4.15.16: Build OK!
v4.14.33: Build OK!
v4.9.93: Build OK!
v4.4.127: Failed to apply! Possible dependencies:
 62cccb8c8e7a ("mm: simplify lock_page_memcg()")

Hi Sasha,

I test the memory cgroup in lts v4.4, for this issue, 62cccb8c8e7a ("mm: 
simplify lock_page_memcg()")

need to adjust and there are several other places that need to be fixed.

I will make the patch for lts v4.4 if no one did.

Thanks.



Please let us know if you'd like to have this patch included in a stable tree.

--
Thanks,
Sasha




Re: [PATCH] writeback: safer lock nesting

2018-04-10 Thread Wang Long



Hi,

[This is an automated email]

This commit has been processed by the -stable helper bot and determined
to be a high probability candidate for -stable trees. (score: 44.5575)

The bot has tested the following trees: v4.16.1, v4.15.16, v4.14.33, v4.9.93, 
v4.4.127.

v4.16.1: Build OK!
v4.15.16: Build OK!
v4.14.33: Build OK!
v4.9.93: Build OK!
v4.4.127: Failed to apply! Possible dependencies:
 62cccb8c8e7a ("mm: simplify lock_page_memcg()")

Hi Sasha,

I test the memory cgroup in lts v4.4, for this issue, 62cccb8c8e7a ("mm: 
simplify lock_page_memcg()")

need to adjust and there are several other places that need to be fixed.

I will make the patch for lts v4.4 if no one did.

Thanks.



Please let us know if you'd like to have this patch included in a stable tree.

--
Thanks,
Sasha




Re: [PATCH v3] writeback: safer lock nesting

2018-04-10 Thread Wang Long

lock_page_memcg()/unlock_page_memcg() use spin_lock_irqsave/restore() if
the page's memcg is undergoing move accounting, which occurs when a
process leaves its memcg for a new one that has
memory.move_charge_at_immigrate set.

unlocked_inode_to_wb_begin,end() use spin_lock_irq/spin_unlock_irq() if the
given inode is switching writeback domains.  Switches occur when enough
writes are issued from a new domain.

This existing pattern is thus suspicious:
 lock_page_memcg(page);
 unlocked_inode_to_wb_begin(inode, );
 ...
 unlocked_inode_to_wb_end(inode, locked);
 unlock_page_memcg(page);

If both inode switch and process memcg migration are both in-flight then
unlocked_inode_to_wb_end() will unconditionally enable interrupts while
still holding the lock_page_memcg() irq spinlock.  This suggests the
possibility of deadlock if an interrupt occurs before
unlock_page_memcg().

 truncate
 __cancel_dirty_page
 lock_page_memcg
 unlocked_inode_to_wb_begin
 unlocked_inode_to_wb_end
 
 
 end_page_writeback
 test_clear_page_writeback
 lock_page_memcg
 
 unlock_page_memcg

Due to configuration limitations this deadlock is not currently possible
because we don't mix cgroup writeback (a cgroupv2 feature) and
memory.move_charge_at_immigrate (a cgroupv1 feature).

If the kernel is hacked to always claim inode switching and memcg
moving_account, then this script triggers lockup in less than a minute:
   cd /mnt/cgroup/memory
   mkdir a b
   echo 1 > a/memory.move_charge_at_immigrate
   echo 1 > b/memory.move_charge_at_immigrate
   (
 echo $BASHPID > a/cgroup.procs
 while true; do
   dd if=/dev/zero of=/mnt/big bs=1M count=256
 done
   ) &
   while true; do
 sync
   done &
   sleep 1h &
   SLEEP=$!
   while true; do
 echo $SLEEP > a/cgroup.procs
 echo $SLEEP > b/cgroup.procs
   done

Given the deadlock is not currently possible, it's debatable if there's
any reason to modify the kernel.  I suggest we should to prevent future
surprises.

This deadlock occurs three times in our environment,

this deadlock occurs three times in our environment. It is better to cc stable 
kernel and
backport it.

Acked-by: Wang Long <wanglon...@meituan.com>

thanks


Reported-by: Wang Long <wanglon...@meituan.com>
Signed-off-by: Greg Thelen <gthe...@google.com>
Change-Id: Ibb773e8045852978f6207074491d262f1b3fb613
---
Changelog since v2:
- explicitly initialize wb_lock_cookie to silence compiler warnings.

Changelog since v1:
- add wb_lock_cookie to record lock context.

  fs/fs-writeback.c|  7 ---
  include/linux/backing-dev-defs.h |  5 +
  include/linux/backing-dev.h  | 30 --
  mm/page-writeback.c  | 18 +-
  4 files changed, 34 insertions(+), 26 deletions(-)

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 1280f915079b..f4b2f6625913 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -745,11 +745,12 @@ int inode_congested(struct inode *inode, int cong_bits)
 */
if (inode && inode_to_wb_is_valid(inode)) {
struct bdi_writeback *wb;
-   bool locked, congested;
+   struct wb_lock_cookie lock_cookie;
+   bool congested;
  
-		wb = unlocked_inode_to_wb_begin(inode, );

+   wb = unlocked_inode_to_wb_begin(inode, _cookie);
congested = wb_congested(wb, cong_bits);
-   unlocked_inode_to_wb_end(inode, locked);
+   unlocked_inode_to_wb_end(inode, _cookie);
return congested;
}
  
diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h

index bfe86b54f6c1..0bd432a4d7bd 100644
--- a/include/linux/backing-dev-defs.h
+++ b/include/linux/backing-dev-defs.h
@@ -223,6 +223,11 @@ static inline void set_bdi_congested(struct 
backing_dev_info *bdi, int sync)
set_wb_congested(bdi->wb.congested, sync);
  }
  
+struct wb_lock_cookie {

+   bool locked;
+   unsigned long flags;
+};
+
  #ifdef CONFIG_CGROUP_WRITEBACK
  
  /**

diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 3e4ce54d84ab..1d744c61d996 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -346,7 +346,7 @@ static inline struct bdi_writeback *inode_to_wb(const 
struct inode *inode)
  /**
   * unlocked_inode_to_wb_begin - begin unlocked inode wb access transaction
   * @inode: target inode
- * @lockedp: temp bool output param, to be passed to the end function
+ * @cookie: output param, to be passed to the end function
   *
   * The caller wants to access the wb associated with @inode but isn't
   * holding inode->i_lock, mapping->tree_lock or wb->list_loc

Re: [PATCH v3] writeback: safer lock nesting

2018-04-10 Thread Wang Long

lock_page_memcg()/unlock_page_memcg() use spin_lock_irqsave/restore() if
the page's memcg is undergoing move accounting, which occurs when a
process leaves its memcg for a new one that has
memory.move_charge_at_immigrate set.

unlocked_inode_to_wb_begin,end() use spin_lock_irq/spin_unlock_irq() if the
given inode is switching writeback domains.  Switches occur when enough
writes are issued from a new domain.

This existing pattern is thus suspicious:
 lock_page_memcg(page);
 unlocked_inode_to_wb_begin(inode, );
 ...
 unlocked_inode_to_wb_end(inode, locked);
 unlock_page_memcg(page);

If both inode switch and process memcg migration are both in-flight then
unlocked_inode_to_wb_end() will unconditionally enable interrupts while
still holding the lock_page_memcg() irq spinlock.  This suggests the
possibility of deadlock if an interrupt occurs before
unlock_page_memcg().

 truncate
 __cancel_dirty_page
 lock_page_memcg
 unlocked_inode_to_wb_begin
 unlocked_inode_to_wb_end
 
 
 end_page_writeback
 test_clear_page_writeback
 lock_page_memcg
 
 unlock_page_memcg

Due to configuration limitations this deadlock is not currently possible
because we don't mix cgroup writeback (a cgroupv2 feature) and
memory.move_charge_at_immigrate (a cgroupv1 feature).

If the kernel is hacked to always claim inode switching and memcg
moving_account, then this script triggers lockup in less than a minute:
   cd /mnt/cgroup/memory
   mkdir a b
   echo 1 > a/memory.move_charge_at_immigrate
   echo 1 > b/memory.move_charge_at_immigrate
   (
 echo $BASHPID > a/cgroup.procs
 while true; do
   dd if=/dev/zero of=/mnt/big bs=1M count=256
 done
   ) &
   while true; do
 sync
   done &
   sleep 1h &
   SLEEP=$!
   while true; do
 echo $SLEEP > a/cgroup.procs
 echo $SLEEP > b/cgroup.procs
   done

Given the deadlock is not currently possible, it's debatable if there's
any reason to modify the kernel.  I suggest we should to prevent future
surprises.

This deadlock occurs three times in our environment,

this deadlock occurs three times in our environment. It is better to cc stable 
kernel and
backport it.

Acked-by: Wang Long 

thanks


Reported-by: Wang Long 
Signed-off-by: Greg Thelen 
Change-Id: Ibb773e8045852978f6207074491d262f1b3fb613
---
Changelog since v2:
- explicitly initialize wb_lock_cookie to silence compiler warnings.

Changelog since v1:
- add wb_lock_cookie to record lock context.

  fs/fs-writeback.c|  7 ---
  include/linux/backing-dev-defs.h |  5 +
  include/linux/backing-dev.h  | 30 --
  mm/page-writeback.c  | 18 +-
  4 files changed, 34 insertions(+), 26 deletions(-)

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 1280f915079b..f4b2f6625913 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -745,11 +745,12 @@ int inode_congested(struct inode *inode, int cong_bits)
 */
if (inode && inode_to_wb_is_valid(inode)) {
struct bdi_writeback *wb;
-   bool locked, congested;
+   struct wb_lock_cookie lock_cookie;
+   bool congested;
  
-		wb = unlocked_inode_to_wb_begin(inode, );

+   wb = unlocked_inode_to_wb_begin(inode, _cookie);
congested = wb_congested(wb, cong_bits);
-   unlocked_inode_to_wb_end(inode, locked);
+   unlocked_inode_to_wb_end(inode, _cookie);
return congested;
}
  
diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h

index bfe86b54f6c1..0bd432a4d7bd 100644
--- a/include/linux/backing-dev-defs.h
+++ b/include/linux/backing-dev-defs.h
@@ -223,6 +223,11 @@ static inline void set_bdi_congested(struct 
backing_dev_info *bdi, int sync)
set_wb_congested(bdi->wb.congested, sync);
  }
  
+struct wb_lock_cookie {

+   bool locked;
+   unsigned long flags;
+};
+
  #ifdef CONFIG_CGROUP_WRITEBACK
  
  /**

diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 3e4ce54d84ab..1d744c61d996 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -346,7 +346,7 @@ static inline struct bdi_writeback *inode_to_wb(const 
struct inode *inode)
  /**
   * unlocked_inode_to_wb_begin - begin unlocked inode wb access transaction
   * @inode: target inode
- * @lockedp: temp bool output param, to be passed to the end function
+ * @cookie: output param, to be passed to the end function
   *
   * The caller wants to access the wb associated with @inode but isn't
   * holding inode->i_lock, mapping->tree_lock or wb->list_lock.  This
@@ -354,12 +354,11 @@ static inline struct bdi_writeback *inode_to_wb(const 
struct inod

Re: [RFC] Is it correctly that the usage for spin_{lock|unlock}_irq in clear_page_dirty_for_io

2018-04-04 Thread Wang Long



On 4/4/2018 7:12 AM, Greg Thelen wrote:

On Tue, Apr 3, 2018 at 5:03 AM Michal Hocko <mho...@kernel.org> wrote:


On Mon 02-04-18 19:50:50, Wang Long wrote:

Hi,  Johannes Weiner and Tejun Heo

I use linux-4.4.y to test the new cgroup controller io and the current
stable kernel linux-4.4.y has the follow logic


int clear_page_dirty_for_io(struct page *page){
...
...
 memcg = mem_cgroup_begin_page_stat(page); --(a)
 wb = unlocked_inode_to_wb_begin(inode, );

-(b)

 if (TestClearPageDirty(page)) {
 mem_cgroup_dec_page_stat(memcg,

MEM_CGROUP_STAT_DIRTY);

 dec_zone_page_state(page, NR_FILE_DIRTY);
 dec_wb_stat(wb, WB_RECLAIMABLE);
 ret =1;
 }
 unlocked_inode_to_wb_end(inode, locked); ---(c)
 mem_cgroup_end_page_stat(memcg); -(d)
 return ret;
...
...
}


when memcg is moving, and I_WB_SWITCH flags for inode is set. the logic
is the following:


spin_lock_irqsave(>move_lock, flags); -(a)
 spin_lock_irq(>i_mapping->tree_lock); (b)
 spin_unlock_irq(>i_mapping->tree_lock); ---(c)
spin_unlock_irqrestore(>move_lock, flags); ---(d)


after (c) , the local irq is enabled. I think it is not correct.

We get a deadlock backtrace after (c), the cpu get an softirq and in the
irq it also call mem_cgroup_begin_page_stat to lock the same
memcg->move_lock.

Since the conditions are too harsh, this scenario is difficult to
reproduce.  But it really exists.

So how about change (b) (c) to spin_lock_irqsave/spin_lock_irqrestore?

Yes, it seems we really need this even for the current tree. Please note
that At least clear_page_dirty_for_io doesn't lock memcg anymore.
__cancel_dirty_page still uses lock_page_memcg though (former
mem_cgroup_begin_page_stat).
--
Michal Hocko
SUSE Labs

I agree the issue looks real in 4.4 stable and upstream.  It seems like
unlocked_inode_to_wb_begin/_end should use spin_lock_irqsave/restore.

I'm testing a little patch now.

Thanks.

When fix it on upstream. The longterm kernel 4.9 and 4.14 also need to fix.



Re: [RFC] Is it correctly that the usage for spin_{lock|unlock}_irq in clear_page_dirty_for_io

2018-04-04 Thread Wang Long



On 4/4/2018 7:12 AM, Greg Thelen wrote:

On Tue, Apr 3, 2018 at 5:03 AM Michal Hocko  wrote:


On Mon 02-04-18 19:50:50, Wang Long wrote:

Hi,  Johannes Weiner and Tejun Heo

I use linux-4.4.y to test the new cgroup controller io and the current
stable kernel linux-4.4.y has the follow logic


int clear_page_dirty_for_io(struct page *page){
...
...
 memcg = mem_cgroup_begin_page_stat(page); --(a)
 wb = unlocked_inode_to_wb_begin(inode, );

-(b)

 if (TestClearPageDirty(page)) {
 mem_cgroup_dec_page_stat(memcg,

MEM_CGROUP_STAT_DIRTY);

 dec_zone_page_state(page, NR_FILE_DIRTY);
 dec_wb_stat(wb, WB_RECLAIMABLE);
 ret =1;
 }
 unlocked_inode_to_wb_end(inode, locked); ---(c)
 mem_cgroup_end_page_stat(memcg); -(d)
 return ret;
...
...
}


when memcg is moving, and I_WB_SWITCH flags for inode is set. the logic
is the following:


spin_lock_irqsave(>move_lock, flags); -(a)
 spin_lock_irq(>i_mapping->tree_lock); (b)
 spin_unlock_irq(>i_mapping->tree_lock); ---(c)
spin_unlock_irqrestore(>move_lock, flags); ---(d)


after (c) , the local irq is enabled. I think it is not correct.

We get a deadlock backtrace after (c), the cpu get an softirq and in the
irq it also call mem_cgroup_begin_page_stat to lock the same
memcg->move_lock.

Since the conditions are too harsh, this scenario is difficult to
reproduce.  But it really exists.

So how about change (b) (c) to spin_lock_irqsave/spin_lock_irqrestore?

Yes, it seems we really need this even for the current tree. Please note
that At least clear_page_dirty_for_io doesn't lock memcg anymore.
__cancel_dirty_page still uses lock_page_memcg though (former
mem_cgroup_begin_page_stat).
--
Michal Hocko
SUSE Labs

I agree the issue looks real in 4.4 stable and upstream.  It seems like
unlocked_inode_to_wb_begin/_end should use spin_lock_irqsave/restore.

I'm testing a little patch now.

Thanks.

When fix it on upstream. The longterm kernel 4.9 and 4.14 also need to fix.



[RFC] Is it correctly that the usage for spin_{lock|unlock}_irq in clear_page_dirty_for_io

2018-04-02 Thread Wang Long


Hi,  Johannes Weiner and Tejun Heo

I use linux-4.4.y to test the new cgroup controller io and the current
stable kernel linux-4.4.y has the follow logic


int clear_page_dirty_for_io(struct page *page){
...
...
    memcg = mem_cgroup_begin_page_stat(page); --(a)
    wb = unlocked_inode_to_wb_begin(inode, ); -(b)
    if (TestClearPageDirty(page)) {
    mem_cgroup_dec_page_stat(memcg, MEM_CGROUP_STAT_DIRTY);
    dec_zone_page_state(page, NR_FILE_DIRTY);
    dec_wb_stat(wb, WB_RECLAIMABLE);
    ret =1;
    }
    unlocked_inode_to_wb_end(inode, locked); ---(c)
    mem_cgroup_end_page_stat(memcg); -(d)
    return ret;
...
...
}


when memcg is moving, and I_WB_SWITCH flags for inode is set. the logic
is the following:


spin_lock_irqsave(>move_lock, flags); -(a)
    spin_lock_irq(>i_mapping->tree_lock); (b)
    spin_unlock_irq(>i_mapping->tree_lock); ---(c)
spin_unlock_irqrestore(>move_lock, flags); ---(d)


after (c) , the local irq is enabled. I think it is not correct.

We get a deadlock backtrace after (c), the cpu get an softirq and in the
irq it also call mem_cgroup_begin_page_stat to lock the same
memcg->move_lock.

Since the conditions are too harsh, this scenario is difficult to
reproduce.  But it really exists.

So how about change (b) (c) to spin_lock_irqsave/spin_lock_irqrestore?

Thanks:-)



[RFC] Is it correctly that the usage for spin_{lock|unlock}_irq in clear_page_dirty_for_io

2018-04-02 Thread Wang Long


Hi,  Johannes Weiner and Tejun Heo

I use linux-4.4.y to test the new cgroup controller io and the current
stable kernel linux-4.4.y has the follow logic


int clear_page_dirty_for_io(struct page *page){
...
...
    memcg = mem_cgroup_begin_page_stat(page); --(a)
    wb = unlocked_inode_to_wb_begin(inode, ); -(b)
    if (TestClearPageDirty(page)) {
    mem_cgroup_dec_page_stat(memcg, MEM_CGROUP_STAT_DIRTY);
    dec_zone_page_state(page, NR_FILE_DIRTY);
    dec_wb_stat(wb, WB_RECLAIMABLE);
    ret =1;
    }
    unlocked_inode_to_wb_end(inode, locked); ---(c)
    mem_cgroup_end_page_stat(memcg); -(d)
    return ret;
...
...
}


when memcg is moving, and I_WB_SWITCH flags for inode is set. the logic
is the following:


spin_lock_irqsave(>move_lock, flags); -(a)
    spin_lock_irq(>i_mapping->tree_lock); (b)
    spin_unlock_irq(>i_mapping->tree_lock); ---(c)
spin_unlock_irqrestore(>move_lock, flags); ---(d)


after (c) , the local irq is enabled. I think it is not correct.

We get a deadlock backtrace after (c), the cpu get an softirq and in the
irq it also call mem_cgroup_begin_page_stat to lock the same
memcg->move_lock.

Since the conditions are too harsh, this scenario is difficult to
reproduce.  But it really exists.

So how about change (b) (c) to spin_lock_irqsave/spin_lock_irqrestore?

Thanks:-)



[PATCH] jbd2: remove the conditional test

2018-02-05 Thread Wang Long
kmem_cache_destroy already handles null pointers, so we can remove the
conditional test entirely.

This patch also set NULL after the kmem_cache_destroy in function
jbd2_journal_destroy_handle_cache.

Signed-off-by: Wang Long <wanglon...@meituan.com>
---
 fs/jbd2/journal.c | 18 +++---
 fs/jbd2/revoke.c  | 12 
 fs/jbd2/transaction.c |  6 ++
 3 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 93016bb..3c27a61a 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -2286,8 +2286,7 @@ static void jbd2_journal_destroy_slabs(void)
int i;
 
for (i = 0; i < JBD2_MAX_SLABS; i++) {
-   if (jbd2_slab[i])
-   kmem_cache_destroy(jbd2_slab[i]);
+   kmem_cache_destroy(jbd2_slab[i]);
jbd2_slab[i] = NULL;
}
 }
@@ -2388,10 +2387,8 @@ static int jbd2_journal_init_journal_head_cache(void)
 
 static void jbd2_journal_destroy_journal_head_cache(void)
 {
-   if (jbd2_journal_head_cache) {
-   kmem_cache_destroy(jbd2_journal_head_cache);
-   jbd2_journal_head_cache = NULL;
-   }
+   kmem_cache_destroy(jbd2_journal_head_cache);
+   jbd2_journal_head_cache = NULL;
 }
 
 /*
@@ -2649,11 +2646,10 @@ static int __init jbd2_journal_init_handle_cache(void)
 
 static void jbd2_journal_destroy_handle_cache(void)
 {
-   if (jbd2_handle_cache)
-   kmem_cache_destroy(jbd2_handle_cache);
-   if (jbd2_inode_cache)
-   kmem_cache_destroy(jbd2_inode_cache);
-
+   kmem_cache_destroy(jbd2_handle_cache);
+   jbd2_handle_cache = NULL;
+   kmem_cache_destroy(jbd2_inode_cache);
+   jbd2_inode_cache = NULL;
 }
 
 /*
diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c
index 696ef15..240779e 100644
--- a/fs/jbd2/revoke.c
+++ b/fs/jbd2/revoke.c
@@ -180,14 +180,10 @@ static struct jbd2_revoke_record_s 
*find_revoke_record(journal_t *journal,
 
 void jbd2_journal_destroy_revoke_caches(void)
 {
-   if (jbd2_revoke_record_cache) {
-   kmem_cache_destroy(jbd2_revoke_record_cache);
-   jbd2_revoke_record_cache = NULL;
-   }
-   if (jbd2_revoke_table_cache) {
-   kmem_cache_destroy(jbd2_revoke_table_cache);
-   jbd2_revoke_table_cache = NULL;
-   }
+   kmem_cache_destroy(jbd2_revoke_record_cache);
+   jbd2_revoke_record_cache = NULL;
+   kmem_cache_destroy(jbd2_revoke_table_cache);
+   jbd2_revoke_table_cache = NULL;
 }
 
 int __init jbd2_journal_init_revoke_caches(void)
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index ac31103..3b642e0 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -49,10 +49,8 @@ int __init jbd2_journal_init_transaction_cache(void)
 
 void jbd2_journal_destroy_transaction_cache(void)
 {
-   if (transaction_cache) {
-   kmem_cache_destroy(transaction_cache);
-   transaction_cache = NULL;
-   }
+   kmem_cache_destroy(transaction_cache);
+   transaction_cache = NULL;
 }
 
 void jbd2_journal_free_transaction(transaction_t *transaction)
-- 
1.8.3.1



[PATCH] jbd2: remove the conditional test

2018-02-05 Thread Wang Long
kmem_cache_destroy already handles null pointers, so we can remove the
conditional test entirely.

This patch also set NULL after the kmem_cache_destroy in function
jbd2_journal_destroy_handle_cache.

Signed-off-by: Wang Long 
---
 fs/jbd2/journal.c | 18 +++---
 fs/jbd2/revoke.c  | 12 
 fs/jbd2/transaction.c |  6 ++
 3 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 93016bb..3c27a61a 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -2286,8 +2286,7 @@ static void jbd2_journal_destroy_slabs(void)
int i;
 
for (i = 0; i < JBD2_MAX_SLABS; i++) {
-   if (jbd2_slab[i])
-   kmem_cache_destroy(jbd2_slab[i]);
+   kmem_cache_destroy(jbd2_slab[i]);
jbd2_slab[i] = NULL;
}
 }
@@ -2388,10 +2387,8 @@ static int jbd2_journal_init_journal_head_cache(void)
 
 static void jbd2_journal_destroy_journal_head_cache(void)
 {
-   if (jbd2_journal_head_cache) {
-   kmem_cache_destroy(jbd2_journal_head_cache);
-   jbd2_journal_head_cache = NULL;
-   }
+   kmem_cache_destroy(jbd2_journal_head_cache);
+   jbd2_journal_head_cache = NULL;
 }
 
 /*
@@ -2649,11 +2646,10 @@ static int __init jbd2_journal_init_handle_cache(void)
 
 static void jbd2_journal_destroy_handle_cache(void)
 {
-   if (jbd2_handle_cache)
-   kmem_cache_destroy(jbd2_handle_cache);
-   if (jbd2_inode_cache)
-   kmem_cache_destroy(jbd2_inode_cache);
-
+   kmem_cache_destroy(jbd2_handle_cache);
+   jbd2_handle_cache = NULL;
+   kmem_cache_destroy(jbd2_inode_cache);
+   jbd2_inode_cache = NULL;
 }
 
 /*
diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c
index 696ef15..240779e 100644
--- a/fs/jbd2/revoke.c
+++ b/fs/jbd2/revoke.c
@@ -180,14 +180,10 @@ static struct jbd2_revoke_record_s 
*find_revoke_record(journal_t *journal,
 
 void jbd2_journal_destroy_revoke_caches(void)
 {
-   if (jbd2_revoke_record_cache) {
-   kmem_cache_destroy(jbd2_revoke_record_cache);
-   jbd2_revoke_record_cache = NULL;
-   }
-   if (jbd2_revoke_table_cache) {
-   kmem_cache_destroy(jbd2_revoke_table_cache);
-   jbd2_revoke_table_cache = NULL;
-   }
+   kmem_cache_destroy(jbd2_revoke_record_cache);
+   jbd2_revoke_record_cache = NULL;
+   kmem_cache_destroy(jbd2_revoke_table_cache);
+   jbd2_revoke_table_cache = NULL;
 }
 
 int __init jbd2_journal_init_revoke_caches(void)
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index ac31103..3b642e0 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -49,10 +49,8 @@ int __init jbd2_journal_init_transaction_cache(void)
 
 void jbd2_journal_destroy_transaction_cache(void)
 {
-   if (transaction_cache) {
-   kmem_cache_destroy(transaction_cache);
-   transaction_cache = NULL;
-   }
+   kmem_cache_destroy(transaction_cache);
+   transaction_cache = NULL;
 }
 
 void jbd2_journal_free_transaction(transaction_t *transaction)
-- 
1.8.3.1



Re: [PATCH] jbd2: set to NULL after kmem_cache_destroy

2018-02-05 Thread Wang Long


On 6/2/2018 1:00 AM, Darrick J. Wong wrote:

On Mon, Feb 05, 2018 at 09:39:17PM +0800, Wang Long wrote:

Signed-off-by: Wang Long <wanglon...@meituan.com>
---
  fs/jbd2/journal.c | 9 ++---
  1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 93016bb..38dc24c 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -2649,11 +2649,14 @@ static int __init jbd2_journal_init_handle_cache(void)
  
  static void jbd2_journal_destroy_handle_cache(void)

  {
-   if (jbd2_handle_cache)
+   if (jbd2_handle_cache) {
kmem_cache_destroy(jbd2_handle_cache);

kmem_cache_destroy already handles null pointers, so you can remove the
conditional test entirely.

--D
Thanks, I will send another patch to remove all conditional test in 
module JBD2.

-   if (jbd2_inode_cache)
+   jbd2_handle_cache = NULL;
+   }
+   if (jbd2_inode_cache) {
kmem_cache_destroy(jbd2_inode_cache);
-
+   jbd2_inode_cache = NULL;
+   }
  }
  
  /*

--
1.8.3.1





Re: [PATCH] jbd2: set to NULL after kmem_cache_destroy

2018-02-05 Thread Wang Long


On 6/2/2018 1:00 AM, Darrick J. Wong wrote:

On Mon, Feb 05, 2018 at 09:39:17PM +0800, Wang Long wrote:

Signed-off-by: Wang Long 
---
  fs/jbd2/journal.c | 9 ++---
  1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 93016bb..38dc24c 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -2649,11 +2649,14 @@ static int __init jbd2_journal_init_handle_cache(void)
  
  static void jbd2_journal_destroy_handle_cache(void)

  {
-   if (jbd2_handle_cache)
+   if (jbd2_handle_cache) {
kmem_cache_destroy(jbd2_handle_cache);

kmem_cache_destroy already handles null pointers, so you can remove the
conditional test entirely.

--D
Thanks, I will send another patch to remove all conditional test in 
module JBD2.

-   if (jbd2_inode_cache)
+   jbd2_handle_cache = NULL;
+   }
+   if (jbd2_inode_cache) {
kmem_cache_destroy(jbd2_inode_cache);
-
+   jbd2_inode_cache = NULL;
+   }
  }
  
  /*

--
1.8.3.1





[PATCH] jbd2: set to NULL after kmem_cache_destroy

2018-02-05 Thread Wang Long
Signed-off-by: Wang Long <wanglon...@meituan.com>
---
 fs/jbd2/journal.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 93016bb..38dc24c 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -2649,11 +2649,14 @@ static int __init jbd2_journal_init_handle_cache(void)
 
 static void jbd2_journal_destroy_handle_cache(void)
 {
-   if (jbd2_handle_cache)
+   if (jbd2_handle_cache) {
kmem_cache_destroy(jbd2_handle_cache);
-   if (jbd2_inode_cache)
+   jbd2_handle_cache = NULL;
+   }
+   if (jbd2_inode_cache) {
kmem_cache_destroy(jbd2_inode_cache);
-
+   jbd2_inode_cache = NULL;
+   }
 }
 
 /*
-- 
1.8.3.1



[PATCH] jbd2: set to NULL after kmem_cache_destroy

2018-02-05 Thread Wang Long
Signed-off-by: Wang Long 
---
 fs/jbd2/journal.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 93016bb..38dc24c 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -2649,11 +2649,14 @@ static int __init jbd2_journal_init_handle_cache(void)
 
 static void jbd2_journal_destroy_handle_cache(void)
 {
-   if (jbd2_handle_cache)
+   if (jbd2_handle_cache) {
kmem_cache_destroy(jbd2_handle_cache);
-   if (jbd2_inode_cache)
+   jbd2_handle_cache = NULL;
+   }
+   if (jbd2_inode_cache) {
kmem_cache_destroy(jbd2_inode_cache);
-
+   jbd2_inode_cache = NULL;
+   }
 }
 
 /*
-- 
1.8.3.1



[PATCH] jbd2: remove duplicate `\n` in jbd_debug

2018-02-05 Thread Wang Long
The current jbd_debug output as the following:

```
[180397.891399] fs/jbd2/commit.c: (jbd2_journal_commit_transaction, 718): JBD2: 
Submit 4 IOs

[180397.891417] fs/jbd2/commit.c: (jbd2_journal_commit_transaction, 821): JBD2: 
commit phase 3

[180397.899183] fs/jbd2/commit.c: (jbd2_journal_commit_transaction, 863): JBD2: 
commit phase 4

[180397.899189] fs/jbd2/commit.c: (jbd2_journal_commit_transaction, 886): JBD2: 
commit phase 5

[180397.900321] fs/jbd2/commit.c: (jbd2_journal_commit_transaction, 923): JBD2: 
commit phase 6

[180397.900327] fs/jbd2/commit.c: (jbd2_journal_commit_transaction, 1092): 
JBD2: commit phase 7
```

Every jbd_debug call in kernel will append `\n` in its
fmt argument, so remove duplicate `\n`

Signed-off-by: Wang Long <wanglon...@meituan.com>
---
 fs/jbd2/journal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 3fbf48e..93016bb 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -114,7 +114,7 @@ void __jbd2_debug(int level, const char *file, const char 
*func,
va_start(args, fmt);
vaf.fmt = fmt;
vaf.va = 
-   printk(KERN_DEBUG "%s: (%s, %u): %pV\n", file, func, line, );
+   printk(KERN_DEBUG "%s: (%s, %u): %pV", file, func, line, );
va_end(args);
 }
 EXPORT_SYMBOL(__jbd2_debug);
-- 
1.8.3.1



[PATCH] jbd2: remove duplicate `\n` in jbd_debug

2018-02-05 Thread Wang Long
The current jbd_debug output as the following:

```
[180397.891399] fs/jbd2/commit.c: (jbd2_journal_commit_transaction, 718): JBD2: 
Submit 4 IOs

[180397.891417] fs/jbd2/commit.c: (jbd2_journal_commit_transaction, 821): JBD2: 
commit phase 3

[180397.899183] fs/jbd2/commit.c: (jbd2_journal_commit_transaction, 863): JBD2: 
commit phase 4

[180397.899189] fs/jbd2/commit.c: (jbd2_journal_commit_transaction, 886): JBD2: 
commit phase 5

[180397.900321] fs/jbd2/commit.c: (jbd2_journal_commit_transaction, 923): JBD2: 
commit phase 6

[180397.900327] fs/jbd2/commit.c: (jbd2_journal_commit_transaction, 1092): 
JBD2: commit phase 7
```

Every jbd_debug call in kernel will append `\n` in its
fmt argument, so remove duplicate `\n`

Signed-off-by: Wang Long 
---
 fs/jbd2/journal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 3fbf48e..93016bb 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -114,7 +114,7 @@ void __jbd2_debug(int level, const char *file, const char 
*func,
va_start(args, fmt);
vaf.fmt = fmt;
vaf.va = 
-   printk(KERN_DEBUG "%s: (%s, %u): %pV\n", file, func, line, );
+   printk(KERN_DEBUG "%s: (%s, %u): %pV", file, func, line, );
va_end(args);
 }
 EXPORT_SYMBOL(__jbd2_debug);
-- 
1.8.3.1



[PATCH] writeback: update comment in inode_io_list_move_locked

2017-12-05 Thread Wang Long
The @head can be wb->b_dirty_time, so update the comment.

Signed-off-by: Wang Long <wanglon...@meituan.com>
---
 fs/fs-writeback.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 8d477cf..7cb1dd1 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -126,7 +126,7 @@ static void wb_io_lists_depopulated(struct bdi_writeback 
*wb)
  * inode_io_list_move_locked - move an inode onto a bdi_writeback IO list
  * @inode: inode to be moved
  * @wb: target bdi_writeback
- * @head: one of @wb->b_{dirty|io|more_io}
+ * @head: one of @wb->b_{dirty|io|more_io|dirty_time}
  *
  * Move @inode->i_io_list to @list of @wb and set %WB_has_dirty_io.
  * Returns %true if @inode is the first occupant of the !dirty_time IO
-- 
1.8.3.1



[PATCH] writeback: update comment in inode_io_list_move_locked

2017-12-05 Thread Wang Long
The @head can be wb->b_dirty_time, so update the comment.

Signed-off-by: Wang Long 
---
 fs/fs-writeback.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 8d477cf..7cb1dd1 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -126,7 +126,7 @@ static void wb_io_lists_depopulated(struct bdi_writeback 
*wb)
  * inode_io_list_move_locked - move an inode onto a bdi_writeback IO list
  * @inode: inode to be moved
  * @wb: target bdi_writeback
- * @head: one of @wb->b_{dirty|io|more_io}
+ * @head: one of @wb->b_{dirty|io|more_io|dirty_time}
  *
  * Move @inode->i_io_list to @list of @wb and set %WB_has_dirty_io.
  * Returns %true if @inode is the first occupant of the !dirty_time IO
-- 
1.8.3.1



[PATCH] writeback: fix comment in __mark_inode_dirty

2017-12-04 Thread Wang Long
Signed-off-by: Wang Long <wanglon...@meituan.com>
---
 fs/fs-writeback.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index cea4836..8d477cf 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -2209,7 +2209,7 @@ void __mark_inode_dirty(struct inode *inode, int flags)
trace_writeback_dirty_inode_enqueue(inode);
 
/*
-* If this is the first dirty inode for this bdi,
+* If this is the first dirty inode for this wb,
 * we have to wake-up the corresponding bdi thread
 * to make sure background write-back happens
 * later.
-- 
1.8.3.1



[PATCH] writeback: fix comment in __mark_inode_dirty

2017-12-04 Thread Wang Long
Signed-off-by: Wang Long 
---
 fs/fs-writeback.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index cea4836..8d477cf 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -2209,7 +2209,7 @@ void __mark_inode_dirty(struct inode *inode, int flags)
trace_writeback_dirty_inode_enqueue(inode);
 
/*
-* If this is the first dirty inode for this bdi,
+* If this is the first dirty inode for this wb,
 * we have to wake-up the corresponding bdi thread
 * to make sure background write-back happens
 * later.
-- 
1.8.3.1



[PATCH] debug cgroup: use task_css_set instead of rcu_dereference

2017-11-20 Thread Wang Long
This macro `task_css_set` verifies that the caller is
inside proper critical section if the kernel set CONFIG_PROVE_RCU=y.

Signed-off-by: Wang Long <wanglon...@meituan.com>
---
 kernel/cgroup/debug.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/cgroup/debug.c b/kernel/cgroup/debug.c
index 5f780d8..9caeda6 100644
--- a/kernel/cgroup/debug.c
+++ b/kernel/cgroup/debug.c
@@ -50,7 +50,7 @@ static int current_css_set_read(struct seq_file *seq, void *v)
 
spin_lock_irq(_set_lock);
rcu_read_lock();
-   cset = rcu_dereference(current->cgroups);
+   cset = task_css_set(current);
refcnt = refcount_read(>refcount);
seq_printf(seq, "css_set %pK %d", cset, refcnt);
if (refcnt > cset->nr_tasks)
@@ -96,7 +96,7 @@ static int current_css_set_cg_links_read(struct seq_file 
*seq, void *v)
 
spin_lock_irq(_set_lock);
rcu_read_lock();
-   cset = rcu_dereference(current->cgroups);
+   cset = task_css_set(current);
list_for_each_entry(link, >cgrp_links, cgrp_link) {
struct cgroup *c = link->cgrp;
 
-- 
1.8.3.1



[PATCH] debug cgroup: use task_css_set instead of rcu_dereference

2017-11-20 Thread Wang Long
This macro `task_css_set` verifies that the caller is
inside proper critical section if the kernel set CONFIG_PROVE_RCU=y.

Signed-off-by: Wang Long 
---
 kernel/cgroup/debug.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/cgroup/debug.c b/kernel/cgroup/debug.c
index 5f780d8..9caeda6 100644
--- a/kernel/cgroup/debug.c
+++ b/kernel/cgroup/debug.c
@@ -50,7 +50,7 @@ static int current_css_set_read(struct seq_file *seq, void *v)
 
spin_lock_irq(_set_lock);
rcu_read_lock();
-   cset = rcu_dereference(current->cgroups);
+   cset = task_css_set(current);
refcnt = refcount_read(>refcount);
seq_printf(seq, "css_set %pK %d", cset, refcnt);
if (refcnt > cset->nr_tasks)
@@ -96,7 +96,7 @@ static int current_css_set_cg_links_read(struct seq_file 
*seq, void *v)
 
spin_lock_irq(_set_lock);
rcu_read_lock();
-   cset = rcu_dereference(current->cgroups);
+   cset = task_css_set(current);
list_for_each_entry(link, >cgrp_links, cgrp_link) {
struct cgroup *c = link->cgrp;
 
-- 
1.8.3.1



[PATCH v2] writeback: remove the unused function parameter

2017-11-04 Thread Wang Long
The parameter `struct bdi_writeback *wb` is not been used in the function
body. so we just remove it.

Signed-off-by: Wang Long <wanglon...@meituan.com>
---
 include/linux/backing-dev.h | 2 +-
 mm/page-writeback.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 1662157..186a2e7 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -95,7 +95,7 @@ static inline s64 wb_stat_sum(struct bdi_writeback *wb, enum 
wb_stat_item item)
 /*
  * maximal error of a stat counter.
  */
-static inline unsigned long wb_stat_error(struct bdi_writeback *wb)
+static inline unsigned long wb_stat_error(void)
 {
 #ifdef CONFIG_SMP
return nr_cpu_ids * WB_STAT_BATCH;
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 0b9c5cb..9287466 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -1543,7 +1543,7 @@ static inline void wb_dirty_limits(struct 
dirty_throttle_control *dtc)
 * actually dirty; with m+n sitting in the percpu
 * deltas.
 */
-   if (dtc->wb_thresh < 2 * wb_stat_error(wb)) {
+   if (dtc->wb_thresh < 2 * wb_stat_error()) {
wb_reclaimable = wb_stat_sum(wb, WB_RECLAIMABLE);
dtc->wb_dirty = wb_reclaimable + wb_stat_sum(wb, WB_WRITEBACK);
} else {
@@ -1802,7 +1802,7 @@ static void balance_dirty_pages(struct address_space 
*mapping,
 * more page. However wb_dirty has accounting errors.  So use
 * the larger and more IO friendly wb_stat_error.
 */
-   if (sdtc->wb_dirty <= wb_stat_error(wb))
+   if (sdtc->wb_dirty <= wb_stat_error())
break;
 
if (fatal_signal_pending(current))
-- 
1.8.3.1



[PATCH v2] writeback: remove the unused function parameter

2017-11-04 Thread Wang Long
The parameter `struct bdi_writeback *wb` is not been used in the function
body. so we just remove it.

Signed-off-by: Wang Long 
---
 include/linux/backing-dev.h | 2 +-
 mm/page-writeback.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 1662157..186a2e7 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -95,7 +95,7 @@ static inline s64 wb_stat_sum(struct bdi_writeback *wb, enum 
wb_stat_item item)
 /*
  * maximal error of a stat counter.
  */
-static inline unsigned long wb_stat_error(struct bdi_writeback *wb)
+static inline unsigned long wb_stat_error(void)
 {
 #ifdef CONFIG_SMP
return nr_cpu_ids * WB_STAT_BATCH;
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 0b9c5cb..9287466 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -1543,7 +1543,7 @@ static inline void wb_dirty_limits(struct 
dirty_throttle_control *dtc)
 * actually dirty; with m+n sitting in the percpu
 * deltas.
 */
-   if (dtc->wb_thresh < 2 * wb_stat_error(wb)) {
+   if (dtc->wb_thresh < 2 * wb_stat_error()) {
wb_reclaimable = wb_stat_sum(wb, WB_RECLAIMABLE);
dtc->wb_dirty = wb_reclaimable + wb_stat_sum(wb, WB_WRITEBACK);
} else {
@@ -1802,7 +1802,7 @@ static void balance_dirty_pages(struct address_space 
*mapping,
 * more page. However wb_dirty has accounting errors.  So use
 * the larger and more IO friendly wb_stat_error.
 */
-   if (sdtc->wb_dirty <= wb_stat_error(wb))
+   if (sdtc->wb_dirty <= wb_stat_error())
break;
 
if (fatal_signal_pending(current))
-- 
1.8.3.1



[PATCH] writeback: remove the unused function parameter

2017-11-04 Thread Wang Long
Signed-off-by: Wang Long <wanglon...@meituan.com>
---
 include/linux/backing-dev.h | 2 +-
 mm/page-writeback.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 1662157..186a2e7 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -95,7 +95,7 @@ static inline s64 wb_stat_sum(struct bdi_writeback *wb, enum 
wb_stat_item item)
 /*
  * maximal error of a stat counter.
  */
-static inline unsigned long wb_stat_error(struct bdi_writeback *wb)
+static inline unsigned long wb_stat_error(void)
 {
 #ifdef CONFIG_SMP
return nr_cpu_ids * WB_STAT_BATCH;
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 0b9c5cb..9287466 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -1543,7 +1543,7 @@ static inline void wb_dirty_limits(struct 
dirty_throttle_control *dtc)
 * actually dirty; with m+n sitting in the percpu
 * deltas.
 */
-   if (dtc->wb_thresh < 2 * wb_stat_error(wb)) {
+   if (dtc->wb_thresh < 2 * wb_stat_error()) {
wb_reclaimable = wb_stat_sum(wb, WB_RECLAIMABLE);
dtc->wb_dirty = wb_reclaimable + wb_stat_sum(wb, WB_WRITEBACK);
} else {
@@ -1802,7 +1802,7 @@ static void balance_dirty_pages(struct address_space 
*mapping,
 * more page. However wb_dirty has accounting errors.  So use
 * the larger and more IO friendly wb_stat_error.
 */
-   if (sdtc->wb_dirty <= wb_stat_error(wb))
+   if (sdtc->wb_dirty <= wb_stat_error())
break;
 
if (fatal_signal_pending(current))
-- 
1.8.3.1



[PATCH] writeback: remove the unused function parameter

2017-11-04 Thread Wang Long
Signed-off-by: Wang Long 
---
 include/linux/backing-dev.h | 2 +-
 mm/page-writeback.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 1662157..186a2e7 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -95,7 +95,7 @@ static inline s64 wb_stat_sum(struct bdi_writeback *wb, enum 
wb_stat_item item)
 /*
  * maximal error of a stat counter.
  */
-static inline unsigned long wb_stat_error(struct bdi_writeback *wb)
+static inline unsigned long wb_stat_error(void)
 {
 #ifdef CONFIG_SMP
return nr_cpu_ids * WB_STAT_BATCH;
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 0b9c5cb..9287466 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -1543,7 +1543,7 @@ static inline void wb_dirty_limits(struct 
dirty_throttle_control *dtc)
 * actually dirty; with m+n sitting in the percpu
 * deltas.
 */
-   if (dtc->wb_thresh < 2 * wb_stat_error(wb)) {
+   if (dtc->wb_thresh < 2 * wb_stat_error()) {
wb_reclaimable = wb_stat_sum(wb, WB_RECLAIMABLE);
dtc->wb_dirty = wb_reclaimable + wb_stat_sum(wb, WB_WRITEBACK);
} else {
@@ -1802,7 +1802,7 @@ static void balance_dirty_pages(struct address_space 
*mapping,
 * more page. However wb_dirty has accounting errors.  So use
 * the larger and more IO friendly wb_stat_error.
 */
-   if (sdtc->wb_dirty <= wb_stat_error(wb))
+   if (sdtc->wb_dirty <= wb_stat_error())
break;
 
if (fatal_signal_pending(current))
-- 
1.8.3.1



[PATCH] workqueue: Fix comment for unbound workqueue's attrbutes

2017-11-04 Thread Wang Long
Signed-off-by: Wang Long <wanglon...@meituan.com>
---
 kernel/workqueue.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index a2dccfe..ea3c29f 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5006,9 +5006,10 @@ int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)
  *
  * Unbound workqueues have the following extra attributes.
  *
- *  id RO int  : the associated pool ID
+ *  pool_ids   RO int  : the associated pool IDs for each node
  *  nice   RW int  : nice value of the workers
  *  cpumaskRW mask : bitmask of allowed CPUs for the workers
+ *  numa   RW bool : whether enable NUMA affinity
  */
 struct wq_device {
struct workqueue_struct *wq;
-- 
1.8.3.1



[PATCH] workqueue: Fix comment for unbound workqueue's attrbutes

2017-11-04 Thread Wang Long
Signed-off-by: Wang Long 
---
 kernel/workqueue.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index a2dccfe..ea3c29f 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5006,9 +5006,10 @@ int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)
  *
  * Unbound workqueues have the following extra attributes.
  *
- *  id RO int  : the associated pool ID
+ *  pool_ids   RO int  : the associated pool IDs for each node
  *  nice   RW int  : nice value of the workers
  *  cpumaskRW mask : bitmask of allowed CPUs for the workers
+ *  numa   RW bool : whether enable NUMA affinity
  */
 struct wq_device {
struct workqueue_struct *wq;
-- 
1.8.3.1



[PATCH v2] kselftest: add kselftest-clean rule

2015-10-07 Thread Wang Long
We use

$make TARGETS="size timers" kselftest

to build and run selftests. but there is no rule
for us to clean the kselftest generated files.

This patch add the rules, for example:

$ make TARGETS="size timers" kselftest-clean

can clean all kselftest generated files.

Signed-off-by: Wang Long 
---
 Makefile | 4 
 1 file changed, 4 insertions(+)

diff --git a/Makefile b/Makefile
index 1d341eb..3edd7b3 100644
--- a/Makefile
+++ b/Makefile
@@ -1075,6 +1075,9 @@ PHONY += kselftest
 kselftest:
$(Q)$(MAKE) -C tools/testing/selftests run_tests
 
+kselftest-clean:
+   $(Q)$(MAKE) -C tools/testing/selftests clean
+
 # ---
 # Modules
 
@@ -1282,6 +1285,7 @@ help:
@echo  '  kselftest   - Build and run kernel selftest (run as root)'
@echo  'Build, install, and boot kernel before'
@echo  'running kselftest on it'
+   @echo  '  kselftest-clean - Remove all generated kselftest files'
@echo  ''
@echo  'Kernel packaging:'
@$(MAKE) $(build)=$(package-dir) help
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] kselftest: add kselftest-clean rule

2015-10-07 Thread Wang Long
We use

$make TARGETS="size timers" kselftest

to build and run selftests. but there is no rule
for us to clean the kselftest generated files.

This patch add the rules, for example:

$ make TARGETS="size timers" kselftest-clean

can clean all kselftest generated files.

Signed-off-by: Wang Long <long.wangl...@huawei.com>
---
 Makefile | 4 
 1 file changed, 4 insertions(+)

diff --git a/Makefile b/Makefile
index 1d341eb..3edd7b3 100644
--- a/Makefile
+++ b/Makefile
@@ -1075,6 +1075,9 @@ PHONY += kselftest
 kselftest:
$(Q)$(MAKE) -C tools/testing/selftests run_tests
 
+kselftest-clean:
+   $(Q)$(MAKE) -C tools/testing/selftests clean
+
 # ---
 # Modules
 
@@ -1282,6 +1285,7 @@ help:
@echo  '  kselftest   - Build and run kernel selftest (run as root)'
@echo  'Build, install, and boot kernel before'
@echo  'running kselftest on it'
+   @echo  '  kselftest-clean - Remove all generated kselftest files'
@echo  ''
@echo  'Kernel packaging:'
@$(MAKE) $(build)=$(package-dir) help
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] kselftest: replace rm -f command with $(RM)

2015-09-29 Thread Wang Long
Some test's Makefile using "$(RM)" while the other's
using "rm -f". It is better to use one of them in all
tests.

"$(RM)" is clearly defined as a Makefile implicit variable
which defaults to "rm -f".
Ref. https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html

Signed-off-by: Wang Long 
---
 tools/testing/selftests/breakpoints/Makefile   | 2 +-
 tools/testing/selftests/efivarfs/Makefile  | 2 +-
 tools/testing/selftests/futex/functional/Makefile  | 2 +-
 tools/testing/selftests/ipc/Makefile   | 2 +-
 tools/testing/selftests/mount/Makefile | 2 +-
 tools/testing/selftests/mqueue/Makefile| 2 +-
 tools/testing/selftests/powerpc/Makefile   | 2 +-
 tools/testing/selftests/powerpc/copyloops/Makefile | 2 +-
 tools/testing/selftests/powerpc/dscr/Makefile  | 2 +-
 tools/testing/selftests/powerpc/mm/Makefile| 2 +-
 tools/testing/selftests/powerpc/pmu/Makefile   | 2 +-
 tools/testing/selftests/powerpc/pmu/ebb/Makefile   | 2 +-
 tools/testing/selftests/powerpc/primitives/Makefile| 2 +-
 tools/testing/selftests/powerpc/stringloops/Makefile   | 2 +-
 tools/testing/selftests/powerpc/switch_endian/Makefile | 2 +-
 tools/testing/selftests/powerpc/tm/Makefile| 2 +-
 tools/testing/selftests/powerpc/vphn/Makefile  | 2 +-
 tools/testing/selftests/ptrace/Makefile| 2 +-
 tools/testing/selftests/timers/Makefile| 2 +-
 19 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/tools/testing/selftests/breakpoints/Makefile 
b/tools/testing/selftests/breakpoints/Makefile
index d27108b..731bd31 100644
--- a/tools/testing/selftests/breakpoints/Makefile
+++ b/tools/testing/selftests/breakpoints/Makefile
@@ -11,4 +11,4 @@ all:
 include ../lib.mk
 
 clean:
-   rm -fr breakpoint_test
+   $(RM) breakpoint_test
diff --git a/tools/testing/selftests/efivarfs/Makefile 
b/tools/testing/selftests/efivarfs/Makefile
index 736c3dd..4a1c629 100644
--- a/tools/testing/selftests/efivarfs/Makefile
+++ b/tools/testing/selftests/efivarfs/Makefile
@@ -10,4 +10,4 @@ TEST_FILES := $(test_objs)
 include ../lib.mk
 
 clean:
-   rm -f $(test_objs)
+   $(RM) $(test_objs)
diff --git a/tools/testing/selftests/futex/functional/Makefile 
b/tools/testing/selftests/futex/functional/Makefile
index 9d6b75e..391d328 100644
--- a/tools/testing/selftests/futex/functional/Makefile
+++ b/tools/testing/selftests/futex/functional/Makefile
@@ -22,4 +22,4 @@ $(TARGETS): $(HEADERS)
 include ../../lib.mk
 
 clean:
-   rm -f $(TARGETS)
+   $(RM) $(TARGETS)
diff --git a/tools/testing/selftests/ipc/Makefile 
b/tools/testing/selftests/ipc/Makefile
index 25d2e70..071a706 100644
--- a/tools/testing/selftests/ipc/Makefile
+++ b/tools/testing/selftests/ipc/Makefile
@@ -19,4 +19,4 @@ TEST_PROGS := msgque_test
 include ../lib.mk
 
 clean:
-   rm -fr ./msgque_test
+   $(RM) ./msgque_test
diff --git a/tools/testing/selftests/mount/Makefile 
b/tools/testing/selftests/mount/Makefile
index 5e35c9c..9629382 100644
--- a/tools/testing/selftests/mount/Makefile
+++ b/tools/testing/selftests/mount/Makefile
@@ -18,4 +18,4 @@ override RUN_TESTS := if [ -f /proc/self/uid_map ] ; \
 override EMIT_TESTS := echo "$(RUN_TESTS)"
 
 clean:
-   rm -f unprivileged-remount-test
+   $(RM) unprivileged-remount-test
diff --git a/tools/testing/selftests/mqueue/Makefile 
b/tools/testing/selftests/mqueue/Makefile
index eebac29..d61b987 100644
--- a/tools/testing/selftests/mqueue/Makefile
+++ b/tools/testing/selftests/mqueue/Makefile
@@ -17,4 +17,4 @@ override define EMIT_TESTS
 endef
 
 clean:
-   rm -f mq_open_tests mq_perf_tests
+   $(RM) mq_open_tests mq_perf_tests
diff --git a/tools/testing/selftests/powerpc/Makefile 
b/tools/testing/selftests/powerpc/Makefile
index 03ca2e6..91aa06d 100644
--- a/tools/testing/selftests/powerpc/Makefile
+++ b/tools/testing/selftests/powerpc/Makefile
@@ -45,7 +45,7 @@ clean:
@for TARGET in $(SUB_DIRS); do \
$(MAKE) -C $$TARGET clean; \
done;
-   rm -f tags
+   $(RM) tags
 
 tags:
find . -name '*.c' -o -name '*.h' | xargs ctags
diff --git a/tools/testing/selftests/powerpc/copyloops/Makefile 
b/tools/testing/selftests/powerpc/copyloops/Makefile
index 384843e..28d6d6c 100644
--- a/tools/testing/selftests/powerpc/copyloops/Makefile
+++ b/tools/testing/selftests/powerpc/copyloops/Makefile
@@ -22,4 +22,4 @@ $(TEST_PROGS): $(EXTRA_SOURCES)
 include ../../lib.mk
 
 clean:
-   rm -f $(TEST_PROGS) *.o
+   $(RM) $(TEST_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/dscr/Makefile 
b/tools/testing/selftests/powerpc/dscr/Makefile
index 49327ee..d32a66e 100644
--- a/tools/testing/selftests/powerpc/dscr/Makefile
+++ b/tools/testing/selftests/powerpc/dscr/Makefile
@@ -11,4 +11,4 @@ $(TEST_PROGS): ../harness.c
 include ../../lib.mk
 
 c

[PATCH] kselftest: replace rm -f command with $(RM)

2015-09-29 Thread Wang Long
Some test's Makefile using "$(RM)" while the other's
using "rm -f". It is better to use one of them in all
tests.

"$(RM)" is clearly defined as a Makefile implicit variable
which defaults to "rm -f".
Ref. https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html

Signed-off-by: Wang Long <long.wangl...@huawei.com>
---
 tools/testing/selftests/breakpoints/Makefile   | 2 +-
 tools/testing/selftests/efivarfs/Makefile  | 2 +-
 tools/testing/selftests/futex/functional/Makefile  | 2 +-
 tools/testing/selftests/ipc/Makefile   | 2 +-
 tools/testing/selftests/mount/Makefile | 2 +-
 tools/testing/selftests/mqueue/Makefile| 2 +-
 tools/testing/selftests/powerpc/Makefile   | 2 +-
 tools/testing/selftests/powerpc/copyloops/Makefile | 2 +-
 tools/testing/selftests/powerpc/dscr/Makefile  | 2 +-
 tools/testing/selftests/powerpc/mm/Makefile| 2 +-
 tools/testing/selftests/powerpc/pmu/Makefile   | 2 +-
 tools/testing/selftests/powerpc/pmu/ebb/Makefile   | 2 +-
 tools/testing/selftests/powerpc/primitives/Makefile| 2 +-
 tools/testing/selftests/powerpc/stringloops/Makefile   | 2 +-
 tools/testing/selftests/powerpc/switch_endian/Makefile | 2 +-
 tools/testing/selftests/powerpc/tm/Makefile| 2 +-
 tools/testing/selftests/powerpc/vphn/Makefile  | 2 +-
 tools/testing/selftests/ptrace/Makefile| 2 +-
 tools/testing/selftests/timers/Makefile| 2 +-
 19 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/tools/testing/selftests/breakpoints/Makefile 
b/tools/testing/selftests/breakpoints/Makefile
index d27108b..731bd31 100644
--- a/tools/testing/selftests/breakpoints/Makefile
+++ b/tools/testing/selftests/breakpoints/Makefile
@@ -11,4 +11,4 @@ all:
 include ../lib.mk
 
 clean:
-   rm -fr breakpoint_test
+   $(RM) breakpoint_test
diff --git a/tools/testing/selftests/efivarfs/Makefile 
b/tools/testing/selftests/efivarfs/Makefile
index 736c3dd..4a1c629 100644
--- a/tools/testing/selftests/efivarfs/Makefile
+++ b/tools/testing/selftests/efivarfs/Makefile
@@ -10,4 +10,4 @@ TEST_FILES := $(test_objs)
 include ../lib.mk
 
 clean:
-   rm -f $(test_objs)
+   $(RM) $(test_objs)
diff --git a/tools/testing/selftests/futex/functional/Makefile 
b/tools/testing/selftests/futex/functional/Makefile
index 9d6b75e..391d328 100644
--- a/tools/testing/selftests/futex/functional/Makefile
+++ b/tools/testing/selftests/futex/functional/Makefile
@@ -22,4 +22,4 @@ $(TARGETS): $(HEADERS)
 include ../../lib.mk
 
 clean:
-   rm -f $(TARGETS)
+   $(RM) $(TARGETS)
diff --git a/tools/testing/selftests/ipc/Makefile 
b/tools/testing/selftests/ipc/Makefile
index 25d2e70..071a706 100644
--- a/tools/testing/selftests/ipc/Makefile
+++ b/tools/testing/selftests/ipc/Makefile
@@ -19,4 +19,4 @@ TEST_PROGS := msgque_test
 include ../lib.mk
 
 clean:
-   rm -fr ./msgque_test
+   $(RM) ./msgque_test
diff --git a/tools/testing/selftests/mount/Makefile 
b/tools/testing/selftests/mount/Makefile
index 5e35c9c..9629382 100644
--- a/tools/testing/selftests/mount/Makefile
+++ b/tools/testing/selftests/mount/Makefile
@@ -18,4 +18,4 @@ override RUN_TESTS := if [ -f /proc/self/uid_map ] ; \
 override EMIT_TESTS := echo "$(RUN_TESTS)"
 
 clean:
-   rm -f unprivileged-remount-test
+   $(RM) unprivileged-remount-test
diff --git a/tools/testing/selftests/mqueue/Makefile 
b/tools/testing/selftests/mqueue/Makefile
index eebac29..d61b987 100644
--- a/tools/testing/selftests/mqueue/Makefile
+++ b/tools/testing/selftests/mqueue/Makefile
@@ -17,4 +17,4 @@ override define EMIT_TESTS
 endef
 
 clean:
-   rm -f mq_open_tests mq_perf_tests
+   $(RM) mq_open_tests mq_perf_tests
diff --git a/tools/testing/selftests/powerpc/Makefile 
b/tools/testing/selftests/powerpc/Makefile
index 03ca2e6..91aa06d 100644
--- a/tools/testing/selftests/powerpc/Makefile
+++ b/tools/testing/selftests/powerpc/Makefile
@@ -45,7 +45,7 @@ clean:
@for TARGET in $(SUB_DIRS); do \
$(MAKE) -C $$TARGET clean; \
done;
-   rm -f tags
+   $(RM) tags
 
 tags:
find . -name '*.c' -o -name '*.h' | xargs ctags
diff --git a/tools/testing/selftests/powerpc/copyloops/Makefile 
b/tools/testing/selftests/powerpc/copyloops/Makefile
index 384843e..28d6d6c 100644
--- a/tools/testing/selftests/powerpc/copyloops/Makefile
+++ b/tools/testing/selftests/powerpc/copyloops/Makefile
@@ -22,4 +22,4 @@ $(TEST_PROGS): $(EXTRA_SOURCES)
 include ../../lib.mk
 
 clean:
-   rm -f $(TEST_PROGS) *.o
+   $(RM) $(TEST_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/dscr/Makefile 
b/tools/testing/selftests/powerpc/dscr/Makefile
index 49327ee..d32a66e 100644
--- a/tools/testing/selftests/powerpc/dscr/Makefile
+++ b/tools/testing/selftests/powerpc/dscr/Makefile
@@ -11,4 +11,4 @@ $(TEST_PROGS): ..

[PATCH] kselftest: replace $(RM) with rm -f command

2015-09-27 Thread Wang Long
Some test's Makefile using "$(RM)" while the other's
using "rm -f". It is better to use one of them in all
tests.

"rm -f" is better, because it is less magic, and everyone
konws what is does.

Signed-off-by: Wang Long 
---
 tools/testing/selftests/capabilities/Makefile | 2 +-
 tools/testing/selftests/kcmp/Makefile | 2 +-
 tools/testing/selftests/membarrier/Makefile   | 2 +-
 tools/testing/selftests/memfd/Makefile| 2 +-
 tools/testing/selftests/net/Makefile  | 2 +-
 tools/testing/selftests/seccomp/Makefile  | 2 +-
 tools/testing/selftests/size/Makefile | 2 +-
 tools/testing/selftests/vm/Makefile   | 2 +-
 tools/testing/selftests/x86/Makefile  | 2 +-
 tools/testing/selftests/zram/Makefile | 2 +-
 10 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/tools/testing/selftests/capabilities/Makefile 
b/tools/testing/selftests/capabilities/Makefile
index 8c8f0c1..dcc1972 100644
--- a/tools/testing/selftests/capabilities/Makefile
+++ b/tools/testing/selftests/capabilities/Makefile
@@ -12,7 +12,7 @@ CFLAGS := -O2 -g -std=gnu99 -Wall -lcap-ng
 all: $(TARGETS)
 
 clean:
-   $(RM) $(TARGETS)
+   rm -f $(TARGETS)
 
 $(TARGETS): %: %.c
$(CC) -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl
diff --git a/tools/testing/selftests/kcmp/Makefile 
b/tools/testing/selftests/kcmp/Makefile
index 2ae7450..2deaee0 100644
--- a/tools/testing/selftests/kcmp/Makefile
+++ b/tools/testing/selftests/kcmp/Makefile
@@ -7,4 +7,4 @@ TEST_PROGS := kcmp_test
 include ../lib.mk
 
 clean:
-   $(RM) kcmp_test kcmp-test-file
+   rn -f kcmp_test kcmp-test-file
diff --git a/tools/testing/selftests/membarrier/Makefile 
b/tools/testing/selftests/membarrier/Makefile
index a1a9708..f23fc58 100644
--- a/tools/testing/selftests/membarrier/Makefile
+++ b/tools/testing/selftests/membarrier/Makefile
@@ -7,4 +7,4 @@ all: $(TEST_PROGS)
 include ../lib.mk
 
 clean:
-   $(RM) $(TEST_PROGS)
+   rm -f $(TEST_PROGS)
diff --git a/tools/testing/selftests/memfd/Makefile 
b/tools/testing/selftests/memfd/Makefile
index 3e7eb79..068fa93 100644
--- a/tools/testing/selftests/memfd/Makefile
+++ b/tools/testing/selftests/memfd/Makefile
@@ -19,4 +19,4 @@ run_fuse: build_fuse
@./run_fuse_test.sh || echo "fuse_test: [FAIL]"
 
 clean:
-   $(RM) memfd_test fuse_test
+   rm -f memfd_test fuse_test
diff --git a/tools/testing/selftests/net/Makefile 
b/tools/testing/selftests/net/Makefile
index fac4782..ec7eaa4 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -16,4 +16,4 @@ TEST_FILES := $(NET_PROGS)
 include ../lib.mk
 
 clean:
-   $(RM) $(NET_PROGS)
+   rm -f $(NET_PROGS)
diff --git a/tools/testing/selftests/seccomp/Makefile 
b/tools/testing/selftests/seccomp/Makefile
index 8401e87..c16072a 100644
--- a/tools/testing/selftests/seccomp/Makefile
+++ b/tools/testing/selftests/seccomp/Makefile
@@ -7,4 +7,4 @@ all: $(TEST_PROGS)
 include ../lib.mk
 
 clean:
-   $(RM) $(TEST_PROGS)
+   rm -f $(TEST_PROGS)
diff --git a/tools/testing/selftests/size/Makefile 
b/tools/testing/selftests/size/Makefile
index bbd0b53..cefe914 100644
--- a/tools/testing/selftests/size/Makefile
+++ b/tools/testing/selftests/size/Makefile
@@ -8,4 +8,4 @@ TEST_PROGS := get_size
 include ../lib.mk
 
 clean:
-   $(RM) get_size
+   rm -f get_size
diff --git a/tools/testing/selftests/vm/Makefile 
b/tools/testing/selftests/vm/Makefile
index 3c53cac..26663c7 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -24,4 +24,4 @@ TEST_FILES := $(BINARIES)
 include ../lib.mk
 
 clean:
-   $(RM) $(BINARIES)
+   rm -f $(BINARIES)
diff --git a/tools/testing/selftests/x86/Makefile 
b/tools/testing/selftests/x86/Makefile
index 29089b2..48b2406 100644
--- a/tools/testing/selftests/x86/Makefile
+++ b/tools/testing/selftests/x86/Makefile
@@ -32,7 +32,7 @@ all_32: $(BINARIES_32)
 all_64: $(BINARIES_64)
 
 clean:
-   $(RM) $(BINARIES_32) $(BINARIES_64)
+   rm -f $(BINARIES_32) $(BINARIES_64)
 
 $(TARGETS_C_32BIT_ALL:%=%_32): %_32: %.c
$(CC) -m32 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl
diff --git a/tools/testing/selftests/zram/Makefile 
b/tools/testing/selftests/zram/Makefile
index 29d8034..e1591c8 100644
--- a/tools/testing/selftests/zram/Makefile
+++ b/tools/testing/selftests/zram/Makefile
@@ -6,4 +6,4 @@ TEST_FILES := zram01.sh zram02.sh zram_lib.sh
 include ../lib.mk
 
 clean:
-   $(RM) err.log
+   rm -f err.log
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] kselftest: replace $(RM) with rm -f command

2015-09-27 Thread Wang Long
Some test's Makefile using "$(RM)" while the other's
using "rm -f". It is better to use one of them in all
tests.

"rm -f" is better, because it is less magic, and everyone
konws what is does.

Signed-off-by: Wang Long <long.wangl...@huawei.com>
---
 tools/testing/selftests/capabilities/Makefile | 2 +-
 tools/testing/selftests/kcmp/Makefile | 2 +-
 tools/testing/selftests/membarrier/Makefile   | 2 +-
 tools/testing/selftests/memfd/Makefile| 2 +-
 tools/testing/selftests/net/Makefile  | 2 +-
 tools/testing/selftests/seccomp/Makefile  | 2 +-
 tools/testing/selftests/size/Makefile | 2 +-
 tools/testing/selftests/vm/Makefile   | 2 +-
 tools/testing/selftests/x86/Makefile  | 2 +-
 tools/testing/selftests/zram/Makefile | 2 +-
 10 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/tools/testing/selftests/capabilities/Makefile 
b/tools/testing/selftests/capabilities/Makefile
index 8c8f0c1..dcc1972 100644
--- a/tools/testing/selftests/capabilities/Makefile
+++ b/tools/testing/selftests/capabilities/Makefile
@@ -12,7 +12,7 @@ CFLAGS := -O2 -g -std=gnu99 -Wall -lcap-ng
 all: $(TARGETS)
 
 clean:
-   $(RM) $(TARGETS)
+   rm -f $(TARGETS)
 
 $(TARGETS): %: %.c
$(CC) -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl
diff --git a/tools/testing/selftests/kcmp/Makefile 
b/tools/testing/selftests/kcmp/Makefile
index 2ae7450..2deaee0 100644
--- a/tools/testing/selftests/kcmp/Makefile
+++ b/tools/testing/selftests/kcmp/Makefile
@@ -7,4 +7,4 @@ TEST_PROGS := kcmp_test
 include ../lib.mk
 
 clean:
-   $(RM) kcmp_test kcmp-test-file
+   rn -f kcmp_test kcmp-test-file
diff --git a/tools/testing/selftests/membarrier/Makefile 
b/tools/testing/selftests/membarrier/Makefile
index a1a9708..f23fc58 100644
--- a/tools/testing/selftests/membarrier/Makefile
+++ b/tools/testing/selftests/membarrier/Makefile
@@ -7,4 +7,4 @@ all: $(TEST_PROGS)
 include ../lib.mk
 
 clean:
-   $(RM) $(TEST_PROGS)
+   rm -f $(TEST_PROGS)
diff --git a/tools/testing/selftests/memfd/Makefile 
b/tools/testing/selftests/memfd/Makefile
index 3e7eb79..068fa93 100644
--- a/tools/testing/selftests/memfd/Makefile
+++ b/tools/testing/selftests/memfd/Makefile
@@ -19,4 +19,4 @@ run_fuse: build_fuse
@./run_fuse_test.sh || echo "fuse_test: [FAIL]"
 
 clean:
-   $(RM) memfd_test fuse_test
+   rm -f memfd_test fuse_test
diff --git a/tools/testing/selftests/net/Makefile 
b/tools/testing/selftests/net/Makefile
index fac4782..ec7eaa4 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -16,4 +16,4 @@ TEST_FILES := $(NET_PROGS)
 include ../lib.mk
 
 clean:
-   $(RM) $(NET_PROGS)
+   rm -f $(NET_PROGS)
diff --git a/tools/testing/selftests/seccomp/Makefile 
b/tools/testing/selftests/seccomp/Makefile
index 8401e87..c16072a 100644
--- a/tools/testing/selftests/seccomp/Makefile
+++ b/tools/testing/selftests/seccomp/Makefile
@@ -7,4 +7,4 @@ all: $(TEST_PROGS)
 include ../lib.mk
 
 clean:
-   $(RM) $(TEST_PROGS)
+   rm -f $(TEST_PROGS)
diff --git a/tools/testing/selftests/size/Makefile 
b/tools/testing/selftests/size/Makefile
index bbd0b53..cefe914 100644
--- a/tools/testing/selftests/size/Makefile
+++ b/tools/testing/selftests/size/Makefile
@@ -8,4 +8,4 @@ TEST_PROGS := get_size
 include ../lib.mk
 
 clean:
-   $(RM) get_size
+   rm -f get_size
diff --git a/tools/testing/selftests/vm/Makefile 
b/tools/testing/selftests/vm/Makefile
index 3c53cac..26663c7 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -24,4 +24,4 @@ TEST_FILES := $(BINARIES)
 include ../lib.mk
 
 clean:
-   $(RM) $(BINARIES)
+   rm -f $(BINARIES)
diff --git a/tools/testing/selftests/x86/Makefile 
b/tools/testing/selftests/x86/Makefile
index 29089b2..48b2406 100644
--- a/tools/testing/selftests/x86/Makefile
+++ b/tools/testing/selftests/x86/Makefile
@@ -32,7 +32,7 @@ all_32: $(BINARIES_32)
 all_64: $(BINARIES_64)
 
 clean:
-   $(RM) $(BINARIES_32) $(BINARIES_64)
+   rm -f $(BINARIES_32) $(BINARIES_64)
 
 $(TARGETS_C_32BIT_ALL:%=%_32): %_32: %.c
$(CC) -m32 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl
diff --git a/tools/testing/selftests/zram/Makefile 
b/tools/testing/selftests/zram/Makefile
index 29d8034..e1591c8 100644
--- a/tools/testing/selftests/zram/Makefile
+++ b/tools/testing/selftests/zram/Makefile
@@ -6,4 +6,4 @@ TEST_FILES := zram01.sh zram02.sh zram_lib.sh
 include ../lib.mk
 
 clean:
-   $(RM) err.log
+   rm -f err.log
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] kselftest: using built-in rule when delete file

2015-09-23 Thread Wang Long
Use make's built-in rules to when delete a file
or delete files.

Signed-off-by: Wang Long 
---
 tools/testing/selftests/breakpoints/Makefile   | 2 +-
 tools/testing/selftests/efivarfs/Makefile  | 2 +-
 tools/testing/selftests/futex/functional/Makefile  | 2 +-
 tools/testing/selftests/ipc/Makefile   | 2 +-
 tools/testing/selftests/mount/Makefile | 2 +-
 tools/testing/selftests/mqueue/Makefile| 2 +-
 tools/testing/selftests/powerpc/Makefile   | 2 +-
 tools/testing/selftests/powerpc/copyloops/Makefile | 2 +-
 tools/testing/selftests/powerpc/dscr/Makefile  | 2 +-
 tools/testing/selftests/powerpc/mm/Makefile| 2 +-
 tools/testing/selftests/powerpc/pmu/Makefile   | 2 +-
 tools/testing/selftests/powerpc/pmu/ebb/Makefile   | 2 +-
 tools/testing/selftests/powerpc/primitives/Makefile| 2 +-
 tools/testing/selftests/powerpc/stringloops/Makefile   | 2 +-
 tools/testing/selftests/powerpc/switch_endian/Makefile | 2 +-
 tools/testing/selftests/powerpc/tm/Makefile| 2 +-
 tools/testing/selftests/powerpc/vphn/Makefile  | 2 +-
 tools/testing/selftests/ptrace/Makefile| 2 +-
 tools/testing/selftests/timers/Makefile| 2 +-
 19 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/tools/testing/selftests/breakpoints/Makefile 
b/tools/testing/selftests/breakpoints/Makefile
index d27108b..731bd31 100644
--- a/tools/testing/selftests/breakpoints/Makefile
+++ b/tools/testing/selftests/breakpoints/Makefile
@@ -11,4 +11,4 @@ all:
 include ../lib.mk
 
 clean:
-   rm -fr breakpoint_test
+   $(RM) breakpoint_test
diff --git a/tools/testing/selftests/efivarfs/Makefile 
b/tools/testing/selftests/efivarfs/Makefile
index 736c3dd..4a1c629 100644
--- a/tools/testing/selftests/efivarfs/Makefile
+++ b/tools/testing/selftests/efivarfs/Makefile
@@ -10,4 +10,4 @@ TEST_FILES := $(test_objs)
 include ../lib.mk
 
 clean:
-   rm -f $(test_objs)
+   $(RM) $(test_objs)
diff --git a/tools/testing/selftests/futex/functional/Makefile 
b/tools/testing/selftests/futex/functional/Makefile
index 9d6b75e..391d328 100644
--- a/tools/testing/selftests/futex/functional/Makefile
+++ b/tools/testing/selftests/futex/functional/Makefile
@@ -22,4 +22,4 @@ $(TARGETS): $(HEADERS)
 include ../../lib.mk
 
 clean:
-   rm -f $(TARGETS)
+   $(RM) $(TARGETS)
diff --git a/tools/testing/selftests/ipc/Makefile 
b/tools/testing/selftests/ipc/Makefile
index 25d2e70..071a706 100644
--- a/tools/testing/selftests/ipc/Makefile
+++ b/tools/testing/selftests/ipc/Makefile
@@ -19,4 +19,4 @@ TEST_PROGS := msgque_test
 include ../lib.mk
 
 clean:
-   rm -fr ./msgque_test
+   $(RM) ./msgque_test
diff --git a/tools/testing/selftests/mount/Makefile 
b/tools/testing/selftests/mount/Makefile
index 5e35c9c..9629382 100644
--- a/tools/testing/selftests/mount/Makefile
+++ b/tools/testing/selftests/mount/Makefile
@@ -18,4 +18,4 @@ override RUN_TESTS := if [ -f /proc/self/uid_map ] ; \
 override EMIT_TESTS := echo "$(RUN_TESTS)"
 
 clean:
-   rm -f unprivileged-remount-test
+   $(RM) unprivileged-remount-test
diff --git a/tools/testing/selftests/mqueue/Makefile 
b/tools/testing/selftests/mqueue/Makefile
index eebac29..d61b987 100644
--- a/tools/testing/selftests/mqueue/Makefile
+++ b/tools/testing/selftests/mqueue/Makefile
@@ -17,4 +17,4 @@ override define EMIT_TESTS
 endef
 
 clean:
-   rm -f mq_open_tests mq_perf_tests
+   $(RM) mq_open_tests mq_perf_tests
diff --git a/tools/testing/selftests/powerpc/Makefile 
b/tools/testing/selftests/powerpc/Makefile
index 03ca2e6..91aa06d 100644
--- a/tools/testing/selftests/powerpc/Makefile
+++ b/tools/testing/selftests/powerpc/Makefile
@@ -45,7 +45,7 @@ clean:
@for TARGET in $(SUB_DIRS); do \
$(MAKE) -C $$TARGET clean; \
done;
-   rm -f tags
+   $(RM) tags
 
 tags:
find . -name '*.c' -o -name '*.h' | xargs ctags
diff --git a/tools/testing/selftests/powerpc/copyloops/Makefile 
b/tools/testing/selftests/powerpc/copyloops/Makefile
index 384843e..28d6d6c 100644
--- a/tools/testing/selftests/powerpc/copyloops/Makefile
+++ b/tools/testing/selftests/powerpc/copyloops/Makefile
@@ -22,4 +22,4 @@ $(TEST_PROGS): $(EXTRA_SOURCES)
 include ../../lib.mk
 
 clean:
-   rm -f $(TEST_PROGS) *.o
+   $(RM) $(TEST_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/dscr/Makefile 
b/tools/testing/selftests/powerpc/dscr/Makefile
index 49327ee..d32a66e 100644
--- a/tools/testing/selftests/powerpc/dscr/Makefile
+++ b/tools/testing/selftests/powerpc/dscr/Makefile
@@ -11,4 +11,4 @@ $(TEST_PROGS): ../harness.c
 include ../../lib.mk
 
 clean:
-   rm -f $(TEST_PROGS) *.o
+   $(RM) $(TEST_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/mm/Makefile 
b/tools/testing/selftests/powerpc/mm/Makefile
index ee179e2..7f63469 100644
--- a/tools/testing/selftests/powerpc/mm/Makefile
+

[PATCH] Documentation: Update kselftest.txt

2015-09-23 Thread Wang Long
Add document for how to install selftests.

Signed-off-by: Wang Long 
---
 Documentation/kselftest.txt | 16 
 1 file changed, 16 insertions(+)

diff --git a/Documentation/kselftest.txt b/Documentation/kselftest.txt
index a87d840..9bbbcdc 100644
--- a/Documentation/kselftest.txt
+++ b/Documentation/kselftest.txt
@@ -54,6 +54,22 @@ To run the hotplug tests:
 - note that some tests will require root privileges.
 
 
+Install selftests
+=
+
+You can use kselftest_install.sh tool installs selftests in default
+location which is tools/testing/selftests/kselftest or an user specified
+location.
+
+To install selftests in default location:
+   $ cd tools/testing/selftests
+   $ ./kselftest_install.sh
+
+To install selftests in an user specified location:
+   $ cd tools/testing/selftests
+   $ ./kselftest_install.sh install_dir
+
+
 Contributing new tests
 ==
 
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] kselftest: add cleankselftest rule

2015-09-23 Thread Wang Long
We use

$make TARGETS="size timers" kselftest

to build and run selftests. but there is no rule
for us to clean the kselftest generated files.

This patch add the rules, for example:

$ make TARGETS="size timers" cleankselftest

can clean all kselftst generated files.

Signed-off-by: Wang Long 
---
 Makefile | 4 
 1 file changed, 4 insertions(+)

diff --git a/Makefile b/Makefile
index 84f4b31..c25d139 100644
--- a/Makefile
+++ b/Makefile
@@ -1075,6 +1075,9 @@ PHONY += kselftest
 kselftest:
$(Q)$(MAKE) -C tools/testing/selftests run_tests
 
+cleankselftest:
+   $(Q)$(MAKE) -C tools/testing/selftests clean
+
 # ---
 # Modules
 
@@ -1282,6 +1285,7 @@ help:
@echo  '  kselftest   - Build and run kernel selftest (run as root)'
@echo  'Build, install, and boot kernel before'
@echo  'running kselftest on it'
+   @echo  '  cleankselftest  - Remove all generated kselftest files'
@echo  ''
@echo  'Kernel packaging:'
@$(MAKE) $(build)=$(package-dir) help
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] kselftest: add cleankselftest rule

2015-09-23 Thread Wang Long
We use

$make TARGETS="size timers" kselftest

to build and run selftests. but there is no rule
for us to clean the kselftest generated files.

This patch add the rules, for example:

$ make TARGETS="size timers" cleankselftest

can clean all kselftst generated files.

Signed-off-by: Wang Long <long.wangl...@huawei.com>
---
 Makefile | 4 
 1 file changed, 4 insertions(+)

diff --git a/Makefile b/Makefile
index 84f4b31..c25d139 100644
--- a/Makefile
+++ b/Makefile
@@ -1075,6 +1075,9 @@ PHONY += kselftest
 kselftest:
$(Q)$(MAKE) -C tools/testing/selftests run_tests
 
+cleankselftest:
+   $(Q)$(MAKE) -C tools/testing/selftests clean
+
 # ---
 # Modules
 
@@ -1282,6 +1285,7 @@ help:
@echo  '  kselftest   - Build and run kernel selftest (run as root)'
@echo  'Build, install, and boot kernel before'
@echo  'running kselftest on it'
+   @echo  '  cleankselftest  - Remove all generated kselftest files'
@echo  ''
@echo  'Kernel packaging:'
@$(MAKE) $(build)=$(package-dir) help
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Documentation: Update kselftest.txt

2015-09-23 Thread Wang Long
Add document for how to install selftests.

Signed-off-by: Wang Long <long.wangl...@huawei.com>
---
 Documentation/kselftest.txt | 16 
 1 file changed, 16 insertions(+)

diff --git a/Documentation/kselftest.txt b/Documentation/kselftest.txt
index a87d840..9bbbcdc 100644
--- a/Documentation/kselftest.txt
+++ b/Documentation/kselftest.txt
@@ -54,6 +54,22 @@ To run the hotplug tests:
 - note that some tests will require root privileges.
 
 
+Install selftests
+=
+
+You can use kselftest_install.sh tool installs selftests in default
+location which is tools/testing/selftests/kselftest or an user specified
+location.
+
+To install selftests in default location:
+   $ cd tools/testing/selftests
+   $ ./kselftest_install.sh
+
+To install selftests in an user specified location:
+   $ cd tools/testing/selftests
+   $ ./kselftest_install.sh install_dir
+
+
 Contributing new tests
 ==
 
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] kselftest: using built-in rule when delete file

2015-09-23 Thread Wang Long
Use make's built-in rules to when delete a file
or delete files.

Signed-off-by: Wang Long <long.wangl...@huawei.com>
---
 tools/testing/selftests/breakpoints/Makefile   | 2 +-
 tools/testing/selftests/efivarfs/Makefile  | 2 +-
 tools/testing/selftests/futex/functional/Makefile  | 2 +-
 tools/testing/selftests/ipc/Makefile   | 2 +-
 tools/testing/selftests/mount/Makefile | 2 +-
 tools/testing/selftests/mqueue/Makefile| 2 +-
 tools/testing/selftests/powerpc/Makefile   | 2 +-
 tools/testing/selftests/powerpc/copyloops/Makefile | 2 +-
 tools/testing/selftests/powerpc/dscr/Makefile  | 2 +-
 tools/testing/selftests/powerpc/mm/Makefile| 2 +-
 tools/testing/selftests/powerpc/pmu/Makefile   | 2 +-
 tools/testing/selftests/powerpc/pmu/ebb/Makefile   | 2 +-
 tools/testing/selftests/powerpc/primitives/Makefile| 2 +-
 tools/testing/selftests/powerpc/stringloops/Makefile   | 2 +-
 tools/testing/selftests/powerpc/switch_endian/Makefile | 2 +-
 tools/testing/selftests/powerpc/tm/Makefile| 2 +-
 tools/testing/selftests/powerpc/vphn/Makefile  | 2 +-
 tools/testing/selftests/ptrace/Makefile| 2 +-
 tools/testing/selftests/timers/Makefile| 2 +-
 19 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/tools/testing/selftests/breakpoints/Makefile 
b/tools/testing/selftests/breakpoints/Makefile
index d27108b..731bd31 100644
--- a/tools/testing/selftests/breakpoints/Makefile
+++ b/tools/testing/selftests/breakpoints/Makefile
@@ -11,4 +11,4 @@ all:
 include ../lib.mk
 
 clean:
-   rm -fr breakpoint_test
+   $(RM) breakpoint_test
diff --git a/tools/testing/selftests/efivarfs/Makefile 
b/tools/testing/selftests/efivarfs/Makefile
index 736c3dd..4a1c629 100644
--- a/tools/testing/selftests/efivarfs/Makefile
+++ b/tools/testing/selftests/efivarfs/Makefile
@@ -10,4 +10,4 @@ TEST_FILES := $(test_objs)
 include ../lib.mk
 
 clean:
-   rm -f $(test_objs)
+   $(RM) $(test_objs)
diff --git a/tools/testing/selftests/futex/functional/Makefile 
b/tools/testing/selftests/futex/functional/Makefile
index 9d6b75e..391d328 100644
--- a/tools/testing/selftests/futex/functional/Makefile
+++ b/tools/testing/selftests/futex/functional/Makefile
@@ -22,4 +22,4 @@ $(TARGETS): $(HEADERS)
 include ../../lib.mk
 
 clean:
-   rm -f $(TARGETS)
+   $(RM) $(TARGETS)
diff --git a/tools/testing/selftests/ipc/Makefile 
b/tools/testing/selftests/ipc/Makefile
index 25d2e70..071a706 100644
--- a/tools/testing/selftests/ipc/Makefile
+++ b/tools/testing/selftests/ipc/Makefile
@@ -19,4 +19,4 @@ TEST_PROGS := msgque_test
 include ../lib.mk
 
 clean:
-   rm -fr ./msgque_test
+   $(RM) ./msgque_test
diff --git a/tools/testing/selftests/mount/Makefile 
b/tools/testing/selftests/mount/Makefile
index 5e35c9c..9629382 100644
--- a/tools/testing/selftests/mount/Makefile
+++ b/tools/testing/selftests/mount/Makefile
@@ -18,4 +18,4 @@ override RUN_TESTS := if [ -f /proc/self/uid_map ] ; \
 override EMIT_TESTS := echo "$(RUN_TESTS)"
 
 clean:
-   rm -f unprivileged-remount-test
+   $(RM) unprivileged-remount-test
diff --git a/tools/testing/selftests/mqueue/Makefile 
b/tools/testing/selftests/mqueue/Makefile
index eebac29..d61b987 100644
--- a/tools/testing/selftests/mqueue/Makefile
+++ b/tools/testing/selftests/mqueue/Makefile
@@ -17,4 +17,4 @@ override define EMIT_TESTS
 endef
 
 clean:
-   rm -f mq_open_tests mq_perf_tests
+   $(RM) mq_open_tests mq_perf_tests
diff --git a/tools/testing/selftests/powerpc/Makefile 
b/tools/testing/selftests/powerpc/Makefile
index 03ca2e6..91aa06d 100644
--- a/tools/testing/selftests/powerpc/Makefile
+++ b/tools/testing/selftests/powerpc/Makefile
@@ -45,7 +45,7 @@ clean:
@for TARGET in $(SUB_DIRS); do \
$(MAKE) -C $$TARGET clean; \
done;
-   rm -f tags
+   $(RM) tags
 
 tags:
find . -name '*.c' -o -name '*.h' | xargs ctags
diff --git a/tools/testing/selftests/powerpc/copyloops/Makefile 
b/tools/testing/selftests/powerpc/copyloops/Makefile
index 384843e..28d6d6c 100644
--- a/tools/testing/selftests/powerpc/copyloops/Makefile
+++ b/tools/testing/selftests/powerpc/copyloops/Makefile
@@ -22,4 +22,4 @@ $(TEST_PROGS): $(EXTRA_SOURCES)
 include ../../lib.mk
 
 clean:
-   rm -f $(TEST_PROGS) *.o
+   $(RM) $(TEST_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/dscr/Makefile 
b/tools/testing/selftests/powerpc/dscr/Makefile
index 49327ee..d32a66e 100644
--- a/tools/testing/selftests/powerpc/dscr/Makefile
+++ b/tools/testing/selftests/powerpc/dscr/Makefile
@@ -11,4 +11,4 @@ $(TEST_PROGS): ../harness.c
 include ../../lib.mk
 
 clean:
-   rm -f $(TEST_PROGS) *.o
+   $(RM) $(TEST_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/mm/Makefile 
b/tools/testing/selftests/powerpc/mm/Makefile
index ee179e2..7f63469 100644
--- a/tools/testing/self

[PATCH v2] kasan: Fix a type conversion error

2015-09-09 Thread Wang Long
The current KASAN code can not find the following out-of-bounds
bugs:
char *ptr;
ptr = kmalloc(8, GFP_KERNEL);
memset(ptr+7, 0, 2);

the cause of the problem is the type conversion error in
*memory_is_poisoned_n* function. So this patch fix that.

Signed-off-by: Wang Long 
Acked-by: Andrey Ryabinin 
---
 mm/kasan/kasan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
index 7b28e9c..5d65d06 100644
--- a/mm/kasan/kasan.c
+++ b/mm/kasan/kasan.c
@@ -204,7 +204,7 @@ static __always_inline bool memory_is_poisoned_n(unsigned 
long addr,
s8 *last_shadow = (s8 *)kasan_mem_to_shadow((void *)last_byte);
 
if (unlikely(ret != (unsigned long)last_shadow ||
-   ((last_byte & KASAN_SHADOW_MASK) >= *last_shadow)))
+   ((long)(last_byte & KASAN_SHADOW_MASK) >= 
*last_shadow)))
return true;
}
return false;
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] kasan: Fix a type conversion error

2015-09-09 Thread Wang Long
The current KASAN code can not find the following out-of-bounds
bugs:
char *ptr;
ptr = kmalloc(8, GFP_KERNEL);
memset(ptr+7, 0, 2);

the cause of the problem is the type conversion error in
*memory_is_poisoned_n* function. So this patch fix that.

Signed-off-by: Wang Long <long.wangl...@huawei.com>
Acked-by: Andrey Ryabinin <aryabi...@virtuozzo.com>
---
 mm/kasan/kasan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
index 7b28e9c..5d65d06 100644
--- a/mm/kasan/kasan.c
+++ b/mm/kasan/kasan.c
@@ -204,7 +204,7 @@ static __always_inline bool memory_is_poisoned_n(unsigned 
long addr,
s8 *last_shadow = (s8 *)kasan_mem_to_shadow((void *)last_byte);
 
if (unlikely(ret != (unsigned long)last_shadow ||
-   ((last_byte & KASAN_SHADOW_MASK) >= *last_shadow)))
+   ((long)(last_byte & KASAN_SHADOW_MASK) >= 
*last_shadow)))
return true;
}
return false;
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] lib: test_kasan: add some testcases

2015-09-08 Thread Wang Long
This patch add some out of bounds testcases to test_kasan
module.

Signed-off-by: Wang Long 
---
 lib/test_kasan.c | 69 
 1 file changed, 69 insertions(+)

diff --git a/lib/test_kasan.c b/lib/test_kasan.c
index c1efb1b..c32f3b0 100644
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -138,6 +138,71 @@ static noinline void __init kmalloc_oob_16(void)
kfree(ptr2);
 }
 
+static noinline void __init kmalloc_oob_memset_2(void)
+{
+   char *ptr;
+   size_t size = 8;
+
+   pr_info("out-of-bounds in memset2\n");
+   ptr = kmalloc(size, GFP_KERNEL);
+   if (!ptr) {
+   pr_err("Allocation failed\n");
+   return;
+   }
+
+   memset(ptr+7, 0, 2);
+   kfree(ptr);
+}
+
+static noinline void __init kmalloc_oob_memset_4(void)
+{
+   char *ptr;
+   size_t size = 8;
+
+   pr_info("out-of-bounds in memset4\n");
+   ptr = kmalloc(size, GFP_KERNEL);
+   if (!ptr) {
+   pr_err("Allocation failed\n");
+   return;
+   }
+
+   memset(ptr+5, 0, 4);
+   kfree(ptr);
+}
+
+
+static noinline void __init kmalloc_oob_memset_8(void)
+{
+   char *ptr;
+   size_t size = 8;
+
+   pr_info("out-of-bounds in memset8\n");
+   ptr = kmalloc(size, GFP_KERNEL);
+   if (!ptr) {
+   pr_err("Allocation failed\n");
+   return;
+   }
+
+   memset(ptr+1, 0, 8);
+   kfree(ptr);
+}
+
+static noinline void __init kmalloc_oob_memset_16(void)
+{
+   char *ptr;
+   size_t size = 16;
+
+   pr_info("out-of-bounds in memset16\n");
+   ptr = kmalloc(size, GFP_KERNEL);
+   if (!ptr) {
+   pr_err("Allocation failed\n");
+   return;
+   }
+
+   memset(ptr+1, 0, 16);
+   kfree(ptr);
+}
+
 static noinline void __init kmalloc_oob_in_memset(void)
 {
char *ptr;
@@ -264,6 +329,10 @@ static int __init kmalloc_tests_init(void)
kmalloc_oob_krealloc_less();
kmalloc_oob_16();
kmalloc_oob_in_memset();
+   kmalloc_oob_memset_2();
+   kmalloc_oob_memset_4();
+   kmalloc_oob_memset_8();
+   kmalloc_oob_memset_16();
kmalloc_uaf();
kmalloc_uaf_memset();
kmalloc_uaf2();
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] kasan: Fix a type conversion error

2015-09-08 Thread Wang Long
The current KASAN code can find the following out-of-bounds
bugs:
char *ptr;
ptr = kmalloc(8, GFP_KERNEL);
memset(ptr+7, 0, 2);

the cause of the problem is the type conversion error in
*memory_is_poisoned_n* function. So this patch fix that.

Signed-off-by: Wang Long 
---
 mm/kasan/kasan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
index 7b28e9c..5d65d06 100644
--- a/mm/kasan/kasan.c
+++ b/mm/kasan/kasan.c
@@ -204,7 +204,7 @@ static __always_inline bool memory_is_poisoned_n(unsigned 
long addr,
s8 *last_shadow = (s8 *)kasan_mem_to_shadow((void *)last_byte);
 
if (unlikely(ret != (unsigned long)last_shadow ||
-   ((last_byte & KASAN_SHADOW_MASK) >= *last_shadow)))
+   ((long)(last_byte & KASAN_SHADOW_MASK) >= 
*last_shadow)))
return true;
}
return false;
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/2] KASAN: fix a type conversion error and add test

2015-09-08 Thread Wang Long
Hi,

This patchset fix a type conversion error for KASAN.

patch 1: this patch add some out-of-bounds testcases, the current KASAN code
can not find these bugs.

patch 2: fix the type conversion error, with this patch, KASAN could find
these out-of-bounds bugs.

Wang Long (2):
  lib: test_kasan: add some testcases
  kasan: Fix a type conversion error

 lib/test_kasan.c | 69 
 mm/kasan/kasan.c |  2 +-
 2 files changed, 70 insertions(+), 1 deletion(-)

-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] kasan: Fix a type conversion error

2015-09-08 Thread Wang Long
The current KASAN code can find the following out-of-bounds
bugs:
char *ptr;
ptr = kmalloc(8, GFP_KERNEL);
memset(ptr+7, 0, 2);

the cause of the problem is the type conversion error in
*memory_is_poisoned_n* function. So this patch fix that.

Signed-off-by: Wang Long <long.wangl...@huawei.com>
---
 mm/kasan/kasan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
index 7b28e9c..5d65d06 100644
--- a/mm/kasan/kasan.c
+++ b/mm/kasan/kasan.c
@@ -204,7 +204,7 @@ static __always_inline bool memory_is_poisoned_n(unsigned 
long addr,
s8 *last_shadow = (s8 *)kasan_mem_to_shadow((void *)last_byte);
 
if (unlikely(ret != (unsigned long)last_shadow ||
-   ((last_byte & KASAN_SHADOW_MASK) >= *last_shadow)))
+   ((long)(last_byte & KASAN_SHADOW_MASK) >= 
*last_shadow)))
return true;
}
return false;
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] lib: test_kasan: add some testcases

2015-09-08 Thread Wang Long
This patch add some out of bounds testcases to test_kasan
module.

Signed-off-by: Wang Long <long.wangl...@huawei.com>
---
 lib/test_kasan.c | 69 
 1 file changed, 69 insertions(+)

diff --git a/lib/test_kasan.c b/lib/test_kasan.c
index c1efb1b..c32f3b0 100644
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -138,6 +138,71 @@ static noinline void __init kmalloc_oob_16(void)
kfree(ptr2);
 }
 
+static noinline void __init kmalloc_oob_memset_2(void)
+{
+   char *ptr;
+   size_t size = 8;
+
+   pr_info("out-of-bounds in memset2\n");
+   ptr = kmalloc(size, GFP_KERNEL);
+   if (!ptr) {
+   pr_err("Allocation failed\n");
+   return;
+   }
+
+   memset(ptr+7, 0, 2);
+   kfree(ptr);
+}
+
+static noinline void __init kmalloc_oob_memset_4(void)
+{
+   char *ptr;
+   size_t size = 8;
+
+   pr_info("out-of-bounds in memset4\n");
+   ptr = kmalloc(size, GFP_KERNEL);
+   if (!ptr) {
+   pr_err("Allocation failed\n");
+   return;
+   }
+
+   memset(ptr+5, 0, 4);
+   kfree(ptr);
+}
+
+
+static noinline void __init kmalloc_oob_memset_8(void)
+{
+   char *ptr;
+   size_t size = 8;
+
+   pr_info("out-of-bounds in memset8\n");
+   ptr = kmalloc(size, GFP_KERNEL);
+   if (!ptr) {
+   pr_err("Allocation failed\n");
+   return;
+   }
+
+   memset(ptr+1, 0, 8);
+   kfree(ptr);
+}
+
+static noinline void __init kmalloc_oob_memset_16(void)
+{
+   char *ptr;
+   size_t size = 16;
+
+   pr_info("out-of-bounds in memset16\n");
+   ptr = kmalloc(size, GFP_KERNEL);
+   if (!ptr) {
+   pr_err("Allocation failed\n");
+   return;
+   }
+
+   memset(ptr+1, 0, 16);
+   kfree(ptr);
+}
+
 static noinline void __init kmalloc_oob_in_memset(void)
 {
char *ptr;
@@ -264,6 +329,10 @@ static int __init kmalloc_tests_init(void)
kmalloc_oob_krealloc_less();
kmalloc_oob_16();
kmalloc_oob_in_memset();
+   kmalloc_oob_memset_2();
+   kmalloc_oob_memset_4();
+   kmalloc_oob_memset_8();
+   kmalloc_oob_memset_16();
kmalloc_uaf();
kmalloc_uaf_memset();
kmalloc_uaf2();
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/2] KASAN: fix a type conversion error and add test

2015-09-08 Thread Wang Long
Hi,

This patchset fix a type conversion error for KASAN.

patch 1: this patch add some out-of-bounds testcases, the current KASAN code
can not find these bugs.

patch 2: fix the type conversion error, with this patch, KASAN could find
these out-of-bounds bugs.

Wang Long (2):
  lib: test_kasan: add some testcases
  kasan: Fix a type conversion error

 lib/test_kasan.c | 69 
 mm/kasan/kasan.c |  2 +-
 2 files changed, 70 insertions(+), 1 deletion(-)

-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH] test_kasan: make kmalloc_oob_krealloc_less more correctly

2015-08-21 Thread Wang Long
In kmalloc_oob_krealloc_less, I think it is better to test
the size2 boundary.

If we do not call krealloc, the access of position size1 will
still cause out-of-bounds and access of position size2 does not.
After call krealloc, the access of position size2 cause
out-of-bounds. So, use size2 is more correctly.

Signed-off-by: Wang Long 
---
 lib/test_kasan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/test_kasan.c b/lib/test_kasan.c
index 044c54d..c1efb1b 100644
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -114,7 +114,7 @@ static noinline void __init kmalloc_oob_krealloc_less(void)
kfree(ptr1);
return;
}
-   ptr2[size1] = 'x';
+   ptr2[size2] = 'x';
kfree(ptr2);
 }
 
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] test_kasan: just fix a typo

2015-08-21 Thread Wang Long
This patch just fix a typo in test_kasan.

Signed-off-by: Wang Long 
---
 lib/test_kasan.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/test_kasan.c b/lib/test_kasan.c
index 098c08e..044c54d 100644
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -65,7 +65,7 @@ static noinline void __init kmalloc_node_oob_right(void)
kfree(ptr);
 }
 
-static noinline void __init kmalloc_large_oob_rigth(void)
+static noinline void __init kmalloc_large_oob_right(void)
 {
char *ptr;
size_t size = KMALLOC_MAX_CACHE_SIZE + 10;
@@ -259,7 +259,7 @@ static int __init kmalloc_tests_init(void)
kmalloc_oob_right();
kmalloc_oob_left();
kmalloc_node_oob_right();
-   kmalloc_large_oob_rigth();
+   kmalloc_large_oob_right();
kmalloc_oob_krealloc_more();
kmalloc_oob_krealloc_less();
kmalloc_oob_16();
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] test_kasan: just fix a typo

2015-08-21 Thread Wang Long
This patch just fix a typo in test_kasan.

Signed-off-by: Wang Long long.wangl...@huawei.com
---
 lib/test_kasan.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/test_kasan.c b/lib/test_kasan.c
index 098c08e..044c54d 100644
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -65,7 +65,7 @@ static noinline void __init kmalloc_node_oob_right(void)
kfree(ptr);
 }
 
-static noinline void __init kmalloc_large_oob_rigth(void)
+static noinline void __init kmalloc_large_oob_right(void)
 {
char *ptr;
size_t size = KMALLOC_MAX_CACHE_SIZE + 10;
@@ -259,7 +259,7 @@ static int __init kmalloc_tests_init(void)
kmalloc_oob_right();
kmalloc_oob_left();
kmalloc_node_oob_right();
-   kmalloc_large_oob_rigth();
+   kmalloc_large_oob_right();
kmalloc_oob_krealloc_more();
kmalloc_oob_krealloc_less();
kmalloc_oob_16();
-- 
1.8.3.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH] test_kasan: make kmalloc_oob_krealloc_less more correctly

2015-08-21 Thread Wang Long
In kmalloc_oob_krealloc_less, I think it is better to test
the size2 boundary.

If we do not call krealloc, the access of position size1 will
still cause out-of-bounds and access of position size2 does not.
After call krealloc, the access of position size2 cause
out-of-bounds. So, use size2 is more correctly.

Signed-off-by: Wang Long long.wangl...@huawei.com
---
 lib/test_kasan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/test_kasan.c b/lib/test_kasan.c
index 044c54d..c1efb1b 100644
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -114,7 +114,7 @@ static noinline void __init kmalloc_oob_krealloc_less(void)
kfree(ptr1);
return;
}
-   ptr2[size1] = 'x';
+   ptr2[size2] = 'x';
kfree(ptr2);
 }
 
-- 
1.8.3.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] arm64: mm: add __init section marker to free_initrd_mem

2015-07-26 Thread Wang Long
It is not needed after booting, this patch moves the
free_initrd_mem() function to the __init section.

This patch also make keep_initrd __initdata, to reduce kernel
size.

Signed-off-by: Wang Long 
---
 arch/arm64/mm/init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index ad87ce8..f5c0680 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -358,9 +358,9 @@ void free_initmem(void)
 
 #ifdef CONFIG_BLK_DEV_INITRD
 
-static int keep_initrd;
+static int keep_initrd __initdata;
 
-void free_initrd_mem(unsigned long start, unsigned long end)
+void __init free_initrd_mem(unsigned long start, unsigned long end)
 {
if (!keep_initrd)
free_reserved_area((void *)start, (void *)end, 0, "initrd");
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] arm: mm: add __init section marker to free_initrd_mem

2015-07-26 Thread Wang Long
It is not needed after booting, this patch moves the
free_initrd_mem() function to the __init section.

This patch also make keep_initrd __initdata, to reduce kernel
size.

Signed-off-by: Wang Long 
---
 arch/arm/mm/init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 8a63b4c..1eaf5d1 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -728,9 +728,9 @@ void free_initmem(void)
 
 #ifdef CONFIG_BLK_DEV_INITRD
 
-static int keep_initrd;
+static int keep_initrd __initdata;
 
-void free_initrd_mem(unsigned long start, unsigned long end)
+void __init free_initrd_mem(unsigned long start, unsigned long end)
 {
if (!keep_initrd) {
if (start == initrd_start)
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] drivers/of/fdt.c: replace pr_warning by pr_warn

2015-07-26 Thread Wang Long
Update the last pr_warning callsite in drivers/of.
When we use script "./scripts/checkpatch.pl" to check
a patch, using pr_warning will produce WARNING:

WARNING: Prefer pr_warn(... to pr_warning(...
#22: FILE: drivers/of/fdt.c:428:
+   pr_warning("End of tree marker overwritten: %08x\n",

So,we should convert pr_warning to pr_warn.

Signed-off-by: Wang Long 
---
 drivers/of/fdt.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 0749656..e1f61b8 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -425,7 +425,7 @@ static void __unflatten_device_tree(const void *blob,
start = 0;
unflatten_dt_node(blob, mem, , NULL, mynodes, 0, false);
if (be32_to_cpup(mem + size) != 0xdeadbeef)
-   pr_warning("End of tree marker overwritten: %08x\n",
+   pr_warn("End of tree marker overwritten: %08x\n",
   be32_to_cpup(mem + size));
 
pr_debug(" <- unflatten_device_tree()\n");
@@ -985,24 +985,24 @@ void __init __weak early_init_dt_add_memory_arch(u64 
base, u64 size)
size &= PAGE_MASK;
 
if (base > MAX_PHYS_ADDR) {
-   pr_warning("Ignoring memory block 0x%llx - 0x%llx\n",
+   pr_warn("Ignoring memory block 0x%llx - 0x%llx\n",
base, base + size);
return;
}
 
if (base + size - 1 > MAX_PHYS_ADDR) {
-   pr_warning("Ignoring memory range 0x%llx - 0x%llx\n",
+   pr_warn("Ignoring memory range 0x%llx - 0x%llx\n",
((u64)MAX_PHYS_ADDR) + 1, base + size);
size = MAX_PHYS_ADDR - base + 1;
}
 
if (base + size < phys_offset) {
-   pr_warning("Ignoring memory block 0x%llx - 0x%llx\n",
+   pr_warn("Ignoring memory block 0x%llx - 0x%llx\n",
   base, base + size);
return;
}
if (base < phys_offset) {
-   pr_warning("Ignoring memory range 0x%llx - 0x%llx\n",
+   pr_warn("Ignoring memory range 0x%llx - 0x%llx\n",
   base, phys_offset);
size -= phys_offset - base;
base = phys_offset;
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] arm: mm: add __init section marker to free_initrd_mem

2015-07-26 Thread Wang Long
It is not needed after booting, this patch moves the
free_initrd_mem() function to the __init section.

This patch also make keep_initrd __initdata, to reduce kernel
size.

Signed-off-by: Wang Long long.wangl...@huawei.com
---
 arch/arm/mm/init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 8a63b4c..1eaf5d1 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -728,9 +728,9 @@ void free_initmem(void)
 
 #ifdef CONFIG_BLK_DEV_INITRD
 
-static int keep_initrd;
+static int keep_initrd __initdata;
 
-void free_initrd_mem(unsigned long start, unsigned long end)
+void __init free_initrd_mem(unsigned long start, unsigned long end)
 {
if (!keep_initrd) {
if (start == initrd_start)
-- 
1.8.3.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] drivers/of/fdt.c: replace pr_warning by pr_warn

2015-07-26 Thread Wang Long
Update the last pr_warning callsite in drivers/of.
When we use script ./scripts/checkpatch.pl to check
a patch, using pr_warning will produce WARNING:

WARNING: Prefer pr_warn(... to pr_warning(...
#22: FILE: drivers/of/fdt.c:428:
+   pr_warning(End of tree marker overwritten: %08x\n,

So,we should convert pr_warning to pr_warn.

Signed-off-by: Wang Long long.wangl...@huawei.com
---
 drivers/of/fdt.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 0749656..e1f61b8 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -425,7 +425,7 @@ static void __unflatten_device_tree(const void *blob,
start = 0;
unflatten_dt_node(blob, mem, start, NULL, mynodes, 0, false);
if (be32_to_cpup(mem + size) != 0xdeadbeef)
-   pr_warning(End of tree marker overwritten: %08x\n,
+   pr_warn(End of tree marker overwritten: %08x\n,
   be32_to_cpup(mem + size));
 
pr_debug( - unflatten_device_tree()\n);
@@ -985,24 +985,24 @@ void __init __weak early_init_dt_add_memory_arch(u64 
base, u64 size)
size = PAGE_MASK;
 
if (base  MAX_PHYS_ADDR) {
-   pr_warning(Ignoring memory block 0x%llx - 0x%llx\n,
+   pr_warn(Ignoring memory block 0x%llx - 0x%llx\n,
base, base + size);
return;
}
 
if (base + size - 1  MAX_PHYS_ADDR) {
-   pr_warning(Ignoring memory range 0x%llx - 0x%llx\n,
+   pr_warn(Ignoring memory range 0x%llx - 0x%llx\n,
((u64)MAX_PHYS_ADDR) + 1, base + size);
size = MAX_PHYS_ADDR - base + 1;
}
 
if (base + size  phys_offset) {
-   pr_warning(Ignoring memory block 0x%llx - 0x%llx\n,
+   pr_warn(Ignoring memory block 0x%llx - 0x%llx\n,
   base, base + size);
return;
}
if (base  phys_offset) {
-   pr_warning(Ignoring memory range 0x%llx - 0x%llx\n,
+   pr_warn(Ignoring memory range 0x%llx - 0x%llx\n,
   base, phys_offset);
size -= phys_offset - base;
base = phys_offset;
-- 
1.8.3.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] arm64: mm: add __init section marker to free_initrd_mem

2015-07-26 Thread Wang Long
It is not needed after booting, this patch moves the
free_initrd_mem() function to the __init section.

This patch also make keep_initrd __initdata, to reduce kernel
size.

Signed-off-by: Wang Long long.wangl...@huawei.com
---
 arch/arm64/mm/init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index ad87ce8..f5c0680 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -358,9 +358,9 @@ void free_initmem(void)
 
 #ifdef CONFIG_BLK_DEV_INITRD
 
-static int keep_initrd;
+static int keep_initrd __initdata;
 
-void free_initrd_mem(unsigned long start, unsigned long end)
+void __init free_initrd_mem(unsigned long start, unsigned long end)
 {
if (!keep_initrd)
free_reserved_area((void *)start, (void *)end, 0, initrd);
-- 
1.8.3.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:irq/core] drivers/irqchip: Replace pr_warning by pr_warn

2015-07-22 Thread tip-bot for Wang Long
Commit-ID:  faca10b9e63e880c81388fbbedf7ede6dcd77c70
Gitweb: http://git.kernel.org/tip/faca10b9e63e880c81388fbbedf7ede6dcd77c70
Author: Wang Long 
AuthorDate: Tue, 21 Jul 2015 08:11:01 +
Committer:  Thomas Gleixner 
CommitDate: Wed, 22 Jul 2015 18:37:42 +0200

drivers/irqchip: Replace pr_warning by pr_warn

Update the last pr_warning callsite in drivers/irqchip.

Signed-off-by: Wang Long 
Cc: 
Cc: 
Cc: 
Cc: 
Cc: 
Cc: 
Link: 
http://lkml.kernel.org/r/1437466261-147373-1-git-send-email-long.wangl...@huawei.com
Signed-off-by: Thomas Gleixner 
---
 drivers/irqchip/exynos-combiner.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/exynos-combiner.c 
b/drivers/irqchip/exynos-combiner.c
index 04e0892..e9c6f2a 100644
--- a/drivers/irqchip/exynos-combiner.c
+++ b/drivers/irqchip/exynos-combiner.c
@@ -185,14 +185,14 @@ static void __init combiner_init(void __iomem 
*combiner_base,
 
combiner_data = kcalloc(max_nr, sizeof (*combiner_data), GFP_KERNEL);
if (!combiner_data) {
-   pr_warning("%s: could not allocate combiner data\n", __func__);
+   pr_warn("%s: could not allocate combiner data\n", __func__);
return;
}
 
combiner_irq_domain = irq_domain_add_linear(np, nr_irq,
_irq_domain_ops, combiner_data);
if (WARN_ON(!combiner_irq_domain)) {
-   pr_warning("%s: irq domain init failed\n", __func__);
+   pr_warn("%s: irq domain init failed\n", __func__);
return;
}
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:irq/core] drivers/irqchip: Replace pr_warning by pr_warn

2015-07-22 Thread tip-bot for Wang Long
Commit-ID:  faca10b9e63e880c81388fbbedf7ede6dcd77c70
Gitweb: http://git.kernel.org/tip/faca10b9e63e880c81388fbbedf7ede6dcd77c70
Author: Wang Long long.wangl...@huawei.com
AuthorDate: Tue, 21 Jul 2015 08:11:01 +
Committer:  Thomas Gleixner t...@linutronix.de
CommitDate: Wed, 22 Jul 2015 18:37:42 +0200

drivers/irqchip: Replace pr_warning by pr_warn

Update the last pr_warning callsite in drivers/irqchip.

Signed-off-by: Wang Long long.wangl...@huawei.com
Cc: linux-arm-ker...@lists.infradead.org
Cc: wangl...@laoqinren.net
Cc: peifei...@huawei.com
Cc: ja...@lakedaemon.net
Cc: kg...@kernel.org
Cc: k.kozlow...@samsung.com
Link: 
http://lkml.kernel.org/r/1437466261-147373-1-git-send-email-long.wangl...@huawei.com
Signed-off-by: Thomas Gleixner t...@linutronix.de
---
 drivers/irqchip/exynos-combiner.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/exynos-combiner.c 
b/drivers/irqchip/exynos-combiner.c
index 04e0892..e9c6f2a 100644
--- a/drivers/irqchip/exynos-combiner.c
+++ b/drivers/irqchip/exynos-combiner.c
@@ -185,14 +185,14 @@ static void __init combiner_init(void __iomem 
*combiner_base,
 
combiner_data = kcalloc(max_nr, sizeof (*combiner_data), GFP_KERNEL);
if (!combiner_data) {
-   pr_warning(%s: could not allocate combiner data\n, __func__);
+   pr_warn(%s: could not allocate combiner data\n, __func__);
return;
}
 
combiner_irq_domain = irq_domain_add_linear(np, nr_irq,
combiner_irq_domain_ops, combiner_data);
if (WARN_ON(!combiner_irq_domain)) {
-   pr_warning(%s: irq domain init failed\n, __func__);
+   pr_warn(%s: irq domain init failed\n, __func__);
return;
}
 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] drivers/irqchip: replace pr_warning by pr_warn

2015-07-21 Thread Wang Long
Update the last pr_warning callsite in drivers/irqchip.

Signed-off-by: Wang Long 
---
 drivers/irqchip/exynos-combiner.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/exynos-combiner.c 
b/drivers/irqchip/exynos-combiner.c
index 5c82e3b..80104f9 100644
--- a/drivers/irqchip/exynos-combiner.c
+++ b/drivers/irqchip/exynos-combiner.c
@@ -185,14 +185,14 @@ static void __init combiner_init(void __iomem 
*combiner_base,
 
combiner_data = kcalloc(max_nr, sizeof (*combiner_data), GFP_KERNEL);
if (!combiner_data) {
-   pr_warning("%s: could not allocate combiner data\n", __func__);
+   pr_warn("%s: could not allocate combiner data\n", __func__);
return;
}
 
combiner_irq_domain = irq_domain_add_linear(np, nr_irq,
_irq_domain_ops, combiner_data);
if (WARN_ON(!combiner_irq_domain)) {
-   pr_warning("%s: irq domain init failed\n", __func__);
+   pr_warn("%s: irq domain init failed\n", __func__);
return;
}
 
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] drivers/of/fdt.c: replace pr_warning by pr_warn

2015-07-21 Thread Wang Long
Update the last pr_warning callsite in drivers/of.

Signed-off-by: Wang Long 
---
 drivers/of/fdt.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 0749656..e1f61b8 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -425,7 +425,7 @@ static void __unflatten_device_tree(const void *blob,
start = 0;
unflatten_dt_node(blob, mem, , NULL, mynodes, 0, false);
if (be32_to_cpup(mem + size) != 0xdeadbeef)
-   pr_warning("End of tree marker overwritten: %08x\n",
+   pr_warn("End of tree marker overwritten: %08x\n",
   be32_to_cpup(mem + size));
 
pr_debug(" <- unflatten_device_tree()\n");
@@ -985,24 +985,24 @@ void __init __weak early_init_dt_add_memory_arch(u64 
base, u64 size)
size &= PAGE_MASK;
 
if (base > MAX_PHYS_ADDR) {
-   pr_warning("Ignoring memory block 0x%llx - 0x%llx\n",
+   pr_warn("Ignoring memory block 0x%llx - 0x%llx\n",
base, base + size);
return;
}
 
if (base + size - 1 > MAX_PHYS_ADDR) {
-   pr_warning("Ignoring memory range 0x%llx - 0x%llx\n",
+   pr_warn("Ignoring memory range 0x%llx - 0x%llx\n",
((u64)MAX_PHYS_ADDR) + 1, base + size);
size = MAX_PHYS_ADDR - base + 1;
}
 
if (base + size < phys_offset) {
-   pr_warning("Ignoring memory block 0x%llx - 0x%llx\n",
+   pr_warn("Ignoring memory block 0x%llx - 0x%llx\n",
   base, base + size);
return;
}
if (base < phys_offset) {
-   pr_warning("Ignoring memory range 0x%llx - 0x%llx\n",
+   pr_warn("Ignoring memory range 0x%llx - 0x%llx\n",
   base, phys_offset);
size -= phys_offset - base;
base = phys_offset;
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] drivers/of/fdt.c: replace pr_warning by pr_warn

2015-07-21 Thread Wang Long
Update the last pr_warning callsite in drivers/of.

Signed-off-by: Wang Long long.wangl...@huawei.com
---
 drivers/of/fdt.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 0749656..e1f61b8 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -425,7 +425,7 @@ static void __unflatten_device_tree(const void *blob,
start = 0;
unflatten_dt_node(blob, mem, start, NULL, mynodes, 0, false);
if (be32_to_cpup(mem + size) != 0xdeadbeef)
-   pr_warning(End of tree marker overwritten: %08x\n,
+   pr_warn(End of tree marker overwritten: %08x\n,
   be32_to_cpup(mem + size));
 
pr_debug( - unflatten_device_tree()\n);
@@ -985,24 +985,24 @@ void __init __weak early_init_dt_add_memory_arch(u64 
base, u64 size)
size = PAGE_MASK;
 
if (base  MAX_PHYS_ADDR) {
-   pr_warning(Ignoring memory block 0x%llx - 0x%llx\n,
+   pr_warn(Ignoring memory block 0x%llx - 0x%llx\n,
base, base + size);
return;
}
 
if (base + size - 1  MAX_PHYS_ADDR) {
-   pr_warning(Ignoring memory range 0x%llx - 0x%llx\n,
+   pr_warn(Ignoring memory range 0x%llx - 0x%llx\n,
((u64)MAX_PHYS_ADDR) + 1, base + size);
size = MAX_PHYS_ADDR - base + 1;
}
 
if (base + size  phys_offset) {
-   pr_warning(Ignoring memory block 0x%llx - 0x%llx\n,
+   pr_warn(Ignoring memory block 0x%llx - 0x%llx\n,
   base, base + size);
return;
}
if (base  phys_offset) {
-   pr_warning(Ignoring memory range 0x%llx - 0x%llx\n,
+   pr_warn(Ignoring memory range 0x%llx - 0x%llx\n,
   base, phys_offset);
size -= phys_offset - base;
base = phys_offset;
-- 
1.8.3.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] drivers/irqchip: replace pr_warning by pr_warn

2015-07-21 Thread Wang Long
Update the last pr_warning callsite in drivers/irqchip.

Signed-off-by: Wang Long long.wangl...@huawei.com
---
 drivers/irqchip/exynos-combiner.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/exynos-combiner.c 
b/drivers/irqchip/exynos-combiner.c
index 5c82e3b..80104f9 100644
--- a/drivers/irqchip/exynos-combiner.c
+++ b/drivers/irqchip/exynos-combiner.c
@@ -185,14 +185,14 @@ static void __init combiner_init(void __iomem 
*combiner_base,
 
combiner_data = kcalloc(max_nr, sizeof (*combiner_data), GFP_KERNEL);
if (!combiner_data) {
-   pr_warning(%s: could not allocate combiner data\n, __func__);
+   pr_warn(%s: could not allocate combiner data\n, __func__);
return;
}
 
combiner_irq_domain = irq_domain_add_linear(np, nr_irq,
combiner_irq_domain_ops, combiner_data);
if (WARN_ON(!combiner_irq_domain)) {
-   pr_warning(%s: irq domain init failed\n, __func__);
+   pr_warn(%s: irq domain init failed\n, __func__);
return;
}
 
-- 
1.8.3.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Documentation: Update filesystems/debugfs.txt

2015-07-16 Thread Wang Long
This patch update the Documentation/filesystems/debugfs.txt
file. The main work is to add the description of the following
functions:
debugfs_create_atomic_t
debugfs_create_u32_array
debugfs_create_devm_seqfile
debugfs_create_file_size

Signed-off-by: Wang Long 
---
 Documentation/filesystems/debugfs.txt | 41 +++
 1 file changed, 41 insertions(+)

diff --git a/Documentation/filesystems/debugfs.txt 
b/Documentation/filesystems/debugfs.txt
index 88ab81c..b1ba8df 100644
--- a/Documentation/filesystems/debugfs.txt
+++ b/Documentation/filesystems/debugfs.txt
@@ -1,4 +1,5 @@
 Copyright 2009 Jonathan Corbet 
+Updated by Wang Long  on 2015/07/16
 
 Debugfs exists as a simple way for kernel developers to make information
 available to user space.  Unlike /proc, which is only meant for information
@@ -51,6 +52,17 @@ operations should be provided; others can be included as 
needed.  Again,
 the return value will be a dentry pointer to the created file, NULL for
 error, or ERR_PTR(-ENODEV) if debugfs support is missing.
 
+Create a file with an initial size, the following function can be used
+instead:
+
+struct dentry *debugfs_create_file_size(const char *name, umode_t mode,
+   struct dentry *parent, void *data,
+   const struct file_operations *fops,
+   loff_t file_size);
+
+file_size is the initial file size. The other parameters are the same
+as the function debugfs_create_file.
+
 In a number of cases, the creation of a set of file operations is not
 actually necessary; the debugfs code provides a number of helper functions
 for simple situations.  Files containing a single integer value can be
@@ -100,6 +112,14 @@ A read on the resulting file will yield either Y (for 
non-zero values) or
 N, followed by a newline.  If written to, it will accept either upper- or
 lower-case values, or 1 or 0.  Any other input will be silently ignored.
 
+Also, atomic_t values can be placed in debugfs with:
+
+struct dentry *debugfs_create_atomic_t(const char *name, umode_t mode,
+   struct dentry *parent, atomic_t *value)
+
+A read of this file will get atomic_t values, and a write of this file
+will set atomic_t values.
+
 Another option is exporting a block of arbitrary binary data, with
 this structure and function:
 
@@ -147,6 +167,27 @@ The "base" argument may be 0, but you may want to build 
the reg32 array
 using __stringify, and a number of register names (macros) are actually
 byte offsets over a base for the register block.
 
+If you want to dump an u32 array in debugfs, you can create file with:
+
+struct dentry *debugfs_create_u32_array(const char *name, umode_t mode,
+   struct dentry *parent,
+   u32 *array, u32 elements);
+
+The "array" argument provides data, and the "elements" argument is
+the number of elements in the array. Note: Once array is created its
+size can not be changed.
+
+There is a helper function to create device related seq_file:
+
+   struct dentry *debugfs_create_devm_seqfile(struct device *dev,
+   const char *name,
+   struct dentry *parent,
+   int (*read_fn)(struct seq_file *s,
+   void *data));
+
+The "dev" argument is the device related to this debugfs file, and
+the "read_fn" is a function pointer which to be called to print the
+seq_file content.
 
 There are a couple of other directory-oriented helper functions:
 
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Documentation: Update filesystems/debugfs.txt

2015-07-16 Thread Wang Long
This patch update the Documentation/filesystems/debugfs.txt
file. The main work is to add the description of the following
functions:
debugfs_create_atomic_t
debugfs_create_u32_array
debugfs_create_devm_seqfile
debugfs_create_file_size

Signed-off-by: Wang Long long.wangl...@huawei.com
---
 Documentation/filesystems/debugfs.txt | 41 +++
 1 file changed, 41 insertions(+)

diff --git a/Documentation/filesystems/debugfs.txt 
b/Documentation/filesystems/debugfs.txt
index 88ab81c..b1ba8df 100644
--- a/Documentation/filesystems/debugfs.txt
+++ b/Documentation/filesystems/debugfs.txt
@@ -1,4 +1,5 @@
 Copyright 2009 Jonathan Corbet cor...@lwn.net
+Updated by Wang Long long.wangl...@huawei.com on 2015/07/16
 
 Debugfs exists as a simple way for kernel developers to make information
 available to user space.  Unlike /proc, which is only meant for information
@@ -51,6 +52,17 @@ operations should be provided; others can be included as 
needed.  Again,
 the return value will be a dentry pointer to the created file, NULL for
 error, or ERR_PTR(-ENODEV) if debugfs support is missing.
 
+Create a file with an initial size, the following function can be used
+instead:
+
+struct dentry *debugfs_create_file_size(const char *name, umode_t mode,
+   struct dentry *parent, void *data,
+   const struct file_operations *fops,
+   loff_t file_size);
+
+file_size is the initial file size. The other parameters are the same
+as the function debugfs_create_file.
+
 In a number of cases, the creation of a set of file operations is not
 actually necessary; the debugfs code provides a number of helper functions
 for simple situations.  Files containing a single integer value can be
@@ -100,6 +112,14 @@ A read on the resulting file will yield either Y (for 
non-zero values) or
 N, followed by a newline.  If written to, it will accept either upper- or
 lower-case values, or 1 or 0.  Any other input will be silently ignored.
 
+Also, atomic_t values can be placed in debugfs with:
+
+struct dentry *debugfs_create_atomic_t(const char *name, umode_t mode,
+   struct dentry *parent, atomic_t *value)
+
+A read of this file will get atomic_t values, and a write of this file
+will set atomic_t values.
+
 Another option is exporting a block of arbitrary binary data, with
 this structure and function:
 
@@ -147,6 +167,27 @@ The base argument may be 0, but you may want to build 
the reg32 array
 using __stringify, and a number of register names (macros) are actually
 byte offsets over a base for the register block.
 
+If you want to dump an u32 array in debugfs, you can create file with:
+
+struct dentry *debugfs_create_u32_array(const char *name, umode_t mode,
+   struct dentry *parent,
+   u32 *array, u32 elements);
+
+The array argument provides data, and the elements argument is
+the number of elements in the array. Note: Once array is created its
+size can not be changed.
+
+There is a helper function to create device related seq_file:
+
+   struct dentry *debugfs_create_devm_seqfile(struct device *dev,
+   const char *name,
+   struct dentry *parent,
+   int (*read_fn)(struct seq_file *s,
+   void *data));
+
+The dev argument is the device related to this debugfs file, and
+the read_fn is a function pointer which to be called to print the
+seq_file content.
 
 There are a couple of other directory-oriented helper functions:
 
-- 
1.8.3.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] kprobes: Use debugfs_remove_recursive instead debugfs_remove

2015-07-15 Thread Wang Long
In debugfs_kprobe_init, we create a directory 'kprobes' and three
files 'list', 'enabled' and 'blacklist'. When any one of the three
files creation fails, we should remove all of them. But debugfs_remove
function can not complete this work. So use debugfs_remove_recursive
instead.

Signed-off-by: Wang Long 
---
 kernel/kprobes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index c90e417..8cd82a5 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -2459,7 +2459,7 @@ static int __init debugfs_kprobe_init(void)
return 0;
 
 error:
-   debugfs_remove(dir);
+   debugfs_remove_recursive(dir);
return -ENOMEM;
 }
 
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] kprobes: Use debugfs_remove_recursive instead debugfs_remove

2015-07-15 Thread Wang Long
In debugfs_kprobe_init, we create a directory 'kprobes' and three
files 'list', 'enabled' and 'blacklist'. When any one of the three
files creation fails, we should remove all of them. But debugfs_remove
function can not complete this work. So use debugfs_remove_recursive
instead.

Signed-off-by: Wang Long long.wangl...@huawei.com
---
 kernel/kprobes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index c90e417..8cd82a5 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -2459,7 +2459,7 @@ static int __init debugfs_kprobe_init(void)
return 0;
 
 error:
-   debugfs_remove(dir);
+   debugfs_remove_recursive(dir);
return -ENOMEM;
 }
 
-- 
1.8.3.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 2/2] apei/erst-dbg: Define pr_fmt macro to avoid the duplication of ERST_DBG_PFX

2015-06-16 Thread Wang Long
Define pr_fmt macro with {ERST DBG: } prefix, then remove all use
of ERST_DBG_PFX in the pr_* functions.

Signed-off-by: Wang Long 
---
 drivers/acpi/apei/erst-dbg.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/acpi/apei/erst-dbg.c b/drivers/acpi/apei/erst-dbg.c
index 3a57ffb..c38133a 100644
--- a/drivers/acpi/apei/erst-dbg.c
+++ b/drivers/acpi/apei/erst-dbg.c
@@ -23,6 +23,8 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include 
 #include 
 #include 
@@ -31,8 +33,6 @@
 
 #include "apei-internal.h"
 
-#define ERST_DBG_PFX   "ERST DBG: "
-
 #define ERST_DBG_RECORD_LEN_MAX0x4000
 
 static void *erst_dbg_buf;
@@ -130,8 +130,7 @@ retry:
if (rc < 0)
goto out;
if (len > ERST_DBG_RECORD_LEN_MAX) {
-   pr_warn(ERST_DBG_PFX
-  "Record (ID: 0x%llx) length is too long: %zd\n",
+   pr_warn("Record (ID: 0x%llx) length is too long: %zd\n",
   id, len);
rc = -EIO;
goto out;
@@ -171,7 +170,7 @@ static ssize_t erst_dbg_write(struct file *filp, const char 
__user *ubuf,
return -EPERM;
 
if (usize > ERST_DBG_RECORD_LEN_MAX) {
-   pr_err(ERST_DBG_PFX "Too long record to be written\n");
+   pr_err("Too long record to be written\n");
return -EINVAL;
}
 
@@ -223,7 +222,7 @@ static struct miscdevice erst_dbg_dev = {
 static __init int erst_dbg_init(void)
 {
if (erst_disable) {
-   pr_info(ERST_DBG_PFX "ERST support is disabled.\n");
+   pr_info("ERST support is disabled.\n");
return -ENODEV;
}
return misc_register(_dbg_dev);
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 1/2] apei/*.c: use pr_warn instead of pr_warning

2015-06-16 Thread Wang Long
This patch can avoid the following WARNING when run
checkpatch.pl:
WARNING: Prefer pr_warn(... to pr_warning(...
#21: FILE: drivers/acpi/apei/erst-dbg.c:134:
+   pr_warning("Record (ID: 0x%llx) length is too long: 
%zd\n",

Signed-off-by: Wang Long 
---
 drivers/acpi/apei/apei-base.c | 12 ++--
 drivers/acpi/apei/einj.c  |  6 +++---
 drivers/acpi/apei/erst-dbg.c  |  2 +-
 drivers/acpi/apei/ghes.c  | 14 +++---
 drivers/acpi/apei/hest.c  |  6 +++---
 5 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/acpi/apei/apei-base.c b/drivers/acpi/apei/apei-base.c
index a85ac07..5e85af3 100644
--- a/drivers/acpi/apei/apei-base.c
+++ b/drivers/acpi/apei/apei-base.c
@@ -182,7 +182,7 @@ rewind:
if (ip == ctx->ip) {
if (entry->instruction >= ctx->instructions ||
!ctx->ins_table[entry->instruction].run) {
-   pr_warning(FW_WARN APEI_PFX
+   pr_warn(FW_WARN APEI_PFX
"Invalid action table, unknown instruction type: %d\n",
   entry->instruction);
return -EINVAL;
@@ -223,7 +223,7 @@ static int apei_exec_for_each_entry(struct 
apei_exec_context *ctx,
if (end)
*end = i;
if (ins >= ctx->instructions || !ins_table[ins].run) {
-   pr_warning(FW_WARN APEI_PFX
+   pr_warn(FW_WARN APEI_PFX
"Invalid action table, unknown instruction type: %d\n",
   ins);
return -EINVAL;
@@ -589,7 +589,7 @@ static int apei_check_gar(struct acpi_generic_address *reg, 
u64 *paddr,
space_id = reg->space_id;
*paddr = get_unaligned(>address);
if (!*paddr) {
-   pr_warning(FW_BUG APEI_PFX
+   pr_warn(FW_BUG APEI_PFX
   "Invalid physical address in GAR 
[0x%llx/%u/%u/%u/%u]\n",
   *paddr, bit_width, bit_offset, access_size_code,
   space_id);
@@ -597,7 +597,7 @@ static int apei_check_gar(struct acpi_generic_address *reg, 
u64 *paddr,
}
 
if (access_size_code < 1 || access_size_code > 4) {
-   pr_warning(FW_BUG APEI_PFX
+   pr_warn(FW_BUG APEI_PFX
   "Invalid access size code in GAR 
[0x%llx/%u/%u/%u/%u]\n",
   *paddr, bit_width, bit_offset, access_size_code,
   space_id);
@@ -614,7 +614,7 @@ static int apei_check_gar(struct acpi_generic_address *reg, 
u64 *paddr,
*access_bit_width = 64;
 
if ((bit_width + bit_offset) > *access_bit_width) {
-   pr_warning(FW_BUG APEI_PFX
+   pr_warn(FW_BUG APEI_PFX
   "Invalid bit width + offset in GAR 
[0x%llx/%u/%u/%u/%u]\n",
   *paddr, bit_width, bit_offset, access_size_code,
   space_id);
@@ -623,7 +623,7 @@ static int apei_check_gar(struct acpi_generic_address *reg, 
u64 *paddr,
 
if (space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY &&
space_id != ACPI_ADR_SPACE_SYSTEM_IO) {
-   pr_warning(FW_BUG APEI_PFX
+   pr_warn(FW_BUG APEI_PFX
   "Invalid address space type in GAR 
[0x%llx/%u/%u/%u/%u]\n",
   *paddr, bit_width, bit_offset, access_size_code,
   space_id);
diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c
index a095d4f..ff3daca 100644
--- a/drivers/acpi/apei/einj.c
+++ b/drivers/acpi/apei/einj.c
@@ -183,7 +183,7 @@ static int einj_get_available_error_type(u32 *type)
 static int einj_timedout(u64 *t)
 {
if ((s64)*t < SPIN_UNIT) {
-   pr_warning(FW_WARN EINJ_PFX
+   pr_warn(FW_WARN EINJ_PFX
   "Firmware does not respond in time\n");
return 1;
}
@@ -325,7 +325,7 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
}
rc = einj_check_trigger_header(trigger_tab);
if (rc) {
-   pr_warning(FW_BUG EINJ_PFX
+   pr_warn(FW_BUG EINJ_PFX
   "The trigger error action table is invalid\n");
goto out_rel_header;
}
@@ -707,7 +707,7 @@ static int __init einj_init(void)
 
rc = einj_check_table(einj_tab);
if (rc) {
-   pr_warning(FW_BUG EINJ_PFX "EINJ table is invalid\n");
+   pr_warn(FW_BUG EINJ_PFX "EINJ table is invalid\n");
return -EINVAL;
}
 
diff --git a/drivers/acpi/apei/erst

[PATCH v2 1/2] apei/*.c: use pr_warn instead of pr_warning

2015-06-16 Thread Wang Long
This patch can avoid the following WARNING when run
checkpatch.pl:
WARNING: Prefer pr_warn(... to pr_warning(...
#21: FILE: drivers/acpi/apei/erst-dbg.c:134:
+   pr_warning(Record (ID: 0x%llx) length is too long: 
%zd\n,

Signed-off-by: Wang Long long.wangl...@huawei.com
---
 drivers/acpi/apei/apei-base.c | 12 ++--
 drivers/acpi/apei/einj.c  |  6 +++---
 drivers/acpi/apei/erst-dbg.c  |  2 +-
 drivers/acpi/apei/ghes.c  | 14 +++---
 drivers/acpi/apei/hest.c  |  6 +++---
 5 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/acpi/apei/apei-base.c b/drivers/acpi/apei/apei-base.c
index a85ac07..5e85af3 100644
--- a/drivers/acpi/apei/apei-base.c
+++ b/drivers/acpi/apei/apei-base.c
@@ -182,7 +182,7 @@ rewind:
if (ip == ctx-ip) {
if (entry-instruction = ctx-instructions ||
!ctx-ins_table[entry-instruction].run) {
-   pr_warning(FW_WARN APEI_PFX
+   pr_warn(FW_WARN APEI_PFX
Invalid action table, unknown instruction type: %d\n,
   entry-instruction);
return -EINVAL;
@@ -223,7 +223,7 @@ static int apei_exec_for_each_entry(struct 
apei_exec_context *ctx,
if (end)
*end = i;
if (ins = ctx-instructions || !ins_table[ins].run) {
-   pr_warning(FW_WARN APEI_PFX
+   pr_warn(FW_WARN APEI_PFX
Invalid action table, unknown instruction type: %d\n,
   ins);
return -EINVAL;
@@ -589,7 +589,7 @@ static int apei_check_gar(struct acpi_generic_address *reg, 
u64 *paddr,
space_id = reg-space_id;
*paddr = get_unaligned(reg-address);
if (!*paddr) {
-   pr_warning(FW_BUG APEI_PFX
+   pr_warn(FW_BUG APEI_PFX
   Invalid physical address in GAR 
[0x%llx/%u/%u/%u/%u]\n,
   *paddr, bit_width, bit_offset, access_size_code,
   space_id);
@@ -597,7 +597,7 @@ static int apei_check_gar(struct acpi_generic_address *reg, 
u64 *paddr,
}
 
if (access_size_code  1 || access_size_code  4) {
-   pr_warning(FW_BUG APEI_PFX
+   pr_warn(FW_BUG APEI_PFX
   Invalid access size code in GAR 
[0x%llx/%u/%u/%u/%u]\n,
   *paddr, bit_width, bit_offset, access_size_code,
   space_id);
@@ -614,7 +614,7 @@ static int apei_check_gar(struct acpi_generic_address *reg, 
u64 *paddr,
*access_bit_width = 64;
 
if ((bit_width + bit_offset)  *access_bit_width) {
-   pr_warning(FW_BUG APEI_PFX
+   pr_warn(FW_BUG APEI_PFX
   Invalid bit width + offset in GAR 
[0x%llx/%u/%u/%u/%u]\n,
   *paddr, bit_width, bit_offset, access_size_code,
   space_id);
@@ -623,7 +623,7 @@ static int apei_check_gar(struct acpi_generic_address *reg, 
u64 *paddr,
 
if (space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY 
space_id != ACPI_ADR_SPACE_SYSTEM_IO) {
-   pr_warning(FW_BUG APEI_PFX
+   pr_warn(FW_BUG APEI_PFX
   Invalid address space type in GAR 
[0x%llx/%u/%u/%u/%u]\n,
   *paddr, bit_width, bit_offset, access_size_code,
   space_id);
diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c
index a095d4f..ff3daca 100644
--- a/drivers/acpi/apei/einj.c
+++ b/drivers/acpi/apei/einj.c
@@ -183,7 +183,7 @@ static int einj_get_available_error_type(u32 *type)
 static int einj_timedout(u64 *t)
 {
if ((s64)*t  SPIN_UNIT) {
-   pr_warning(FW_WARN EINJ_PFX
+   pr_warn(FW_WARN EINJ_PFX
   Firmware does not respond in time\n);
return 1;
}
@@ -325,7 +325,7 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
}
rc = einj_check_trigger_header(trigger_tab);
if (rc) {
-   pr_warning(FW_BUG EINJ_PFX
+   pr_warn(FW_BUG EINJ_PFX
   The trigger error action table is invalid\n);
goto out_rel_header;
}
@@ -707,7 +707,7 @@ static int __init einj_init(void)
 
rc = einj_check_table(einj_tab);
if (rc) {
-   pr_warning(FW_BUG EINJ_PFX EINJ table is invalid\n);
+   pr_warn(FW_BUG EINJ_PFX EINJ table is invalid\n);
return -EINVAL;
}
 
diff --git a/drivers/acpi/apei/erst-dbg.c b/drivers/acpi/apei/erst-dbg.c
index 04ab5c9..3a57ffb 100644
--- a/drivers/acpi/apei/erst-dbg.c
+++ b/drivers/acpi/apei/erst-dbg.c
@@ -130,7 +130,7 @@ retry:
if (rc  0

[PATCH v2 2/2] apei/erst-dbg: Define pr_fmt macro to avoid the duplication of ERST_DBG_PFX

2015-06-16 Thread Wang Long
Define pr_fmt macro with {ERST DBG: } prefix, then remove all use
of ERST_DBG_PFX in the pr_* functions.

Signed-off-by: Wang Long long.wangl...@huawei.com
---
 drivers/acpi/apei/erst-dbg.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/acpi/apei/erst-dbg.c b/drivers/acpi/apei/erst-dbg.c
index 3a57ffb..c38133a 100644
--- a/drivers/acpi/apei/erst-dbg.c
+++ b/drivers/acpi/apei/erst-dbg.c
@@ -23,6 +23,8 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME :  fmt
+
 #include linux/kernel.h
 #include linux/module.h
 #include linux/uaccess.h
@@ -31,8 +33,6 @@
 
 #include apei-internal.h
 
-#define ERST_DBG_PFX   ERST DBG: 
-
 #define ERST_DBG_RECORD_LEN_MAX0x4000
 
 static void *erst_dbg_buf;
@@ -130,8 +130,7 @@ retry:
if (rc  0)
goto out;
if (len  ERST_DBG_RECORD_LEN_MAX) {
-   pr_warn(ERST_DBG_PFX
-  Record (ID: 0x%llx) length is too long: %zd\n,
+   pr_warn(Record (ID: 0x%llx) length is too long: %zd\n,
   id, len);
rc = -EIO;
goto out;
@@ -171,7 +170,7 @@ static ssize_t erst_dbg_write(struct file *filp, const char 
__user *ubuf,
return -EPERM;
 
if (usize  ERST_DBG_RECORD_LEN_MAX) {
-   pr_err(ERST_DBG_PFX Too long record to be written\n);
+   pr_err(Too long record to be written\n);
return -EINVAL;
}
 
@@ -223,7 +222,7 @@ static struct miscdevice erst_dbg_dev = {
 static __init int erst_dbg_init(void)
 {
if (erst_disable) {
-   pr_info(ERST_DBG_PFX ERST support is disabled.\n);
+   pr_info(ERST support is disabled.\n);
return -ENODEV;
}
return misc_register(erst_dbg_dev);
-- 
1.8.3.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] apei/*.c: use pr_warn instead of pr_warning

2015-06-15 Thread Wang Long
This patch can avoid the following WARNING when run
checkpatch.pl:
WARNING: Prefer pr_warn(... to pr_warning(...
#21: FILE: drivers/acpi/apei/erst-dbg.c:134:
+   pr_warning("Record (ID: 0x%llx) length is too long: 
%zd\n",

Signed-off-by: Wang Long 
---
 drivers/acpi/apei/apei-base.c | 12 ++--
 drivers/acpi/apei/einj.c  |  6 +++---
 drivers/acpi/apei/erst-dbg.c  |  2 +-
 drivers/acpi/apei/ghes.c  | 14 +++---
 drivers/acpi/apei/hest.c  |  6 +++---
 5 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/acpi/apei/apei-base.c b/drivers/acpi/apei/apei-base.c
index a85ac07..5e85af3 100644
--- a/drivers/acpi/apei/apei-base.c
+++ b/drivers/acpi/apei/apei-base.c
@@ -182,7 +182,7 @@ rewind:
if (ip == ctx->ip) {
if (entry->instruction >= ctx->instructions ||
!ctx->ins_table[entry->instruction].run) {
-   pr_warning(FW_WARN APEI_PFX
+   pr_warn(FW_WARN APEI_PFX
"Invalid action table, unknown instruction type: %d\n",
   entry->instruction);
return -EINVAL;
@@ -223,7 +223,7 @@ static int apei_exec_for_each_entry(struct 
apei_exec_context *ctx,
if (end)
*end = i;
if (ins >= ctx->instructions || !ins_table[ins].run) {
-   pr_warning(FW_WARN APEI_PFX
+   pr_warn(FW_WARN APEI_PFX
"Invalid action table, unknown instruction type: %d\n",
   ins);
return -EINVAL;
@@ -589,7 +589,7 @@ static int apei_check_gar(struct acpi_generic_address *reg, 
u64 *paddr,
space_id = reg->space_id;
*paddr = get_unaligned(>address);
if (!*paddr) {
-   pr_warning(FW_BUG APEI_PFX
+   pr_warn(FW_BUG APEI_PFX
   "Invalid physical address in GAR 
[0x%llx/%u/%u/%u/%u]\n",
   *paddr, bit_width, bit_offset, access_size_code,
   space_id);
@@ -597,7 +597,7 @@ static int apei_check_gar(struct acpi_generic_address *reg, 
u64 *paddr,
}
 
if (access_size_code < 1 || access_size_code > 4) {
-   pr_warning(FW_BUG APEI_PFX
+   pr_warn(FW_BUG APEI_PFX
   "Invalid access size code in GAR 
[0x%llx/%u/%u/%u/%u]\n",
   *paddr, bit_width, bit_offset, access_size_code,
   space_id);
@@ -614,7 +614,7 @@ static int apei_check_gar(struct acpi_generic_address *reg, 
u64 *paddr,
*access_bit_width = 64;
 
if ((bit_width + bit_offset) > *access_bit_width) {
-   pr_warning(FW_BUG APEI_PFX
+   pr_warn(FW_BUG APEI_PFX
   "Invalid bit width + offset in GAR 
[0x%llx/%u/%u/%u/%u]\n",
   *paddr, bit_width, bit_offset, access_size_code,
   space_id);
@@ -623,7 +623,7 @@ static int apei_check_gar(struct acpi_generic_address *reg, 
u64 *paddr,
 
if (space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY &&
space_id != ACPI_ADR_SPACE_SYSTEM_IO) {
-   pr_warning(FW_BUG APEI_PFX
+   pr_warn(FW_BUG APEI_PFX
   "Invalid address space type in GAR 
[0x%llx/%u/%u/%u/%u]\n",
   *paddr, bit_width, bit_offset, access_size_code,
   space_id);
diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c
index a095d4f..ff3daca 100644
--- a/drivers/acpi/apei/einj.c
+++ b/drivers/acpi/apei/einj.c
@@ -183,7 +183,7 @@ static int einj_get_available_error_type(u32 *type)
 static int einj_timedout(u64 *t)
 {
if ((s64)*t < SPIN_UNIT) {
-   pr_warning(FW_WARN EINJ_PFX
+   pr_warn(FW_WARN EINJ_PFX
   "Firmware does not respond in time\n");
return 1;
}
@@ -325,7 +325,7 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
}
rc = einj_check_trigger_header(trigger_tab);
if (rc) {
-   pr_warning(FW_BUG EINJ_PFX
+   pr_warn(FW_BUG EINJ_PFX
   "The trigger error action table is invalid\n");
goto out_rel_header;
}
@@ -707,7 +707,7 @@ static int __init einj_init(void)
 
rc = einj_check_table(einj_tab);
if (rc) {
-   pr_warning(FW_BUG EINJ_PFX "EINJ table is invalid\n");
+   pr_warn(FW_BUG EINJ_PFX "EINJ table is invalid\n");
return -EINVAL;
}
 
diff --git a/drivers/acpi/apei/erst

[PATCH 2/2] apei/erst-dbg: Define pr_fmt macro to avoid the duplication of ERST_DBG_PFX

2015-06-15 Thread Wang Long
Define pr_fmt macro with {ERST DBG: } prefix, then remove all use
of ERST_DBG_PFXin the pr_* functions.

Signed-off-by: Wang Long 
---
 drivers/acpi/apei/erst-dbg.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/apei/erst-dbg.c b/drivers/acpi/apei/erst-dbg.c
index 3a57ffb..48e9490 100644
--- a/drivers/acpi/apei/erst-dbg.c
+++ b/drivers/acpi/apei/erst-dbg.c
@@ -31,7 +31,8 @@
 
 #include "apei-internal.h"
 
-#define ERST_DBG_PFX   "ERST DBG: "
+#undef pr_fmt
+#define pr_fmt(fmt) "ERST DBG: " fmt
 
 #define ERST_DBG_RECORD_LEN_MAX0x4000
 
@@ -130,8 +131,7 @@ retry:
if (rc < 0)
goto out;
if (len > ERST_DBG_RECORD_LEN_MAX) {
-   pr_warn(ERST_DBG_PFX
-  "Record (ID: 0x%llx) length is too long: %zd\n",
+   pr_warn("Record (ID: 0x%llx) length is too long: %zd\n",
   id, len);
rc = -EIO;
goto out;
@@ -171,7 +171,7 @@ static ssize_t erst_dbg_write(struct file *filp, const char 
__user *ubuf,
return -EPERM;
 
if (usize > ERST_DBG_RECORD_LEN_MAX) {
-   pr_err(ERST_DBG_PFX "Too long record to be written\n");
+   pr_err("Too long record to be written\n");
return -EINVAL;
}
 
@@ -223,7 +223,7 @@ static struct miscdevice erst_dbg_dev = {
 static __init int erst_dbg_init(void)
 {
if (erst_disable) {
-   pr_info(ERST_DBG_PFX "ERST support is disabled.\n");
+   pr_info("ERST support is disabled.\n");
return -ENODEV;
}
return misc_register(_dbg_dev);
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] apei/*.c: use pr_warn instead of pr_warning

2015-06-15 Thread Wang Long
This patch can avoid the following WARNING when run
checkpatch.pl:
WARNING: Prefer pr_warn(... to pr_warning(...
#21: FILE: drivers/acpi/apei/erst-dbg.c:134:
+   pr_warning(Record (ID: 0x%llx) length is too long: 
%zd\n,

Signed-off-by: Wang Long long.wangl...@huawei.com
---
 drivers/acpi/apei/apei-base.c | 12 ++--
 drivers/acpi/apei/einj.c  |  6 +++---
 drivers/acpi/apei/erst-dbg.c  |  2 +-
 drivers/acpi/apei/ghes.c  | 14 +++---
 drivers/acpi/apei/hest.c  |  6 +++---
 5 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/acpi/apei/apei-base.c b/drivers/acpi/apei/apei-base.c
index a85ac07..5e85af3 100644
--- a/drivers/acpi/apei/apei-base.c
+++ b/drivers/acpi/apei/apei-base.c
@@ -182,7 +182,7 @@ rewind:
if (ip == ctx-ip) {
if (entry-instruction = ctx-instructions ||
!ctx-ins_table[entry-instruction].run) {
-   pr_warning(FW_WARN APEI_PFX
+   pr_warn(FW_WARN APEI_PFX
Invalid action table, unknown instruction type: %d\n,
   entry-instruction);
return -EINVAL;
@@ -223,7 +223,7 @@ static int apei_exec_for_each_entry(struct 
apei_exec_context *ctx,
if (end)
*end = i;
if (ins = ctx-instructions || !ins_table[ins].run) {
-   pr_warning(FW_WARN APEI_PFX
+   pr_warn(FW_WARN APEI_PFX
Invalid action table, unknown instruction type: %d\n,
   ins);
return -EINVAL;
@@ -589,7 +589,7 @@ static int apei_check_gar(struct acpi_generic_address *reg, 
u64 *paddr,
space_id = reg-space_id;
*paddr = get_unaligned(reg-address);
if (!*paddr) {
-   pr_warning(FW_BUG APEI_PFX
+   pr_warn(FW_BUG APEI_PFX
   Invalid physical address in GAR 
[0x%llx/%u/%u/%u/%u]\n,
   *paddr, bit_width, bit_offset, access_size_code,
   space_id);
@@ -597,7 +597,7 @@ static int apei_check_gar(struct acpi_generic_address *reg, 
u64 *paddr,
}
 
if (access_size_code  1 || access_size_code  4) {
-   pr_warning(FW_BUG APEI_PFX
+   pr_warn(FW_BUG APEI_PFX
   Invalid access size code in GAR 
[0x%llx/%u/%u/%u/%u]\n,
   *paddr, bit_width, bit_offset, access_size_code,
   space_id);
@@ -614,7 +614,7 @@ static int apei_check_gar(struct acpi_generic_address *reg, 
u64 *paddr,
*access_bit_width = 64;
 
if ((bit_width + bit_offset)  *access_bit_width) {
-   pr_warning(FW_BUG APEI_PFX
+   pr_warn(FW_BUG APEI_PFX
   Invalid bit width + offset in GAR 
[0x%llx/%u/%u/%u/%u]\n,
   *paddr, bit_width, bit_offset, access_size_code,
   space_id);
@@ -623,7 +623,7 @@ static int apei_check_gar(struct acpi_generic_address *reg, 
u64 *paddr,
 
if (space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY 
space_id != ACPI_ADR_SPACE_SYSTEM_IO) {
-   pr_warning(FW_BUG APEI_PFX
+   pr_warn(FW_BUG APEI_PFX
   Invalid address space type in GAR 
[0x%llx/%u/%u/%u/%u]\n,
   *paddr, bit_width, bit_offset, access_size_code,
   space_id);
diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c
index a095d4f..ff3daca 100644
--- a/drivers/acpi/apei/einj.c
+++ b/drivers/acpi/apei/einj.c
@@ -183,7 +183,7 @@ static int einj_get_available_error_type(u32 *type)
 static int einj_timedout(u64 *t)
 {
if ((s64)*t  SPIN_UNIT) {
-   pr_warning(FW_WARN EINJ_PFX
+   pr_warn(FW_WARN EINJ_PFX
   Firmware does not respond in time\n);
return 1;
}
@@ -325,7 +325,7 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
}
rc = einj_check_trigger_header(trigger_tab);
if (rc) {
-   pr_warning(FW_BUG EINJ_PFX
+   pr_warn(FW_BUG EINJ_PFX
   The trigger error action table is invalid\n);
goto out_rel_header;
}
@@ -707,7 +707,7 @@ static int __init einj_init(void)
 
rc = einj_check_table(einj_tab);
if (rc) {
-   pr_warning(FW_BUG EINJ_PFX EINJ table is invalid\n);
+   pr_warn(FW_BUG EINJ_PFX EINJ table is invalid\n);
return -EINVAL;
}
 
diff --git a/drivers/acpi/apei/erst-dbg.c b/drivers/acpi/apei/erst-dbg.c
index 04ab5c9..3a57ffb 100644
--- a/drivers/acpi/apei/erst-dbg.c
+++ b/drivers/acpi/apei/erst-dbg.c
@@ -130,7 +130,7 @@ retry:
if (rc  0

[PATCH 2/2] apei/erst-dbg: Define pr_fmt macro to avoid the duplication of ERST_DBG_PFX

2015-06-15 Thread Wang Long
Define pr_fmt macro with {ERST DBG: } prefix, then remove all use
of ERST_DBG_PFXin the pr_* functions.

Signed-off-by: Wang Long long.wangl...@huawei.com
---
 drivers/acpi/apei/erst-dbg.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/apei/erst-dbg.c b/drivers/acpi/apei/erst-dbg.c
index 3a57ffb..48e9490 100644
--- a/drivers/acpi/apei/erst-dbg.c
+++ b/drivers/acpi/apei/erst-dbg.c
@@ -31,7 +31,8 @@
 
 #include apei-internal.h
 
-#define ERST_DBG_PFX   ERST DBG: 
+#undef pr_fmt
+#define pr_fmt(fmt) ERST DBG:  fmt
 
 #define ERST_DBG_RECORD_LEN_MAX0x4000
 
@@ -130,8 +131,7 @@ retry:
if (rc  0)
goto out;
if (len  ERST_DBG_RECORD_LEN_MAX) {
-   pr_warn(ERST_DBG_PFX
-  Record (ID: 0x%llx) length is too long: %zd\n,
+   pr_warn(Record (ID: 0x%llx) length is too long: %zd\n,
   id, len);
rc = -EIO;
goto out;
@@ -171,7 +171,7 @@ static ssize_t erst_dbg_write(struct file *filp, const char 
__user *ubuf,
return -EPERM;
 
if (usize  ERST_DBG_RECORD_LEN_MAX) {
-   pr_err(ERST_DBG_PFX Too long record to be written\n);
+   pr_err(Too long record to be written\n);
return -EINVAL;
}
 
@@ -223,7 +223,7 @@ static struct miscdevice erst_dbg_dev = {
 static __init int erst_dbg_init(void)
 {
if (erst_disable) {
-   pr_info(ERST_DBG_PFX ERST support is disabled.\n);
+   pr_info(ERST support is disabled.\n);
return -ENODEV;
}
return misc_register(erst_dbg_dev);
-- 
1.8.3.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ring-buffer-benchmark: Fix the wrong sched_priority of producer

2015-06-10 Thread Wang Long
The producer should be used producer_fifo as its sched_priority,
so correct it.

Signed-off-by: Wang Long 
---
 kernel/trace/ring_buffer_benchmark.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/ring_buffer_benchmark.c 
b/kernel/trace/ring_buffer_benchmark.c
index 13d945c..1b28df2 100644
--- a/kernel/trace/ring_buffer_benchmark.c
+++ b/kernel/trace/ring_buffer_benchmark.c
@@ -450,7 +450,7 @@ static int __init ring_buffer_benchmark_init(void)
 
if (producer_fifo >= 0) {
struct sched_param param = {
-   .sched_priority = consumer_fifo
+   .sched_priority = producer_fifo
};
sched_setscheduler(producer, SCHED_FIFO, );
} else
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ring-buffer-benchmark: Fix the wrong type

2015-06-10 Thread Wang Long
The macro 'module_param' shows that the type of the
variable disable_reader and write_iteration is unsigned
integer. so, we change their type form int to unsigned int.

Signed-off-by: Wang Long 
---
 kernel/trace/ring_buffer_benchmark.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/ring_buffer_benchmark.c 
b/kernel/trace/ring_buffer_benchmark.c
index 1b28df2..e1b4a81 100644
--- a/kernel/trace/ring_buffer_benchmark.c
+++ b/kernel/trace/ring_buffer_benchmark.c
@@ -32,11 +32,11 @@ static struct task_struct *producer;
 static struct task_struct *consumer;
 static unsigned long read;
 
-static int disable_reader;
+static unsigned int disable_reader;
 module_param(disable_reader, uint, 0644);
 MODULE_PARM_DESC(disable_reader, "only run producer");
 
-static int write_iteration = 50;
+static unsigned int write_iteration = 50;
 module_param(write_iteration, uint, 0644);
 MODULE_PARM_DESC(write_iteration, "# of writes between timestamp readings");
 
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ring-buffer-benchmark: Fix the wrong param in module_param

2015-06-10 Thread Wang Long
The {producer|consumer}_{nice|fifo} parameters are integer
type, we should use 'int' as the second param in module_param.

For example(consumer_fifo):
the default value of consumer_fifo is -1.
   Without this patch:
# cat /sys/module/ring_buffer_benchmark/parameters/consumer_fifo
4294967295
   With this patch:
# cat /sys/module/ring_buffer_benchmark/parameters/consumer_fifo
-1

Signed-off-by: Wang Long 
---
 kernel/trace/ring_buffer_benchmark.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/ring_buffer_benchmark.c 
b/kernel/trace/ring_buffer_benchmark.c
index e1b4a81..61b933b 100644
--- a/kernel/trace/ring_buffer_benchmark.c
+++ b/kernel/trace/ring_buffer_benchmark.c
@@ -46,16 +46,16 @@ static int consumer_nice = MAX_NICE;
 static int producer_fifo = -1;
 static int consumer_fifo = -1;
 
-module_param(producer_nice, uint, 0644);
+module_param(producer_nice, int, 0644);
 MODULE_PARM_DESC(producer_nice, "nice prio for producer");
 
-module_param(consumer_nice, uint, 0644);
+module_param(consumer_nice, int, 0644);
 MODULE_PARM_DESC(consumer_nice, "nice prio for consumer");
 
-module_param(producer_fifo, uint, 0644);
+module_param(producer_fifo, int, 0644);
 MODULE_PARM_DESC(producer_fifo, "fifo prio for producer");
 
-module_param(consumer_fifo, uint, 0644);
+module_param(consumer_fifo, int, 0644);
 MODULE_PARM_DESC(consumer_fifo, "fifo prio for consumer");
 
 static int read_events;
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ring-buffer-benchmark: Fix the wrong sched_priority of producer

2015-06-10 Thread Wang Long
The producer should be used producer_fifo as its sched_priority,
so correct it.

Signed-off-by: Wang Long long.wangl...@huawei.com
---
 kernel/trace/ring_buffer_benchmark.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/ring_buffer_benchmark.c 
b/kernel/trace/ring_buffer_benchmark.c
index 13d945c..1b28df2 100644
--- a/kernel/trace/ring_buffer_benchmark.c
+++ b/kernel/trace/ring_buffer_benchmark.c
@@ -450,7 +450,7 @@ static int __init ring_buffer_benchmark_init(void)
 
if (producer_fifo = 0) {
struct sched_param param = {
-   .sched_priority = consumer_fifo
+   .sched_priority = producer_fifo
};
sched_setscheduler(producer, SCHED_FIFO, param);
} else
-- 
1.8.3.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ring-buffer-benchmark: Fix the wrong type

2015-06-10 Thread Wang Long
The macro 'module_param' shows that the type of the
variable disable_reader and write_iteration is unsigned
integer. so, we change their type form int to unsigned int.

Signed-off-by: Wang Long long.wangl...@huawei.com
---
 kernel/trace/ring_buffer_benchmark.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/ring_buffer_benchmark.c 
b/kernel/trace/ring_buffer_benchmark.c
index 1b28df2..e1b4a81 100644
--- a/kernel/trace/ring_buffer_benchmark.c
+++ b/kernel/trace/ring_buffer_benchmark.c
@@ -32,11 +32,11 @@ static struct task_struct *producer;
 static struct task_struct *consumer;
 static unsigned long read;
 
-static int disable_reader;
+static unsigned int disable_reader;
 module_param(disable_reader, uint, 0644);
 MODULE_PARM_DESC(disable_reader, only run producer);
 
-static int write_iteration = 50;
+static unsigned int write_iteration = 50;
 module_param(write_iteration, uint, 0644);
 MODULE_PARM_DESC(write_iteration, # of writes between timestamp readings);
 
-- 
1.8.3.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ring-buffer-benchmark: Fix the wrong param in module_param

2015-06-10 Thread Wang Long
The {producer|consumer}_{nice|fifo} parameters are integer
type, we should use 'int' as the second param in module_param.

For example(consumer_fifo):
the default value of consumer_fifo is -1.
   Without this patch:
# cat /sys/module/ring_buffer_benchmark/parameters/consumer_fifo
4294967295
   With this patch:
# cat /sys/module/ring_buffer_benchmark/parameters/consumer_fifo
-1

Signed-off-by: Wang Long long.wangl...@huawei.com
---
 kernel/trace/ring_buffer_benchmark.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/ring_buffer_benchmark.c 
b/kernel/trace/ring_buffer_benchmark.c
index e1b4a81..61b933b 100644
--- a/kernel/trace/ring_buffer_benchmark.c
+++ b/kernel/trace/ring_buffer_benchmark.c
@@ -46,16 +46,16 @@ static int consumer_nice = MAX_NICE;
 static int producer_fifo = -1;
 static int consumer_fifo = -1;
 
-module_param(producer_nice, uint, 0644);
+module_param(producer_nice, int, 0644);
 MODULE_PARM_DESC(producer_nice, nice prio for producer);
 
-module_param(consumer_nice, uint, 0644);
+module_param(consumer_nice, int, 0644);
 MODULE_PARM_DESC(consumer_nice, nice prio for consumer);
 
-module_param(producer_fifo, uint, 0644);
+module_param(producer_fifo, int, 0644);
 MODULE_PARM_DESC(producer_fifo, fifo prio for producer);
 
-module_param(consumer_fifo, uint, 0644);
+module_param(consumer_fifo, int, 0644);
 MODULE_PARM_DESC(consumer_fifo, fifo prio for consumer);
 
 static int read_events;
-- 
1.8.3.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] pstore/ram: delete the redundant persistent_ram_zap call

2015-06-09 Thread Wang Long
In ramoops_init_prz function, we have already call
persistent_ram_zap in persistent_ram_new, so just
delete it.

Signed-off-by: Wang Long 
---
 fs/pstore/ram.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 44a549b..fc8db9d 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -437,8 +437,6 @@ static int ramoops_init_prz(struct device *dev, struct 
ramoops_context *cxt,
return err;
}
 
-   persistent_ram_zap(*prz);
-
*paddr += sz;
 
return 0;
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] pstore/ram: delete the redundant persistent_ram_zap call

2015-06-09 Thread Wang Long
In ramoops_init_prz function, we have already call
persistent_ram_zap in persistent_ram_new, so just
delete it.

Signed-off-by: Wang Long long.wangl...@huawei.com
---
 fs/pstore/ram.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 44a549b..fc8db9d 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -437,8 +437,6 @@ static int ramoops_init_prz(struct device *dev, struct 
ramoops_context *cxt,
return err;
}
 
-   persistent_ram_zap(*prz);
-
*paddr += sz;
 
return 0;
-- 
1.8.3.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] netevent: remove automatic variable in register_netevent_notifier()

2015-05-28 Thread Wang Long
Remove automatic variable 'err' in register_netevent_notifier() and
return the result of atomic_notifier_chain_register() directly.

Signed-off-by: Wang Long 
---
 net/core/netevent.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/core/netevent.c b/net/core/netevent.c
index f17ccd2..8b3bc4f 100644
--- a/net/core/netevent.c
+++ b/net/core/netevent.c
@@ -31,10 +31,7 @@ static ATOMIC_NOTIFIER_HEAD(netevent_notif_chain);
  */
 int register_netevent_notifier(struct notifier_block *nb)
 {
-   int err;
-
-   err = atomic_notifier_chain_register(_notif_chain, nb);
-   return err;
+   return atomic_notifier_chain_register(_notif_chain, nb);
 }
 EXPORT_SYMBOL_GPL(register_netevent_notifier);
 
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] netevent: remove automatic variable in register_netevent_notifier()

2015-05-28 Thread Wang Long
Remove automatic variable 'err' in register_netevent_notifier() and
return the return value of atomic_notifier_chain_register() directly.

Signed-off-by: Wang Long 
---
 net/core/netevent.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/core/netevent.c b/net/core/netevent.c
index f17ccd2..8b3bc4f 100644
--- a/net/core/netevent.c
+++ b/net/core/netevent.c
@@ -31,10 +31,7 @@ static ATOMIC_NOTIFIER_HEAD(netevent_notif_chain);
  */
 int register_netevent_notifier(struct notifier_block *nb)
 {
-   int err;
-
-   err = atomic_notifier_chain_register(_notif_chain, nb);
-   return err;
+   return atomic_notifier_chain_register(_notif_chain, nb);
 }
 EXPORT_SYMBOL_GPL(register_netevent_notifier);
 
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   4   >