From patchwork Mon Jun 17 05:24:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khem Raj X-Patchwork-Id: 166967 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2404187ilk; Sun, 16 Jun 2019 22:25:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4MEgU64ZqdN1yLENcukj3ROlhaIvw8Yk18o+WUGLzdSX8k7J2QIM3crPElyaTz3rR4eTN X-Received: by 2002:a65:5685:: with SMTP id v5mr48235047pgs.184.1560749114698; Sun, 16 Jun 2019 22:25:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560749114; cv=none; d=google.com; s=arc-20160816; b=ZpTymQayp/uQZ3nB9z0jXlqvn8S2JX8qnbqDQMH8KDyiCXK/W3EEflGA4U9pplJ/Y5 LKCuyslatOAZa7lk2k/37MBop7A353T0RNXtUROEw7siQR86fA7N0dKnUvWGWsNqI09o 2YSbFedGj5JENnb0YtykB9CnE9/yMqc5UzbVFiuINtK92nvYR0HycdWfyknQqTrqG+en QuPyRNKwDpCtlOlLlUkJYz6POgiBqgHz3L8mBwwOsCd76kO24Aq07WdLeaj93v/KhKx9 yLSTcV1/thkhTbiLhN5Ce+8qC77ZuGwTDggqfN5t1VranYHa0KegNil7yLkLNpNZ6LuT Xx5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:delivered-to; bh=NzGIY8F1vm3mdFCxmgynLO7h111K9GTTW6EeEu2M0BI=; b=uxov8OgvikjVztoOQKDATF4548pCw4fozghg6Okpa2TVF0QHjeziEfqU092aeE892l uV//bDGggK89EKfvBuX1BKhNAu3aaxz1cK2FPKN8mo8Yr6khnjiC0ayd5AMxM7KDaPKi WUqPcUuCUkxx5EBzVu3JPVhPjFmg98WSMdU6e1WP1RIGaF9WTVZh36cLg3LwGHto1QsO ygam0MhCli8yKXbFMyhiJiQpUAHGyT7FtOh/wOJSL/fJKOcOQ3Nlhvn3zdcjvrglzRUO OpeTx364ksu7QeLbPaKfz7w3F9VdvVaQ5USZf6la+PPIMag/iBXXkqTfrGkmUq7xiNHz vT9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b="OVX56YH/"; spf=pass (google.com: best guess record for domain of openembedded-devel-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-devel-bounces@lists.openembedded.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from mail.openembedded.org (mail.openembedded.org. [140.211.169.62]) by mx.google.com with ESMTP id f9si3513563pgc.1.2019.06.16.22.25.14; Sun, 16 Jun 2019 22:25:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of openembedded-devel-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) client-ip=140.211.169.62; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b="OVX56YH/"; spf=pass (google.com: best guess record for domain of openembedded-devel-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-devel-bounces@lists.openembedded.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from ec2-34-214-78-129.us-west-2.compute.amazonaws.com (localhost [127.0.0.1]) by mail.openembedded.org (Postfix) with ESMTP id 24CB57E9ED; Mon, 17 Jun 2019 05:25:11 +0000 (UTC) X-Original-To: openembedded-devel@lists.openembedded.org Delivered-To: openembedded-devel@lists.openembedded.org Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by mail.openembedded.org (Postfix) with ESMTP id 0A0007E508 for ; Mon, 17 Jun 2019 05:24:48 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id s24so3581292plr.8 for ; Sun, 16 Jun 2019 22:24:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bqCuQ8dPDOpb9DpTgpZTmFeh3etK9YkTzrTk1UeYAno=; b=OVX56YH/2NSt5D2Eks37Z2k5gYtgo9gwVaIy+IT9iryKI54SnmugszTRTrgtWefcRL 9boHm5uOx/nNIP524WTw283ScHVBmCyHM7U8yrZUa7vZSfZu3gyC0xG1oRHRiTG+QYnT ItKeTU2t7wxqCtRXRGJrowtyFCiwsA12O1HbzPY06bru03g1VW6F5cfrVfp0djM62JoI HCKBzJm/F/fqn46MPEfbn2ZyQY/w6uxTawNeceU+C2Yz07II82DTH9wrUSlc2yHNvqMC 7cy8MpNxZX176U/pnUwRSxgTwYdgsrvIiBJzpKPEXp59cLLOC+UWwaETlbwJQ/BNHDzL MS4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bqCuQ8dPDOpb9DpTgpZTmFeh3etK9YkTzrTk1UeYAno=; b=rhJGFDQ+DQ17qR9wao0grJHKXnvFAHGLFxgKvxsSg3FOUV3IneLYZBFYqHxPMfHdEb 5oA6geSac/9C4J2sEILRxRZLLKq+QrUFbxX5hDpF/qvv3KkApRfTQkTg4dl0pCUBWINO cvPEg9iEjNgFyUOoE3XUUAGhDuqNSWuOwfYlQlCob3lv1PuSc80MJ/R+s8Tkx+1SamNm W6iGKQxeQCfe6UDPY5bER/4lcA9Z8a+VjaIovIvDg1Zpy89xdZefqx7S1n8qr00XUXE2 WS7m5CoqGgfbCA56qbKdnNoq+R2sXczMi2DE9dYunK5RSY74vKl34UZKDNyWBgqz5u/Z RAew== X-Gm-Message-State: APjAAAUJUEUnfML/kRGvlLZbLjtGoDwPb/695zpZPfISA15JKIUsif5e TpeybOrY2kIxPN7hrXhxiUQO9SKH0gg= X-Received: by 2002:a17:902:2ae7:: with SMTP id j94mr21874568plb.270.1560749089722; Sun, 16 Jun 2019 22:24:49 -0700 (PDT) Received: from apollo.hsd1.ca.comcast.net ([2601:646:8500:6bc6::3c7b]) by smtp.gmail.com with ESMTPSA id c124sm10156911pfa.115.2019.06.16.22.24.49 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 16 Jun 2019 22:24:49 -0700 (PDT) From: Khem Raj To: openembedded-devel@lists.openembedded.org Date: Sun, 16 Jun 2019 22:24:39 -0700 Message-Id: <20190617052440.18958-2-raj.khem@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190617052440.18958-1-raj.khem@gmail.com> References: <20190617052440.18958-1-raj.khem@gmail.com> MIME-Version: 1.0 Subject: [oe] [meta-oe][PATCH 2/3] stressapptest: Implement reading sysfs and use it if sysconf is not there X-BeenThere: openembedded-devel@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Using the OpenEmbedded metadata to build Distributions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: openembedded-devel-bounces@lists.openembedded.org Errors-To: openembedded-devel-bounces@lists.openembedded.org This helps in building on musl platform where _SC_LEVEL1_DCACHE_LINESIZE is not available Signed-off-by: Khem Raj --- .../read_sysfs_for_cachesize.patch | 72 +++++++++++++++++++ .../stressapptest/stressapptest_1.0.9.bb | 1 + 2 files changed, 73 insertions(+) create mode 100644 meta-oe/recipes-benchmark/stressapptest/stressapptest/read_sysfs_for_cachesize.patch -- 2.22.0 -- _______________________________________________ Openembedded-devel mailing list Openembedded-devel@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-devel diff --git a/meta-oe/recipes-benchmark/stressapptest/stressapptest/read_sysfs_for_cachesize.patch b/meta-oe/recipes-benchmark/stressapptest/stressapptest/read_sysfs_for_cachesize.patch new file mode 100644 index 0000000000..8c251aeb97 --- /dev/null +++ b/meta-oe/recipes-benchmark/stressapptest/stressapptest/read_sysfs_for_cachesize.patch @@ -0,0 +1,72 @@ +sysconf params like _SC_LEVEL1_DCACHE_LINESIZE are not universally +implemented, therefore check for them being available, if not there +then read the sysfs directly to get the value + +Upstream-Status: Pending +Signed-off-by: Khem Raj +--- a/src/sat.cc ++++ b/src/sat.cc +@@ -1482,15 +1482,47 @@ int Sat::CpuCount() { + return sysconf(_SC_NPROCESSORS_CONF); + } + ++int Sat::ReadInt(const char *filename, int *value) { ++ char line[64]; ++ int fd = open(filename, O_RDONLY), err = -1; ++ ++ if (fd < 0) ++ return -1; ++ if (read(fd, line, sizeof(line)) > 0) { ++ *value = atoi(line); ++ err = 0; ++ } ++ ++ close(fd); ++ return err; ++} ++ + // Return the worst case (largest) cache line size of the various levels of + // cache actually prsent in the machine. + int Sat::CacheLineSize() { +- int max_linesize = sysconf(_SC_LEVEL1_DCACHE_LINESIZE); +- int linesize = sysconf(_SC_LEVEL2_CACHE_LINESIZE); ++ int max_linesize, linesize; ++#ifdef _SC_LEVEL1_DCACHE_LINESIZE ++ max_linesize = sysconf(_SC_LEVEL1_DCACHE_LINESIZE); ++#else ++ ReadInt("/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size", &max_linesize); ++#endif ++#ifdef _SC_LEVEL2_DCACHE_LINESIZE ++ linesize = sysconf(_SC_LEVEL2_DCACHE_LINESIZE); ++#else ++ ReadInt("/sys/devices/system/cpu/cpu0/cache/index1/coherency_line_size", &linesize); ++#endif + if (linesize > max_linesize) max_linesize = linesize; +- linesize = sysconf(_SC_LEVEL3_CACHE_LINESIZE); ++#ifdef _SC_LEVEL3_DCACHE_LINESIZE ++ linesize = sysconf(_SC_LEVEL3_DCACHE_LINESIZE); ++#else ++ ReadInt("/sys/devices/system/cpu/cpu0/cache/index2/coherency_line_size", &linesize); ++#endif + if (linesize > max_linesize) max_linesize = linesize; +- linesize = sysconf(_SC_LEVEL4_CACHE_LINESIZE); ++#ifdef _SC_LEVEL4_DCACHE_LINESIZE ++ linesize = sysconf(_SC_LEVEL4_DCACHE_LINESIZE); ++#else ++ ReadInt("/sys/devices/system/cpu/cpu0/cache/index3/coherency_line_size", &linesize); ++#endif + if (linesize > max_linesize) max_linesize = linesize; + return max_linesize; + } +--- a/src/sat.h ++++ b/src/sat.h +@@ -136,7 +136,8 @@ class Sat { + int CpuCount(); + // Return the worst-case (largest) cache line size of the system. + int CacheLineSize(); +- ++ // Read int values from kernel file system e.g. sysfs ++ int ReadInt(const char *filename, int *value); + // Collect error counts from threads. + int64 GetTotalErrorCount(); + diff --git a/meta-oe/recipes-benchmark/stressapptest/stressapptest_1.0.9.bb b/meta-oe/recipes-benchmark/stressapptest/stressapptest_1.0.9.bb index 679201c528..aa1bf1cd32 100644 --- a/meta-oe/recipes-benchmark/stressapptest/stressapptest_1.0.9.bb +++ b/meta-oe/recipes-benchmark/stressapptest/stressapptest_1.0.9.bb @@ -11,6 +11,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=55ea9d559f985fb4834317d8ed6b9e58" SRC_URI = "https://github.com/${PN}/${PN}/archive/v${PV}.tar.gz \ file://libcplusplus-compat.patch \ + file://read_sysfs_for_cachesize.patch \ " SRC_URI[md5sum] = "d3a526c174c049dd7a1068dc74a62be2"