mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: tglx@linutronix.de
Cc: Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>,
	Frank v Waveren <fvw@var.cx>
Subject: Re: [PATCH] prevent timespec/timeval to ktime_t overflow
Date: Sat, 2 Sep 2006 12:32:29 -0700	[thread overview]
Message-ID: <20060902123229.f514c344.akpm@osdl.org> (raw)
In-Reply-To: <1157222493.29250.383.camel@localhost.localdomain>

On Sat, 02 Sep 2006 20:41:33 +0200
Thomas Gleixner <tglx@linutronix.de> wrote:

> On Fri, 2006-09-01 at 20:13 -0700, Andrew Morton wrote:
> > > Fun, here is a version with a bigabyte blocker.
> > 
> > Your patch triggers waaaaaaay early.
> > 
> > netconsole: remote IP 192.168.2.33
> > netconsole: remote ethernet address 00:0d:56:c6:c6:cc
> > Initializing CPU#0
> > PID hash table entries: 4096 (order: 12, 32768 bytes)
> > time.c: Using 14.318180 MHz WALL HPET GTOD HPET/TSC timer.
> > time.c: Detected 3400.238 MHz processor.
> > ktime_set: -1157140842 : 0
> 
> -------------^   !!!!!!!
> 
> > BUG: warning at include/linux/ktime.h:84/ktime_set()
> > 
> > Call Trace:
> >  <IRQ> [<ffffffff80247021>] hrtimer_run_queues+0x10e/0x211
> 
> This seems to happen inside hrtimer_get_softirq_time().
> wall_to_monotonic is negative.
> 
> Why does the check trigger ? We compare a "long", which contains a
> negative value against some positive constant. 
> 
> ktime_t ktime_set(const long secs, const unsigned long nsecs)
> {
> 	if (unlikely(secs >= KTIME_SEC_MAX)) {
> 
> where KTIME_SEC_MAX is 0x7FFFFFFFFFFFFFFF / 1000 000 000 = 
> 
> 9223372036 == 0x225C17D04,
> 
> which is compared against 
> 
> -1157140842 == 0xFFFFFFFFBB076E96
> 
> This smells like gcc magic. Can you please disassemble the code in
> question ?
> 

ktime_set:
.LFB522:
	.file 1 "kernel/hrtimer.c"
	.loc 1 884 0
.LVL0:
	pushq	%rbp	#
.LCFI0:
	movq	%rsp, %rbp	#,
.LCFI1:
.LBB2:
.LBB3:
.LBB4:
	.file 2 "include/asm/current.h"
	.loc 2 11 0
#APP
	movq %gs:0,%rax	#, t
.LVL1:
#NO_APP
.LBE4:
.LBE3:
.LBE2:
	.loc 1 888 0
	cmpq	$0, 208(%rax)	#, <variable>.mm
	je	.L2	#,
	movabsq	$9223372035, %rax	#, tmp66
.LVL2:
	cmpq	%rax, %rdi	# tmp66, secs
	jbe	.L2	#,
	.loc 1 889 0
	cmpl	$0, no88bigabytes.11819(%rip)	#, no88bigabytes
	jne	.L5	#,
	.loc 1 890 0
	movl	$1, no88bigabytes.11819(%rip)	#, no88bigabytes
	.loc 1 891 0
	movq	%rsi, %rdx	# nsecs, nsecs
	movq	%rdi, %rsi	# secs, secs


-- 
VGER BF report: H 0.000301227

  parent reply	other threads:[~2006-09-02 19:32 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-30  8:44 Thomas Gleixner
2006-08-30 21:44 ` Frank v Waveren
2006-08-30 22:05   ` Thomas Gleixner
2006-08-30 22:08     ` Frank v Waveren
2006-08-30 22:22       ` Thomas Gleixner
2006-08-30 22:26         ` Frank v Waveren
2006-09-01  3:46 ` Andrew Morton
2006-09-01  8:56   ` Thomas Gleixner
2006-09-01  9:04     ` Andrew Morton
2006-09-01  9:30       ` Thomas Gleixner
2006-09-02  3:13         ` Andrew Morton
2006-09-02  3:32           ` Andrew Morton
2006-09-02  8:08           ` Andi Kleen
2006-09-02 18:41           ` Thomas Gleixner
2006-09-02 19:28             ` Thomas Gleixner
2006-09-02 19:43               ` Andrew Morton
2006-09-02 19:32             ` Andrew Morton [this message]
2006-09-02 11:04   ` Frank v Waveren
2006-09-02 18:44     ` Thomas Gleixner
2006-09-03  3:13       ` Frank v Waveren

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=20060902123229.f514c344.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=fvw@var.cx \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /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

Powered by JetHome