From patchwork Fri Jul 23 19:16:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Kacur X-Patchwork-Id: 485509 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 480D0C4320E for ; Fri, 23 Jul 2021 19:16:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2ABE660EB0 for ; Fri, 23 Jul 2021 19:16:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229839AbhGWSgC (ORCPT ); Fri, 23 Jul 2021 14:36:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbhGWSgB (ORCPT ); Fri, 23 Jul 2021 14:36:01 -0400 Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CA81C061575 for ; Fri, 23 Jul 2021 12:16:35 -0700 (PDT) Received: by mail-qk1-x735.google.com with SMTP id x3so2384157qkl.6 for ; Fri, 23 Jul 2021 12:16:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uNq/B4U2dBc8G6K/XCaGRWYL5akaMP5oc1ffDTFl8Dk=; b=qhBkh93rKHU0gPqujA7AP0HQBxTix4ooxhTT1WX0AyJJFHGSKcSqtfVqNlG78LJ75t ++rg/1g/wL2qdnDt+Y3sXHbiLd/+f3hMxmKhsqVjpbhX3SNtSueBuiZJjSkIs87u+eYh PqpqPJ+LzvETHYJCOmDcLo1JUc9QUBSTKi84wEPcHXDw91GFUSWwrdH1Dk1EikW+crXa AKoeHUY3iNTjHrUTq8IRoK9QoNOPZUQIpzBAWAEDK4ZqUackMB48mrIt0Tz0DvtJ4cQB kxrCI0HohHkFAWeF328wkMZoKJOYrgQ7P6IFPMQrAazm/rgvwkKDYVc4Dw/dRllyPe5Q aGAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=uNq/B4U2dBc8G6K/XCaGRWYL5akaMP5oc1ffDTFl8Dk=; b=EKoU5kgPlfnbBmTvgZ3RCQ2WwOZD3IKpCjmRFrAuSNIAyu4k0Oe+lqULPGnkcTHtEz ABIh2WYP64+CzoN1cP6kWnzN95pyup/0Si5C+1VGLvRPQjgoswklORcbPBaV1jRI0ZrZ TqPUNEBavq2LcqZcZ1vcj7Lx2f4ewhQ4CDBqDDxEnkBmKhgKc2zjBoqUPL3IECkDoABF Vaf8nnYEdPrwVmf0LiG0PgYG/clXxWu23/WzEwAam7ifdnSQjUyCE+8W/+/riWxPcpOT YOIMCbIF5mDUqHdY5hsAns+CKwq7zX945aNwV2tFEphWty7gGe/Asudx/tUyE2AkFTR/ Rjaw== X-Gm-Message-State: AOAM532Gdws1PcQ4GfUsyBQuucgBmLl3XQ6hl6A+8BZShISHmNQZq48P T8Eu0H5HAbK5Qq+lvQYWAwgWqhCQNwSoBQ== X-Google-Smtp-Source: ABdhPJyvdFl6TiuAZMLju0+4d1iwEBTzrL25netpE39puaqbPxI5DXYhGnJlxzKfXCSI+LbJ2J6h6A== X-Received: by 2002:a37:44cb:: with SMTP id r194mr6122896qka.436.1627067794107; Fri, 23 Jul 2021 12:16:34 -0700 (PDT) Received: from localhost.localdomain (bras-base-rdwyon0600w-grc-07-184-147-141-243.dsl.bell.ca. [184.147.141.243]) by smtp.gmail.com with ESMTPSA id a3sm7379274qtx.56.2021.07.23.12.16.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jul 2021 12:16:33 -0700 (PDT) Sender: John Kacur From: John Kacur To: RT Cc: Clark Williams , Daniel Wagner , Daniel Bristot de Oliveria , Juri Lelli , Steven Rostedt , John Kacur Subject: [PATCH 1/2] sched_deadline: Accommodate new location of HRTICK file in kernel Date: Fri, 23 Jul 2021 15:16:08 -0400 Message-Id: <20210723191609.14072-2-jkacur@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723191609.14072-1-jkacur@redhat.com> References: <20210723191609.14072-1-jkacur@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Newer kernels rename /sys/kernel/debug/sched_features to /sys/kernel/debug/sched/features Modify sched_deadline tests to look for the new file and if that fails look for the old file name These functions are based on ones in stalld, and stalld itself has functions based on the sched_deadline programs in rt-tests Signed-off-by: John Kacur --- src/sched_deadline/cyclicdeadline.c | 65 ++++++++++++++++++++++------- src/sched_deadline/deadline_test.c | 61 +++++++++++++++++++++------ 2 files changed, 100 insertions(+), 26 deletions(-) diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c index 8447424273ee..4a38ec2274c9 100644 --- a/src/sched_deadline/cyclicdeadline.c +++ b/src/sched_deadline/cyclicdeadline.c @@ -230,12 +230,53 @@ found: mark_fd = open(files, O_WRONLY); } +/* + * Return true if file exists + */ +static int check_file_exists(char *path) +{ + int ret; + struct stat st; + + ret = !stat(path, &st); + + return ret; + +} + +/* + * Return 0 on success + */ + +static int fill_sched_features(char *path) +{ + int ret; + const char *debugfs; + + debugfs = find_debugfs(); + if (strlen(debugfs) == 0) + return -1; + + snprintf(path, MAX_PATH, "%s/sched/features", debugfs); + ret = check_file_exists(path); + if (ret) + return 0; + + snprintf(path, MAX_PATH, "%s/sched_features", debugfs); + ret = check_file_exists(path); + if (ret) + return 0; + + memset(path, 0, MAX_PATH); + + return ret; + +} + static int setup_hr_tick(void) { - const char *debugfs = find_debugfs(); - char files[strlen(debugfs) + strlen("/sched_features") + 1]; + char path[MAX_PATH]; char buf[500]; - struct stat st; static int set = 0; char *p; int ret; @@ -244,27 +285,23 @@ static int setup_hr_tick(void) if (set) return 1; - set = 1; - if (strlen(debugfs) == 0) - return 0; - - sprintf(files, "%s/sched_features", debugfs); - ret = stat(files, &st); - if (ret < 0) + ret = fill_sched_features(path); + if (ret) return 0; - fd = open(files, O_RDWR); - perror(files); - if (fd < 0) + fd = open(path, O_RDWR); + if (fd < 0) { + perror(path); return 0; + } len = sizeof(buf); ret = read(fd, buf, len); if (ret < 0) { - perror(files); + perror(path); close(fd); return 0; } diff --git a/src/sched_deadline/deadline_test.c b/src/sched_deadline/deadline_test.c index 395c2370f69a..c1e890319895 100644 --- a/src/sched_deadline/deadline_test.c +++ b/src/sched_deadline/deadline_test.c @@ -368,6 +368,49 @@ found: mark_fd = open(files, O_WRONLY); } +/* + * Return true if file exists + */ +static int check_file_exists(char *path) +{ + int ret; + struct stat st; + + ret = !stat(path, &st); + + return ret; + +} + +/* + * Return 0 on success + */ + +static int fill_sched_features(char *path) +{ + int ret; + const char *debugfs; + + debugfs = find_debugfs(); + if (strlen(debugfs) == 0) + return -1; + + snprintf(path, MAX_PATH, "%s/sched/features", debugfs); + ret = check_file_exists(path); + if (ret) + return 0; + + snprintf(path, MAX_PATH, "%s/sched_features", debugfs); + ret = check_file_exists(path); + if (ret) + return 0; + + memset(path, 0, MAX_PATH); + + return ret; + +} + /** * setup_hr_tick - Enable the HRTICK in sched_features (if available) * @@ -381,10 +424,8 @@ found: */ static int setup_hr_tick(void) { - const char *debugfs = find_debugfs(); - char files[strlen(debugfs) + strlen("/sched_features") + 1]; + char path[MAX_PATH]; char buf[500]; - struct stat st; static int set = 0; char *p; int ret; @@ -396,17 +437,13 @@ static int setup_hr_tick(void) set = 1; - if (strlen(debugfs) == 0) - return 0; - - sprintf(files, "%s/sched_features", debugfs); - ret = stat(files, &st); - if (ret < 0) + ret = fill_sched_features(path); + if (ret) return 0; - fd = open(files, O_RDWR); + fd = open(path, O_RDWR); if (fd < 0) { - perror(files); + perror(path); return 0; } @@ -414,7 +451,7 @@ static int setup_hr_tick(void) ret = read(fd, buf, len); if (ret < 0) { - perror(files); + perror(path); close(fd); return 0; } From patchwork Fri Jul 23 19:16:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Kacur X-Patchwork-Id: 484946 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E97DFC432BE for ; Fri, 23 Jul 2021 19:16:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C86CA60E9C for ; Fri, 23 Jul 2021 19:16:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229874AbhGWSgD (ORCPT ); Fri, 23 Jul 2021 14:36:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbhGWSgC (ORCPT ); Fri, 23 Jul 2021 14:36:02 -0400 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9038C061575 for ; Fri, 23 Jul 2021 12:16:35 -0700 (PDT) Received: by mail-qt1-x835.google.com with SMTP id a19so2401509qtx.1 for ; Fri, 23 Jul 2021 12:16:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VwmaNC18sXscCMtXWmWzOlc9azNKE3E4LfYxFFgg53A=; b=qfkW8uZfY/W0s4NLVI8b+3lvmvbuUpFfmST6SaQj0fWmirC1ipLluXRF8JcWkBUY1X pNud4r3TP3kqK0r8F1qGSZRDcZRaWmCE2o4wpa2yhd0JY6YHuJ9Z8KGg/QsInmlk3Q15 k5Pdr3PMyR78Lw2lR6GxuqNHQhlJ8mUL2gz1TDU6yAIsU+pjrzFBUoVNG0BVsBBLQYzz XL4D32j9RIFs9EAxebqNJHQDhTGqmsOy9ceFFOsj7fizJNNyYwugTRSNf7HHW1m32yvt 5ITwdhaa+aOXdMJ9flPLZ2+Ajl9A7dV7d/gmCu8KkR09kW6RkfZ6ofM8WPuwE0VxkPmn sc1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=VwmaNC18sXscCMtXWmWzOlc9azNKE3E4LfYxFFgg53A=; b=I4sBjbqFqyRIFrHZeZs8JbLHXGovhsP1EDJI4TL3Hy7kNDTja0DD2PgG3yIKDT3v00 FtG/wEUdFL6THKCXYgFWwSaIRSfegNIKjnRXX0R0Q9IbXm4kfLzHebF7yjsU+WDqea0M d8Ldx0Kkum1DZFsHmea3P/HwiaUnfB+Q8iZR6GQZEYVuvLusvF01SLnEsYXgmAllUnXW ugQxi1whZFkAWGykThj68ap3CQsuR7pSa8djKGVpdEq48/x1AWWb3GaKojsiaGpe0KWn Bd0DSeS4hI725C02/EIm2yEyY1hSYSrA21gW7kk/mSurGdPGzv5gStWvT2uk8Rxs7ycK bAag== X-Gm-Message-State: AOAM5326fa+xhYzZYcnAHyme3sla9b2HYKPpoIYbggo0Sm8AaqB7KRpT B8qDx6/dRX+Tn/zx4YsXPxUxFrBvF5Ld1g== X-Google-Smtp-Source: ABdhPJx8sH9RI+OYA4f1nRL7sjZBsCSn38xLzimh4xwdpS2HDBNw2ztOoYpJHrXLsrgQRNbgKVh5ww== X-Received: by 2002:a05:622a:18a:: with SMTP id s10mr5238815qtw.269.1627067794832; Fri, 23 Jul 2021 12:16:34 -0700 (PDT) Received: from localhost.localdomain (bras-base-rdwyon0600w-grc-07-184-147-141-243.dsl.bell.ca. [184.147.141.243]) by smtp.gmail.com with ESMTPSA id a3sm7379274qtx.56.2021.07.23.12.16.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jul 2021 12:16:34 -0700 (PDT) Sender: John Kacur From: John Kacur To: RT Cc: Clark Williams , Daniel Wagner , Daniel Bristot de Oliveria , Juri Lelli , Steven Rostedt , John Kacur Subject: [PATCH 2/2] sched_deadline: Use HRTICK_DL for sched_deadline tests Date: Fri, 23 Jul 2021 15:16:09 -0400 Message-Id: <20210723191609.14072-3-jkacur@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723191609.14072-1-jkacur@redhat.com> References: <20210723191609.14072-1-jkacur@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org If the HRTICK_DL feature is available, use it for the sched_deadline tests, otherwise fall back to HRTICK This code is based on changes in stalld - which in turn was based on these sched_deadline tests Signed-off-by: John Kacur --- src/sched_deadline/cyclicdeadline.c | 27 ++++++++++++++++++++++----- src/sched_deadline/deadline_test.c | 28 +++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c index 4a38ec2274c9..4860a40f5e6b 100644 --- a/src/sched_deadline/cyclicdeadline.c +++ b/src/sched_deadline/cyclicdeadline.c @@ -278,6 +278,7 @@ static int setup_hr_tick(void) char path[MAX_PATH]; char buf[500]; static int set = 0; + int hrtick_dl = 0; char *p; int ret; int len; @@ -311,18 +312,34 @@ static int setup_hr_tick(void) ret = 1; - p = strstr(buf, "HRTICK"); - if (p + 3 >= buf) { + p = strstr(buf, "HRTICK_DL"); + if (p && p - 3 >= buf) { + hrtick_dl = 1; p -= 3; - if (strncmp(p, "NO_HRTICK", 9) == 0) { - ret = write(fd, "HRTICK", 6); - if (ret != 6) + if (strncmp(p, "NO_HRTICK_DL", 12) == 0) { + ret = write(fd, "HRTICK_DL", 9); + if (ret != 9) ret = 0; else ret = 1; } } + /* Backwards compatibility for kernel that only have HRTICK */ + if (!hrtick_dl) { + p = strstr(buf, "HRTICK"); + if (p && p - 3 >= buf) { + p -=3; + if (strncmp(p, "NO_HRTICK", 9) == 0) { + ret = write(fd, "HRTICK", 6); + if (ret != 6) + ret = 0; + else + ret = 1; + } + } + } + close(fd); return ret; } diff --git a/src/sched_deadline/deadline_test.c b/src/sched_deadline/deadline_test.c index c1e890319895..a48c231c1281 100644 --- a/src/sched_deadline/deadline_test.c +++ b/src/sched_deadline/deadline_test.c @@ -427,6 +427,7 @@ static int setup_hr_tick(void) char path[MAX_PATH]; char buf[500]; static int set = 0; + int hrtick_dl = 0; char *p; int ret; int len; @@ -461,18 +462,35 @@ static int setup_hr_tick(void) ret = 1; - p = strstr(buf, "HRTICK"); - if (p + 3 >= buf) { + p = strstr(buf, "HRTICK_DL"); + if (p && p - 3 >= buf) { + hrtick_dl = 1; p -= 3; - if (strncmp(p, "NO_HRTICK", 9) == 0) { - ret = write(fd, "HRTICK", 6); - if (ret != 6) + if (strncmp(p, "NO_HRTICK_DL", 12) == 0) { + ret = write(fd, "HRTICK_DL", 9); + if (ret != 9) ret = 0; else ret = 1; } } + /* Backwards compatibility for kernel that only have HRTICK */ + if (!hrtick_dl) { + p = strstr(buf, "HRTICK"); + if (p && p - 3 >= buf) { + p -=3; + if (strncmp(p, "NO_HRTICK", 9) == 0) { + ret = write(fd, "HRTICK", 6); + if (ret != 6) + ret = 0; + else + ret = 1; + } + } + } + + close(fd); return ret; }