From owner-freebsd-hackers@FreeBSD.ORG Mon Nov 25 22:26:00 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EA75329A; Mon, 25 Nov 2013 22:26:00 +0000 (UTC) Received: from frv154.fwdcdn.com (frv154.fwdcdn.com [212.42.77.154]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A8C8B2E5C; Mon, 25 Nov 2013 22:26:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ukr.net; s=fsm; h=Content-Transfer-Encoding:Content-Type:Mime-Version:Message-ID:Subject:To:From:Date; bh=GEIDBN7xelYZGSv05Y02qrIR3g0Psmr+v85sc8IBuBk=; b=bPBQgNAWFbYVIHTOH5TzdNJuXVxEUKI0xx77fXHuFWAi+IwLIgEe4UVqp5UBRSpEsFbGgi+YgAKcsfDtezbTubdpIsxqR1GEP4MjQ7gFgpqp7swiEe+0I64Jk18oB+HHXfBMWAKLT2U5cK/TXP+RH0yNW+cKaTPC5qYTo2Qi0ZU=; Received: from [37.115.116.138] (helo=nonamehost.local) by frv154.fwdcdn.com with esmtpsa ID 1Vl4bN-0005Hv-Mj ; Tue, 26 Nov 2013 00:25:57 +0200 Date: Tue, 26 Nov 2013 00:25:57 +0200 From: Ivan Klymenko To: freebsd-hackers@freebsd.org, freebsd-questions@freebsd.org Subject: SCHED_ULE and function sched_shouldpreempt Message-ID: <20131126002557.6820c60e@nonamehost.local> X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.19; amd64-portbld-freebsd10.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Authentication-Result: IP=37.115.116.138; mail.from=fidaj@ukr.net; dkim=pass; header.d=ukr.net X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Nov 2013 22:26:01 -0000 Hello all. sched_shouldpreempt function can return only 2 values: 0 or 1 there is a set of specific conditions under which the function returns 1 if the remaining conditions - it will return 0. why use a kung fu which is currently in use? not be simpler to use that variant?: --- sched_ule.c.orig 2013-11-18 17:41:52.000000000 +0200 +++ sched_ule.c 2013-11-18 17:48:21.000000000 +0200 @@ -419,32 +419,7 @@ static inline int sched_shouldpreempt(int pri, int cpri, int remote) { - /* - * If the new priority is not better than the current priority there is - * nothing to do. - */ - if (pri >= cpri) - return (0); - /* - * Always preempt idle. - */ - if (cpri >= PRI_MIN_IDLE) - return (1); - /* - * If preemption is disabled don't preempt others. - */ - if (preempt_thresh == 0) - return (0); - /* - * Preempt if we exceed the threshold. - */ - if (pri <= preempt_thresh) - return (1); - /* - * If we're interactive or better and there is non-interactive - * or worse running preempt only remote processors. - */ - if (remote && pri <= PRI_MAX_INTERACT && cpri > PRI_MAX_INTERACT) + if ((remote && pri <= PRI_MAX_INTERACT && cpri > PRI_MAX_INTERACT)||(pri <= preempt_thresh)||(cpri >= PRI_MIN_IDLE)) return (1); return (0); } or indeed there is some uneven distribution fulfillment of certain conditions under which the execution time of that function will be much more? or to use the original variant there is any other reasons? Thanks.