From patchwork Mon Mar 18 13:42:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Hrubis X-Patchwork-Id: 1057889 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44NHSl49lwz9s5c for ; Tue, 19 Mar 2019 00:43:18 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 283AD3EA1E5 for ; Mon, 18 Mar 2019 14:43:15 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) by picard.linux.it (Postfix) with ESMTP id BAE853EA133 for ; Mon, 18 Mar 2019 14:43:12 +0100 (CET) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id B14F21A00F09 for ; Mon, 18 Mar 2019 14:43:11 +0100 (CET) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id E8F62AD70; Mon, 18 Mar 2019 13:43:10 +0000 (UTC) From: Cyril Hrubis To: ltp@lists.linux.it Date: Mon, 18 Mar 2019 14:42:27 +0100 Message-Id: <20190318134227.17385-1-chrubis@suse.cz> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH] lib/tst_checkpoint: Retry sleep on EINTR X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Previously we haven't retried on EINTR, the main reason for that was that all the tests using checkpoints haven't cared at all since signals were not involved. However I think that retry on EINTR should be done by default, since checkpoints returning from sleep on random signal delivery are broken, and no test in the tree actually depends on such behavior. Currently tests for tgkill have emerged on ML where child needs to sleep while parent sends signals to the child, this commit allows to use checkpoints for these tests. This commit implements the simpliest way how to retry, it's just a simple loop over the futex() call that repeats on EINTR. The only side effect is that timeout is restarted after the thread sleeping in futex() got signal, since we use relative timeouts after all. However the hypotetical worst case that can happen is that the test will timeout and will end up being killed by the test library in a case that one test would sleep on checkpoint while other would send signals in a loop. Hoever chances for this arrangement are quite small. Signed-off-by: Cyril Hrubis CC: Sumit Garg CC: Jan Stancek Acked-by: Jan Stancek Acked-by: Sumit Garg --- lib/tst_checkpoint.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/tst_checkpoint.c b/lib/tst_checkpoint.c index 5455d0378..5e5b11496 100644 --- a/lib/tst_checkpoint.c +++ b/lib/tst_checkpoint.c @@ -85,6 +85,7 @@ void tst_checkpoint_init(const char *file, const int lineno, int tst_checkpoint_wait(unsigned int id, unsigned int msec_timeout) { struct timespec timeout; + int ret; if (id >= tst_max_futexes) { errno = EOVERFLOW; @@ -94,8 +95,12 @@ int tst_checkpoint_wait(unsigned int id, unsigned int msec_timeout) timeout.tv_sec = msec_timeout/1000; timeout.tv_nsec = (msec_timeout%1000) * 1000000; - return syscall(SYS_futex, &tst_futexes[id], FUTEX_WAIT, - tst_futexes[id], &timeout); + do { + ret = syscall(SYS_futex, &tst_futexes[id], FUTEX_WAIT, + tst_futexes[id], &timeout); + } while (ret == -1 && errno == EINTR); + + return ret; } int tst_checkpoint_wake(unsigned int id, unsigned int nr_wake,