mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Lee Revell <rlrevell@joe-job.com>
Cc: Ingo Molnar <mingo@elte.hu>, linux-kernel@vger.kernel.org
Subject: Re: [patch] Real-Time Preemption, -RT-2.6.11-rc3-V0.7.38-01
Date: Thu, 10 Mar 2005 04:37:56 -0500 (EST)	[thread overview]
Message-ID: <Pine.LNX.4.58.0503100323370.14016@localhost.localdomain> (raw)
In-Reply-To: <1108789704.8411.9.camel@krustophenia.net>


Hi Ingo,

I notice a problem with the bit_spin_locks that would probably explain the
kjournald latency problems. I'm working on a custom kernel based on your's
and I needed to temporarily remove the scheduler_tick from
update_process_times to implement some special scheduling needs.  This
caused kjournal to go into an infinite loop.

Here's your bit_spin_lock:

static inline void bit_spin_lock(int bitnum, unsigned long *addr)
{
	/*
	 * Assuming the lock is uncontended, this never enters
	 * the body of the outer loop. If it is contended, then
	 * within the inner loop a non-atomic test is used to
	 * busywait with less bus contention for a good time to
	 * attempt to acquire the lock bit.
	 */
#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) ||
defined(CONFIG_PREEMPT)
	while (test_and_set_bit(bitnum, addr))
		while (test_bit(bitnum, addr))
			cpu_relax();
#endif
	__acquire(bitlock);
}


You removed the preempt disable and added the CONFIG_PREEMPT. What happens
if a lower priority process gets the bit lock and gets preempted by a
higher priority process that then tries to get this lock. It spins until
it's quota runs out.  This is what is happening to kjournald. A lower
priority process gets the bit lock and kjournald preempts it causing
kjournald to spin until it's quota is up to let the other process
release the lock.  Now, luckly your kernel kjournald is not realtime
FIFO. If it were, you would than have a deadlock, try it. I just set
kjournald (using your kernel) to FIFO prio 42 (prio 58 inside the kernel),
and with a non-rt task, I did a build of the kernel.  After a minute or
two, all processes under the priority of kjournald were starved out of the
CPU, and kjournald was spinning.  Make sure your kjournald has a lower
prioirty than your interrupt threads.

The culprit is jbd_lock_bh_state and jbd_lock_bh_journal_head which call
bit_spin_lock.

Example of long latency: (or deadlock)

journal_refile_buffer
   --> spin_lock(&journal->j_list_lock);
   --> journal_remove_journal_head(bh);
         --> jbd_lock_bh_journal_head(bh);
               --> bit_spin_lock(BH_JournalHead, &bh->b_state);

The short term fix is probably to put back the preempt_disables, the long
term is to get rid of these stupid bit_spin_lock busy loops.

-- Steve


On Sat, 19 Feb 2005, Lee Revell wrote:

