public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Schwartz <davids@webmaster.com>
To: <olaf.dietsche--list.linux-kernel@exmail.de>
Cc: <linux-kernel@vger.kernel.org>
Subject: Re: What is a livelock? (was: [patch] sys_sync livelock fix)
Date: Mon, 18 Feb 2002 14:19:24 -0800	[thread overview]
Message-ID: <20020218221926.AAA3883@shell.webmaster.com@whenever> (raw)
In-Reply-To: <87pu3aw1ue.fsf@tigram.bogus.local>


>I still don't get it :-(. When there is more work, this more work
>needs to be done. So, how could livelock be considered a bug? It's
>just overload. Or is this about the work, which must be done _after_
>the queue is empty?

	Livelock situations can differ. One common issue is when you tune your 
ability to handle load only at a certain point and the load level is such 
that you never reach that point.

	Consider:

int work_count;
while(1)
{
 work_count=0;
 while(work_is_still_to_be_done())
 {
  do_work();
  work_count++;
 }
 if(work_count>250)
  create_more_threads();
}

	In this case, you may be so busy doing work that you never look at how much 
work you did and realize it was too much, so the additional threads never get 
created, and so you remain overloaded forever.

	There are other livelock scenarios that don't involve load over what the 
system can actually take, just over what the system is currently tuned to 
take. Any scheme that considers tuning a low priority can get into this kind 
of problem.

	Here's another case:

lock(first_lock);
/* some stuff */
 lock(second_lock);
 while(there_is_work())
 {
  unlock(second_lock);
  do_work();
  lock(second_lock);
 }
 unlock(second_lock);
/* more stuff */
unlock(first_lock);

	In this case, so long as work keeps flowing in and keeps this thread 
saturated, the first lock may never be released. This is true even if there 
are other threads capable of doing this work without holding the first lock. 
Since this thread remains perpetually ready, it may remain perpetually 
scheduled. This is probably the most common type of livelock encountered in 
kernel code.

	DS



  parent reply	other threads:[~2002-02-18 22:19 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-12 23:13 [patch] sys_sync livelock fix Andrew Morton
2002-02-12 23:31 ` Alan Cox
2002-02-12 23:22   ` Andrew Morton
2002-02-13  0:28     ` Alan Cox
2002-02-13  3:28       ` Bill Davidsen
2002-02-13  3:46         ` Jeff Garzik
2002-02-13 15:11           ` Daniel Phillips
2002-02-13 22:24             ` Bill Davidsen
2002-02-13 22:41               ` Mike Fedyk
2002-02-14  0:26               ` Daniel Phillips
2002-02-14  0:37                 ` Andrew Morton
2002-02-14  0:49                   ` Daniel Phillips
2002-02-14  0:53                     ` Andrew Morton
2002-02-14  1:27                       ` Daniel Phillips
2002-02-14  1:29                         ` Andrew Morton
2002-02-14  1:59                     ` Mike Fedyk
2002-02-14  2:07                       ` Daniel Phillips
2002-02-13 23:31             ` Rob Landley
2002-02-14  0:44               ` Daniel Phillips
2002-02-12 23:29   ` Rik van Riel
2002-02-13  0:25     ` Alan Cox
2002-02-13  0:15       ` Rik van Riel
2002-02-13  0:36         ` Alan Cox
2002-02-13  0:36           ` Rik van Riel
2002-02-13  0:39           ` Andrew Morton
2002-02-13  3:42             ` Bill Davidsen
2002-02-13  3:54             ` Bill Davidsen
2002-02-13  4:01               ` Jeff Garzik
2002-02-13  4:53                 ` Bill Davidsen
2002-02-13 15:17                 ` Daniel Phillips
2002-02-13  4:29               ` Andrew Morton
2002-02-13  5:21                 ` Bill Davidsen
2002-02-13  5:35                   ` Andrew Morton
2002-02-18  2:29                     ` Bill Davidsen
2002-02-13 14:09                   ` bill davidsen
2002-02-13 15:29                   ` Daniel Phillips
2002-02-13 22:53                     ` Bill Davidsen
2002-02-14  0:33                       ` Daniel Phillips
2002-02-13  1:36 ` What is a livelock? (was: [patch] sys_sync livelock fix) Olaf Dietsche
2002-02-13  1:56   ` Andrew Morton
2002-02-13  2:30     ` Olaf Dietsche
2002-02-13  2:39       ` Andrew Morton
2002-02-13 16:19         ` Olaf Dietsche
2002-02-13  2:52       ` William Lee Irwin III
2002-02-18 22:19       ` David Schwartz [this message]
2002-02-13  2:33   ` Rob Landley

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=20020218221926.AAA3883@shell.webmaster.com@whenever \
    --to=davids@webmaster.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olaf.dietsche--list.linux-kernel@exmail.de \
    /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