From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758390Ab3HMQ3Q (ORCPT ); Tue, 13 Aug 2013 12:29:16 -0400 Received: from terminus.zytor.com ([198.137.202.10]:34220 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758224Ab3HMQ3N (ORCPT ); Tue, 13 Aug 2013 12:29:13 -0400 Message-ID: <520A5EA5.8090301@zytor.com> Date: Tue, 13 Aug 2013 09:28:21 -0700 From: "H. Peter Anvin" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Ingo Molnar CC: Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Mike Galbraith , Andi Kleen , Linux Kernel Mailing List Subject: Re: [RFC] per-cpu preempt_count References: <20130812115113.GE27162@twins.programming.kicks-ass.net> <20130812175830.GB18691@gmail.com> <20130813103056.GA2170@gmail.com> <20130813122652.GA24092@twins.programming.kicks-ass.net> <20130813155637.GA5280@gmail.com> In-Reply-To: <20130813155637.GA5280@gmail.com> X-Enigmail-Version: 1.5.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/13/2013 08:56 AM, Ingo Molnar wrote: > > * Linus Torvalds wrote: > >> On Tue, Aug 13, 2013 at 5:26 AM, Peter Zijlstra wrote: >>> >>> So we're now down to something like: >>> >>> decl fs:preempt_count >>> cmpl PREEMPT_NEED_RESCHED,fs:preempt_count >>> jnz 1f >> >> Well, this isn't worth doing unless you can make PREEMPT_NEED_RESCHED be >> the high bit, and we can combine it into just "decl+jns". Otherwise we'd >> be better off with the simpler two separate adjacent variables. > > Definitely, the cmpl should be avoided. > > PREEMPT_NEED_RESCHED could be made the high bit - or maybe an even simpler > solution is to invert its meaning: making '0' the "it needs to resched!" > case, so the check would be decl+jz? > That is pretty elegant. A little more elegant in fact than my suggestion to bias NEED_RESCHED by 0x7fffffff and test the overflow flag. That way we also avoid going off to the slow path without the count being zero, which although we already covered that it doesn't matter all that much still is a nice bonus. -hpa