From patchwork Fri Aug 28 21:18:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 52812 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id D000B22EBF for ; Fri, 28 Aug 2015 21:24:04 +0000 (UTC) Received: by labd1 with SMTP id d1sf22058470lab.0 for ; Fri, 28 Aug 2015 14:24:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=sMH0st8dc1I8RnLaQSzt/CYTZCOmrcdtPXfQAdenF5o=; b=blVYTqVHCBpigXdkywca/rSh9BpgC8WuZOEd3hPZgaUpWL3uQFME7VBE0SAg0HePcu UTNSC8vKnzKEUgWy01DuoVqe27WR7WGlGOGwspj7b+Vfk2dROERqct0RKcXZNeP0LiSE TIolVC5UZ4FjVhN5hkg+ujownMxmgHfETN1djbP6eIHKOomR8LySxAxiTFxhwC6ybWef cIO2kTsy250BXX2eLOBb/p3ifOm6VB6YA+W+95FxeysDCKZkPDbv4GLz0/ZyMHYPdG64 qxgtXNBL1qDF6S6YS4oqeKzBeQRhns9niZoUOd9WSLDhGlFr9KrQo3cAutNLiTMO3h11 xBSQ== X-Gm-Message-State: ALoCoQkQu6pTTHsTkw1WO8k8Gsix9dpbiBIgZYY17UvqRExvBXove99juv9WZ5Pjk5VJ7PDf6xw4 X-Received: by 10.180.35.162 with SMTP id i2mr1653306wij.6.1440797043800; Fri, 28 Aug 2015 14:24:03 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.185.67 with SMTP id fa3ls248471lac.76.gmail; Fri, 28 Aug 2015 14:24:03 -0700 (PDT) X-Received: by 10.152.23.38 with SMTP id j6mr5583912laf.47.1440797043524; Fri, 28 Aug 2015 14:24:03 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id z1si6893049lbw.159.2015.08.28.14.24.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Aug 2015 14:24:03 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by lanb10 with SMTP id b10so5159140lan.2 for ; Fri, 28 Aug 2015 14:24:03 -0700 (PDT) X-Received: by 10.112.77.10 with SMTP id o10mr5797861lbw.73.1440797043348; Fri, 28 Aug 2015 14:24:03 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.151.194 with SMTP id us2csp128105lbb; Fri, 28 Aug 2015 14:24:01 -0700 (PDT) X-Received: by 10.140.234.130 with SMTP id f124mr20529998qhc.103.1440797041600; Fri, 28 Aug 2015 14:24:01 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id j63si8759283qgf.123.2015.08.28.14.24.00; Fri, 28 Aug 2015 14:24:01 -0700 (PDT) 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; Received: by lists.linaro.org (Postfix, from userid 109) id C803A61CA0; Fri, 28 Aug 2015 21:24:00 +0000 (UTC) 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.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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 934D961D5F; Fri, 28 Aug 2015 21:19:28 +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 3087B61D3E; Fri, 28 Aug 2015 21:19:16 +0000 (UTC) Received: from mail-ob0-f175.google.com (mail-ob0-f175.google.com [209.85.214.175]) by lists.linaro.org (Postfix) with ESMTPS id 26F2D61CF9 for ; Fri, 28 Aug 2015 21:19:07 +0000 (UTC) Received: by obkg7 with SMTP id g7so52600279obk.3 for ; Fri, 28 Aug 2015 14:19:06 -0700 (PDT) X-Received: by 10.182.47.202 with SMTP id f10mr6822707obn.56.1440796746664; Fri, 28 Aug 2015 14:19:06 -0700 (PDT) Received: from Ubuntu15.localdomain (cpe-24-28-70-239.austin.res.rr.com. [24.28.70.239]) by smtp.gmail.com with ESMTPSA id k5sm4297965oev.16.2015.08.28.14.19.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Aug 2015 14:19:06 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Fri, 28 Aug 2015 16:18:54 -0500 Message-Id: <1440796737-8636-8-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1440796737-8636-1-git-send-email-bill.fischofer@linaro.org> References: <1440796737-8636-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv4 07/10] validation: schedule: test scheduler groups X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: 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" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: bill.fischofer@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.54 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Bill Fischofer --- test/validation/scheduler/scheduler.c | 188 ++++++++++++++++++++++++++++++++++ test/validation/scheduler/scheduler.h | 1 + 2 files changed, 189 insertions(+) diff --git a/test/validation/scheduler/scheduler.c b/test/validation/scheduler/scheduler.c index afd505f..1e9a669 100644 --- a/test/validation/scheduler/scheduler.c +++ b/test/validation/scheduler/scheduler.c @@ -35,6 +35,8 @@ #define ENABLE_EXCL_ATOMIC 1 #define MAGIC 0xdeadbeef +#define MAGIC1 0xdeadbeef +#define MAGIC2 0xcafef00d /* Test global variables */ typedef struct { @@ -162,6 +164,191 @@ void scheduler_test_queue_destroy(void) CU_ASSERT_FATAL(odp_pool_destroy(p) == 0); } +void scheduler_test_groups(void) +{ + odp_pool_t p; + odp_pool_param_t params; + odp_queue_param_t qp; + odp_queue_t queue_grp1, queue_grp2, from; + odp_buffer_t buf; + odp_event_t ev; + uint32_t *u32; + int i, j, rc; + odp_schedule_sync_t sync[] = {ODP_SCHED_SYNC_NONE, + ODP_SCHED_SYNC_ATOMIC, + ODP_SCHED_SYNC_ORDERED}; + int thr_id = odp_thread_id(); + odp_thrmask_t zeromask, mymask, testmask; + odp_schedule_group_t mygrp1, mygrp2, lookup; + + odp_thrmask_zero(&zeromask); + odp_thrmask_zero(&mymask); + odp_thrmask_set(&mymask, thr_id); + + /* Can't find a group before we create it */ + lookup = odp_schedule_group_lookup("Test Group 1"); + CU_ASSERT(lookup == ODP_SCHED_GROUP_INVALID); + + /* Now create the group */ + mygrp1 = odp_schedule_group_create("Test Group 1", &zeromask); + CU_ASSERT_FATAL(mygrp1 != ODP_SCHED_GROUP_INVALID); + + /* Verify we can now find it */ + lookup = odp_schedule_group_lookup("Test Group 1"); + CU_ASSERT(lookup == mygrp1); + + /* Threadmask should be retrievable and be what we expect */ + rc = odp_schedule_group_thrmask(mygrp1, &testmask); + CU_ASSERT(rc == 0); + CU_ASSERT(!odp_thrmask_isset(&testmask, thr_id)); + + /* Now join the group and verify we're part of it */ + rc = odp_schedule_group_join(mygrp1, &mymask); + CU_ASSERT(rc == 0); + + rc = odp_schedule_group_thrmask(mygrp1, &testmask); + CU_ASSERT(rc == 0); + CU_ASSERT(odp_thrmask_isset(&testmask, thr_id)); + + /* We can't join or leave an unknown group */ + rc = odp_schedule_group_join(ODP_SCHED_GROUP_INVALID, &mymask); + CU_ASSERT(rc != 0); + + rc = odp_schedule_group_leave(ODP_SCHED_GROUP_INVALID, &mymask); + CU_ASSERT(rc != 0); + + /* But we can leave our group */ + rc = odp_schedule_group_leave(mygrp1, &mymask); + CU_ASSERT(rc == 0); + + rc = odp_schedule_group_thrmask(mygrp1, &testmask); + CU_ASSERT(rc == 0); + CU_ASSERT(!odp_thrmask_isset(&testmask, thr_id)); + + /* We shouldn't be able to find our second group before creating it */ + lookup = odp_schedule_group_lookup("Test Group 2"); + CU_ASSERT(lookup == ODP_SCHED_GROUP_INVALID); + + /* Now create it and verify we can find it */ + mygrp2 = odp_schedule_group_create("Test Group 2", &zeromask); + CU_ASSERT_FATAL(mygrp2 != ODP_SCHED_GROUP_INVALID); + + lookup = odp_schedule_group_lookup("Test Group 2"); + CU_ASSERT(lookup == mygrp2); + + /* Verify we're not part of it */ + rc = odp_schedule_group_thrmask(mygrp2, &testmask); + CU_ASSERT(rc == 0); + CU_ASSERT(!odp_thrmask_isset(&testmask, thr_id)); + + /* Now join the group and verify we're part of it */ + rc = odp_schedule_group_join(mygrp2, &mymask); + CU_ASSERT(rc == 0); + + rc = odp_schedule_group_thrmask(mygrp2, &testmask); + CU_ASSERT(rc == 0); + CU_ASSERT(odp_thrmask_isset(&testmask, thr_id)); + + /* Now verify scheduler adherence to groups */ + odp_queue_param_init(&qp); + odp_pool_param_init(¶ms); + params.buf.size = 100; + params.buf.align = 0; + params.buf.num = 2; + params.type = ODP_POOL_BUFFER; + + p = odp_pool_create("sched_group_pool", ¶ms); + + CU_ASSERT_FATAL(p != ODP_POOL_INVALID); + + for (i = 0; i < 3; i++) { + qp.sched.prio = ODP_SCHED_PRIO_DEFAULT; + qp.sched.sync = sync[i]; + qp.sched.group = mygrp1; + + /* Create and populate a group in group 1 */ + queue_grp1 = odp_queue_create("sched_group_test_queue 1", + ODP_QUEUE_TYPE_SCHED, &qp); + CU_ASSERT_FATAL(queue_grp1 != ODP_QUEUE_INVALID); + CU_ASSERT_FATAL(odp_queue_sched_group(queue_grp1) == mygrp1); + + buf = odp_buffer_alloc(p); + + CU_ASSERT_FATAL(buf != ODP_BUFFER_INVALID); + + u32 = odp_buffer_addr(buf); + u32[0] = MAGIC1; + + ev = odp_buffer_to_event(buf); + if (!(CU_ASSERT(odp_queue_enq(queue_grp1, ev) == 0))) + odp_buffer_free(buf); + + /* Now create and populate a queue in group 2 */ + qp.sched.group = mygrp2; + queue_grp2 = odp_queue_create("sched_group_test_queue_2", + ODP_QUEUE_TYPE_SCHED, &qp); + CU_ASSERT_FATAL(queue_grp2 != ODP_QUEUE_INVALID); + CU_ASSERT_FATAL(odp_queue_sched_group(queue_grp2) == mygrp2); + + buf = odp_buffer_alloc(p); + CU_ASSERT_FATAL(buf != ODP_BUFFER_INVALID); + + u32 = odp_buffer_addr(buf); + u32[0] = MAGIC2; + + ev = odp_buffer_to_event(buf); + if (!(CU_ASSERT(odp_queue_enq(queue_grp2, ev) == 0))) + odp_buffer_free(buf); + + /* Scheduler should give us the event from Group 2 */ + ev = odp_schedule(&from, ODP_SCHED_WAIT); + CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID); + CU_ASSERT_FATAL(from == queue_grp2); + + buf = odp_buffer_from_event(ev); + u32 = odp_buffer_addr(buf); + + CU_ASSERT_FATAL(u32[0] == MAGIC2); + + odp_buffer_free(buf); + + /* Scheduler should not return anything now since we're + * not in Group 1 and Queue 2 is empty. Do this several + * times to confirm. + */ + + for (j = 0; j < 10; j++) { + ev = odp_schedule(&from, ODP_SCHED_NO_WAIT); + CU_ASSERT_FATAL(ev == ODP_EVENT_INVALID) + } + + /* Now join group 1 and verify we can get the event */ + rc = odp_schedule_group_join(mygrp1, &mymask); + CU_ASSERT_FATAL(rc == 0); + + ev = odp_schedule(&from, ODP_SCHED_WAIT); + CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID); + CU_ASSERT_FATAL(from == queue_grp1); + + buf = odp_buffer_from_event(ev); + u32 = odp_buffer_addr(buf); + + CU_ASSERT_FATAL(u32[0] == MAGIC1); + + odp_buffer_free(buf); + + /* Leave group 1 for next pass */ + rc = odp_schedule_group_leave(mygrp1, &mymask); + CU_ASSERT_FATAL(rc == 0); + + /* Done with queues for this round */ + CU_ASSERT_FATAL(odp_queue_destroy(queue_grp1) == 0); + CU_ASSERT_FATAL(odp_queue_destroy(queue_grp2) == 0); + } + + CU_ASSERT_FATAL(odp_pool_destroy(p) == 0); +} + static void *schedule_common_(void *arg) { thread_args_t *args = (thread_args_t *)arg; @@ -780,6 +967,7 @@ CU_TestInfo scheduler_suite[] = { {"schedule_wait_time", scheduler_test_wait_time}, {"schedule_num_prio", scheduler_test_num_prio}, {"schedule_queue_destroy", scheduler_test_queue_destroy}, + {"schedule_groups", scheduler_test_groups}, {"schedule_1q_1t_n", scheduler_test_1q_1t_n}, {"schedule_1q_1t_a", scheduler_test_1q_1t_a}, {"schedule_1q_1t_o", scheduler_test_1q_1t_o}, diff --git a/test/validation/scheduler/scheduler.h b/test/validation/scheduler/scheduler.h index 31f02ca..eab8787 100644 --- a/test/validation/scheduler/scheduler.h +++ b/test/validation/scheduler/scheduler.h @@ -13,6 +13,7 @@ void scheduler_test_wait_time(void); void scheduler_test_num_prio(void); void scheduler_test_queue_destroy(void); +void scheduler_test_groups(void); void scheduler_test_1q_1t_n(void); void scheduler_test_1q_1t_a(void); void scheduler_test_1q_1t_o(void);