From patchwork Fri Jan 15 09:14:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 59849 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp414700lbb; Fri, 15 Jan 2016 01:15:24 -0800 (PST) X-Received: by 10.140.173.132 with SMTP id t126mr12455101qht.96.1452849324367; Fri, 15 Jan 2016 01:15:24 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id s13si3020227qki.121.2016.01.15.01.15.24; Fri, 15 Jan 2016 01:15:24 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id E12F260762; Fri, 15 Jan 2016 09:15:23 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=RusBasJq; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id D58E5618CB; Fri, 15 Jan 2016 09:14:24 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id BD9EA616DC; Fri, 15 Jan 2016 09:14:17 +0000 (UTC) Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com [209.85.215.51]) by lists.linaro.org (Postfix) with ESMTPS id 6EEBB60762 for ; Fri, 15 Jan 2016 09:14:15 +0000 (UTC) Received: by mail-lf0-f51.google.com with SMTP id c192so278961687lfe.2 for ; Fri, 15 Jan 2016 01:14:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HUe3WSk7zPifLXJBHNEQi+fz72FYlvlUIIXw+x03Hqc=; b=RusBasJqsccZar06Pj3E7dBVW93aQ0CIP48bLzbHDQGnexHlk1gYofFLk1nPwfa4nE 897u0lb7k5elGb5RJufltmB9phLEvGGEx7vYSgJBUdQO6jDQ+ZbpqysySAD/7tQg7Nz1 Ln5txMW/Dv4FVEtaC3Nbl2057z0eeyDvSpLHM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HUe3WSk7zPifLXJBHNEQi+fz72FYlvlUIIXw+x03Hqc=; b=aWfIZxmosm/VvDVGRItRU0f9KLxfmkZIRizvfelk2ajp0sFVrphUvZ/z4VV5edaaeq msgUPQWKJNOBopNI6xDj2D6cUJ65mEQ47DKflzr3LfWRyRCE+FxOTYK5pFBZsQtbZSX9 tOHbmlWA3dklC/yauSWmmYaZ7KPWwr1mT1j2X+UXKzCOqfSkJquIBiW8cxWuiDiFLFNz 7cytjZQSR/7aRAYeQfatoLA4z8u5kxIetmPM6Ri5bhODmkQ02tA1s95c6MyO3LiPUKHN rt7UfKdhmLqx7wz6Or+44egCCqFlnwvv6YJqO4a8iGeVGyUFXDMB903tqlHCmMRghfob ti/A== X-Gm-Message-State: ALoCoQn8eBTzid6hETrJG8vuuje45oaWmz1An5sTAmv+ObQSXf0HQl0kl6dhF5UZ9eoPooymhUJR1RdYtf0pXS/eR9ItpNMkXg== X-Received: by 10.25.156.198 with SMTP id f189mr2786774lfe.70.1452849253756; Fri, 15 Jan 2016 01:14:13 -0800 (PST) Received: from localhost.localdomain (ppp91-76-173-134.pppoe.mtu-net.ru. [91.76.173.134]) by smtp.gmail.com with ESMTPSA id um4sm1258380lbb.1.2016.01.15.01.14.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Jan 2016 01:14:13 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Fri, 15 Jan 2016 12:14:07 +0300 Message-Id: <1452849247-32266-2-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1452849247-32266-1-git-send-email-maxim.uvarov@linaro.org> References: <1452849247-32266-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: timers patch Subject: [lng-odp] [API-NEXT PATCHv1 2/2] linux-generic/validation: wait for timer handler completiion after timer deletion X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Add test case based on previous seg fault code that pool destroy does not fail if there are some timers in fight. Signed-off-by: Maxim Uvarov --- platform/linux-generic/odp_timer.c | 15 ++++++++++++++- test/validation/timer/timer.c | 15 +++++++++++++++ test/validation/timer/timer.h | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c index b8f34fb..95fe130 100644 --- a/platform/linux-generic/odp_timer.c +++ b/platform/linux-generic/odp_timer.c @@ -259,6 +259,16 @@ static odp_timer_pool *odp_timer_pool_new( return tp; } +static void _finalyze_timers_handlers(void) +{ + struct timespec ts; + + ts.tv_sec = 0; + ts.tv_nsec = 50 * ODP_TIME_MSEC_IN_NS; + if (nanosleep(&ts, NULL) < 0) + ODP_ABORT("nanosleep failed"); +} + static void odp_timer_pool_del(odp_timer_pool *tp) { odp_spinlock_lock(&tp->lock); @@ -270,8 +280,11 @@ static void odp_timer_pool_del(odp_timer_pool *tp) /* timer pool which is still in use */ ODP_ABORT("%s: timers in use\n", tp->name); } - if (tp->param.clk_src == ODP_CLOCK_CPU) + if (tp->param.clk_src == ODP_CLOCK_CPU) { itimer_fini(tp); + _finalyze_timers_handlers(); + } + int rc = odp_shm_free(tp->shm); if (rc != 0) ODP_ABORT("Failed to free shared memory (%d)\n", rc); diff --git a/test/validation/timer/timer.c b/test/validation/timer/timer.c index db0a5ca..879ff67 100644 --- a/test/validation/timer/timer.c +++ b/test/validation/timer/timer.c @@ -22,6 +22,9 @@ /** @private Number of timers per thread */ #define NTIMERS 2000 +/** @private Dont wait for timers completition */ +static int dont_wait_for_timer_comp; + /** @private Barrier for thread synchronisation */ static odp_barrier_t test_barrier; @@ -277,6 +280,9 @@ static void _wait_for_timers_expiration(void) { struct timespec ts; + if (dont_wait_for_timer_comp) + return; + ts.tv_sec = 0; ts.tv_nsec = 50 * ODP_TIME_MSEC_IN_NS; if (nanosleep(&ts, NULL) < 0) @@ -539,11 +545,20 @@ void timer_test_odp_timer_all(void) CU_PASS("ODP timer test"); } +/* @private Timer test case entrypoint */ +void timer_test_destroy_pool_with_scheduled_timers(void) +{ + dont_wait_for_timer_comp = 1; + timer_test_odp_timer_all(); + dont_wait_for_timer_comp = 0; +} + odp_testinfo_t timer_suite[] = { ODP_TEST_INFO(timer_test_timeout_pool_alloc), ODP_TEST_INFO(timer_test_timeout_pool_free), ODP_TEST_INFO(timer_test_odp_timer_cancel), ODP_TEST_INFO(timer_test_odp_timer_all), + ODP_TEST_INFO(timer_test_destroy_pool_with_scheduled_timers), ODP_TEST_INFO_NULL, }; diff --git a/test/validation/timer/timer.h b/test/validation/timer/timer.h index 46ea8d7..4f805b4 100644 --- a/test/validation/timer/timer.h +++ b/test/validation/timer/timer.h @@ -14,6 +14,7 @@ void timer_test_timeout_pool_alloc(void); void timer_test_timeout_pool_free(void); void timer_test_odp_timer_cancel(void); void timer_test_odp_timer_all(void); +void timer_test_destroy_pool_with_scheduled_timers(void); /* test arrays: */ extern odp_testinfo_t timer_suite[];