public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Williams <pwil3058@bigpond.net.au>
To: Con Kolivas <kernel@kolivas.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Staircase scheduler v7.4
Date: Mon, 28 Jun 2004 09:50:57 +1000	[thread overview]
Message-ID: <40DF5D61.2030208@bigpond.net.au> (raw)
In-Reply-To: <Pine.LNX.4.58.0406272026330.29572@kolivas.org>

Con Kolivas wrote:
> On Sun, 27 Jun 2004, Con Kolivas wrote:
> 
> 
>>Ok I found a problem which alost certainly is responsible in the 
>>conversion from nanoseconds to Hz and may if you're unlucky give a blank 
>>timeslice. Can you try this (against staircase7.4). I'm almost certain 
>>it's responsbile. 
> 
> 
> Hmm that will be the problem but that may not compile because of the darn 
> long long division thingy. I'll get a clean patch to you later on that 
> does the same thing, sorry.

Here's a routine that I use for unsigned 64 bit divides. This is 
theoretically correct and (just to make sure :-)) thoroughly tested in a 
user space test program against a proper 64 bit divide.  It can't be 
used to initialize static variables but that's OK because the compiler 
can do the 64 bit arithmetic itself to correctly initialize them.

static inline unsigned long long sched_div_64(unsigned long long a, 
unsigned long long b)
{
#if BITS_PER_LONG < 64
	/*
	 * Assume that there's no 64 bit divide available
	 */
	if (a < b)
		return 0;
	/*
	 * Scale down until b less than 32 bits so that we can do
	 * a divide using do_div() (see div64.h).
	 */
	while (b > ULONG_MAX) { a >>= 1; b >>= 1; }

	(void)do_div(a, (unsigned long)b);

	return a;
#else
	return a / b;
#endif
}

Peter
PS If we knew the calling conventions for the library routines 
(__udivdi3, etc.) that the compiler tries to use to do 64 bit divides we 
could implement them in the kernel (where necessary) and 64 bit divide 
problems would become a thing of the past.
-- 
Peter Williams                                   pwil3058@bigpond.net.au

"Learning, n. The kind of ignorance distinguishing the studious."
  -- Ambrose Bierce


  reply	other threads:[~2004-06-27 23:51 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-25 16:40 [PATCH] Staircase scheduler v7.4 Michael Buesch
2004-06-25 16:46 ` Con Kolivas
2004-06-25 18:44   ` Michael Buesch
2004-06-25 19:05     ` Willy Tarreau
2004-06-25 19:48       ` Michael Buesch
2004-06-26  1:11         ` kernel
2004-06-26 16:33           ` Michael Buesch
2004-06-26 17:29           ` Michael Buesch
2004-06-27  9:14             ` Con Kolivas
2004-06-27 19:17             ` Felipe Alfaro Solana
2004-06-27 19:28               ` Michael Buesch
2004-06-27 21:55                 ` Felipe Alfaro Solana
2004-06-28  0:15                   ` Con Kolivas
2004-06-28  8:40                     ` Felipe Alfaro Solana
2004-06-28  8:49                       ` Nick Piggin
2004-06-28 11:53                         ` Felipe Alfaro Solana
2004-06-28 12:11                           ` Con Kolivas
2004-06-28 15:03                             ` Oswald Buddenhagen
2004-06-28 15:19                               ` Con Kolivas
2004-06-28 15:39                                 ` Oswald Buddenhagen
2004-06-28 17:11                             ` Felipe Alfaro Solana
2004-06-29  4:36                               ` Nick Piggin
2004-06-28 23:21                         ` Peter Williams
2004-06-29  4:44                           ` Nick Piggin
2004-06-29  6:01                             ` Ed Sweetman
2004-06-29  6:55                               ` Nick Piggin
2004-06-26  2:05         ` Con Kolivas
2004-06-27 10:24         ` Con Kolivas
2004-06-27 10:27           ` Con Kolivas
2004-06-27 23:50             ` Peter Williams [this message]
2004-06-27 12:00         ` Con Kolivas
2004-06-27 12:04           ` Con Kolivas
2004-06-27 12:54             ` Michael Buesch
2004-06-27 13:15               ` Con Kolivas
2004-06-25 16:46 ` Michael Buesch
  -- strict thread matches above, loose matches on Subject: below --
2004-06-25 14:38 Con Kolivas
2004-06-25 18:32 ` Matthias Urlichs
2004-06-26  1:28   ` Con Kolivas
2004-06-25 22:20 ` Willy Tarreau
2004-06-26  1:05   ` kernel
2004-06-26 20:04 ` Wes Janzen
2004-06-26 20:11   ` Michael Buesch
2004-06-26 21:14     ` Wes Janzen
2004-06-26 21:38       ` Prakash K. Cheemplavam
2004-06-27  9:16   ` Con Kolivas
2004-06-27 11:40     ` Grzegorz Kulewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=40DF5D61.2030208@bigpond.net.au \
    --to=pwil3058@bigpond.net.au \
    --cc=kernel@kolivas.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox