From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sergio Gonzalez Monroy Subject: Re: [PATCH v5] eal: fix allocating all free hugepages Date: Wed, 8 Jun 2016 12:27:35 +0100 Message-ID: <5e903b16-453e-100f-fea4-75229e33344f@intel.com> References: <1453661393-85704-1-git-send-email-jianfeng.tan@intel.com> <1464665827-24965-1-git-send-email-jianfeng.tan@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Cc: nhorman@tuxdriver.com, david.marchand@6wind.com, thomas.monjalon@6wind.com To: Jianfeng Tan , dev@dpdk.org Return-path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 08F433794 for ; Wed, 8 Jun 2016 13:27:37 +0200 (CEST) In-Reply-To: <1464665827-24965-1-git-send-email-jianfeng.tan@intel.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 31/05/2016 04:37, Jianfeng Tan wrote: > EAL memory init allocates all free hugepages of the whole system, > which seen from sysfs, even when applications do not ask so many. > When there is a limitation on how many hugepages an application can > use (such as cgroup.hugetlb), or hugetlbfs is specified with an > option of size (exceeding the quota of the fs), it just fails to > start even there are enough hugepages allocated. > > To fix above issue, this patch: > - Changes the logic to continue memory init to see if hugetlb > requirement of application can be addressed by already allocated > hugepages. > - To make sure each hugepage is allocated successfully, we add a > recover mechanism, which relies on a mem access to fault-in > hugepages, and if it fails with SIGBUS, recover to previously > saved stack environment with siglongjmp(). > > For the case of CONFIG_RTE_EAL_SINGLE_FILE_SEGMENTS (enabled by > default when compiling IVSHMEM target), it's indispensable to > mapp all free hugepages in the system. Under this case, it fails > to start when allocating fails. > > Test example: > a. cgcreate -g hugetlb:/test-subgroup > b. cgset -r hugetlb.1GB.limit_in_bytes=2147483648 test-subgroup > c. cgexec -g hugetlb:test-subgroup \ > ./examples/helloworld/build/helloworld -c 0x2 -n 4 > > > Fixes: af75078fece ("first public release") > > Signed-off-by: Jianfeng Tan > Acked-by: Neil Horman > --- > v5: > - Make this method as default instead of using an option. > - When SIGBUS is triggered in the case of RTE_EAL_SINGLE_FILE_SEGMENTS, > just return error. > - Add prefix "huge_" to newly added function and static variables. > - Move the internal_config.memory assignment after the page allocations. > v4: > - Change map_all_hugepages to return unsigned instead of int. > v3: > - Reword commit message to include it fixes the hugetlbfs quota issue. > - setjmp -> sigsetjmp. > - Fix RTE_LOG complaint from ERR to DEBUG as it does not mean init error > so far. > - Fix the second map_all_hugepages's return value check. > v2: > - Address the compiling error by move setjmp into a wrap method. > > lib/librte_eal/linuxapp/eal/eal.c | 20 ----- > lib/librte_eal/linuxapp/eal/eal_memory.c | 138 ++++++++++++++++++++++++++++--- > 2 files changed, 125 insertions(+), 33 deletions(-) > Acked-by: Sergio Gonzalez Monroy