Re: [linux-yocto] [PATCH][v5.2/standard/preempt-rt/base] printk: devkmsg: read: Return EPIPE when the first message user-space wants has gone

2019-10-02 Thread Bruce Ashfield
I didn't merge this directly, but instead updated the -rt branches to
-rt9 .. so I got your change that way.

Cheers,

Bruce

On Sun, Sep 29, 2019 at 5:36 AM  wrote:
>
> From: He Zhe 
>
> This fixes ltp failure,
> kmsg01.c:444: FAIL: read returned: 56: SUCCESS
>
> When user-space wants to read the first message, that is when user->seq
> is 0, and that message has gone, it currently automatically resets
> user->seq to current first seq. This mis-aligns with mainline kernel.
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/ABI/testing/dev-kmsg#n39
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/printk/printk.c#n899
>
> We should inform user-space that what it wants has gone by returning EPIPE
> in such scenario.
>
> Link: https://lore.kernel.org/linux-rt-users/8736gls1aj@linutronix.de/T/#t
>
> Signed-off-by: He Zhe 
> ---
>  kernel/printk/printk.c | 12 
>  1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index e3fa33f..58c545a 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -703,14 +703,10 @@ static ssize_t devkmsg_read(struct file *file, char 
> __user *buf,
> goto out;
> }
>
> -   if (user->seq == 0) {
> -   user->seq = seq;
> -   } else {
> -   user->seq++;
> -   if (user->seq < seq) {
> -   ret = -EPIPE;
> -   goto restore_out;
> -   }
> +   user->seq++;
> +   if (user->seq < seq) {
> +   ret = -EPIPE;
> +   goto restore_out;
> }
>
> msg = (struct printk_log *)>msgbuf[0];
> --
> 2.7.4
>


-- 
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II
-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH][v5.2/standard/preempt-rt/base] printk: devkmsg: read: Return EPIPE when the first message user-space wants has gone

2019-09-29 Thread zhe.he
From: He Zhe 

This fixes ltp failure,
kmsg01.c:444: FAIL: read returned: 56: SUCCESS

When user-space wants to read the first message, that is when user->seq
is 0, and that message has gone, it currently automatically resets
user->seq to current first seq. This mis-aligns with mainline kernel.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/ABI/testing/dev-kmsg#n39
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/printk/printk.c#n899

We should inform user-space that what it wants has gone by returning EPIPE
in such scenario.

Link: https://lore.kernel.org/linux-rt-users/8736gls1aj@linutronix.de/T/#t

Signed-off-by: He Zhe 
---
 kernel/printk/printk.c | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index e3fa33f..58c545a 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -703,14 +703,10 @@ static ssize_t devkmsg_read(struct file *file, char 
__user *buf,
goto out;
}
 
-   if (user->seq == 0) {
-   user->seq = seq;
-   } else {
-   user->seq++;
-   if (user->seq < seq) {
-   ret = -EPIPE;
-   goto restore_out;
-   }
+   user->seq++;
+   if (user->seq < seq) {
+   ret = -EPIPE;
+   goto restore_out;
}
 
msg = (struct printk_log *)>msgbuf[0];
-- 
2.7.4

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto