From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 8D4D0B0A5 for ; Wed, 16 Apr 2014 13:11:22 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 16 Apr 2014 04:11:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,871,1389772800"; d="scan'208";a="521562933" Received: from irsmsx103.ger.corp.intel.com ([163.33.3.157]) by fmsmga002.fm.intel.com with ESMTP; 16 Apr 2014 04:11:13 -0700 Received: from irsmsx106.ger.corp.intel.com (163.33.3.31) by IRSMSX103.ger.corp.intel.com (163.33.3.157) with Microsoft SMTP Server (TLS) id 14.3.123.3; Wed, 16 Apr 2014 12:11:12 +0100 Received: from irsmsx104.ger.corp.intel.com ([169.254.5.2]) by IRSMSX106.ger.corp.intel.com ([169.254.8.26]) with mapi id 14.03.0123.003; Wed, 16 Apr 2014 12:11:13 +0100 From: "Burakov, Anatoly" To: "dev@dpdk.org" Thread-Topic: [PATCH] EAL: Take reserved hugepages into account Thread-Index: Ac9ZZDW2MKsItJ1sTaiqdCkaff3eLA== Date: Wed, 16 Apr 2014 11:11:12 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH] EAL: Take reserved hugepages into account X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Apr 2014 11:11:23 -0000 Some applications reserve hugepages for later use, but DPDK doesn't take re= served pages into account when calculating number of available number of hu= gepages. This patch adds reading from "resv_hugepages" file in addition to = "free_hugepages". --- lib/librte_eal/linuxapp/eal/eal_hugepage_info.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c b/lib/librte_e= al/linuxapp/eal/eal_hugepage_info.c index ef4cd1d..4ffeda5 100644 --- a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c +++ b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c @@ -66,8 +66,16 @@ static int32_t get_num_hugepages(const char *subdir) { char path[PATH_MAX]; - long unsigned num_pages =3D 0; + long unsigned resv_pages, num_pages =3D 0; const char *nr_hp_file; + const char *nr_rsvd_file =3D "resv_hugepages"; + + /* first, check how many reserved pages kernel reports */ + rte_snprintf(path, sizeof(path), "%s/%s/%s", + sys_dir_path, subdir, nr_rsvd_file); + + if (eal_parse_sysfs_value(path, &resv_pages) < 0) + return 0; =20 /* if secondary process, just look at the number of hugepages, * otherwise look at number of free hugepages */ @@ -76,6 +84,8 @@ get_num_hugepages(const char *subdir) else nr_hp_file =3D "free_hugepages"; =20 + memset(path, 0, sizeof(path)); + rte_snprintf(path, sizeof(path), "%s/%s/%s", sys_dir_path, subdir, nr_hp_file); =20 @@ -86,6 +96,10 @@ get_num_hugepages(const char *subdir) RTE_LOG(WARNING, EAL, "No free hugepages reported in %s\n", subdir); =20 + /* adjust num_pages in case of primary process */ + if (num_pages > 0 && internal_config.process_type =3D=3D RTE_PROC_PRIMARY= ) + num_pages -=3D resv_pages; + return (int32_t)num_pages; } =20 --=20 1.8.1.4