From: Alex Elder <elder@linaro.org>
To: "Petr Mládek" <pmladek@suse.cz>
Cc: akpm@linux-foundation.org, kay@vrfy.org, bp@suse.de,
john.stultz@linaro.org, jack@suse.cz,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/5] printk: update previous message for LOG_PREFIX
Date: Fri, 18 Jul 2014 07:04:21 -0500 [thread overview]
Message-ID: <53C90D45.4000407@linaro.org> (raw)
In-Reply-To: <20140718090251.GV6774@pathway.suse.cz>
On 07/18/2014 04:02 AM, Petr Mládek wrote:
> On Thu 2014-07-17 12:59:10, Alex Elder wrote:
>> If log_store() gets flags containing LOG_PREFIX, it indicates the
>> record getting stored should implicitly complete the previous log
>> record and start a new one.
>>
>> We can also ensure the previous record is completed by keeping
>> track of the previously-logged record, and adding the LOG_NEWLINE
>> flag to it when log_store() sees a LOG_PREFIX flag.
>>
>> Signed-off-by: Alex Elder <elder@linaro.org>
>> ---
>> kernel/printk/printk.c | 14 +++++++++++++-
>> 1 file changed, 13 insertions(+), 1 deletion(-)
>>
>> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
>> index e35d91a..6b72a77 100644
>> --- a/kernel/printk/printk.c
>> +++ b/kernel/printk/printk.c
>> @@ -242,6 +242,9 @@ static size_t syslog_partial;
>> static u64 log_first_seq;
>> static u32 log_first_idx;
>>
>> +/* Pointer to the last record written into the log */
>> +static struct printk_log *log_last_msg;
>> +
>> /* index and sequence number of the next record to store in the buffer */
>> static u64 log_next_seq;
>> static u32 log_next_idx;
>> @@ -425,7 +428,13 @@ static int log_store(int facility, int level,
>> log_next_idx = 0;
>> }
>>
>> - /* fill message */
>> + /*
>> + * If we're forcing a new log record, update the flags for
>> + * the previous one to mark it complete.
>> + */
>> + if (flags & LOG_PREFIX && log_last_msg)
>> + log_last_msg->flags |= LOG_NEWLINE;
>
> You are not allowed to do this. The previous message might already be
> proceed by readers (console, syslog, kmsg).
>
> IMHO, you will not be able to make this safe without adding extra
> complexity into the readers. So, I am afraid that there is no win
> in vanishing the LOG_PREFIX flag.
You're right. I had not been thinking about this.
We can't change the flag state of a log entry that's
already been read, and we have no (good) way of knowing
when that has occurred.
I'll retract this and related patches, and will rework
it accordingly. I'm still going to try to do what I
can with this (and the previous) series to be simplified.
I'm going to look at the rest of your reviews first.
Thank you.
-Alex
> Best Regards,
> Petr
>
>> msg = (struct printk_log *)(log_buf + log_next_idx);
>> memcpy(log_text(msg), text, text_len);
>> msg->text_len = text_len;
>> @@ -449,6 +458,9 @@ static int log_store(int facility, int level,
>> log_next_idx += msg->len;
>> log_next_seq++;
>>
>> + /* Save our previous record address for next time. */
>> + log_last_msg = msg;
>> +
>> return msg->text_len;
>> }
>>
>> --
>> 1.9.1
>>
next prev parent reply other threads:[~2014-07-18 12:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-17 17:59 [PATCH 0/5] printk: more log flag simplification Alex Elder
2014-07-17 17:59 ` [PATCH 1/5] printk: kill LOG_CONT Alex Elder
2014-07-17 17:59 ` [PATCH 2/5] printk: update previous message for LOG_PREFIX Alex Elder
2014-07-18 9:02 ` Petr Mládek
2014-07-18 12:04 ` Alex Elder [this message]
2014-07-17 17:59 ` [PATCH 3/5] printk: stop actually recording LOG_PREFIX Alex Elder
2014-07-17 17:59 ` [PATCH 4/5] printk: kill LOG_PREFIX Alex Elder
2014-07-17 17:59 ` [PATCH 5/5] printk: rename LOG_NEWLINE and tidy up Alex Elder
2014-07-18 1:37 ` [PATCH 0/5] printk: more log flag simplification Kay Sievers
2014-07-18 1:54 ` Alex Elder
2014-07-18 9:22 ` Petr Mládek
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=53C90D45.4000407@linaro.org \
--to=elder@linaro.org \
--cc=akpm@linux-foundation.org \
--cc=bp@suse.de \
--cc=jack@suse.cz \
--cc=john.stultz@linaro.org \
--cc=kay@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.cz \
/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