From patchwork Mon Mar 2 21:44:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Kacur X-Patchwork-Id: 213190 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=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 7E6ABC3F2D1 for ; Mon, 2 Mar 2020 21:44:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4665620732 for ; Mon, 2 Mar 2020 21:44:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W6ck+kLd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726910AbgCBVoo (ORCPT ); Mon, 2 Mar 2020 16:44:44 -0500 Received: from mail-qt1-f194.google.com ([209.85.160.194]:41915 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726232AbgCBVoo (ORCPT ); Mon, 2 Mar 2020 16:44:44 -0500 Received: by mail-qt1-f194.google.com with SMTP id l21so1242041qtr.8 for ; Mon, 02 Mar 2020 13:44:44 -0800 (PST) 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=kxJMYlr0unCfgSF1dH4l7Ll4cSqbfMDatVMrWLNzVek=; b=W6ck+kLd1v2uYCwC2xpUO26A12KmnOVaAHhmFW9dyiGW6VAkCT/1Qh33T8Eal7Q7pi zthvOF73oxGaDUIZ1daqldjP1JmiskJ7kkv9mp2/ZihjI1fXB6fhM2nkonl0wZZhKwEd nv6MXClSIxQuh+o5txng5i1rDJ4jm/ZrGjBc7iJeLdlNrv0x0bhl6jvUcEqi7iKoFQ2o 1GxwAox71EglLpDOqroLy2kJvq2N7d3WqYiV34VD2B5g29aQejtuvJKoM7/avbLj8RGz 0BWD/DhMDRmIrJtJbpyszRYa2L0My39cs6nbR8KLTHabockRcXhBlmCPNgdhKcuTjktr hMwQ== 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=kxJMYlr0unCfgSF1dH4l7Ll4cSqbfMDatVMrWLNzVek=; b=idpXPyQ9QTgHgZkEbr/e+7QyBjjJ01BgS/V+83hGsQUguQRL5xZPrR63vJ9pUTqeJR wtv3r4LCpHIyPjP5r9kYiEx2XllRE+DVVxQTOIWkmXOvjUrcYkjUawdT6EWK5AXJ5yT0 FkRYSOgJ1weKG3V8GznGiaQhjV/zxu9NXeAGS3C9a7VBabq/nuOG0qs1YnrEgrgUufY4 or1Dt7vlnLxaidmcezSg3VkkqYwUpV5GHklq4KMgCzItg9bfiPsSzMplAokKA5zTWDPH E+JfnWnZWJcRy0/q+iCEW+tWQtJ750xAV7v+7lIOcdEMN9ruF2wQHkczdkhgmxCYA9OF xVKA== X-Gm-Message-State: ANhLgQ3DSwue39gNAS+n+MWpVpId4sp3lge/2HXXkREVThC7xuLbVvR9 W4ua0PfAJsQ69BuK9E2P0DEsTTDoGvk= X-Google-Smtp-Source: ADFU+vsYYXuGkof54bzKH2azxhhmZXaODXN8lZxemV5dFZYM//9YA4cbmhzGMeP07kUiGXxEju/cWw== X-Received: by 2002:aed:2944:: with SMTP id s62mr1603022qtd.289.1583185483348; Mon, 02 Mar 2020 13:44:43 -0800 (PST) Received: from planxty.redhat.com (rdwyon0600w-lp130-03-64-231-46-127.dsl.bell.ca. [64.231.46.127]) by smtp.gmail.com with ESMTPSA id n8sm10858796qkn.49.2020.03.02.13.44.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Mar 2020 13:44:42 -0800 (PST) From: John Kacur To: rt-users Cc: Clark Williams , John Kacur Subject: [PATCH 2/6] rt-tests: cyclictest: Report all errors from pthread_setaffinity_np Date: Mon, 2 Mar 2020 16:44:26 -0500 Message-Id: <20200302214430.15825-3-jkacur@redhat.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302214430.15825-1-jkacur@redhat.com> References: <20200302214430.15825-1-jkacur@redhat.com> MIME-Version: 1.0 Sender: linux-rt-users-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org On error pthread_setaffinity_np returns a non-zero number. Make sure cyclictest prints a warning in all such cases. Signed-off-by: John Kacur --- src/cyclictest/cyclictest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index c66755dd4d87..bd1fcd1092aa 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -650,7 +650,7 @@ static void *timerthread(void *param) CPU_ZERO(&mask); CPU_SET(par->cpu, &mask); thread = pthread_self(); - if (pthread_setaffinity_np(thread, sizeof(mask), &mask) == -1) + if (pthread_setaffinity_np(thread, sizeof(mask), &mask) != 0) warn("Could not set CPU affinity to CPU #%d\n", par->cpu); } From patchwork Mon Mar 2 21:44:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Kacur X-Patchwork-Id: 213189 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=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 38019C3F2D7 for ; Mon, 2 Mar 2020 21:44:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0991020732 for ; Mon, 2 Mar 2020 21:44:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IUBSu8Bq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726969AbgCBVoq (ORCPT ); Mon, 2 Mar 2020 16:44:46 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:37081 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726695AbgCBVoq (ORCPT ); Mon, 2 Mar 2020 16:44:46 -0500 Received: by mail-qk1-f194.google.com with SMTP id m9so1351962qke.4 for ; Mon, 02 Mar 2020 13:44:45 -0800 (PST) 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=Ter0RuiKxIJWmkmNVK7sC0QBAqg66x2Dni6EBTpo6Y4=; b=IUBSu8BqLe2LcFFt7D6k6C+S8Jt6mS2utcsSUMLgfzTfXpvhmkwI85Ls33enWFSOFj 42OsOKYh+V8L0dNg002yl34F5GgP49/J+Ow9gvCGeoSPHdA2+Jvl2/IF3AzIdsVDkuSy kI5tGW/M4ADWbIsbOF1nfVZ6v8VAuhq44BDQpcJfBWqGFdMQd7EH1f3RYuOOHceZxi7A WMkFr617HPzAFaVZr5dL4bz967h+1FIlF4kTtKOcvxeaoT+2Pox6uIRvg2iQXWPpg/5s 4xUEYHMYJCrIbYcVXRID1axtQNlG/zFUXwBHbEm2U0SSu2gcPE4V/R8AohLsPNwiJpcs 0lyQ== 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=Ter0RuiKxIJWmkmNVK7sC0QBAqg66x2Dni6EBTpo6Y4=; b=QOJZie09LQEu8BJfbFUcQ73PUUkC+dSDGQuJTAcPoDjAwFWw6NDHAqeb0ZNmEMNdOq ZFWg+hvvUZq2PIRRwjedIxVXEqgW4CjrTlD8EzRMwiR90cQejCyIt2T/ZoMlEpNhncq2 w096bGiKwIAddZKuyuGOyn99+UUAMuXJ0WgSq10azqQzy8dEj7hE27Q81lRFocjtZ8Zc AVKkjYq0/KElqH35XaQjixa9FItSCsnTYYdzJdWXcezwElysQLL8lAdDezqXeYsDvZNk y26S4dh8pskY/UcwAZVt+uFXN2MBJz2BAcVr8fKjfKQSQZXLo8+nXCXYx39oZs4fpe/G M5uQ== X-Gm-Message-State: ANhLgQ3CdcQAT8vW6oXUXoUjvQt5Bbux14nh32ZRjqhA0fEzTu1fKlep QriP8JHu7bTfTTmzdnw0rz/5Iay5+OY= X-Google-Smtp-Source: ADFU+vs4EaqRmZD4mw8pV2G7AkZnBYcFQpq0WT6QymTYWjPBEfSUOi0cJgHn3A/mgqERrKCTfHrIIg== X-Received: by 2002:a37:4bd3:: with SMTP id y202mr1311246qka.32.1583185485246; Mon, 02 Mar 2020 13:44:45 -0800 (PST) Received: from planxty.redhat.com (rdwyon0600w-lp130-03-64-231-46-127.dsl.bell.ca. [64.231.46.127]) by smtp.gmail.com with ESMTPSA id n8sm10858796qkn.49.2020.03.02.13.44.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Mar 2020 13:44:44 -0800 (PST) From: John Kacur To: rt-users Cc: Clark Williams , John Kacur Subject: [PATCH 4/6] rt-tests: cyclictest: Fix parsing affinity with leading exclamation mark Date: Mon, 2 Mar 2020 16:44:28 -0500 Message-Id: <20200302214430.15825-5-jkacur@redhat.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302214430.15825-1-jkacur@redhat.com> References: <20200302214430.15825-1-jkacur@redhat.com> MIME-Version: 1.0 Sender: linux-rt-users-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org The case in which the user specifies the affinity with a space and a leading exclamation mark was not working. For example ./cyclictest -t -a'!4-5' was working correctly, but the following was not. ./cyclictest -t -a '!4-5' Fix this by recognizing this input as a non-error case. Signed-off-by: John Kacur --- src/cyclictest/cyclictest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index 1d2962fda777..18c383689dc2 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -1199,7 +1199,7 @@ static void process_options (int argc, char *argv[], int max_cpus) if (optarg != NULL) { parse_cpumask(optarg, max_cpus); setaffinity = AFFINITY_SPECIFIED; - } else if (optind X-Patchwork-Id: 213188 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=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 2533FC3F2D1 for ; Mon, 2 Mar 2020 21:44:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E905F22B48 for ; Mon, 2 Mar 2020 21:44:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NFNEuNOm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727103AbgCBVos (ORCPT ); Mon, 2 Mar 2020 16:44:48 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:40543 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727067AbgCBVos (ORCPT ); Mon, 2 Mar 2020 16:44:48 -0500 Received: by mail-qt1-f193.google.com with SMTP id o10so1243258qtr.7 for ; Mon, 02 Mar 2020 13:44:47 -0800 (PST) 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=R1n6pw/8iPjNaOQsjF7JGDkoGDmdi5XsnqPrMHVoS9w=; b=NFNEuNOmbO6MbGyZ07Wk7A+7HmheiLo84kLHRB0HYVgdfcREnGjoZt2SqaUt/pwBzS 2GPX/ZswwwzAsYjN/Ac9mNRAckMbU6oPvqG5b0YE5KhyYdk8fk75qt4u/h2toaBFLWqL SglP2TCRCD/at8gDa3F1ocFRrq0aupnztCbVC/4oZxl6vrumUOHPUqL9ByoaBKvxmSPy DMRbB/JMa7HNEvWYppeWjVpzalTfBquO05BalJhxv0iROj/k7SlwbVaDLVrNT4gswcDc ilOcSsvdYEjJfCmagky5Ile0J45zojEYrlKt2s2OvBowuSbK+X07ASG/2REcOE3qv4WR vMeA== 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=R1n6pw/8iPjNaOQsjF7JGDkoGDmdi5XsnqPrMHVoS9w=; b=YgcuGg0t9ghdi05TE1Rs75b6MNT8WwTJkR8jiFH2BnZQzO9qZVlqZLGqNLj7xexhGD ZJaBHKq81sxs0yD4PQfm3eFSuyiX4LF0bMnzWCeM2u2yDPOkBJ8AIVy8MRnVwYNeE10R Gb9VZMG5AKClBHscYAO8L0VD2iqcWGVhhxjBSDFV9RNGEJyWq1sltjmbq4Qiu33wTeeR lSOEdTMdK+EqRD4vB9TTZ58rfCLacx9HrjqXsippxF2ImmFfMFHcNb7IO/1UpULRLwh2 2lonxPbFX6TtxVDZpEeGqTpbUWoFKdD7sERTDoeULe3TSjXl76gmD3MbjYMSFz6la0fX 7b/Q== X-Gm-Message-State: ANhLgQ174RfJM08b+dtpHiqGCx3QOvT4Sdbz/g6xOS3nXIw3sc2jOwLb AMh38hEnIFwvE6PCvTg6M7WBEsXf11Q= X-Google-Smtp-Source: ADFU+vtWS6YVrrlKCN37L7gCve1GL01HAxpjMxOBiEuIyh42NJ281EGV2DSl7eHeully14wtFBLstQ== X-Received: by 2002:ac8:1ca:: with SMTP id b10mr1644088qtg.314.1583185486827; Mon, 02 Mar 2020 13:44:46 -0800 (PST) Received: from planxty.redhat.com (rdwyon0600w-lp130-03-64-231-46-127.dsl.bell.ca. [64.231.46.127]) by smtp.gmail.com with ESMTPSA id n8sm10858796qkn.49.2020.03.02.13.44.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Mar 2020 13:44:46 -0800 (PST) From: John Kacur To: rt-users Cc: Clark Williams , John Kacur Subject: [PATCH 6/6] rt-tests: cyclictest: Only run on runtime affinity and user supplied affinity Date: Mon, 2 Mar 2020 16:44:30 -0500 Message-Id: <20200302214430.15825-7-jkacur@redhat.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302214430.15825-1-jkacur@redhat.com> References: <20200302214430.15825-1-jkacur@redhat.com> MIME-Version: 1.0 Sender: linux-rt-users-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Currently if the user passes the affinity to cyclictest, threads are run there even if they should be excluded according to the affinity of the runtime environment. For example taskset -c 4-7 cyclictest -t -a 1-6 Should run on the interesection of this, that is on cpus 4,5,6 Fix this so it works as expected Note, one caveat, this apply to the threads that cyclictest creates, but only the initial taskset applies to the main cyclictest thread, so the main thread can run on cpus 4,5,6 and 7 Signed-off-by: John Kacur --- src/cyclictest/cyclictest.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index ce93ad0643cd..13d2b1722890 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -1044,8 +1044,13 @@ static unsigned int is_cpumask_zero(const struct bitmask *mask) static int cpu_for_thread_sp(int thread_num, int max_cpus) { unsigned int m, cpu, i, num_cpus; + num_cpus = rt_numa_bitmask_count(affinity_mask); + if (num_cpus == 0) { + fatal("No allowable cpus to run on\n"); + } + m = thread_num % num_cpus; /* there are num_cpus bits set, we want position of m'th one */ @@ -1091,6 +1096,30 @@ static int cpu_for_thread_ua(int thread_num, int max_cpus) } +/* After this function is called, affinity_mask is the intersection of the user + * supplied affinity mask and the affinity mask from the run time environment */ +static void use_current_cpuset(const int max_cpus) +{ + int i; + pid_t pid; + struct bitmask *curmask; + + pid = getpid(); + + curmask = numa_bitmask_alloc(sizeof(struct bitmask)); + numa_sched_getaffinity(pid, curmask); + + /* Clear bits that are not set in both the cpuset from the environment, + * and in the user specified affinity for cyclictest */ + for (i=0; i < max_cpus; i++) { + if ((!rt_numa_bitmask_isbitset(affinity_mask, i)) || (!rt_numa_bitmask_isbitset(curmask, i))) { + numa_bitmask_clearbit(affinity_mask, i); + } + } + + numa_bitmask_free(curmask); +} + static void parse_cpumask(const char *option, const int max_cpus) { affinity_mask = rt_numa_parse_cpustring(option, max_cpus); @@ -1098,7 +1127,10 @@ static void parse_cpumask(const char *option, const int max_cpus) if (is_cpumask_zero(affinity_mask)) { rt_bitmask_free(affinity_mask); affinity_mask = NULL; + } else { + use_current_cpuset(max_cpus); } + } if (!affinity_mask) display_help(1);