Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757635AbYHASRB (ORCPT ); Fri, 1 Aug 2008 14:17:01 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757400AbYHASQt (ORCPT ); Fri, 1 Aug 2008 14:16:49 -0400 Received: from sca-es-mail-2.Sun.COM ([192.18.43.133]:57250 "EHLO sca-es-mail-2.sun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752038AbYHASQr (ORCPT ); Fri, 1 Aug 2008 14:16:47 -0400 Date: Fri, 01 Aug 2008 12:16:16 -0600 From: Andreas Dilger Subject: Re: high resolution timers, scheduling & sleep granularity In-reply-to: <20080801132537.GB14001@unused.rdu.redhat.com> To: Josef Bacik Cc: Ric Wheeler , Thomas Gleixner , Ingo Molnar , linux-fsdevel@vger.kernel.org, Chris Mason , linux-kernel@vger.kernel.org Message-id: <20080801181616.GZ3292@webber.adilger.int> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Content-disposition: inline X-GPG-Key: 1024D/0D35BED6 X-GPG-Fingerprint: 7A37 5D79 BF1B CECA D44F 8A29 A488 39F5 0D35 BED6 References: <4892FC11.4020105@redhat.com> <20080801132537.GB14001@unused.rdu.redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1669 Lines: 50 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. -- 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/