All of lore.kernel.org
 help / color / mirror / Atom feed
From: Balbir Singh <balbir@in.ibm.com>
To: Mauricio Lin <mauriciolin@gmail.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: Jiffies wraparound is not treated in the schedstats
Date: Thu, 09 Nov 2006 11:59:45 +0530	[thread overview]
Message-ID: <4552CAD9.1080603@in.ibm.com> (raw)
In-Reply-To: <3f250c710611081005v5fcf3236qfb10b47bab1ada5f@mail.gmail.com>

Mauricio Lin wrote:
> Hi Balbir,
> 
> Do you know why in the sched_info_arrive() and sched_info_depart()
> functions the calculation of delta_jiffies does not use the time_after
> or time_before macro to prevent  the miscalculation when jiffies
> overflow?
> 
> For instance the delta_jiffies variable is simply calculated as:
> 
> delta_jiffies = now - t->sched_info.last_queued;
> 
> Do not you think the more logical way should be
> 
> if (time_after(now, t->sched_info.last_queued))
>    delta_jiffies = now - t->sched_info.last_queued;
> else
>    delta_jiffies = (MAX_JIFFIES - t->sched_info.last_queued) + now
> 

What's MAX_JIFFIES? Is it MAX_ULONG? jiffies is unsigned long
so you'll have to be careful with unsigned long arithmetic.

Consider that now is 5 and t->sched_info.last_queued is 10.

On my system

perl -e '{printf("%lu\n", -5 + (1<<32) - 1);}'
4294967291

perl -e '{printf("%lu\n", -5 );}'
4294967291


> I have included more variables to measure some issues of schedule in
> the kernel (following schedstat idea) and I noticed that jiffies
> wraparound has led to wrong values, since the user space tool when
> collecting the values is producing negative values.
> 

hmm.. jiffies wrapped around in sched_info_depart()? I've never seen
that happen. Could you post the additions and user space tool to look at?
What additional features are you planning to measure in the scheduler?

> Any comments?
> 
> Can I provide a patch for that?
> 

Please feel free to provide patches, this is open source!!

> BR,
> 
> Mauricio Lin.


-- 

	Balbir Singh,
	Linux Technology Center,
	IBM Software Labs

  reply	other threads:[~2006-11-09  6:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-08 18:05 Jiffies wraparound is not treated in the schedstats Mauricio Lin
2006-11-09  6:29 ` Balbir Singh [this message]
2006-11-09  6:45   ` Balbir Singh
2006-11-09 14:35   ` Mauricio Lin
2007-05-30  4:03   ` Oleg Verych
  -- strict thread matches above, loose matches on Subject: below --
2006-11-08 19:01 Kaz Kylheku

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=4552CAD9.1080603@in.ibm.com \
    --to=balbir@in.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mauriciolin@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.