mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: tip-bot for John Stultz <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: shuahkh@osg.samsung.com, linux-kernel@vger.kernel.org,
	hpa@zytor.com, bristot@redhat.com, richardcochran@gmail.com,
	jbohac@suse.cz, tglx@linutronix.de, jack@suse.cz,
	mingo@kernel.org, prarit@redhat.com, john.stultz@linaro.org
Subject: [tip:timers/core] selftest: Timers: Avoid signal deadlock in leap-a-day
Date: Thu, 18 Jun 2015 06:30:27 -0700	[thread overview]
Message-ID: <tip-51a16c1e887a5975ada27a3ae935a4f2783005da@git.kernel.org> (raw)
In-Reply-To: <1434565003-3386-1-git-send-email-john.stultz@linaro.org>

Commit-ID:  51a16c1e887a5975ada27a3ae935a4f2783005da
Gitweb:     http://git.kernel.org/tip/51a16c1e887a5975ada27a3ae935a4f2783005da
Author:     John Stultz <john.stultz@linaro.org>
AuthorDate: Wed, 17 Jun 2015 11:16:43 -0700
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 18 Jun 2015 15:28:14 +0200

selftest: Timers: Avoid signal deadlock in leap-a-day

In 0c4a5fc95b1df (Add leap-second timer edge testing to
leap-a-day.c), we added a timer to the test which checks to make
sure timers near the leapsecond edge behave correctly.

However, the output generated from the timer uses ctime_r, which
isn't async-signal safe, and should that signal land while the
main test is using ctime_r to print its output, its possible for
the test to deadlock on glibc internal locks.

Thus this patch reworks the output to avoid using ctime_r in
the signal handler.

Signed-off-by: John Stultz <john.stultz@linaro.org>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jiri Bohac <jbohac@suse.cz>
Cc: Shuah Khan <shuahkh@osg.samsung.com>
Cc: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/r/1434565003-3386-1-git-send-email-john.stultz@linaro.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 tools/testing/selftests/timers/leap-a-day.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/tools/testing/selftests/timers/leap-a-day.c b/tools/testing/selftests/timers/leap-a-day.c
index 331c4f7..fb46ad6 100644
--- a/tools/testing/selftests/timers/leap-a-day.c
+++ b/tools/testing/selftests/timers/leap-a-day.c
@@ -141,27 +141,28 @@ void handler(int unused)
 void sigalarm(int signo)
 {
 	struct timex tx;
-	char buf[26];
 	int ret;
 
 	tx.modes = 0;
 	ret = adjtimex(&tx);
 
-	ctime_r(&tx.time.tv_sec, buf);
-	buf[strlen(buf)-1] = 0; /*remove trailing\n */
-	printf("%s + %6ld us (%i)\t%s - TIMER FIRED\n",
-					buf,
+	if (tx.time.tv_sec < next_leap) {
+		printf("Error: Early timer expiration! (Should be %ld)\n", next_leap);
+		error_found = 1;
+		printf("adjtimex: %10ld sec + %6ld us (%i)\t%s\n",
+					tx.time.tv_sec,
 					tx.time.tv_usec,
 					tx.tai,
 					time_state_str(ret));
-
-	if (tx.time.tv_sec < next_leap) {
-		printf("Error: Early timer expiration!\n");
-		error_found = 1;
 	}
 	if (ret != TIME_WAIT) {
-		printf("Error: Incorrect NTP state?\n");
+		printf("Error: Timer seeing incorrect NTP state? (Should be TIME_WAIT)\n");
 		error_found = 1;
+		printf("adjtimex: %10ld sec + %6ld us (%i)\t%s\n",
+					tx.time.tv_sec,
+					tx.time.tv_usec,
+					tx.tai,
+					time_state_str(ret));
 	}
 }
 
@@ -297,7 +298,7 @@ int main(int argc, char **argv)
 		printf("Scheduling leap second for %s", ctime(&next_leap));
 
 		/* Set up timer */
-		printf("Setting timer for %s", ctime(&next_leap));
+		printf("Setting timer for %ld -  %s", next_leap, ctime(&next_leap));
 		memset(&se, 0, sizeof(se));
 		se.sigev_notify = SIGEV_SIGNAL;
 		se.sigev_signo = signum;

      reply	other threads:[~2015-06-18 13:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-17 18:16 [PATCH] selftest: timers: " John Stultz
2015-06-18 13:30 ` tip-bot for John Stultz [this message]

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=tip-51a16c1e887a5975ada27a3ae935a4f2783005da@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=bristot@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jack@suse.cz \
    --cc=jbohac@suse.cz \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=prarit@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=shuahkh@osg.samsung.com \
    --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

all inboxes | Powered by JetHome®