Linux-rt-users archive on lore.kernel.org
 help / color / Atom feed
* [PATCH RT] printk: devkmsg: read: Return EPIPE when the first message user-space wants has gone
@ 2019-09-24  7:26 zhe.he
  2019-09-24 23:49 ` John Ogness
  0 siblings, 1 reply; 2+ messages in thread
From: zhe.he @ 2019-09-24  7:26 UTC (permalink / raw)
  To: john.ogness, linux-rt-users, linux-kernel, zhe.he

From: He Zhe <zhe.he@windriver.com>

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.

Signed-off-by: He Zhe <zhe.he@windriver.com>
---
 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 e3fa33f2e23c..58c545a528b3 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 *)&user->msgbuf[0];
-- 
2.17.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH RT] printk: devkmsg: read: Return EPIPE when the first message user-space wants has gone
  2019-09-24  7:26 [PATCH RT] printk: devkmsg: read: Return EPIPE when the first message user-space wants has gone zhe.he
@ 2019-09-24 23:49 ` John Ogness
  0 siblings, 0 replies; 2+ messages in thread
From: John Ogness @ 2019-09-24 23:49 UTC (permalink / raw)
  To: zhe.he; +Cc: linux-rt-users, linux-kernel

On 2019-09-24, <zhe.he@windriver.com> wrote:
> From: He Zhe <zhe.he@windriver.com>
>
> 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.
>
> Signed-off-by: He Zhe <zhe.he@windriver.com>

Signed-off-by: John Ogness <john.ogness@linutronix.de>

> ---
>  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 e3fa33f2e23c..58c545a528b3 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 *)&user->msgbuf[0];

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-24  7:26 [PATCH RT] printk: devkmsg: read: Return EPIPE when the first message user-space wants has gone zhe.he
2019-09-24 23:49 ` John Ogness

Linux-rt-users archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rt-users/0 linux-rt-users/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rt-users linux-rt-users/ https://lore.kernel.org/linux-rt-users \
		linux-rt-users@vger.kernel.org
	public-inbox-index linux-rt-users

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rt-users


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git