Re: [PATCH] cgroup: Remove unnecessary call to strstrip()

2021-01-14 Thread Hao Lee
> Perhaps the code be then simplified a bit
>
> -- >8 --
> From: =?UTF-8?q?Michal=20Koutn=C3=BD?= 
> Date: Thu, 14 Jan 2021 13:23:39 +0100
> Subject: [PATCH] cgroup: cgroup.{procs,threads} factor out common parts
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> The functions cgroup_threads_start and cgroup_procs_start are almost
> identical. In order to reduce duplication, factor out the common code in
> similar fashion we already do for other threadgroup/task functions. No
> functional changes are intended.

Nice work. I didn't realize this simplification :)

Regards,
Hao Lee


[tip: x86/cleanups] x86/entry: Remove now unused do_IRQ() declaration

2021-01-12 Thread tip-bot2 for Hao Lee
The following commit has been merged into the x86/cleanups branch of tip:

Commit-ID: 11aa1415d8bd2920ce884356479eabbd64b1df2a
Gitweb:
https://git.kernel.org/tip/11aa1415d8bd2920ce884356479eabbd64b1df2a
Author:Hao Lee 
AuthorDate:Sun, 03 Jan 2021 03:08:34 
Committer: Borislav Petkov 
CommitterDate: Tue, 12 Jan 2021 14:37:37 +01:00

x86/entry: Remove now unused do_IRQ() declaration

do_IRQ() has been replaced by common_interrupt() in

  fa5e5c409213 ("x86/entry: Use idtentry for interrupts")

Remove its now unused declaration.

Signed-off-by: Hao Lee 
Signed-off-by: Borislav Petkov 
Link: https://lkml.kernel.org/r/20210103030834.ga15...@haolee.github.io
---
 arch/x86/include/asm/irq.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/x86/include/asm/irq.h b/arch/x86/include/asm/irq.h
index 528c8a7..76d3896 100644
--- a/arch/x86/include/asm/irq.h
+++ b/arch/x86/include/asm/irq.h
@@ -40,8 +40,6 @@ extern void native_init_IRQ(void);
 
 extern void __handle_irq(struct irq_desc *desc, struct pt_regs *regs);
 
-extern __visible void do_IRQ(struct pt_regs *regs, unsigned long vector);
-
 extern void init_ISA_irqs(void);
 
 extern void __init init_IRQ(void);


[PATCH] x86/entry: Remove deprecated do_IRQ declaration

2021-01-02 Thread Hao Lee
do_IRQ has been replaced by common_interrupt in
commit fa5e5c409213 ("x86/entry: Use idtentry for interrupts")

Remove its declaration.

Signed-off-by: Hao Lee 
---
 arch/x86/include/asm/irq.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/x86/include/asm/irq.h b/arch/x86/include/asm/irq.h
index 528c8a71fe7f..76d389691b5b 100644
--- a/arch/x86/include/asm/irq.h
+++ b/arch/x86/include/asm/irq.h
@@ -40,8 +40,6 @@ extern void native_init_IRQ(void);
 
 extern void __handle_irq(struct irq_desc *desc, struct pt_regs *regs);
 
-extern __visible void do_IRQ(struct pt_regs *regs, unsigned long vector);
-
 extern void init_ISA_irqs(void);
 
 extern void __init init_IRQ(void);
-- 
2.24.1



[PATCH] cgroup: Remove unnecessary call to strstrip()

2021-01-02 Thread Hao Lee
The string buf will be stripped in cgroup_procs_write_start() before it
is converted to int, so remove this unnecessary call to strstrip().

Signed-off-by: Hao Lee 
---
 kernel/cgroup/cgroup.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 5e9cb81c088a..8b3554c1113a 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -4774,8 +4774,6 @@ static ssize_t cgroup_threads_write(struct 
kernfs_open_file *of,
ssize_t ret;
bool locked;
 
-   buf = strstrip(buf);
-
dst_cgrp = cgroup_kn_lock_live(of->kn, false);
if (!dst_cgrp)
return -ENODEV;
-- 
2.24.1



Re: [PATCH] cgroup: Remove unnecessary call to strstrip()

2020-10-01 Thread Hao Lee
Ping. Thanks.

On Tue, Sep 08, 2020 at 01:33:50PM +, Hao Lee wrote:
> The string buf will be stripped in cgroup_procs_write_start() before it
> is converted to int, so remove this unnecessary call to strstrip().
> 
> Signed-off-by: Hao Lee 
> ---
>  kernel/cgroup/cgroup.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
> index b6714166106d..90ee7e73eb2e 100644
> --- a/kernel/cgroup/cgroup.c
> +++ b/kernel/cgroup/cgroup.c
> @@ -4772,14 +4772,12 @@ static ssize_t cgroup_threads_write(struct 
> kernfs_open_file *of,
>  {
>   struct cgroup *src_cgrp, *dst_cgrp;
>   struct task_struct *task;
>   ssize_t ret;
>   bool locked;
>  
> - buf = strstrip(buf);
> -
>   dst_cgrp = cgroup_kn_lock_live(of->kn, false);
>   if (!dst_cgrp)
>   return -ENODEV;
>  
>   task = cgroup_procs_write_start(buf, false, );
>   ret = PTR_ERR_OR_ZERO(task);
> -- 
> 2.24.1
> 


Re: [PATCH] cgroup: Delete unnecessary if statement in css_visible()

2020-10-01 Thread Hao Lee
Hi, ping...

On Sat, Aug 29, 2020 at 10:03:16AM +, Hao Lee wrote:
> css_visible() is called in either cgroup_apply_control_enable()
> or cgroup_apply_control_disable().
> In cgroup_apply_control_enable(), we have checked ss_mask before calling
> css_visible(), so there is no need to do the same thing again.
> In cgroup_apply_control_disable():
>  - If css->parent is not NULL, we have checked ss_mask in the
>second condition, so there is no need to do the same thing again.
>  - If css->parent is NULL, dsct is root cgroup so the deleted if
>statement is always false and there is no need to keep it.
> 
> Signed-off-by: Hao Lee 
> ---
>  kernel/cgroup/cgroup.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
> index dd247747ec14..b6714166106d 100644
> --- a/kernel/cgroup/cgroup.c
> +++ b/kernel/cgroup/cgroup.c
> @@ -3023,8 +3023,6 @@ static bool css_visible(struct cgroup_subsys_state *css)
>  
>   if (cgroup_control(cgrp) & (1 << ss->id))
>   return true;
> - if (!(cgroup_ss_mask(cgrp) & (1 << ss->id)))
> - return false;
>   return cgroup_on_dfl(cgrp) && ss->implicit_on_dfl;
>  }
>  
> -- 
> 2.24.1
> 


Can we remove the checking of CONFIG_ARCH_HAS_PTE_SPECIAL in __vm_insert_mixed?

2020-09-28 Thread Hao Lee
Sorry, the previous email is corrupted. This is a resending.

In the current code, if the architecture supports PTE_SPECIAL,
__vm_insert_mixed() becomes a simple encapsulation of insert_pfn()
because it always calls insert_pfn() and never calls insert_page(). This
behavior is inconsistent with the function's name. As described in commit
423bad600443 ("mm: add vm_insert_mixed"), this function is designed to
supports _both_ raw pfns and pfns with struct page, but in architecture
with PTE_SPECIAL, it treats the latter as the former. So, I think we'd
better remove the checking of CONFIG_ARCH_HAS_PTE_SPECIAL to make the
behavior consistent for all architectures. If my understanding is right,
I can submit a patch to fix this. Thanks.

Regards,
Hao Lee


[no subject]

2020-09-28 Thread Hao Lee
dan.j.wiilli...@intel.com
Bcc: 
Subject: Can we remove the checking of CONFIG_ARCH_HAS_PTE_SPECIAL in
 __vm_insert_mixed?
Reply-To: 

In the current code, if the architecture supports PTE_SPECIAL,
__vm_insert_mixed() becomes a simple encapsulation of insert_pfn()
because it always calls insert_pfn() and never calls insert_page(). This
behavior is inconsistent with the function's name. As described in
commit 423bad600443 ("mm: add vm_insert_mixed"), this function is
designed to supports _both_ raw pfns and pfns with struct page, but in
architecture with PTE_SPECIAL, it treats the latter as the former. So, I
think we'd better remove the checking of CONFIG_ARCH_HAS_PTE_SPECIAL to
make the behavior consistent for all architectures. If my understanding
is right, I can submit a patch to fix this. Thanks.

Regards,
Hao Lee


Re: [PATCH] fs: Eliminate a local variable to make the code more clear

2020-09-09 Thread Hao Lee
On Wed, Sep 09, 2020 at 07:54:44AM -0500, Eric W. Biederman wrote:
> Hao Lee  writes:
> 
> > On Tue, Sep 08, 2020 at 07:48:57PM +0100, Al Viro wrote:
> >> On Tue, Sep 08, 2020 at 01:06:56PM +, Hao Lee wrote:
> >> > ping
> >> > 
> >> > On Wed, Jul 29, 2020 at 03:21:28PM +, Hao Lee wrote:
> >> > > The dentry local variable is introduced in 'commit 84d17192d2afd ("get
> >> > > rid of full-hash scan on detaching vfsmounts")' to reduce the length of
> >> > > some long statements for example
> >> > > mutex_lock(>dentry->d_inode->i_mutex). We have already used
> >> > > inode_lock(dentry->d_inode) to do the same thing now, and its length is
> >> > > acceptable. Furthermore, it seems not concise that assign path->dentry
> >> > > to local variable dentry in the statement before goto. So, this 
> >> > > function
> >> > > would be more clear if we eliminate the local variable dentry.
> >> 
> >> How does it make the function more clear?  More specifically, what
> >> analysis of behaviour is simplified by that?
> >
> > When I first read this function, it takes me a few seconds to think
> > about if the local variable dentry is always equal to path->dentry and
> > want to know if it has special purpose. This local variable may confuse
> > other people too, so I think it would be better to eliminate it.
> 
> I tend to have the opposite reaction.  I read your patch and wonder
> why path->dentry needs to be reread what is changing path that I can not see.
> my back.

If I understand correctly, accessing path->dentry->d_inode needs one
more instruction than accessing dentry->d_inode, so the original code is
more efficient.

> 
> Now for clarity it would probably help to do something like:
> 
> diff --git a/fs/namespace.c b/fs/namespace.c
> index bae0e95b3713..430f3b4785e3 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -2206,7 +2206,7 @@ static struct mountpoint *lock_mount(struct path *path)
> return mp;
> }
> namespace_unlock();
> -   inode_unlock(path->dentry->d_inode);
> +   inode_unlock(dentry->d_inode);
> path_put(path);
> path->mnt = mnt;
> dentry = path->dentry = dget(mnt->mnt_root);
> 
> 
> So at least the inode_lock and inode_unlock are properly paired.
> 
> At first glance inode_unlock using path->dentry instead of dentry
> appears to be an oversight in 84d17192d2af ("get rid of full-hash scan
> on detaching vfsmounts").  

I think I have understood why we use the local variable dentry. Thanks.

Regards,
Hao Lee

> 
> 
> Eric


Re: [PATCH] fs: Eliminate a local variable to make the code more clear

2020-09-08 Thread Hao Lee
On Tue, Sep 08, 2020 at 07:48:57PM +0100, Al Viro wrote:
> On Tue, Sep 08, 2020 at 01:06:56PM +0000, Hao Lee wrote:
> > ping
> > 
> > On Wed, Jul 29, 2020 at 03:21:28PM +, Hao Lee wrote:
> > > The dentry local variable is introduced in 'commit 84d17192d2afd ("get
> > > rid of full-hash scan on detaching vfsmounts")' to reduce the length of
> > > some long statements for example
> > > mutex_lock(>dentry->d_inode->i_mutex). We have already used
> > > inode_lock(dentry->d_inode) to do the same thing now, and its length is
> > > acceptable. Furthermore, it seems not concise that assign path->dentry
> > > to local variable dentry in the statement before goto. So, this function
> > > would be more clear if we eliminate the local variable dentry.
> 
> How does it make the function more clear?  More specifically, what
> analysis of behaviour is simplified by that?

When I first read this function, it takes me a few seconds to think
about if the local variable dentry is always equal to path->dentry and
want to know if it has special purpose. This local variable may confuse
other people too, so I think it would be better to eliminate it.

Thanks,
Hao Lee


Re: [PATCH] fs: Eliminate a local variable to make the code more clear

2020-09-08 Thread Hao Lee
ping

On Wed, Jul 29, 2020 at 03:21:28PM +, Hao Lee wrote:
> The dentry local variable is introduced in 'commit 84d17192d2afd ("get
> rid of full-hash scan on detaching vfsmounts")' to reduce the length of
> some long statements for example
> mutex_lock(>dentry->d_inode->i_mutex). We have already used
> inode_lock(dentry->d_inode) to do the same thing now, and its length is
> acceptable. Furthermore, it seems not concise that assign path->dentry
> to local variable dentry in the statement before goto. So, this function
> would be more clear if we eliminate the local variable dentry.
> 
> The function logic is not changed.
> 
> Signed-off-by: Hao Lee 
> ---
>  fs/namespace.c | 13 ++---
>  1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/namespace.c b/fs/namespace.c
> index 4a0f600a3328..fcb93586fcc9 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -2187,20 +2187,19 @@ static int attach_recursive_mnt(struct mount 
> *source_mnt,
>  static struct mountpoint *lock_mount(struct path *path)
>  {
>   struct vfsmount *mnt;
> - struct dentry *dentry = path->dentry;
>  retry:
> - inode_lock(dentry->d_inode);
> - if (unlikely(cant_mount(dentry))) {
> - inode_unlock(dentry->d_inode);
> + inode_lock(path->dentry->d_inode);
> + if (unlikely(cant_mount(path->dentry))) {
> + inode_unlock(path->dentry->d_inode);
>   return ERR_PTR(-ENOENT);
>   }
>   namespace_lock();
>   mnt = lookup_mnt(path);
>   if (likely(!mnt)) {
> - struct mountpoint *mp = get_mountpoint(dentry);
> + struct mountpoint *mp = get_mountpoint(path->dentry);
>   if (IS_ERR(mp)) {
>   namespace_unlock();
> - inode_unlock(dentry->d_inode);
> + inode_unlock(path->dentry->d_inode);
>   return mp;
>   }
>   return mp;
> @@ -2209,7 +2208,7 @@ static struct mountpoint *lock_mount(struct path *path)
>   inode_unlock(path->dentry->d_inode);
>   path_put(path);
>   path->mnt = mnt;
> - dentry = path->dentry = dget(mnt->mnt_root);
> + path->dentry = dget(mnt->mnt_root);
>   goto retry;
>  }
>  
> -- 
> 2.24.1
> 


Re: [PATCH] cgroup: Delete unnecessary if statement in css_visible()

2020-09-08 Thread Hao Lee
Hello,

ping

On Sat, Aug 29, 2020 at 10:03:16AM +, Hao Lee wrote:
> css_visible() is called in either cgroup_apply_control_enable()
> or cgroup_apply_control_disable().
> In cgroup_apply_control_enable(), we have checked ss_mask before calling
> css_visible(), so there is no need to do the same thing again.
> In cgroup_apply_control_disable():
>  - If css->parent is not NULL, we have checked ss_mask in the
>second condition, so there is no need to do the same thing again.
>  - If css->parent is NULL, dsct is root cgroup so the deleted if
>statement is always false and there is no need to keep it.
> 
> Signed-off-by: Hao Lee 
> ---
>  kernel/cgroup/cgroup.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
> index dd247747ec14..b6714166106d 100644
> --- a/kernel/cgroup/cgroup.c
> +++ b/kernel/cgroup/cgroup.c
> @@ -3023,8 +3023,6 @@ static bool css_visible(struct cgroup_subsys_state *css)
>  
>   if (cgroup_control(cgrp) & (1 << ss->id))
>   return true;
> - if (!(cgroup_ss_mask(cgrp) & (1 << ss->id)))
> - return false;
>   return cgroup_on_dfl(cgrp) && ss->implicit_on_dfl;
>  }
>  
> -- 
> 2.24.1
> 


[PATCH] cgroup: Remove unnecessary call to strstrip()

2020-09-08 Thread Hao Lee
The string buf will be stripped in cgroup_procs_write_start() before it
is converted to int, so remove this unnecessary call to strstrip().

Signed-off-by: Hao Lee 
---
 kernel/cgroup/cgroup.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index b6714166106d..90ee7e73eb2e 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -4772,14 +4772,12 @@ static ssize_t cgroup_threads_write(struct 
kernfs_open_file *of,
 {
struct cgroup *src_cgrp, *dst_cgrp;
struct task_struct *task;
ssize_t ret;
bool locked;
 
-   buf = strstrip(buf);
-
dst_cgrp = cgroup_kn_lock_live(of->kn, false);
if (!dst_cgrp)
return -ENODEV;
 
task = cgroup_procs_write_start(buf, false, );
ret = PTR_ERR_OR_ZERO(task);
-- 
2.24.1



[PATCH] cgroup: Delete unnecessary if statement in css_visible()

2020-08-29 Thread Hao Lee
css_visible() is called in either cgroup_apply_control_enable()
or cgroup_apply_control_disable().
In cgroup_apply_control_enable(), we have checked ss_mask before calling
css_visible(), so there is no need to do the same thing again.
In cgroup_apply_control_disable():
 - If css->parent is not NULL, we have checked ss_mask in the
   second condition, so there is no need to do the same thing again.
 - If css->parent is NULL, dsct is root cgroup so the deleted if
   statement is always false and there is no need to keep it.

Signed-off-by: Hao Lee 
---
 kernel/cgroup/cgroup.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index dd247747ec14..b6714166106d 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -3023,8 +3023,6 @@ static bool css_visible(struct cgroup_subsys_state *css)
 
if (cgroup_control(cgrp) & (1 << ss->id))
return true;
-   if (!(cgroup_ss_mask(cgrp) & (1 << ss->id)))
-   return false;
return cgroup_on_dfl(cgrp) && ss->implicit_on_dfl;
 }
 
-- 
2.24.1



Re: [PATCH] fs: Eliminate a local variable to make the code more clear

2020-08-14 Thread Hao Lee
Ping

On Wed, Jul 29, 2020 at 11:21 PM Hao Lee  wrote:
>
> The dentry local variable is introduced in 'commit 84d17192d2afd ("get
> rid of full-hash scan on detaching vfsmounts")' to reduce the length of
> some long statements for example
> mutex_lock(>dentry->d_inode->i_mutex). We have already used
> inode_lock(dentry->d_inode) to do the same thing now, and its length is
> acceptable. Furthermore, it seems not concise that assign path->dentry
> to local variable dentry in the statement before goto. So, this function
> would be more clear if we eliminate the local variable dentry.
>
> The function logic is not changed.
>
> Signed-off-by: Hao Lee 
> ---
>  fs/namespace.c | 13 ++---
>  1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/fs/namespace.c b/fs/namespace.c
> index 4a0f600a3328..fcb93586fcc9 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -2187,20 +2187,19 @@ static int attach_recursive_mnt(struct mount 
> *source_mnt,
>  static struct mountpoint *lock_mount(struct path *path)
>  {
> struct vfsmount *mnt;
> -   struct dentry *dentry = path->dentry;
>  retry:
> -   inode_lock(dentry->d_inode);
> -   if (unlikely(cant_mount(dentry))) {
> -   inode_unlock(dentry->d_inode);
> +   inode_lock(path->dentry->d_inode);
> +   if (unlikely(cant_mount(path->dentry))) {
> +   inode_unlock(path->dentry->d_inode);
> return ERR_PTR(-ENOENT);
> }
> namespace_lock();
> mnt = lookup_mnt(path);
> if (likely(!mnt)) {
> -   struct mountpoint *mp = get_mountpoint(dentry);
> +   struct mountpoint *mp = get_mountpoint(path->dentry);
> if (IS_ERR(mp)) {
> namespace_unlock();
> -   inode_unlock(dentry->d_inode);
> +   inode_unlock(path->dentry->d_inode);
> return mp;
> }
> return mp;
> @@ -2209,7 +2208,7 @@ static struct mountpoint *lock_mount(struct path *path)
> inode_unlock(path->dentry->d_inode);
> path_put(path);
> path->mnt = mnt;
> -   dentry = path->dentry = dget(mnt->mnt_root);
> +   path->dentry = dget(mnt->mnt_root);
> goto retry;
>  }
>
> --
> 2.24.1
>


[PATCH] fs: Eliminate a local variable to make the code more clear

2020-07-29 Thread Hao Lee
The dentry local variable is introduced in 'commit 84d17192d2afd ("get
rid of full-hash scan on detaching vfsmounts")' to reduce the length of
some long statements for example
mutex_lock(>dentry->d_inode->i_mutex). We have already used
inode_lock(dentry->d_inode) to do the same thing now, and its length is
acceptable. Furthermore, it seems not concise that assign path->dentry
to local variable dentry in the statement before goto. So, this function
would be more clear if we eliminate the local variable dentry.

The function logic is not changed.

Signed-off-by: Hao Lee 
---
 fs/namespace.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index 4a0f600a3328..fcb93586fcc9 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2187,20 +2187,19 @@ static int attach_recursive_mnt(struct mount 
*source_mnt,
 static struct mountpoint *lock_mount(struct path *path)
 {
struct vfsmount *mnt;
-   struct dentry *dentry = path->dentry;
 retry:
-   inode_lock(dentry->d_inode);
-   if (unlikely(cant_mount(dentry))) {
-   inode_unlock(dentry->d_inode);
+   inode_lock(path->dentry->d_inode);
+   if (unlikely(cant_mount(path->dentry))) {
+   inode_unlock(path->dentry->d_inode);
return ERR_PTR(-ENOENT);
}
namespace_lock();
mnt = lookup_mnt(path);
if (likely(!mnt)) {
-   struct mountpoint *mp = get_mountpoint(dentry);
+   struct mountpoint *mp = get_mountpoint(path->dentry);
if (IS_ERR(mp)) {
namespace_unlock();
-   inode_unlock(dentry->d_inode);
+   inode_unlock(path->dentry->d_inode);
return mp;
}
return mp;
@@ -2209,7 +2208,7 @@ static struct mountpoint *lock_mount(struct path *path)
inode_unlock(path->dentry->d_inode);
path_put(path);
path->mnt = mnt;
-   dentry = path->dentry = dget(mnt->mnt_root);
+   path->dentry = dget(mnt->mnt_root);
goto retry;
 }
 
-- 
2.24.1



[PATCH] mm: fix comments based on per-node memcg

2019-10-22 Thread Hao Lee
These comments should be updated as memcg limit enforcement has been moved
from zones to nodes.

Signed-off-by: Hao Lee 
---
 include/linux/memcontrol.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index ae703ea3ef48..12c29f74c02a 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -112,7 +112,7 @@ struct memcg_shrinker_map {
 };
 
 /*
- * per-zone information in memory controller.
+ * per-node information in memory controller.
  */
 struct mem_cgroup_per_node {
struct lruvec   lruvec;
@@ -399,8 +399,7 @@ mem_cgroup_nodeinfo(struct mem_cgroup *memcg, int nid)
  * @memcg: memcg of the wanted lruvec
  *
  * Returns the lru list vector holding pages for a given @node or a given
- * @memcg and @zone. This can be the node lruvec, if the memory controller
- * is disabled.
+ * @memcg. This can be the node lruvec, if the memory controller is disabled.
  */
 static inline struct lruvec *mem_cgroup_lruvec(struct pglist_data *pgdat,
struct mem_cgroup *memcg)
-- 
2.14.5



[PATCH] mm: fix struct member name in function comments

2019-09-27 Thread Hao Lee
The member in struct zonelist is _zonerefs instead of zones.

Signed-off-by: Hao Lee 
---
 include/linux/mmzone.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 3f38c30d2f13..6d44a49b3f29 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1064,7 +1064,7 @@ static inline struct zoneref *first_zones_zonelist(struct 
zonelist *zonelist,
 /**
  * for_each_zone_zonelist_nodemask - helper macro to iterate over valid zones 
in a zonelist at or below a given zone index and within a nodemask
  * @zone - The current zone in the iterator
- * @z - The current pointer within zonelist->zones being iterated
+ * @z - The current pointer within zonelist->_zonerefs being iterated
  * @zlist - The zonelist being iterated
  * @highidx - The zone index of the highest zone to return
  * @nodemask - Nodemask allowed by the allocator
-- 
2.14.5



Re: [PATCH v2] tty: serial: 8250: Fix type field in format string

2019-04-29 Thread Hao Lee
On Mon, 29 Apr 2019 at 22:31, Greg KH  wrote:
> This causes build warnings when applied, I'm having to drop it now.
>
> Please be more careful, when submitting patches, always test-build them
> first.

I have found my mistake. Although I have built a kernel to test my
patch, I forget to turn on the 8250 configurations which are turned
off during another kernel test. As a result, 8250_pnp.c was not
compiled at all, so I didn't see any warnings. Sorry for that and
thanks for your guidance. I will submit my patch v3.


[PATCH v3] tty: serial: 8250: Fix type field in format string

2019-04-29 Thread Hao Lee
The dev_dbg statement should print the value of uart.port.mapbase instead
of its address. Besides that, uart.port.irq and uart.port.iotype are all
unsigned types, so using %u is more appropriate.

Signed-off-by: Hao Lee 
---
 drivers/tty/serial/8250/8250_pnp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_pnp.c 
b/drivers/tty/serial/8250/8250_pnp.c
index 431e69a5a6a0..dfca33141fcc 100644
--- a/drivers/tty/serial/8250/8250_pnp.c
+++ b/drivers/tty/serial/8250/8250_pnp.c
@@ -462,8 +462,8 @@ serial_pnp_probe(struct pnp_dev *dev, const struct 
pnp_device_id *dev_id)
return -ENODEV;
 
dev_dbg(>dev,
-"Setup PNP port: port %lx, mem %pa, irq %d, type %d\n",
-uart.port.iobase, ,
+"Setup PNP port: port %#lx, mem %#llx, irq %u, type %u\n",
+uart.port.iobase, (unsigned long long)uart.port.mapbase,
 uart.port.irq, uart.port.iotype);
 
if (flags & CIR_PORT) {
-- 
2.14.5



[PATCH v2] tty: serial: 8250: Fix type field in format string

2019-04-27 Thread Hao Lee
The dev_dbg statement should print the value of uart.port.mapbase instead
of its address. Besides that, uart.port.irq and uart.port.iotype are all
unsigned types, so using %u is more appropriate.

Signed-off-by: Hao Lee 
---
 drivers/tty/serial/8250/8250_pnp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_pnp.c 
b/drivers/tty/serial/8250/8250_pnp.c
index 431e69a5a6a0..9dea11baf479 100644
--- a/drivers/tty/serial/8250/8250_pnp.c
+++ b/drivers/tty/serial/8250/8250_pnp.c
@@ -462,8 +462,8 @@ serial_pnp_probe(struct pnp_dev *dev, const struct 
pnp_device_id *dev_id)
return -ENODEV;
 
dev_dbg(>dev,
-"Setup PNP port: port %lx, mem %pa, irq %d, type %d\n",
-uart.port.iobase, ,
+"Setup PNP port: port %#lx, mem %#lx, irq %u, type %u\n",
+uart.port.iobase, uart.port.mapbase,
 uart.port.irq, uart.port.iotype);
 
if (flags & CIR_PORT) {
-- 
2.14.5



Re: [PATCH] tty: serial: 8250: Fix type field in format string

2019-04-27 Thread Hao Lee
On Sat, 27 Apr 2019 at 16:09, Greg KH  wrote:
>
> On Sat, Apr 27, 2019 at 04:00:15PM +0800, Hao Lee wrote:
> > The variable type and the type field is inconsistent.
>
> In what way?  Please be very specific when you resend this.

The main problem is the dev_dbg statement should print the value of
uart.port.mapbase instead of its address. Besides that, uart.port.irq
and uart.port.iotype are all unsigned types, so using %u is more
appropriate.

Regards,
Hao Lee


[PATCH] tty: serial: 8250: Fix type field in format string

2019-04-27 Thread Hao Lee
The variable type and the type field is inconsistent.

Signed-off-by: Hao Lee 
---
 drivers/tty/serial/8250/8250_pnp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_pnp.c 
b/drivers/tty/serial/8250/8250_pnp.c
index 431e69a5a6a0..9dea11baf479 100644
--- a/drivers/tty/serial/8250/8250_pnp.c
+++ b/drivers/tty/serial/8250/8250_pnp.c
@@ -462,8 +462,8 @@ serial_pnp_probe(struct pnp_dev *dev, const struct 
pnp_device_id *dev_id)
return -ENODEV;
 
dev_dbg(>dev,
-"Setup PNP port: port %lx, mem %pa, irq %d, type %d\n",
-uart.port.iobase, ,
+"Setup PNP port: port %#lx, mem %#lx, irq %u, type %u\n",
+uart.port.iobase, uart.port.mapbase,
 uart.port.irq, uart.port.iotype);
 
if (flags & CIR_PORT) {
-- 
2.14.5



Re: [PATCH] mm: remove a redundant condition in the for loop

2017-06-19 Thread Hao Lee
On Tue, Jun 20, 2017 at 3:05 AM, Rasmus Villemoes
<li...@rasmusvillemoes.dk> wrote:
> On Mon, Jun 19 2017, Vlastimil Babka <vba...@suse.cz> wrote:
>
>> On 06/19/2017 03:54 PM, Hao Lee wrote:
>>> The variable current_order decreases from MAX_ORDER-1 to order, so the
>>> condition current_order <= MAX_ORDER-1 is always true.
>>>
>>> Signed-off-by: Hao Lee <haolee.sw...@gmail.com>
>>
>> Sounds right.
>>
>> Acked-by: Vlastimil Babka <vba...@suse.cz>
>
> current_order and order are both unsigned, and if order==0,
> current_order >= order is always true, and we may decrement
> current_order past 0 making it UINT_MAX... A comment would be in order,
> though.

Thanks, I didn't notice unsigned subtraction. Sorry about that.


Re: [PATCH] mm: remove a redundant condition in the for loop

2017-06-19 Thread Hao Lee
On Tue, Jun 20, 2017 at 3:05 AM, Rasmus Villemoes
 wrote:
> On Mon, Jun 19 2017, Vlastimil Babka  wrote:
>
>> On 06/19/2017 03:54 PM, Hao Lee wrote:
>>> The variable current_order decreases from MAX_ORDER-1 to order, so the
>>> condition current_order <= MAX_ORDER-1 is always true.
>>>
>>> Signed-off-by: Hao Lee 
>>
>> Sounds right.
>>
>> Acked-by: Vlastimil Babka 
>
> current_order and order are both unsigned, and if order==0,
> current_order >= order is always true, and we may decrement
> current_order past 0 making it UINT_MAX... A comment would be in order,
> though.

Thanks, I didn't notice unsigned subtraction. Sorry about that.


[PATCH] mm: remove a redundant condition in the for loop

2017-06-19 Thread Hao Lee
The variable current_order decreases from MAX_ORDER-1 to order, so the
condition current_order <= MAX_ORDER-1 is always true.

Signed-off-by: Hao Lee <haolee.sw...@gmail.com>
---
 mm/page_alloc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 2302f25..9120c2b 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2215,9 +2215,8 @@ __rmqueue_fallback(struct zone *zone, unsigned int order, 
int start_migratetype)
bool can_steal;
 
/* Find the largest possible block of pages in the other list */
-   for (current_order = MAX_ORDER-1;
-   current_order >= order && current_order <= 
MAX_ORDER-1;
-   --current_order) {
+   for (current_order = MAX_ORDER-1; current_order >= order;
+   --current_order) {
area = &(zone->free_area[current_order]);
fallback_mt = find_suitable_fallback(area, current_order,
start_migratetype, false, _steal);
-- 
2.9.3



[PATCH] mm: remove a redundant condition in the for loop

2017-06-19 Thread Hao Lee
The variable current_order decreases from MAX_ORDER-1 to order, so the
condition current_order <= MAX_ORDER-1 is always true.

Signed-off-by: Hao Lee 
---
 mm/page_alloc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 2302f25..9120c2b 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2215,9 +2215,8 @@ __rmqueue_fallback(struct zone *zone, unsigned int order, 
int start_migratetype)
bool can_steal;
 
/* Find the largest possible block of pages in the other list */
-   for (current_order = MAX_ORDER-1;
-   current_order >= order && current_order <= 
MAX_ORDER-1;
-   --current_order) {
+   for (current_order = MAX_ORDER-1; current_order >= order;
+   --current_order) {
area = &(zone->free_area[current_order]);
fallback_mt = find_suitable_fallback(area, current_order,
start_migratetype, false, _steal);
-- 
2.9.3



[PATCH] mm: fix spelling error

2017-04-03 Thread Hao Lee
Fix variable name error in comments. No code changes.

Signed-off-by: Hao Lee <haolee.sw...@gmail.com>
---
 include/linux/gfp.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index db373b9..ff3d651 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -297,8 +297,8 @@ static inline bool gfpflags_allow_blocking(const gfp_t 
gfp_flags)
 
 /*
  * GFP_ZONE_TABLE is a word size bitstring that is used for looking up the
- * zone to use given the lowest 4 bits of gfp_t. Entries are ZONE_SHIFT long
- * and there are 16 of them to cover all possible combinations of
+ * zone to use given the lowest 4 bits of gfp_t. Entries are GFP_ZONES_SHIFT
+ * bits long and there are 16 of them to cover all possible combinations of
  * __GFP_DMA, __GFP_DMA32, __GFP_MOVABLE and __GFP_HIGHMEM.
  *
  * The zone fallback order is MOVABLE=>HIGHMEM=>NORMAL=>DMA32=>DMA.
-- 
2.9.3



[PATCH] mm: fix spelling error

2017-04-03 Thread Hao Lee
Fix variable name error in comments. No code changes.

Signed-off-by: Hao Lee 
---
 include/linux/gfp.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index db373b9..ff3d651 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -297,8 +297,8 @@ static inline bool gfpflags_allow_blocking(const gfp_t 
gfp_flags)
 
 /*
  * GFP_ZONE_TABLE is a word size bitstring that is used for looking up the
- * zone to use given the lowest 4 bits of gfp_t. Entries are ZONE_SHIFT long
- * and there are 16 of them to cover all possible combinations of
+ * zone to use given the lowest 4 bits of gfp_t. Entries are GFP_ZONES_SHIFT
+ * bits long and there are 16 of them to cover all possible combinations of
  * __GFP_DMA, __GFP_DMA32, __GFP_MOVABLE and __GFP_HIGHMEM.
  *
  * The zone fallback order is MOVABLE=>HIGHMEM=>NORMAL=>DMA32=>DMA.
-- 
2.9.3



[PATCH v1] i2c: designware: save the preset value of DW_IC_SDA_HOLD

2016-08-27 Thread Zhuo-hao Lee
There are several ways to set the SDA hold time for i2c controller,
including: Device Tree, built-in device properties and ACPI. However,
if the SDA hold time is not specified by above method, we should
read the value, where it is preset by firmware, and save it to
sda_hold_time. This is needed because when i2c controller enters
runtime suspend, the DW_IC_SDA_HOLD value will be reset to chipset
default value. And during runtime resume, i2c_dw_init will be called
to reconfigure i2c controller. If sda_hold_time is zero, the chipset
default hold time will be used, that will be too short for some
platforms. Therefore, to have a better tolerance, the DW_IC_SDA_HOLD
value should be kept by sda_hold_time.

Signed-off-by: Zhuo-hao Lee <zhuo-hao@intel.com>
---
 drivers/i2c/busses/i2c-designware-core.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-core.c 
b/drivers/i2c/busses/i2c-designware-core.c
index c6922b8..fcd973d 100644
--- a/drivers/i2c/busses/i2c-designware-core.c
+++ b/drivers/i2c/busses/i2c-designware-core.c
@@ -367,13 +367,17 @@ int i2c_dw_init(struct dw_i2c_dev *dev)
dev_dbg(dev->dev, "Fast-mode HCNT:LCNT = %d:%d\n", hcnt, lcnt);
 
/* Configure SDA Hold Time if required */
-   if (dev->sda_hold_time) {
-   reg = dw_readl(dev, DW_IC_COMP_VERSION);
-   if (reg >= DW_IC_SDA_HOLD_MIN_VERS)
+   reg = dw_readl(dev, DW_IC_COMP_VERSION);
+   if (reg >= DW_IC_SDA_HOLD_MIN_VERS) {
+   if (dev->sda_hold_time) {
dw_writel(dev, dev->sda_hold_time, DW_IC_SDA_HOLD);
-   else
-   dev_warn(dev->dev,
-   "Hardware too old to adjust SDA hold time.");
+   } else {
+   /* Keep previous hold time setting if no one set it */
+   dev->sda_hold_time = dw_readl(dev, DW_IC_SDA_HOLD);
+   }
+   } else {
+   dev_warn(dev->dev,
+   "Hardware too old to adjust SDA hold time.\n");
}
 
/* Configure Tx/Rx FIFO threshold levels */
-- 
1.9.1



[PATCH v1] i2c: designware: save the preset value of DW_IC_SDA_HOLD

2016-08-27 Thread Zhuo-hao Lee
There are several ways to set the SDA hold time for i2c controller,
including: Device Tree, built-in device properties and ACPI. However,
if the SDA hold time is not specified by above method, we should
read the value, where it is preset by firmware, and save it to
sda_hold_time. This is needed because when i2c controller enters
runtime suspend, the DW_IC_SDA_HOLD value will be reset to chipset
default value. And during runtime resume, i2c_dw_init will be called
to reconfigure i2c controller. If sda_hold_time is zero, the chipset
default hold time will be used, that will be too short for some
platforms. Therefore, to have a better tolerance, the DW_IC_SDA_HOLD
value should be kept by sda_hold_time.

Signed-off-by: Zhuo-hao Lee 
---
 drivers/i2c/busses/i2c-designware-core.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-core.c 
b/drivers/i2c/busses/i2c-designware-core.c
index c6922b8..fcd973d 100644
--- a/drivers/i2c/busses/i2c-designware-core.c
+++ b/drivers/i2c/busses/i2c-designware-core.c
@@ -367,13 +367,17 @@ int i2c_dw_init(struct dw_i2c_dev *dev)
dev_dbg(dev->dev, "Fast-mode HCNT:LCNT = %d:%d\n", hcnt, lcnt);
 
/* Configure SDA Hold Time if required */
-   if (dev->sda_hold_time) {
-   reg = dw_readl(dev, DW_IC_COMP_VERSION);
-   if (reg >= DW_IC_SDA_HOLD_MIN_VERS)
+   reg = dw_readl(dev, DW_IC_COMP_VERSION);
+   if (reg >= DW_IC_SDA_HOLD_MIN_VERS) {
+   if (dev->sda_hold_time) {
dw_writel(dev, dev->sda_hold_time, DW_IC_SDA_HOLD);
-   else
-   dev_warn(dev->dev,
-   "Hardware too old to adjust SDA hold time.");
+   } else {
+   /* Keep previous hold time setting if no one set it */
+   dev->sda_hold_time = dw_readl(dev, DW_IC_SDA_HOLD);
+   }
+   } else {
+   dev_warn(dev->dev,
+   "Hardware too old to adjust SDA hold time.\n");
}
 
/* Configure Tx/Rx FIFO threshold levels */
-- 
1.9.1



[PATCH v3] alarmtimer: fix unexpected rtc interrupt when system resume from S3

2015-11-17 Thread zhuo-hao . lee
From: zhuo-hao 

Before the system go to suspend (S3), if user create a timer with clockid
CLOCK_REALTIME_ALARM/CLOCK_BOOTTIME_ALARM and set a "large" timeout value
to this timer. The function alarmtimer_suspend will be called to setup
a timeout value to RTC timer to avoid the system sleep over time. However,
if the system wakeup early than RTC timeout, the RTC timer will not be cleared.
And this will cause the hpet_rtc_interrupt come unexpectedly until the RTC
timeout. To fix this problem, just adding alarmtimer_resume to cancel the
RTC timer.

This was noticed because the HPET RTC emulation fires an interrupt every
16ms(=1/2^DEFAULT_RTC_SHIFT) up to the point where the alarm time is reached.
This program always hits this situation(https://lkml.org/lkml/2015/11/8/326),
if system wake up earlier than alarm time.

Cc: Thomas Gleixner 
Cc: John Stultz 
Signed-off-by: Zhuo-hao Lee 
---
 kernel/time/alarmtimer.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 7fbba63..e840ed8 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -271,11 +271,27 @@ static int alarmtimer_suspend(struct device *dev)
__pm_wakeup_event(ws, MSEC_PER_SEC);
return ret;
 }
+
+static int alarmtimer_resume(struct device *dev)
+{
+   struct rtc_device *rtc;
+
+   rtc = alarmtimer_get_rtcdev();
+   if (rtc)
+   rtc_timer_cancel(rtc, );
+   return 0;
+}
+
 #else
 static int alarmtimer_suspend(struct device *dev)
 {
return 0;
 }
+
+static int alarmtimer_resume(struct device *dev)
+{
+   return 0;
+}
 #endif
 
 static void alarmtimer_freezerset(ktime_t absexp, enum alarmtimer_type type)
@@ -800,6 +816,7 @@ out:
 /* Suspend hook structures */
 static const struct dev_pm_ops alarmtimer_pm_ops = {
.suspend = alarmtimer_suspend,
+   .resume = alarmtimer_resume,
 };
 
 static struct platform_driver alarmtimer_driver = {
-- 
2.1.2

--
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 v3] alarmtimer: fix unexpected rtc interrupt when system resume from S3

2015-11-17 Thread zhuo-hao . lee
From: zhuo-hao <zhuo-hao@intel.com>

Before the system go to suspend (S3), if user create a timer with clockid
CLOCK_REALTIME_ALARM/CLOCK_BOOTTIME_ALARM and set a "large" timeout value
to this timer. The function alarmtimer_suspend will be called to setup
a timeout value to RTC timer to avoid the system sleep over time. However,
if the system wakeup early than RTC timeout, the RTC timer will not be cleared.
And this will cause the hpet_rtc_interrupt come unexpectedly until the RTC
timeout. To fix this problem, just adding alarmtimer_resume to cancel the
RTC timer.

This was noticed because the HPET RTC emulation fires an interrupt every
16ms(=1/2^DEFAULT_RTC_SHIFT) up to the point where the alarm time is reached.
This program always hits this situation(https://lkml.org/lkml/2015/11/8/326),
if system wake up earlier than alarm time.

Cc: Thomas Gleixner <t...@linutronix.de>
Cc: John Stultz <john.stu...@linaro.org>
Signed-off-by: Zhuo-hao Lee <zhuo-hao@intel.com>
---
 kernel/time/alarmtimer.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 7fbba63..e840ed8 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -271,11 +271,27 @@ static int alarmtimer_suspend(struct device *dev)
__pm_wakeup_event(ws, MSEC_PER_SEC);
return ret;
 }
+
+static int alarmtimer_resume(struct device *dev)
+{
+   struct rtc_device *rtc;
+
+   rtc = alarmtimer_get_rtcdev();
+   if (rtc)
+   rtc_timer_cancel(rtc, );
+   return 0;
+}
+
 #else
 static int alarmtimer_suspend(struct device *dev)
 {
return 0;
 }
+
+static int alarmtimer_resume(struct device *dev)
+{
+   return 0;
+}
 #endif
 
 static void alarmtimer_freezerset(ktime_t absexp, enum alarmtimer_type type)
@@ -800,6 +816,7 @@ out:
 /* Suspend hook structures */
 static const struct dev_pm_ops alarmtimer_pm_ops = {
.suspend = alarmtimer_suspend,
+   .resume = alarmtimer_resume,
 };
 
 static struct platform_driver alarmtimer_driver = {
-- 
2.1.2

--
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] alarmtimer: fix unexpected rtc interrupt when system resume from S3

2015-11-04 Thread zhuo-hao . lee
From: zhuo-hao 

Before the system go to suspend (S3), if user create a timer with clockid
CLOCK_REALTIME_ALARM/CLOCK_BOOTTIME_ALARM and set a "large" timeout value
to this timer. The function alarmtimer_suspend will be called to setup
a timeout value to RTC timer to avoid the system sleep over time. However,
if the system wakeup early than RTC timeout, the RTC timer will not be cleared.
And this will cause the hpet_rtc_interrupt come unexpectedly until the RTC
timeout. To fix this problem, just adding alarmtimer_resume to cancel the
RTC timer.

Signed-off-by: Zhuo-hao Lee 
---
 kernel/time/alarmtimer.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 7fbba63..e840ed8 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -271,11 +271,27 @@ static int alarmtimer_suspend(struct device *dev)
__pm_wakeup_event(ws, MSEC_PER_SEC);
return ret;
 }
+
+static int alarmtimer_resume(struct device *dev)
+{
+   struct rtc_device *rtc;
+
+   rtc = alarmtimer_get_rtcdev();
+   if (rtc)
+   rtc_timer_cancel(rtc, );
+   return 0;
+}
+
 #else
 static int alarmtimer_suspend(struct device *dev)
 {
return 0;
 }
+
+static int alarmtimer_resume(struct device *dev)
+{
+   return 0;
+}
 #endif
 
 static void alarmtimer_freezerset(ktime_t absexp, enum alarmtimer_type type)
@@ -800,6 +816,7 @@ out:
 /* Suspend hook structures */
 static const struct dev_pm_ops alarmtimer_pm_ops = {
.suspend = alarmtimer_suspend,
+   .resume = alarmtimer_resume,
 };
 
 static struct platform_driver alarmtimer_driver = {
-- 
1.9.1

--
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] alarmtimer: fix unexpected rtc interrupt when system resume

2015-11-04 Thread zhuo-hao . lee
From: zhuo-hao 

Before the system go to suspend (S3), if user create a timer with clockid
CLOCK_REALTIME_ALARM/CLOCK_BOOTTIME_ALARM and set a "large" timeout value
to this timer. The function alarmtimer_suspend will be called to setup
a timeout value to RTC timer to avoid the system sleep over time. However,
if the system wakeup early than RTC timeout, the RTC timer will not be cleared.
And this will cause the hpet_rtc_interrupt come unexpectedly until the RTC
timeout. To fix this problem, just adding alarmtimer_resume to cancel the
RTC timer.

Signed-off-by: Zhuo-hao Lee 
---
 kernel/time/alarmtimer.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 7fbba63..37ffccd 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -271,11 +271,25 @@ static int alarmtimer_suspend(struct device *dev)
__pm_wakeup_event(ws, MSEC_PER_SEC);
return ret;
 }
+
+static int alarmtimer_resume(struct device *dev)
+{
+   struct rtc_device *rtc;
+
+   rtc = alarmtimer_get_rtcdev();
+   return rtc ? rtc_timer_cancel(rtc, ) : 0;
+}
+
 #else
 static int alarmtimer_suspend(struct device *dev)
 {
return 0;
 }
+
+static int alarmtimer_resume(struct device *dev)
+{
+   return 0;
+}
 #endif
 
 static void alarmtimer_freezerset(ktime_t absexp, enum alarmtimer_type type)
@@ -800,6 +814,7 @@ out:
 /* Suspend hook structures */
 static const struct dev_pm_ops alarmtimer_pm_ops = {
.suspend = alarmtimer_suspend,
+   .resume = alarmtimer_resume,
 };
 
 static struct platform_driver alarmtimer_driver = {
-- 
1.9.1

--
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] alarmtimer: fix unexpected rtc interrupt when system resume

2015-11-04 Thread zhuo-hao . lee
From: zhuo-hao <zhuo-hao@intel.com>

Before the system go to suspend (S3), if user create a timer with clockid
CLOCK_REALTIME_ALARM/CLOCK_BOOTTIME_ALARM and set a "large" timeout value
to this timer. The function alarmtimer_suspend will be called to setup
a timeout value to RTC timer to avoid the system sleep over time. However,
if the system wakeup early than RTC timeout, the RTC timer will not be cleared.
And this will cause the hpet_rtc_interrupt come unexpectedly until the RTC
timeout. To fix this problem, just adding alarmtimer_resume to cancel the
RTC timer.

Signed-off-by: Zhuo-hao Lee <zhuo-hao@intel.com>
---
 kernel/time/alarmtimer.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 7fbba63..37ffccd 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -271,11 +271,25 @@ static int alarmtimer_suspend(struct device *dev)
__pm_wakeup_event(ws, MSEC_PER_SEC);
return ret;
 }
+
+static int alarmtimer_resume(struct device *dev)
+{
+   struct rtc_device *rtc;
+
+   rtc = alarmtimer_get_rtcdev();
+   return rtc ? rtc_timer_cancel(rtc, ) : 0;
+}
+
 #else
 static int alarmtimer_suspend(struct device *dev)
 {
return 0;
 }
+
+static int alarmtimer_resume(struct device *dev)
+{
+   return 0;
+}
 #endif
 
 static void alarmtimer_freezerset(ktime_t absexp, enum alarmtimer_type type)
@@ -800,6 +814,7 @@ out:
 /* Suspend hook structures */
 static const struct dev_pm_ops alarmtimer_pm_ops = {
.suspend = alarmtimer_suspend,
+   .resume = alarmtimer_resume,
 };
 
 static struct platform_driver alarmtimer_driver = {
-- 
1.9.1

--
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] alarmtimer: fix unexpected rtc interrupt when system resume from S3

2015-11-04 Thread zhuo-hao . lee
From: zhuo-hao <zhuo-hao@intel.com>

Before the system go to suspend (S3), if user create a timer with clockid
CLOCK_REALTIME_ALARM/CLOCK_BOOTTIME_ALARM and set a "large" timeout value
to this timer. The function alarmtimer_suspend will be called to setup
a timeout value to RTC timer to avoid the system sleep over time. However,
if the system wakeup early than RTC timeout, the RTC timer will not be cleared.
And this will cause the hpet_rtc_interrupt come unexpectedly until the RTC
timeout. To fix this problem, just adding alarmtimer_resume to cancel the
RTC timer.

Signed-off-by: Zhuo-hao Lee <zhuo-hao@intel.com>
---
 kernel/time/alarmtimer.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 7fbba63..e840ed8 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -271,11 +271,27 @@ static int alarmtimer_suspend(struct device *dev)
__pm_wakeup_event(ws, MSEC_PER_SEC);
return ret;
 }
+
+static int alarmtimer_resume(struct device *dev)
+{
+   struct rtc_device *rtc;
+
+   rtc = alarmtimer_get_rtcdev();
+   if (rtc)
+   rtc_timer_cancel(rtc, );
+   return 0;
+}
+
 #else
 static int alarmtimer_suspend(struct device *dev)
 {
return 0;
 }
+
+static int alarmtimer_resume(struct device *dev)
+{
+   return 0;
+}
 #endif
 
 static void alarmtimer_freezerset(ktime_t absexp, enum alarmtimer_type type)
@@ -800,6 +816,7 @@ out:
 /* Suspend hook structures */
 static const struct dev_pm_ops alarmtimer_pm_ops = {
.suspend = alarmtimer_suspend,
+   .resume = alarmtimer_resume,
 };
 
 static struct platform_driver alarmtimer_driver = {
-- 
1.9.1

--
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/