> On Fri, 2005-02-04 at 11:03 +0100, Ingo Molnar wrote:
> >   http://redhat.com/~mingo/realtime-preempt/
> >
>
> Testing on an all SCSI 1.3Ghz Athlon XP system, I am seeing very long
> latencies in the journalling code with 2.6.11-rc4-RT-V0.7.39-02.
>
> preemption latency trace v1.1.4 on 2.6.11-rc4-RT-V0.7.39-02
> --------------------------------------------------------------------
>  latency: 713 µs, #3455/3455, CPU#0 | (M:preempt VP:0, KP:1, SP:1 HP:1 #P:1)
>     -----------------
>     | task: ksoftirqd/0-2 (uid:0 nice:-10 policy:0 rt_prio:0)
>     -----------------
>
>                  _------=> CPU#
>                 / _-----=> irqs-off
>                | / _----=> need-resched
>                || / _---=> hardirq/softirq
>                ||| / _--=> preempt-depth
>                |||| /
>                |||||     delay
>    cmd     pid ||||| time  |   caller
>       \   /    |||||   \   |   /
> kjournal-2478  0dn.4    0µs!: <756f6a6b> (<6c616e72>)
> kjournal-2478  0dn.4    0µs : __trace_start_sched_wakeup (try_to_wake_up)
> kjournal-2478  0dn.3    0µs : preempt_schedule (try_to_wake_up)
> kjournal-2478  0dn.3    0µs : try_to_wake_up <<...>-2> (69 73):
> kjournal-2478  0dn.2    0µs : preempt_schedule (try_to_wake_up)
> kjournal-2478  0dn.2    0µs : wake_up_process (do_softirq)
> kjournal-2478  0dn.1    1µs < (1)
>
> The repeating pattern is 8 of these:
>
> kjournal-2478  0.n.1    1µs : inverted_lock (journal_commit_transaction)
> kjournal-2478  0.n.1    1µs : __journal_unfile_buffer (journal_commit_transaction)
> kjournal-2478  0.n.1    1µs : journal_remove_journal_head (journal_commit_transaction)
> kjournal-2478  0.n.1    1µs : __journal_remove_journal_head (journal_remove_journal_head)
> kjournal-2478  0.n.1    1µs : __brelse (__journal_remove_journal_head)
> kjournal-2478  0.n.1    1µs : journal_free_journal_head (journal_remove_journal_head)
> kjournal-2478  0.n.1    2µs : kmem_cache_free (journal_free_journal_head)
>
> and one of these:
>
> kjournal-2478  0dn.1    9µs : cache_flusharray (kmem_cache_free)
> kjournal-2478  0dn.2    9µs : free_block (cache_flusharray)
> kjournal-2478  0dn.1   11µs : preempt_schedule (cache_flusharray)
> kjournal-2478  0dn.1   11µs : memmove (cache_flusharray)
> kjournal-2478  0dn.1   11µs : memcpy (memmove)
>
> etc.  Finally:
>
> kjournal-2478  0dn.1  704µs : cache_flusharray (kmem_cache_free)
> kjournal-2478  0dn.2  704µs+: free_block (cache_flusharray)
> kjournal-2478  0dn.1  707µs : preempt_schedule (cache_flusharray)
> kjournal-2478  0dn.1  707µs : memmove (cache_flusharray)
> kjournal-2478  0dn.1  707µs : memcpy (memmove)
> kjournal-2478  0.n.1  708µs : inverted_lock (journal_commit_transaction)
> kjournal-2478  0.n.1  708µs : __journal_unfile_buffer (journal_commit_transaction)
> kjournal-2478  0.n.1  709µs : journal_remove_journal_head (journal_commit_transaction)
> kjournal-2478  0.n.1  709µs : __journal_remove_journal_head (journal_remove_journal_head)
> kjournal-2478  0.n.1  709µs : __brelse (__journal_remove_journal_head)
> kjournal-2478  0.n.1  709µs : journal_free_journal_head (journal_remove_journal_head)
> kjournal-2478  0.n.1  709µs : kmem_cache_free (journal_free_journal_head)
> kjournal-2478  0.n..  710µs : preempt_schedule (journal_commit_transaction)
> kjournal-2478  0dn..  710µs : __schedule (preempt_schedule)
> kjournal-2478  0dn..  710µs : profile_hit (__schedule)
> kjournal-2478  0dn.1  710µs : sched_clock (__schedule)
> kjournal-2478  0dn.2  711µs : dequeue_task (__schedule)
> kjournal-2478  0dn.2  711µs : recalc_task_prio (__schedule)
> kjournal-2478  0dn.2  711µs : effective_prio (recalc_task_prio)
> kjournal-2478  0dn.2  711µs : enqueue_task (__schedule)
>    <...>-2     0d..2  712µs : __switch_to (__schedule)
>    <...>-2     0d..2  712µs : __schedule <kjournal-2478> (73 69):
>    <...>-2     0d..2  712µs : finish_task_switch (__schedule)
>    <...>-2     0d..1  712µs : trace_stop_sched_switched (finish_task_switch)
>    <...>-2     0d..1  712µs : trace_stop_sched_switched <<...>-2> (69 0):
>    <...>-2     0d..1  713µs : trace_stop_sched_switched (finish_task_switch)
>
> Lee
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

  parent reply	other threads:[~2005-03-10  9:38 UTC|newest]

