From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andreas Dilger Subject: Re: high resolution timers, scheduling & sleep granularity Date: Fri, 01 Aug 2008 12:16:16 -0600 Message-ID: <20080801181616.GZ3292@webber.adilger.int> References: <4892FC11.4020105@redhat.com> <20080801132537.GB14001@unused.rdu.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7BIT Cc: Ric Wheeler , Thomas Gleixner , Ingo Molnar , linux-fsdevel@vger.kernel.org, Chris Mason , linux-kernel@vger.kernel.org To: Josef Bacik Return-path: In-reply-to: <20080801132537.GB14001@unused.rdu.redhat.com> Content-disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org 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.