From patchwork Wed Jun 17 18:16:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 49984 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CF2A2228CC for ; Wed, 17 Jun 2015 18:16:54 +0000 (UTC) Received: by wgfj7 with SMTP id j7sf11362053wgf.1 for ; Wed, 17 Jun 2015 11:16:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=z2IxT4Awt7LvsWTZanWr9n/2nbG7nX9r5wCw9rZ5Zic=; b=H0R4n1KSMUdylFDjpGvTUaKXkTpkj73tXSffBTd1VEHSp4IZsdw//G5JBEV0eJ5eTF x8Ot6j1Fkq1uUXIEBG5KF6eDkXx0f/Sr8I1T4ciolLUwCsrFS7wfmuMeUb+2RoGnPkmJ AATu7n3T4GGk2hjNdB+2rP2cGw9ogkrhaH9m6ze4kN4w8NLxu834Dt1X+Aou8/PoMDcK sBhhLn87iVYmk3qlKugHJY8xOtT+NzXPnketgmU8Nbh5RD2gLuZo3i4QqlJ8ve/FvRhd K2ncH79divJSWmwnMs31PfzXUP36MP/0K6OuCT8hXa/l4q3ZZwLTkNfnfTpKOvjvj7r3 +/gg== X-Gm-Message-State: ALoCoQkJDwEONA/YNbiA74tq+Y9/6ymKBUDJYyDGFYrVwkf5V6zDKDM4fD3FTZHufSyKydgtuQhq X-Received: by 10.112.203.168 with SMTP id kr8mr6530946lbc.10.1434565014108; Wed, 17 Jun 2015 11:16:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.18.199 with SMTP id y7ls308175lad.47.gmail; Wed, 17 Jun 2015 11:16:53 -0700 (PDT) X-Received: by 10.152.21.5 with SMTP id r5mr9242671lae.24.1434565013826; Wed, 17 Jun 2015 11:16:53 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id dc7si4237436lad.124.2015.06.17.11.16.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jun 2015 11:16:53 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by lacny3 with SMTP id ny3so38888040lac.3 for ; Wed, 17 Jun 2015 11:16:53 -0700 (PDT) X-Received: by 10.152.21.136 with SMTP id v8mr9234678lae.19.1434565013489; Wed, 17 Jun 2015 11:16:53 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp638589lbb; Wed, 17 Jun 2015 11:16:52 -0700 (PDT) X-Received: by 10.70.49.73 with SMTP id s9mr13104428pdn.149.1434565011778; Wed, 17 Jun 2015 11:16:51 -0700 (PDT) Received: from mail-pd0-f169.google.com (mail-pd0-f169.google.com. [209.85.192.169]) by mx.google.com with ESMTPS id u3si7424117pde.161.2015.06.17.11.16.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jun 2015 11:16:51 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.192.169 as permitted sender) client-ip=209.85.192.169; Received: by pdjm12 with SMTP id m12so45807380pdj.3 for ; Wed, 17 Jun 2015 11:16:50 -0700 (PDT) X-Received: by 10.66.121.163 with SMTP id ll3mr13771240pab.100.1434565010805; Wed, 17 Jun 2015 11:16:50 -0700 (PDT) Received: from localhost.localdomain (c-71-63-136-39.hsd1.or.comcast.net. [71.63.136.39]) by mx.google.com with ESMTPSA id qw13sm5465422pab.14.2015.06.17.11.16.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Jun 2015 11:16:49 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Prarit Bhargava , Daniel Bristot de Oliveira , Richard Cochran , Jan Kara , Jiri Bohac , Ingo Molnar , Thomas Gleixner , Shuah Khan Subject: [PATCH] selftest: timers: Avoid signal deadlock in leap-a-day Date: Wed, 17 Jun 2015 11:16:43 -0700 Message-Id: <1434565003-3386-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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. Cc: Prarit Bhargava Cc: Daniel Bristot de Oliveira Cc: Richard Cochran Cc: Jan Kara Cc: Jiri Bohac Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Shuah Khan Signed-off-by: John Stultz --- (This applies to tip/timers/core) 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;