From: Csdncannon <csdncannon@gmail.com>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: Arnd Bergmann <arnd@arndb.de>, linuxppc-dev@ozlabs.org
Subject: Re: Continual reading from the PowerPc time base register is not stable
Date: Tue, 6 Apr 2010 16:02:39 +0800 [thread overview]
Message-ID: <p2l43c137a81004060102m206cf121y61b120cfccfc790e@mail.gmail.com> (raw)
In-Reply-To: <43c137a81003260514o7efaf667h326b4a33069b8a71@mail.gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 1223 bytes --]
Hi guys
In fact my problem is gettimeofday cannot return right value
sometimes, and this will bring instability to our system software. You can
find a law from the log that there is a 17592 seconds' shift every time
error occurs.
2010/3/26 Csdncannon <csdncannon@gmail.com>
> Yes, the missing 64-bit conversion is the key problem, I will try removing
> isync later.
>
> Thanks for your support.
>
>
> 2010/3/26 Segher Boessenkool <segher@kernel.crashing.org>
>
>> > Yes indeed. Could you post the relevant piece if disassembly from
>>
>> > your original binary (the one that has the problem)? Or send me the
>> > binary (not to the mailing list), I'll do it then.
>>
>> Ah scratch that. I compiled your original code (after fixing the
>> compile errors -- there is no such type as "bool" in C).
>>
>> The problem is that (upper << 32) | lower thing. "upper" is a 32-bit
>> type, so shifting it by 32 or more bits is undefined. GCC compiles this
>> to (shortened):
>>
>> 0: mftbu 9 ; mftbl 11 ; mftbu 0 ; cmpw 0,9 ; bne 0b # so far so good
>> slwi 0,0,0 ; or 4,0,11 ; li 3,0 ; blr
>>
>> so it shifts by 0, i.e. it does upper | lower .
>>
>> Case closed, no hardware problem :-)
>>
>>
>> Segher
>>
>>
>
[-- Attachment #1.2: Type: text/html, Size: 2014 bytes --]
[-- Attachment #2: gettime.c --]
[-- Type: application/octet-stream, Size: 1112 bytes --]
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
int main(void)
{
struct timeval now, timeout;
gettimeofday( &now, (struct timezone *)NULL );
int count = 0;
while(1)
{
count ++;
if(gettimeofday( &timeout, (struct timezone *)NULL ))
{
printf("gettimeofday failed1: tv_sec %d , tv_usec %d \n", timeout.tv_sec, timeout.tv_usec);
}
usleep( 5 );
if(gettimeofday( &now, (struct timezone *)NULL ))
{
printf("gettimeofday failed2: tv_sec %d , tv_usec %d \n", now.tv_sec, now.tv_usec);
};
if ((timeout.tv_sec - now.tv_sec) > 1)
{
printf("Serious : timeout %d , now %d \n", timeout.tv_sec, now.tv_sec);
}
else if((now.tv_sec - timeout.tv_sec) > 1)
{
printf("Failed : timeout %d , now %d \n", timeout.tv_sec, now.tv_sec);
}
if(count > 1000000)
{
count = 0;
printf(" %d , %d \n", timeout.tv_sec, now.tv_sec);
}
}
}
[-- Attachment #3: gettime.log --]
[-- Type: application/octet-stream, Size: 939 bytes --]
root@tlab8378:/root> /mnt/server/Gino/gettime
1270540744 , 1270540744
Failed : timeout 1270540749 , now 1270558341
Serious : timeout 1270558341 , now 1270540749
1270540755 , 1270540755
1270540765 , 1270540765
Failed : timeout 1270540774 , now 1270558366
Serious : timeout 1270558366 , now 1270540774
1270540775 , 1270540775
1270540786 , 1270540786
1270540796 , 1270540796
Failed : timeout 1270540802 , now 1270558394
Serious : timeout 1270558394 , now 1270540802
Failed : timeout 1270540803 , now 1270558395
Serious : timeout 1270558395 , now 1270540803
1270540806 , 1270540806
Failed : timeout 1270540814 , now 1270558406
Serious : timeout 1270558406 , now 1270540814
1270540816 , 1270540816
1270540827 , 1270540827
1270540837 , 1270540837
1270540847 , 1270540847
Failed : timeout 1270540855 , now 1270558447
Serious : timeout 1270558447 , now 1270540855
1270540858 , 1270540858
next prev parent reply other threads:[~2010-04-06 8:02 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-25 2:41 Continual reading from the PowerPc time base register is not stable Csdncannon
2010-03-25 8:21 ` Benjamin Herrenschmidt
2010-03-25 10:05 ` Arnd Bergmann
2010-03-25 15:00 ` Csdncannon
2010-03-25 20:38 ` Benjamin Herrenschmidt
2010-03-26 1:11 ` Csdncannon
2010-03-26 1:22 ` Segher Boessenkool
2010-03-26 2:01 ` Csdncannon
2010-03-26 8:52 ` Segher Boessenkool
2010-03-26 9:01 ` Segher Boessenkool
2010-03-26 12:14 ` Csdncannon
2010-04-06 8:02 ` Csdncannon [this message]
2010-03-26 1:55 ` Benjamin Herrenschmidt
2010-03-26 2:04 ` Csdncannon
2010-03-25 22:00 ` Chris Friesen
2010-03-25 22:57 ` Benjamin Herrenschmidt
2010-03-25 23:37 ` Kumar Gala
2010-03-25 21:37 ` Segher Boessenkool
2010-04-10 3:14 ` Csdncannon
2010-04-22 0:44 ` Kim Phillips
2010-04-22 0:50 ` Benjamin Herrenschmidt
2010-04-22 23:27 ` Kim Phillips
2010-04-23 10:57 ` Csdncannon
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=p2l43c137a81004060102m206cf121y61b120cfccfc790e@mail.gmail.com \
--to=csdncannon@gmail.com \
--cc=arnd@arndb.de \
--cc=linuxppc-dev@ozlabs.org \
--cc=segher@kernel.crashing.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;
as well as URLs for NNTP newsgroup(s).