From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Thornber Subject: Re: [PATCH] dm-bufio Date: Mon, 17 Oct 2011 15:15:22 +0100 Message-ID: <20111017141521.GB10136@ubuntu> References: <20111017100808.GA4635@ubuntu> Reply-To: device-mapper development Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com To: Mikulas Patocka Cc: dm-devel@redhat.com, Mike Snitzer , "Alasdair G. Kergon" List-Id: dm-devel.ids On Mon, Oct 17, 2011 at 10:04:16AM -0400, Mikulas Patocka wrote: > > If you're going to use cond_resched() at least do so a little more > > intelligently than putting it in _every_ loop. For instance you call it on > > every iteration of a sweep through the hash table. The call to > > cond_resched will take more time than the loop body. At least make a > > change so it's only done every n'th iteration. > > I think it would be better to use > #ifndef CONFIG_PREEMPT > if (need_resched()) cond_resched(); > #endif > > need_resched() is inlined and translates to a single condition. Yep, that would be fine. > I don't know why Linux doesn't provide a macro for it, this would be > useful far beyond dm code. Agreed, I was very surprised that cond_resched() expands out to a function call rather than a test + fn call. Get a patch together and I'll merge. - Joe