* [PATCH 1/1] Char: moxa, fix and optimise empty timer
@ 2007-07-25 21:43 Jiri Slaby
2007-07-26 5:08 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Jiri Slaby @ 2007-07-25 21:43 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
moxa, fix and optimise empty timer
don't wait and delete empty timer in empty timer function. Also fire next
empty timer at rounded jiffies to save power.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
commit da52793b6347e8b6b048526ce2422e29b20bb335
tree ad0bee78e45beef89dc740f81e0606d782296542
parent 3a69b463dcad1ff142f46e8fb74e7dc5a092eb60
author Jiri Slaby <jirislaby@gmail.com> Wed, 25 Jul 2007 23:42:49 +0200
committer Jiri Slaby <jirislaby@gmail.com> Wed, 25 Jul 2007 23:42:49 +0200
drivers/char/moxa.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index ed76f0a..5000b3b 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -1040,14 +1040,14 @@ static void check_xmit_empty(unsigned long data)
struct moxa_port *ch;
ch = (struct moxa_port *) data;
- del_timer_sync(&moxa_ports[ch->port].emptyTimer);
if (ch->tty && (ch->statusflags & EMPTYWAIT)) {
if (MoxaPortTxQueue(ch->port) == 0) {
ch->statusflags &= ~EMPTYWAIT;
tty_wakeup(ch->tty);
return;
}
- mod_timer(&moxa_ports[ch->port].emptyTimer, jiffies + HZ);
+ mod_timer(&moxa_ports[ch->port].emptyTimer,
+ round_jiffies(jiffies + HZ));
} else
ch->statusflags &= ~EMPTYWAIT;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] Char: moxa, fix and optimise empty timer
2007-07-25 21:43 [PATCH 1/1] Char: moxa, fix and optimise empty timer Jiri Slaby
@ 2007-07-26 5:08 ` Andrew Morton
2007-07-27 19:52 ` Jiri Slaby
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2007-07-26 5:08 UTC (permalink / raw)
To: Jiri Slaby; +Cc: linux-kernel
On Wed, 25 Jul 2007 23:43:29 +0200 (CEST) Jiri Slaby <jirislaby@gmail.com> wrote:
> moxa, fix and optimise empty timer
>
> don't wait and delete empty timer in empty timer function. Also fire next
> empty timer at rounded jiffies to save power.
>
What is actually being "fixed" here?
>
> ---
> commit da52793b6347e8b6b048526ce2422e29b20bb335
> tree ad0bee78e45beef89dc740f81e0606d782296542
> parent 3a69b463dcad1ff142f46e8fb74e7dc5a092eb60
> author Jiri Slaby <jirislaby@gmail.com> Wed, 25 Jul 2007 23:42:49 +0200
> committer Jiri Slaby <jirislaby@gmail.com> Wed, 25 Jul 2007 23:42:49 +0200
>
> drivers/char/moxa.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
> index ed76f0a..5000b3b 100644
> --- a/drivers/char/moxa.c
> +++ b/drivers/char/moxa.c
> @@ -1040,14 +1040,14 @@ static void check_xmit_empty(unsigned long data)
> struct moxa_port *ch;
>
> ch = (struct moxa_port *) data;
> - del_timer_sync(&moxa_ports[ch->port].emptyTimer);
> if (ch->tty && (ch->statusflags & EMPTYWAIT)) {
> if (MoxaPortTxQueue(ch->port) == 0) {
> ch->statusflags &= ~EMPTYWAIT;
> tty_wakeup(ch->tty);
> return;
> }
> - mod_timer(&moxa_ports[ch->port].emptyTimer, jiffies + HZ);
> + mod_timer(&moxa_ports[ch->port].emptyTimer,
> + round_jiffies(jiffies + HZ));
> } else
> ch->statusflags &= ~EMPTYWAIT;
> }
A call to check_xmit_empty() used to guarantee that the timer was no longer
running (if the first `if' succeeds and the second does not), but that is
no longer the case. You're sure this is correct?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] Char: moxa, fix and optimise empty timer
2007-07-26 5:08 ` Andrew Morton
@ 2007-07-27 19:52 ` Jiri Slaby
0 siblings, 0 replies; 3+ messages in thread
From: Jiri Slaby @ 2007-07-27 19:52 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
Andrew Morton napsal(a):
> On Wed, 25 Jul 2007 23:43:29 +0200 (CEST) Jiri Slaby <jirislaby@gmail.com> wrote:
>
>> moxa, fix and optimise empty timer
>>
>> don't wait and delete empty timer in empty timer function. Also fire next
>> empty timer at rounded jiffies to save power.
>>
>
> What is actually being "fixed" here?
Lockup (see below).
>> ---
>> commit da52793b6347e8b6b048526ce2422e29b20bb335
>> tree ad0bee78e45beef89dc740f81e0606d782296542
>> parent 3a69b463dcad1ff142f46e8fb74e7dc5a092eb60
>> author Jiri Slaby <jirislaby@gmail.com> Wed, 25 Jul 2007 23:42:49 +0200
>> committer Jiri Slaby <jirislaby@gmail.com> Wed, 25 Jul 2007 23:42:49 +0200
>>
>> drivers/char/moxa.c | 4 ++--
>> 1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
>> index ed76f0a..5000b3b 100644
>> --- a/drivers/char/moxa.c
>> +++ b/drivers/char/moxa.c
>> @@ -1040,14 +1040,14 @@ static void check_xmit_empty(unsigned long data)
>> struct moxa_port *ch;
>>
>> ch = (struct moxa_port *) data;
>> - del_timer_sync(&moxa_ports[ch->port].emptyTimer);
It's "wait until the code below me is finished". At least the _sync is buggy.
>> if (ch->tty && (ch->statusflags & EMPTYWAIT)) {
>> if (MoxaPortTxQueue(ch->port) == 0) {
>> ch->statusflags &= ~EMPTYWAIT;
>> tty_wakeup(ch->tty);
>> return;
>> }
>> - mod_timer(&moxa_ports[ch->port].emptyTimer, jiffies + HZ);
>> + mod_timer(&moxa_ports[ch->port].emptyTimer,
>> + round_jiffies(jiffies + HZ));
>> } else
>> ch->statusflags &= ~EMPTYWAIT;
>> }
>
> A call to check_xmit_empty() used to guarantee that the timer was no longer
> running (if the first `if' succeeds and the second does not), but that is
Correct me if I'm wrong, but it guaranteed nothing. When the timer function is
called (note, that check_xmit_empty is timer.function), timer base lock is held
and there is no window to schedule the timer again when its function is running.
> no longer the case. You're sure this is correct?
I still think so.
thanks,
--
Jiri Slaby (jirislaby@gmail.com)
Faculty of Informatics, Masaryk University
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-27 19:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-25 21:43 [PATCH 1/1] Char: moxa, fix and optimise empty timer Jiri Slaby
2007-07-26 5:08 ` Andrew Morton
2007-07-27 19:52 ` Jiri Slaby
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox