From patchwork Wed May 11 13:02:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 67513 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp212565qge; Wed, 11 May 2016 06:03:07 -0700 (PDT) X-Received: by 10.140.198.10 with SMTP id t10mr3255807qha.22.1462971787848; Wed, 11 May 2016 06:03:07 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 14si4969094qkt.280.2016.05.11.06.03.07; Wed, 11 May 2016 06:03:07 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 4EDCB6163F; Wed, 11 May 2016 13:03:07 +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 09B07615CA; Wed, 11 May 2016 13:03:04 +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 9EA786163B; Wed, 11 May 2016 13:03:01 +0000 (UTC) Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com [209.85.215.51]) by lists.linaro.org (Postfix) with ESMTPS id 8AB09615CA for ; Wed, 11 May 2016 13:02:59 +0000 (UTC) Received: by mail-lf0-f51.google.com with SMTP id m64so48495367lfd.1 for ; Wed, 11 May 2016 06:02:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=c88qpYZ55/vvsfZ0gbH4XKamiUyIzVDC5co91xBPvUU=; b=M0R/EKOQLu2fH8RrjRgKWlw1b4kH61PiDFS5WRCsBMKQ4fB4TAm8a2ygqQXKTKMrw6 uDCmyG+1eCBbVF34TRUpYcIk3Zl1gQPlgdo27WiZAlcQQL+2obd26OGBebieFNTIkCFn u7Hdz/rkBWaQST3z0h9dg95OAMu7/vdvtuc5y6gAkeRvmOTL470omltbKmAbFeENbM8x U40CDxqKQZtcLS1COy9E811Hm+HoeAdC6D7d+yRHedrM9KMiynu9sCowtKrsLh65C4DY O+KZebLiRuGImqSlIf3wWTv+PO52WOobkcvQilZ/wnFlU0iSzVbM4s643lwdemdjjzlk Y2IQ== X-Gm-Message-State: AOPr4FUPwKHhNrJHKUQRyCEMKGf42u5o8EglWAFJ5WOLqBRbig5N+DakR+YnzUnoDEcH2XD1B8k= X-Received: by 10.25.150.207 with SMTP id y198mr1517317lfd.76.1462971778497; Wed, 11 May 2016 06:02:58 -0700 (PDT) Received: from localhost.localdomain (ppp91-77-173-31.pppoe.mtu-net.ru. [91.77.173.31]) by smtp.gmail.com with ESMTPSA id 92sm1296970lfw.25.2016.05.11.06.02.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 May 2016 06:02:57 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Wed, 11 May 2016 16:02:49 +0300 Message-Id: <1462971770-16409-2-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.7.1.250.gff4ea60 In-Reply-To: <1462971770-16409-1-git-send-email-maxim.uvarov@linaro.org> References: <1462971770-16409-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv3 1/2] linux-generic: use default huge page size X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" 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" odp_shm_reserve() relays on huge page size to round up requested size. If 1 Gb pages present than parser takes it first as first alphabetical file name in sysfs. That lead to issue where all allocations wants 1 GB HP. This patch takes system default huge pages which are usually 2Mb, and has to be enough for existence odp example apps and validation tests. Reported-by: B.Nousilal Signed-off-by: Maxim Uvarov --- platform/linux-generic/odp_system_info.c | 43 +++++++++++--------------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c index 0f1f3c7..ff422f6 100644 --- a/platform/linux-generic/odp_system_info.c +++ b/platform/linux-generic/odp_system_info.c @@ -24,12 +24,9 @@ #include #include - #define CACHE_LNSZ_FILE \ "/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size" -#define HUGE_PAGE_DIR "/sys/kernel/mm/hugepages" - /* * Report the number of logical CPUs detected at boot time */ @@ -77,37 +74,27 @@ static int systemcpu_cache_line_size(void) #endif -static int huge_page_size(void) +static uint64_t default_huge_page_size(void) { - DIR *dir; - struct dirent *dirent; - int size = 0; + char str[1024]; + uint64_t sz; + FILE *file; - dir = opendir(HUGE_PAGE_DIR); - if (dir == NULL) { - ODP_ERR("%s not found\n", HUGE_PAGE_DIR); - return 0; - } - - while ((dirent = readdir(dir)) != NULL) { - int temp = 0; - - if (sscanf(dirent->d_name, "hugepages-%i", &temp) != 1) - continue; - - if (temp > size) - size = temp; - } + file = fopen("/proc/meminfo", "rt"); - if (closedir(dir)) { - ODP_ERR("closedir failed\n"); - return 0; + while (fgets(str, sizeof(str), file) != NULL) { + if (sscanf(str, "Hugepagesize: %8lu kB", &sz) == 1) { + ODP_DBG("defaut hp size is %" PRIu64 " kB\n", sz); + fclose(file); + return sz * 1024; + } } - return size * 1024; + ODP_ERR("unable to get default hp size\n"); + fclose(file); + return 0; } - /* * Analysis of /sys/devices/system/cpu/ files */ @@ -137,7 +124,7 @@ static int systemcpu(odp_system_info_t *sysinfo) return -1; } - sysinfo->huge_page_size = huge_page_size(); + sysinfo->huge_page_size = default_huge_page_size(); return 0; }