Thread overview: 125+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-04 10:03 Ingo Molnar
2005-02-04 15:19 ` Kevin Hilman
2005-02-04 17:30   ` Ingo Molnar
2005-02-04 18:19 ` Tom Rini
2005-02-07  9:03   ` Ingo Molnar
2005-02-07 14:35     ` Tom Rini
2005-02-08  8:27       ` Ingo Molnar
2005-02-06  4:19 ` Valdis.Kletnieks
2005-02-07  9:21   ` Ingo Molnar
2005-02-07 15:08     ` Real-Time Preemption and UML? Esben Nielsen
2005-02-07 18:35       ` Jeff Dike
2005-02-07 23:14         ` Esben Nielsen
2005-02-08  8:39           ` Ingo Molnar
2005-02-08 18:55             ` Jeff Dike
2005-02-08 21:20               ` Esben Nielsen
2005-02-08 21:44                 ` Ingo Molnar
2005-02-08 23:02                   ` Esben Nielsen
2005-02-08  7:55 ` [patch] Real-Time Preemption, -RT-2.6.11-rc3-V0.7.38-01 Valdis.Kletnieks
2005-02-08  8:45   ` Ingo Molnar
2005-02-08 10:26     ` Valdis.Kletnieks
2005-02-08 21:58 ` William Weston
2005-02-09 11:51   ` Ingo Molnar
2005-02-10  2:13     ` William Weston
2005-02-10  7:52       ` Ingo Molnar
2005-02-10 20:21         ` George Anzinger
2005-02-10 20:40           ` Ingo Molnar
2005-02-10 21:05             ` George Anzinger
2005-02-11  8:34               ` Ingo Molnar
2005-02-11  9:38                 ` Sven Dietrich
2005-02-11  9:42                   ` Ingo Molnar
2005-02-11  0:09           ` Sven Dietrich
2005-02-11  6:01             ` George Anzinger
2005-02-11  8:28             ` Ingo Molnar
2005-02-11  9:53               ` Sven Dietrich
2005-02-11 10:04                 ` Ingo Molnar
2005-02-11 21:49                   ` Steven Rostedt
2005-02-13 12:59                     ` Ingo Molnar
2005-02-13 15:11                       ` Steven Rostedt
2005-03-03 19:36         ` [patch] Real-Time Preemption, deactivate() scheduling issue Eugeny S. Mints
2005-03-03 22:32           ` Esben Nielsen
2005-03-04 11:56             ` Eugeny S. Mints
2005-03-04 15:45               ` George Anzinger
2005-03-29  8:45           ` Ingo Molnar
2005-02-09 12:48   ` [patch] Real-Time Preemption, -RT-2.6.11-rc3-V0.7.38-01 Stephen Smalley
2005-02-10  2:20     ` William Weston
2005-02-19  5:08 ` Lee Revell
2005-02-19  6:47   ` Lee Revell
2005-02-19  9:00   ` Ingo Molnar
2005-02-19  9:03     ` Ingo Molnar
2005-02-19 20:45       ` Lee Revell
2005-02-20  0:19         ` Lee Revell
2005-03-17 16:33         ` Lee Revell
2005-02-23  2:22       ` Lee Revell
2005-03-10  9:37   ` Steven Rostedt [this message]
2005-03-10  9:54     ` Steven Rostedt
2005-03-11  9:57       ` Ingo Molnar
2005-03-11 10:15         ` Steven Rostedt
2005-03-11 10:17           ` Ingo Molnar
2005-03-11 10:24             ` Steven Rostedt
2005-03-11 10:43               ` Andrew Morton
2005-03-11 10:53                 ` Steven Rostedt
2005-03-11 14:40                 ` Steven Rostedt
2005-03-11 15:08                   ` Steven Rostedt
2005-03-11 15:30                     ` K.R. Foley
2005-03-11 15:38                   ` Ingo Molnar
2005-03-11 16:01                     ` Steven Rostedt
2005-03-11 20:39                     ` Steven Rostedt
2005-03-11 20:46                       ` Lee Revell
2005-03-11 22:06                         ` Lee Revell
2005-03-14  7:37                           ` Steven Rostedt
2005-03-14  9:33                             ` Steven Rostedt
2005-03-14 10:10                               ` Steven Rostedt
2005-03-14 15:50                                 ` Steven Rostedt
2005-03-14 19:02                                   ` Steven Rostedt
2005-03-15 11:44                                   ` Steven Rostedt
2005-03-15 12:00                                     ` Ingo Molnar
2005-03-15 13:07                                       ` Steven Rostedt
2005-03-15 13:35                                         ` Ingo Molnar
2005-03-15 13:55                                           ` Steven Rostedt
2005-03-15 19:12                                             ` Andrew Morton
2005-03-15 18:05                                           ` Steven Rostedt
2005-03-15 19:09                                             ` Lee Revell
2005-03-16  7:50                                               ` Steven Rostedt
2005-03-16 18:21                                                 ` Lee Revell
2005-03-16  7:31                                             ` Steven Rostedt
2005-03-16  8:50                                             ` Ingo Molnar
2005-03-16  9:15                                               ` Andrew Morton
2005-03-16  9:51                                                 ` [patch 0/3] j_state_lock, j_list_lock, remove-bitlocks Ingo Molnar
2005-03-16  9:53                                                   ` [patch 1/3] j_state_lock -> j_state_sem Ingo Molnar
2005-03-16  9:53                                                     ` [patch 2/3] j_list_lock -> j_list_sem Ingo Molnar
2005-03-16  9:57                                                       ` [patch 3/3] remove bitlocks Ingo Molnar
2005-03-16 10:04                                                   ` [patch 0/3] j_state_lock, j_list_lock, remove-bitlocks Andrew Morton
2005-03-16 10:12                                                     ` Ingo Molnar
2005-03-16 10:23                                                       ` Steven Rostedt
2005-03-16 10:26                                                         ` Ingo Molnar
2005-03-16 10:26                                                       ` Andrew Morton
2005-03-16 10:29                                                         ` Ingo Molnar
2005-03-16 10:41                                                           ` Andrew Morton
2005-03-16 10:34                                                         ` Arjan van de Ven
2005-03-16 10:19                                                     ` Ingo Molnar
2005-03-16 10:40                                                       ` Andrew Morton
2005-03-16 10:51                                                         ` Ingo Molnar
2005-03-16 11:05                                                         ` Steven Rostedt
2005-03-16 11:19                                                           ` Andrew Morton
2005-03-16 14:04                                                             ` Steven Rostedt
2005-03-16 16:47                                                               ` Steven Rostedt
2005-03-16 17:47                                                                 ` Steven Rostedt
2005-03-16 19:20                                                                   ` Lee Revell
2005-03-17  7:15                                                                     ` Steven Rostedt
2005-03-17 15:41                                                                       ` Lee Revell
2005-03-17 16:23                                                                         ` Steven Rostedt
2005-03-17 16:36                                                                           ` Lee Revell
2005-03-18  6:58                                                                             ` Steven Rostedt
2005-03-18 18:19                                                                               ` Lee Revell
2005-03-16 21:15                                                                   ` Andrew Morton
2005-03-17  9:21                                                                     ` Steven Rostedt
2005-03-18  9:23                                                                       ` [PATCH] remove lame schedule in journal inverted_lock (was: Re: [patch 0/3] j_state_lock, j_list_lock, remove-bitlocks) Steven Rostedt
2005-03-18  9:32                                                                         ` Andrew Morton
2005-03-18 10:38                                                                           ` Steven Rostedt
2005-03-18 11:07                                                                             ` Andrew Morton
2005-03-18 12:10                                                                               ` Steven Rostedt
2005-03-17  9:58                                                                   ` [patch 0/3] j_state_lock, j_list_lock, remove-bitlocks Steven Rostedt
2005-03-11  9:28 ` [patch] Real-Time Preemption, -RT-2.6.11-final-V0.7.40-00 Ingo Molnar
2005-03-11 12:10   ` Andrew Walrond
2005-03-14 20:19     ` Tom Rini

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=Pine.LNX.4.58.0503100323370.14016@localhost.localdomain \
    --to=rostedt@goodmis.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rlrevell@joe-job.com \
    /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

all inboxes | Powered by JetHome®