From patchwork Fri Nov 5 16:25:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 12605101 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73D5FC433F5 for ; Fri, 5 Nov 2021 16:25:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B24B611C0 for ; Fri, 5 Nov 2021 16:25:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229926AbhKEQ2a (ORCPT ); Fri, 5 Nov 2021 12:28:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233102AbhKEQ23 (ORCPT ); Fri, 5 Nov 2021 12:28:29 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E81DC061714 for ; Fri, 5 Nov 2021 09:25:49 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id g3so15868538ljm.8 for ; Fri, 05 Nov 2021 09:25:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UrGzSNLl9hkWQ6FY0wrjlvm9IW4EhNpFnEOVw1+6lI0=; b=cVjspeqH37diRa4ySe6S2iiA1czmxfOtOWLfHoi5JdPW0nCQu/RUnglVsGr+rjbT6k u7eO1hSzHFioTYrxlCnLamDqmnjFC8lyLVdRPA3WCX56FEwRTsfbrZzX0yFKWlAIC18F 0OTX/yMqnJFwPLjZcYAIEAsY5ncjbglIRVQ0TeWRNyPYuj/m4owkRTqfjkA5IOWPVUhk u4K3Pp4t5kgqyBpmbr0jy3gl3wS8BOJ4pNH3M6cPTnnKsSTWCcty+KuzN7c9gpU/Se5H OgXaAF0fE86e0wiqbxTbPyCRpV4OIwtXpFskRbopwuQ7RWJKvecgZ7YxM37qV7V51xsH o1sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UrGzSNLl9hkWQ6FY0wrjlvm9IW4EhNpFnEOVw1+6lI0=; b=ouQsG87yipiSxyYrCzDGNHKf2HELB0BU2WBPXxsGC8XJCE5cp74m0S9XxDMj+HSBmr liQJF4PjUbMxmFcE1BK8sgpMPjpVYk++KXnGZkaqeKRtDo/tiIp+KgLXm0eX5wXJupxW hLn18Qox9idbZEht2YgWI2Y/TuWeVrF4MlXGkjRa0DabYI+9XHWo+U7Td+K9ujQskPKC c1dUTwqF65FLjs4+3/nWURFG42phF6wr/qqvoDo9VPcE3uiodMEMChEf+nzyYGFE+VmP pjnDZT/0RwNikFrMaQV6OV/KPdDDJWJ9z+qQPWsxpuS/fN5guxxAKMJTvvRAxv6XMa9m JOgQ== X-Gm-Message-State: AOAM533W6I3QfG+o4SkshoNm3WGyyBE+o+boLYbjfqH9QA7O/ItAoCCs 2w/KAg5YXzXhAkbSD6Cpz/DYkQ== X-Google-Smtp-Source: ABdhPJxc+p+Sfr1lDnaHzVQSMv9ex6Kr2Ycy5rJpErG8VNnPs4Ud2FdjIX/NFVqB/7lmod7aZKjflA== X-Received: by 2002:a2e:b8c3:: with SMTP id s3mr9383633ljp.496.1636129547776; Fri, 05 Nov 2021 09:25:47 -0700 (PDT) Received: from localhost (c-9b28e555.07-21-73746f28.bbcust.telenor.se. [85.229.40.155]) by smtp.gmail.com with ESMTPSA id x20sm874133lfu.196.2021.11.05.09.25.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Nov 2021 09:25:46 -0700 (PDT) From: Anders Roxell To: shuah@kernel.org, christian@brauner.io Cc: nathan@kernel.org, ndesaulniers@google.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Anders Roxell , Arnd Bergmann Subject: [PATCH 1/2] selftests: cgroup: build error multiple outpt files Date: Fri, 5 Nov 2021 17:25:29 +0100 Message-Id: <20211105162530.3307666-1-anders.roxell@linaro.org> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org When building selftests/cgroup: with clang the following error are seen: clang -Wall -pthread test_memcontrol.c cgroup_util.c ../clone3/clone3_selftests.h -o /home/anders/.cache/tuxmake/builds/current/kselftest/cgroup/test_memcontrol clang: error: cannot specify -o when generating multiple output files make[3]: *** [../lib.mk:146: /home/anders/.cache/tuxmake/builds/current/kselftest/cgroup/test_memcontrol] Error 1 Rework to add the header files to LOCAL_HDRS before including ../lib.mk, since the dependency is evaluated in '$(OUTPUT)/%:%.c $(LOCAL_HDRS)' in file lib.mk. Suggested-by: Arnd Bergmann Signed-off-by: Anders Roxell Acked-by: Christian Brauner --- tools/testing/selftests/cgroup/Makefile | 12 +++++++----- tools/testing/selftests/lib.mk | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/cgroup/Makefile b/tools/testing/selftests/cgroup/Makefile index 59e222460581..745fe25fa0b9 100644 --- a/tools/testing/selftests/cgroup/Makefile +++ b/tools/testing/selftests/cgroup/Makefile @@ -11,10 +11,12 @@ TEST_GEN_PROGS += test_core TEST_GEN_PROGS += test_freezer TEST_GEN_PROGS += test_kill +LOCAL_HDRS += $(selfdir)/clone3/clone3_selftests.h $(selfdir)/pidfd/pidfd.h + include ../lib.mk -$(OUTPUT)/test_memcontrol: cgroup_util.c ../clone3/clone3_selftests.h -$(OUTPUT)/test_kmem: cgroup_util.c ../clone3/clone3_selftests.h -$(OUTPUT)/test_core: cgroup_util.c ../clone3/clone3_selftests.h -$(OUTPUT)/test_freezer: cgroup_util.c ../clone3/clone3_selftests.h -$(OUTPUT)/test_kill: cgroup_util.c ../clone3/clone3_selftests.h ../pidfd/pidfd.h +$(OUTPUT)/test_memcontrol: cgroup_util.c +$(OUTPUT)/test_kmem: cgroup_util.c +$(OUTPUT)/test_core: cgroup_util.c +$(OUTPUT)/test_freezer: cgroup_util.c +$(OUTPUT)/test_kill: cgroup_util.c diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk index fe7ee2b0f29c..a40add31a2e3 100644 --- a/tools/testing/selftests/lib.mk +++ b/tools/testing/selftests/lib.mk @@ -141,7 +141,7 @@ endif # Selftest makefiles can override those targets by setting # OVERRIDE_TARGETS = 1. ifeq ($(OVERRIDE_TARGETS),) -LOCAL_HDRS := $(selfdir)/kselftest_harness.h $(selfdir)/kselftest.h +LOCAL_HDRS += $(selfdir)/kselftest_harness.h $(selfdir)/kselftest.h $(OUTPUT)/%:%.c $(LOCAL_HDRS) $(LINK.c) $(filter-out $(LOCAL_HDRS),$^) $(LDLIBS) -o $@ From patchwork Fri Nov 5 16:25:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 12605103 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7870EC4332F for ; Fri, 5 Nov 2021 16:25:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5BB0F61252 for ; Fri, 5 Nov 2021 16:25:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233373AbhKEQ2c (ORCPT ); Fri, 5 Nov 2021 12:28:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233245AbhKEQ2b (ORCPT ); Fri, 5 Nov 2021 12:28:31 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E6D0C061205 for ; Fri, 5 Nov 2021 09:25:51 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id g29so5664537lfv.4 for ; Fri, 05 Nov 2021 09:25:51 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=QUTfLy1iCpJaN03F0qB7HmLPMvYCUl4mt7QEsJfTLts=; b=kkEJtaY1K2n82x/UBfegIqqgxmEgtDimvV3nuidIgABKW6b/bWTBhKWCqRTYZJ6zXJ cjn1R6E286iVDSbguU8u6YX1fG9GY0efrxqXQdEFis4uxZWnS15oJ6srFgw2x4Ur0CYe T0LjNOrKMx0JX1ecJygQwJzqvpTK3QFosK0E1oo/1IL2KCaLwZ8XswtAGt3zbzHb5Qe0 eMZioRrukDQNT++0Lf9TI/g5tpO1ZnhKMa/1NNoxH0p+YkheoJ71aQd6+DTfwdfckguN sf4aQePetkg2GUbAcJwtQrFsJCUpAcpPczLPGcyHM3C06ZbU8YiqY4kkkW/4bX2uHod1 8KLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QUTfLy1iCpJaN03F0qB7HmLPMvYCUl4mt7QEsJfTLts=; b=Tm+NBt433yVOUzBoUYbE4iTA9D8XMc0wVn3HcPr9Zo+8g/mgLA5eCg6GzzqdQaqiAD JD3mha3dClctZm4WEAMlJ8Shdr7BASGH4YVtpESV3bbjg1DHol4cASVm0ElNd3MrSFn1 01t5FiDD5LCX1Q+U+FhR46A8KQMXPSzY4/wM/37TNw/hSb9SU8fK1krcNS76aC6QY1Mh 5Bt1eP44+c6b3Gpz/e7YxwmDuE+0Wv3hgwaBbfKFvqFOQj8pBj9SmJjHlgBMRI0RY8hf lALQmuS4deuObxTmZct5DFqjSdb2Ill+bmCOu+SFac5lHtzVPVerIgKoQHv1J0ctX/cv 5gDQ== X-Gm-Message-State: AOAM532RQ+d+08CUUrshYlOV80Ui2wRvpwfajqIWs5s8pHjE2gIjcnXa XvhfCWltDKB/h8v1vBgJEo2aLg== X-Google-Smtp-Source: ABdhPJy8KooI80fVpt9eaxrWsH+brvLejZ46wccflYYtY1bDxHtC/FMcxFJmC2hqfHTBccTJ8cSStw== X-Received: by 2002:a05:6512:1113:: with SMTP id l19mr28399988lfg.201.1636129549793; Fri, 05 Nov 2021 09:25:49 -0700 (PDT) Received: from localhost (c-9b28e555.07-21-73746f28.bbcust.telenor.se. [85.229.40.155]) by smtp.gmail.com with ESMTPSA id t3sm870833lfc.216.2021.11.05.09.25.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Nov 2021 09:25:49 -0700 (PDT) From: Anders Roxell To: shuah@kernel.org, christian@brauner.io Cc: nathan@kernel.org, ndesaulniers@google.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Anders Roxell Subject: [PATCH 2/2] selftests: cgroup: use function 'labs()' over 'abs()' Date: Fri, 5 Nov 2021 17:25:30 +0100 Message-Id: <20211105162530.3307666-2-anders.roxell@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211105162530.3307666-1-anders.roxell@linaro.org> References: <20211105162530.3307666-1-anders.roxell@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org When building selftests/cgroup with clang, the compiler warn about the function abs() see below: In file included from test_memcontrol.c:21: ./cgroup_util.h:16:9: warning: absolute value function 'abs' given an argument of type 'long' but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value] return abs(a - b) <= (a + b) / 100 * err; ^ ./cgroup_util.h:16:9: note: use function 'labs' instead return abs(a - b) <= (a + b) / 100 * err; ^~~ labs The note indicates what to do, Rework to use the function 'labs()'. Signed-off-by: Anders Roxell Reviewed-by: Nick Desaulniers Acked-by: Christian Brauner --- tools/testing/selftests/cgroup/cgroup_util.h | 2 +- tools/testing/selftests/cgroup/test_kmem.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/cgroup/cgroup_util.h b/tools/testing/selftests/cgroup/cgroup_util.h index 82e59cdf16e7..76b35d9dffb5 100644 --- a/tools/testing/selftests/cgroup/cgroup_util.h +++ b/tools/testing/selftests/cgroup/cgroup_util.h @@ -13,7 +13,7 @@ */ static inline int values_close(long a, long b, int err) { - return abs(a - b) <= (a + b) / 100 * err; + return labs(a - b) <= (a + b) / 100 * err; } extern int cg_find_unified_root(char *root, size_t len); diff --git a/tools/testing/selftests/cgroup/test_kmem.c b/tools/testing/selftests/cgroup/test_kmem.c index 22b31ebb3513..d65bb8fe876a 100644 --- a/tools/testing/selftests/cgroup/test_kmem.c +++ b/tools/testing/selftests/cgroup/test_kmem.c @@ -192,7 +192,7 @@ static int test_kmem_memcg_deletion(const char *root) goto cleanup; sum = slab + anon + file + kernel_stack + pagetables + percpu + sock; - if (abs(sum - current) < MAX_VMSTAT_ERROR) { + if (labs(sum - current) < MAX_VMSTAT_ERROR) { ret = KSFT_PASS; } else { printf("memory.current = %ld\n", current); @@ -383,7 +383,7 @@ static int test_percpu_basic(const char *root) current = cg_read_long(parent, "memory.current"); percpu = cg_read_key_long(parent, "memory.stat", "percpu "); - if (current > 0 && percpu > 0 && abs(current - percpu) < + if (current > 0 && percpu > 0 && labs(current - percpu) < MAX_VMSTAT_ERROR) ret = KSFT_PASS; else