Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1687912 > unrolled thread
| Started by | Pierre Kuo <vichy.kuo@gmail.com> |
|---|---|
| First post | 2017-07-15 12:40 +0200 |
| Last post | 2017-07-17 13:10 +0200 |
| Articles | 4 — 4 participants |
Back to article view | Back to linux.kernel
[PATCH] printk: modify console_unlock with printk-safe macros Pierre Kuo <vichy.kuo@gmail.com> - 2017-07-15 12:40 +0200
Re: [PATCH] printk: modify console_unlock with printk-safe macros Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-07-15 14:40 +0200
Re: [PATCH] printk: modify console_unlock with printk-safe macros Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-07-17 11:30 +0200
Re: [PATCH] printk: modify console_unlock with printk-safe macros pierre kuo <vichy.kuo@gmail.com> - 2017-07-17 13:10 +0200
| From | Pierre Kuo <vichy.kuo@gmail.com> |
|---|---|
| Date | 2017-07-15 12:40 +0200 |
| Subject | [PATCH] printk: modify console_unlock with printk-safe macros |
| Message-ID | <u3sEq-ke-21@gated-at.bofh.it> |
From: pierre Kuo <vichy.kuo@gmail.com>
In commit de6fcbdb68b2 ("printk: convert the rest to printk-safe"), we
create 4 helper macros to make printk-safe usage easier.
Here we modify some part of console_unlock with above marcros.
Signed-off-by: Pierre Kuo <vichy.kuo@gmail.com>
---
kernel/printk/printk.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index fc47863..21557cc 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2194,8 +2194,7 @@ void console_unlock(void)
size_t ext_len = 0;
size_t len;
- printk_safe_enter_irqsave(flags);
- raw_spin_lock(&logbuf_lock);
+ logbuf_lock_irqsave(flags);
if (seen_seq != log_next_seq) {
wake_klogd = true;
seen_seq = log_next_seq;
@@ -2267,8 +2266,7 @@ void console_unlock(void)
*/
raw_spin_lock(&logbuf_lock);
retry = console_seq != log_next_seq;
- raw_spin_unlock(&logbuf_lock);
- printk_safe_exit_irqrestore(flags);
+ logbuf_unlock_irqrestore(flags);
if (retry && console_trylock())
goto again;
--
1.7.9.5
[toc] | [next] | [standalone]
| From | Andy Shevchenko <andy.shevchenko@gmail.com> |
|---|---|
| Date | 2017-07-15 14:40 +0200 |
| Message-ID | <u3uwy-1t8-9@gated-at.bofh.it> |
| In reply to | #1687912 |
On Sat, Jul 15, 2017 at 1:36 PM, Pierre Kuo <vichy.kuo@gmail.com> wrote:
> In commit de6fcbdb68b2 ("printk: convert the rest to printk-safe"), we
> create 4 helper macros to make printk-safe usage easier.
> Here we modify some part of console_unlock with above marcros.
> raw_spin_lock(&logbuf_lock);
...and now we have "orphaned" call to lock.
> - raw_spin_unlock(&logbuf_lock);
> + logbuf_unlock_irqrestore(flags);
Personally I can't say this makes things clearer.
--
With Best Regards,
Andy Shevchenko
[toc] | [prev] | [next] | [standalone]
| From | Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> |
|---|---|
| Date | 2017-07-17 11:30 +0200 |
| Message-ID | <u4avN-3bA-25@gated-at.bofh.it> |
| In reply to | #1687912 |
On (07/15/17 18:36), Pierre Kuo wrote:
[..]
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index fc47863..21557cc 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -2194,8 +2194,7 @@ void console_unlock(void)
> size_t ext_len = 0;
> size_t len;
>
> - printk_safe_enter_irqsave(flags);
> - raw_spin_lock(&logbuf_lock);
> + logbuf_lock_irqsave(flags);
> if (seen_seq != log_next_seq) {
> wake_klogd = true;
> seen_seq = log_next_seq;
> @@ -2267,8 +2266,7 @@ void console_unlock(void)
> */
> raw_spin_lock(&logbuf_lock);
> retry = console_seq != log_next_seq;
> - raw_spin_unlock(&logbuf_lock);
> - printk_safe_exit_irqrestore(flags);
> + logbuf_unlock_irqrestore(flags);
>
> if (retry && console_trylock())
> goto again;
I did it that particular way for a reason - console_unlock() does a
bunch of tricks: unlocking logbuf in the middle of printing loop,
breaking out of loop with local IRQs disabled, re-taking the logbuf
after the loop still will local IRQs disabled, etc. etc. I didn't
want to (and still don't) mix-in logbuf macros; we do things that
macros don't cover anyway. sorry, I don't agree that the patch
improves readability.
-ss
[toc] | [prev] | [next] | [standalone]
| From | pierre kuo <vichy.kuo@gmail.com> |
|---|---|
| Date | 2017-07-17 13:10 +0200 |
| Message-ID | <u4c4z-4fj-13@gated-at.bofh.it> |
| In reply to | #1688820 |
hi Sergey and Andy:
> On (07/15/17 18:36), Pierre Kuo wrote:
> [..]
>> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
>> index fc47863..21557cc 100644
>> --- a/kernel/printk/printk.c
>> +++ b/kernel/printk/printk.c
>> @@ -2194,8 +2194,7 @@ void console_unlock(void)
>> size_t ext_len = 0;
>> size_t len;
>>
>> - printk_safe_enter_irqsave(flags);
>> - raw_spin_lock(&logbuf_lock);
>> + logbuf_lock_irqsave(flags);
>> if (seen_seq != log_next_seq) {
>> wake_klogd = true;
>> seen_seq = log_next_seq;
>> @@ -2267,8 +2266,7 @@ void console_unlock(void)
>> */
>> raw_spin_lock(&logbuf_lock);
>> retry = console_seq != log_next_seq;
>> - raw_spin_unlock(&logbuf_lock);
>> - printk_safe_exit_irqrestore(flags);
>> + logbuf_unlock_irqrestore(flags);
>>
>> if (retry && console_trylock())
>> goto again;
>
> I did it that particular way for a reason - console_unlock() does a
> bunch of tricks: unlocking logbuf in the middle of printing loop,
> breaking out of loop with local IRQs disabled, re-taking the logbuf
> after the loop still will local IRQs disabled, etc. etc. I didn't
> want to (and still don't) mix-in logbuf macros; we do things that
> macros don't cover anyway. sorry, I don't agree that the patch
> improves readability.
Got ur points and appreciate for your illustration. ^^
Thanks a lot,
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web