From patchwork Tue May 10 14:45:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 67457 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2168642qge; Tue, 10 May 2016 07:46:42 -0700 (PDT) X-Received: by 10.140.163.85 with SMTP id j82mr43918003qhj.40.1462891602353; Tue, 10 May 2016 07:46:42 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id v127si1668160qkd.7.2016.05.10.07.46.41; Tue, 10 May 2016 07:46:42 -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 8BD1D6163E; Tue, 10 May 2016 14:46:41 +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 C367361586; Tue, 10 May 2016 14:46:29 +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 01BDE61586; Tue, 10 May 2016 14:46:25 +0000 (UTC) Received: from mail-lf0-f52.google.com (mail-lf0-f52.google.com [209.85.215.52]) by lists.linaro.org (Postfix) with ESMTPS id 5599161647 for ; Tue, 10 May 2016 14:45:42 +0000 (UTC) Received: by mail-lf0-f52.google.com with SMTP id m64so17556377lfd.1 for ; Tue, 10 May 2016 07:45:42 -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; bh=HWMuHD7EJR9Jpn/Faqqh5+ZmCI6UwekOBJwFtcIFYuk=; b=evnxhEAFyWvcvZIpeKvLZXEk2j1KSaqWigsz/b/BXvuVgRigTxh3jmlqFbo8KE0mCf ymMbczrspgZz3YPC7N5t73wiaH1ugsyiN4Kau8c+fq04WUHXRGwt6NUcV2OvxJB/Sh0x AVobWaFTf2IHnDZjia7TMJzwiGckFuX633sb3/wSZPYznZ0udbt59IQ5Rk/uY+wsf4gm M58SZUrj00JE/wDBnqHuSOySUVWfJhDR1zw7Po7AQTMfAPrk/hcGOPKYPlMqMQGGAM8+ Se55ZNVWVuVkEdBaUvHI1rLyn2VAlDCqrewyAK7z6/qXbm85HCppcm91DH7S5IyzK5Eb lMtg== X-Gm-Message-State: AOPr4FW4pZcG4P/wzO+EkHWP9diGG77CvM6Ho2uso/Xd0O267p2cN+Vfymr3G1+kB1rlWl/2Hls= X-Received: by 10.112.61.39 with SMTP id m7mr17202095lbr.72.1462891540765; Tue, 10 May 2016 07:45:40 -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 r3sm443068lbj.26.2016.05.10.07.45.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 May 2016 07:45:40 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Tue, 10 May 2016 17:45:27 +0300 Message-Id: <1462891527-29359-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.7.1.250.gff4ea60 X-Topics: patch Subject: [lng-odp] [PATCH] 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 | 46 +++++++++++++------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c index 0f1f3c7..14244c3 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,30 @@ static int systemcpu_cache_line_size(void) #endif -static int huge_page_size(void) +static int default_huge_page_size(void) { - DIR *dir; - struct dirent *dirent; - int size = 0; + char str[1024]; + char *pos; + 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) { + pos = strstr(str, "Hugepagesize:"); + if (pos) { + *(pos - 1) = '\0'; + if (sscanf(pos, "@ %ld kB", &sz) == 1) { + fclose(file); + return sz * 1024; + } + } } - return size * 1024; + fclose(file); + return 0; } - /* * Analysis of /sys/devices/system/cpu/ files */ @@ -137,7 +127,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; }