From: John Stultz <john.stultz@linaro.org>
To: John Stultz <johnstul@us.ibm.com>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>,
Prarit Bhargava <prarit@redhat.com>,
stable@vger.kernel.org, Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 0/2][RFC] Potential fix for leapsecond caused futex issue (v2)
Date: Sun, 01 Jul 2012 11:34:12 -0700 [thread overview]
Message-ID: <4FF09824.6040909@linaro.org> (raw)
In-Reply-To: <1341167401-31342-1-git-send-email-johnstul@us.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 341 bytes --]
On 07/01/2012 11:29 AM, John Stultz wrote:
> From: John Stultz <john.stultz@linaro.org>
>
> Here's round two on this one.
And again, attached is the test case I've been using to trigger
leapseconds, should anyone else want to help with testing the patches or
reproducing problems.
To build:
gcc leaptest.c -o leaptest -lrt
thanks
-john
[-- Attachment #2: leaptest.c --]
[-- Type: text/x-csrc, Size: 2076 bytes --]
/* Leap second test
* by: john stultz (johnstul@us.ibm.com)
* (C) Copyright IBM 2012
* Licensed under the GPL
*/
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
#include <sys/timex.h>
#define CALLS_PER_LOOP 64
#define NSEC_PER_SEC 1000000000ULL
/* returns 1 if a <= b, 0 otherwise */
static inline int in_order(struct timespec a, struct timespec b)
{
if(a.tv_sec < b.tv_sec)
return 1;
if(a.tv_sec > b.tv_sec)
return 0;
if(a.tv_nsec > b.tv_nsec)
return 0;
return 1;
}
int main(void)
{
struct timeval tv;
struct timex tx;
struct timespec list[CALLS_PER_LOOP];
int i, inconsistent;
int clock_type = CLOCK_REALTIME;
long now, then;
/* Get the current time */
gettimeofday(&tv, NULL);
/* Calculate the next leap second */
tv.tv_sec += 86400 - tv.tv_sec % 86400;
/* Set the time to be 10 seconds from that time */
tv.tv_sec -= 10;
settimeofday(&tv, NULL);
/* Set the leap second insert flag */
tx.modes = ADJ_STATUS;
tx.status = STA_INS;
adjtimex(&tx);
clock_gettime(clock_type, &list[0]);
now = then = list[0].tv_sec;
while(now - then < 30){
inconsistent = 0;
/* Fill list */
for(i=0; i < CALLS_PER_LOOP; i++)
clock_gettime(clock_type, &list[i]);
/* Check for inconsistencies */
for(i=0; i < CALLS_PER_LOOP-1; i++)
if(!in_order(list[i],list[i+1]))
inconsistent = i;
/* display inconsistency */
if(inconsistent){
unsigned long long delta;
for(i=0; i < CALLS_PER_LOOP; i++){
if(i == inconsistent)
printf("--------------------\n");
printf("%lu:%lu\n",list[i].tv_sec,
list[i].tv_nsec);
if(i == inconsistent + 1 )
printf("--------------------\n");
}
delta = list[inconsistent].tv_sec*NSEC_PER_SEC;
delta += list[inconsistent].tv_nsec;
delta -= list[inconsistent+1].tv_sec*NSEC_PER_SEC;
delta -= list[inconsistent+1].tv_nsec;
printf("Delta: %llu ns\n", delta);
fflush(0);
break;
}
now = list[0].tv_sec;
}
/* clear TIME_WAIT */
tx.modes = ADJ_STATUS;
tx.status = 0;
adjtimex(&tx);
return 0;
}
next prev parent reply other threads:[~2012-07-01 18:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-01 18:29 [PATCH 0/2][RFC] Potential fix for leapsecond caused futex issue (v2) John Stultz
2012-07-01 18:30 ` [PATCH 1/2] [RFC] Fix clock_was_set so it is safe to call from atomic John Stultz
2012-07-02 8:53 ` Thomas Gleixner
2012-07-02 22:11 ` John Stultz
2012-07-01 18:30 ` [PATCH 2/2] [RFC] Fix leapsecond triggered hrtimer/futex load spike issue John Stultz
2012-07-01 18:34 ` John Stultz [this message]
2012-07-01 18:47 ` [PATCH 0/2][RFC] Potential fix for leapsecond caused futex issue (v2) Jan Engelhardt
2012-07-01 22:05 ` John Stultz
2012-07-02 4:12 ` John Stultz
2012-07-02 13:53 ` Prarit Bhargava
2012-07-02 18:51 ` Dave Jones
2012-07-02 19:08 ` John Stultz
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=4FF09824.6040909@linaro.org \
--to=john.stultz@linaro.org \
--cc=johnstul@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=prarit@redhat.com \
--cc=stable@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).