From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pv0-f170.google.com (mail-pv0-f170.google.com [74.125.83.170]) by ozlabs.org (Postfix) with ESMTP id B6D00B7CF0 for ; Tue, 6 Apr 2010 18:02:41 +1000 (EST) Received: by pvg6 with SMTP id 6so2228667pvg.15 for ; Tue, 06 Apr 2010 01:02:40 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <43c137a81003260514o7efaf667h326b4a33069b8a71@mail.gmail.com> References: <43c137a81003241941p84cba56y3e02e40cb22623e2@mail.gmail.com> <201003251105.10033.arnd@arndb.de> <43c137a81003250800n660195c5k42c8516068aeda8d@mail.gmail.com> <1269549524.8599.243.camel@pasglop> <43c137a81003251811s52ac72eaud921d187e9747098@mail.gmail.com> <50253.84.105.60.153.1269566569.squirrel@gate.crashing.org> <43c137a81003251901h229b873bh7593c59a5ef66ae9@mail.gmail.com> <51131.84.105.60.153.1269593558.squirrel@gate.crashing.org> <51142.84.105.60.153.1269594081.squirrel@gate.crashing.org> <43c137a81003260514o7efaf667h326b4a33069b8a71@mail.gmail.com> Date: Tue, 6 Apr 2010 16:02:39 +0800 Message-ID: Subject: Re: Continual reading from the PowerPc time base register is not stable From: Csdncannon To: Segher Boessenkool Content-Type: multipart/mixed; boundary=001636b1467798941c04838cde6a Cc: Arnd Bergmann , linuxppc-dev@ozlabs.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , --001636b1467798941c04838cde6a Content-Type: multipart/alternative; boundary=001636b1467798941104838cde68 --001636b1467798941104838cde68 Content-Type: text/plain; charset=ISO-8859-1 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 > 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 > >> > 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 >> >> > --001636b1467798941104838cde68 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi guys
=A0=A0=A0=A0=A0=A0 In fact my problem is gettimeofday cannot ret= urn right value sometimes, and this will bring instability to our system so= ftware. 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 &= lt;segher@k= ernel.crashing.org>
> Y= es indeed. =A0Could you post the relevant piece if disassembly from

> your original binary (the one that has the problem)? =A0Or send me the=
> binary (not to the mailing list), I'll do it then.

Ah scratch that. =A0I c= ompiled your original code (after fixing the
compile errors -- there is no such type as "bool" in C).

The problem is that =A0(upper << 32) | lower =A0thing. =A0"upper= " is a 32-bit
type, so shifting it by 32 or more bits is undefined. =A0GCC compiles this<= br> to (shortened):

0: mftbu 9 ; mftbl 11 ; mftbu 0 ; cmpw 0,9 ; bne 0b =A0# so far so good
=A0 slwi 0,0,0 ; or 4,0,11 ; li 3,0 ; blr

so it shifts by 0, i.e. it does =A0upper | lower .

Case closed, no hardware problem :-)


Segher



--001636b1467798941104838cde68-- --001636b1467798941c04838cde6a Content-Type: application/octet-stream; name="gettime.c" Content-Disposition: attachment; filename="gettime.c" Content-Transfer-Encoding: base64 X-Attachment-Id: f_g7of8x0j0 I2luY2x1ZGUgPGlvc3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1lb3V0LnR2X3NlYykgPiAxKQ0K CQl7DQoJCQlwcmludGYoIkZhaWxlZCA6IHRpbWVvdXQgJWQgLCBub3cgJWQgXG4iLCB0aW1lb3V0 LnR2X3NlYywgbm93LnR2X3NlYyk7DQoJCX0NCg0KICAgICAgICBpZihjb3VudCA+IDEwMDAwMDAp DQoNCiAgICAgICAgew0KDQogICAgICAgICAgICBjb3VudCA9IDA7DQoNCiAgICAgICAgICAgIHBy aW50ZigiICVkICwgICAlZCBcbiIsIHRpbWVvdXQudHZfc2VjLCBub3cudHZfc2VjKTsNCg0KICAg ICAgICB9DQoNCiAgICB9DQoNCiANCg0KfQ0KDQo= --001636b1467798941c04838cde6a Content-Type: application/octet-stream; name="gettime.log" Content-Disposition: attachment; filename="gettime.log" Content-Transfer-Encoding: base64 X-Attachment-Id: f_g7of9it31 cm9vdEB0bGFiODM3ODovcm9vdD4gL21udC9zZXJ2ZXIvR2luby9nZXR0aW1lDQogMTI3MDU0MDc0 NCAsICAgMTI3MDU0MDc0NA0KRmFpbGVkIDogdGltZW91dCAxMjcwNTQwNzQ5ICwgbm93IDEyNzA1 NTgzNDENClNlcmlvdXMgOiB0aW1lb3V0IDEyNzA1NTgzNDEgLCBub3cgMTI3MDU0MDc0OQ0KIDEy NzA1NDA3NTUgLCAgIDEyNzA1NDA3NTUNCiAxMjcwNTQwNzY1ICwgICAxMjcwNTQwNzY1DQpGYWls ZWQgOiB0aW1lb3V0IDEyNzA1NDA3NzQgLCBub3cgMTI3MDU1ODM2Ng0KU2VyaW91cyA6IHRpbWVv dXQgMTI3MDU1ODM2NiAsIG5vdyAxMjcwNTQwNzc0DQogMTI3MDU0MDc3NSAsICAgMTI3MDU0MDc3 NQ0KIDEyNzA1NDA3ODYgLCAgIDEyNzA1NDA3ODYNCiAxMjcwNTQwNzk2ICwgICAxMjcwNTQwNzk2 DQpGYWlsZWQgOiB0aW1lb3V0IDEyNzA1NDA4MDIgLCBub3cgMTI3MDU1ODM5NA0KU2VyaW91c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