From patchwork Wed Aug 26 23:41:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 52746 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by patches.linaro.org (Postfix) with ESMTPS id 9AB4D22E9E for ; Wed, 26 Aug 2015 23:45:36 +0000 (UTC) Received: by lbcue2 with SMTP id ue2sf820842lbc.1 for ; Wed, 26 Aug 2015 16:45:35 -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=iSLHve4+i1OHYIIXeQIMEFx+gvasEFPZRKc3bq4u1B76dpqpusPywVCV4EHDQSCjR3 3hp0zRe6neu+7XinlTR/kJ4hm6PUz0ym5aZO1Sr/ReHu6QtGLZRPUVtKnyXJBudndOYU x7RmUr8N/blOgeQmGpSEee2kwlu0n9nJmv+hMcT2STmgsde11MkS7xuTcF8GeKkxM6g8 zQeo29IvAazYtWnErYCX83tiyTSe72x2VCuOblP10aLlNeQR+WY/DU+aVY9pTS5kbffB c8KMLEjs43f44VhelBgzmjB+gmRuuaQ1MRU8Z0d6Hmmz0SlIQ3x0dujOXN+tsQ3lzyBA RUtA== X-Gm-Message-State: ALoCoQlxR43yssKDq3+SaVc4/8SXaIteE27a5IStR1OYJ/s6WuHY9j2z3nSELs3NAFksXaHJd3hH X-Received: by 10.152.1.164 with SMTP id 4mr361664lan.2.1440632735592; Wed, 26 Aug 2015 16:45:35 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.4.227 with SMTP id n3ls26537lan.0.gmail; Wed, 26 Aug 2015 16:45:35 -0700 (PDT) X-Received: by 10.152.22.168 with SMTP id e8mr1053382laf.40.1440632735458; Wed, 26 Aug 2015 16:45:35 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id zx2si278488lbb.82.2015.08.26.16.45.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2015 16:45:35 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by labns7 with SMTP id ns7so1760650lab.0 for ; Wed, 26 Aug 2015 16:45:35 -0700 (PDT) X-Received: by 10.152.5.228 with SMTP id v4mr1060332lav.36.1440632735335; Wed, 26 Aug 2015 16:45:35 -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.162.200 with SMTP id yc8csp4257764lbb; Wed, 26 Aug 2015 16:45:34 -0700 (PDT) X-Received: by 10.50.62.243 with SMTP id b19mr7585070igs.88.1440632733622; Wed, 26 Aug 2015 16:45:33 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id l10si4689607igx.84.2015.08.26.16.45.32; Wed, 26 Aug 2015 16:45:33 -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 344A96182D; Wed, 26 Aug 2015 23:45:32 +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_H3, RCVD_IN_MSPIKE_WL, 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 D3F76620F0; Wed, 26 Aug 2015 23:42:30 +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 13A78620F0; Wed, 26 Aug 2015 23:42:23 +0000 (UTC) Received: from mail-oi0-f50.google.com (mail-oi0-f50.google.com [209.85.218.50]) by lists.linaro.org (Postfix) with ESMTPS id 5ADD862048 for ; Wed, 26 Aug 2015 23:41:44 +0000 (UTC) Received: by oiev193 with SMTP id v193so1768358oie.3 for ; Wed, 26 Aug 2015 16:41:44 -0700 (PDT) X-Received: by 10.202.187.87 with SMTP id l84mr771138oif.31.1440632503825; Wed, 26 Aug 2015 16:41:43 -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 np9sm194060obb.14.2015.08.26.16.41.43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Aug 2015 16:41:43 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Wed, 26 Aug 2015 18:41:30 -0500 Message-Id: <1440632493-31734-8-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1440632493-31734-1-git-send-email-bill.fischofer@linaro.org> References: <1440632493-31734-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv3 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.50 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);