From: <zhe.he@windriver.com>
To: <john.ogness@linutronix.de>, <linux-rt-users@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <zhe.he@windriver.com>
Subject: [PATCH RT] printk: devkmsg: read: Return EPIPE when the first message user-space wants has gone
Date: Tue, 24 Sep 2019 15:26:39 +0800 [thread overview]
Message-ID: <20190924072639.25986-1-zhe.he@windriver.com> (raw)
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
next reply other threads:[~2019-09-24 7:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-24 7:26 zhe.he [this message]
2019-09-24 23:49 ` [PATCH RT] printk: devkmsg: read: Return EPIPE when the first message user-space wants has gone John Ogness
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190924072639.25986-1-zhe.he@windriver.com \
--to=zhe.he@windriver.com \
--cc=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).