linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@sun.com>
To: Josef Bacik <jbacik@redhat.com>
Cc: Ric Wheeler <rwheeler@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
	linux-fsdevel@vger.kernel.org,
	Chris Mason <chris.mason@oracle.com>,
	linux-kernel@vger.kernel.org
Subject: Re: high resolution timers, scheduling & sleep granularity
Date: Fri, 01 Aug 2008 12:16:16 -0600	[thread overview]
Message-ID: <20080801181616.GZ3292@webber.adilger.int> (raw)
In-Reply-To: <20080801132537.GB14001@unused.rdu.redhat.com>

On Aug 01, 2008  09:25 -0400, Josef Bacik wrote:
> +	if (unlikely(!journal->j_average_commit_time))
> +		journal->j_average_commit_time = commit_time;
> +	else
> +		journal->j_average_commit_time = (commit_time +
> +					journal->j_average_commit_time) / 2;

You may also consider making this a decaying average, so that minor changes
in the workload are smoothed out.  Also, it is probably easier to read
likely(foo) instead of unlikely(!foo)...

	if (likely(journal->j_average_commit_time != 0))
		journal->j_average_commit_time =
			(commit_time * 3 + journal->j_average_commit_time) / 4;
	else
		journal->j_average_commit_time = commit_time;

> +	if (journal->print_count < 100) {
> +		journal->print_count++;
> +		printk(KERN_ERR "avg commit time = %lu\n",
> +		       journal->j_average_commit_time);
> +	}

There is already the jbd stats patch in jbd2 that is reporting this
information for the previous transactions.

>  
> +		spin_lock(&journal->j_state_lock);
> +		commit_time = journal->j_average_commit_time;
> +		spin_unlock(&journal->j_state_lock);
> +
> +		sleep_time = elapsed_jiffies(transaction->t_start_time, jiffies);
> +		if (!sleep_time)
> +			sleep_time = 1;
> +		sleep_time = (commit_time / sleep_time) * commit_time;

I was also going to comment on the use of jiffies here, but Ric beat me
to it.

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

      parent reply	other threads:[~2008-08-01 18:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-01 12:05 high resolution timers, scheduling & sleep granularity Ric Wheeler
2008-08-01 13:25 ` Josef Bacik
2008-08-01 13:57   ` Ric Wheeler
2008-08-01 13:55     ` Josef Bacik
2008-08-01 14:50   ` Peter Zijlstra
2008-08-01 14:34     ` Josef Bacik
2008-08-01 15:03     ` Ric Wheeler
2008-08-01 18:16   ` Andreas Dilger [this message]

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=20080801181616.GZ3292@webber.adilger.int \
    --to=adilger@sun.com \
    --cc=chris.mason@oracle.com \
    --cc=jbacik@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rwheeler@redhat.com \
    --cc=tglx@linutronix.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;
as well as URLs for NNTP newsgroup(s).