From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id B34006CB1 for ; Thu, 19 May 2016 04:11:18 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP; 18 May 2016 19:11:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,332,1459839600"; d="scan'208";a="106559015" Received: from shwdeisgchi083.ccr.corp.intel.com (HELO [10.239.67.193]) ([10.239.67.193]) by fmsmga004.fm.intel.com with ESMTP; 18 May 2016 19:11:17 -0700 To: Sergio Gonzalez Monroy , Thomas Monjalon References: <1457089092-4128-1-git-send-email-jianfeng.tan@intel.com> <1463013881-27985-1-git-send-email-jianfeng.tan@intel.com> <1671292.hQI6ccxuUZ@xps13> <63ae23d7-7ca3-46e5-cfc1-1a6684395428@intel.com> Cc: dev@dpdk.org, david.marchand@6wind.com, nhorman@tuxdriver.com From: "Tan, Jianfeng" Message-ID: Date: Thu, 19 May 2016 10:11:16 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <63ae23d7-7ca3-46e5-cfc1-1a6684395428@intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v4] eal: make hugetlb initialization more robust 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: Thu, 19 May 2016 02:11:19 -0000 Hi Thomas & Sergio, On 5/18/2016 4:06 PM, Sergio Gonzalez Monroy wrote: > On 17/05/2016 17:40, Thomas Monjalon wrote: >> 2016-05-12 00:44, Jianfeng Tan: >>> This patch adds an option, --huge-trybest, to use a recover >>> mechanism to >>> the case that there are not so many hugepages (declared in sysfs), >>> which >>> can be used. It relys on a mem access to fault-in hugepages, and if >>> fails >> relys -> relies >> >>> with SIGBUS, recover to previously saved stack environment with >>> siglongjmp(). >>> >>> Besides, this solution fixes an issue when hugetlbfs is specified >>> with an >>> option of size. Currently DPDK does not respect the quota of a >>> hugetblfs >>> mount. It fails to init the EAL because it tries to map the number >>> of free >>> hugepages in the system rather than using the number specified in >>> the quota >>> for that mount. >> It looks to be a bug. Why adding an option? >> What is the benefit of the old behaviour, not using --try-best? > > I do not see any benefit to the old behavior. > Given that we need the signal handling for the cgroup use case, I > would be inclined to use > this method as the default instead of trying to figure out how many > hugepages we have free, etc. > > Thoughts? I tend to use this method as the default too, with some warning logs as suggested by David, and return error from rte_eal_memory() when sigbus is triggered under the case of RTE_EAL_SINGLE_FILE_SEGMENTS. Thomas, all other trivial issues will be fixed in next version. Thank you! Thanks, Jianfeng > > Sergio > >>> +static sigjmp_buf jmpenv; >>> + >>> +static void sigbus_handler(int signo __rte_unused) >>> +{ >>> + siglongjmp(jmpenv, 1); >>> +} >>> + >>> +/* Put setjmp into a wrap method to avoid compiling error. Any >>> non-volatile, >>> + * non-static local variable in the stack frame calling sigsetjmp >>> might be >>> + * clobbered by a call to longjmp. >>> + */ >>> +static int wrap_sigsetjmp(void) >>> +{ >>> + return sigsetjmp(jmpenv, 1); >>> +} >> Please add the word "huge" to these variables and functions. >> >>> +static struct sigaction action_old; >>> +static int need_recover; >>> + >>> +static void >>> +register_sigbus(void) >>> +{ >>> + sigset_t mask; >>> + struct sigaction action; >>> + >>> + sigemptyset(&mask); >>> + sigaddset(&mask, SIGBUS); >>> + action.sa_flags = 0; >>> + action.sa_mask = mask; >>> + action.sa_handler = sigbus_handler; >>> + >>> + need_recover = !sigaction(SIGBUS, &action, &action_old); >>> +} >>> + >>> +static void >>> +recover_sigbus(void) >>> +{ >>> + if (need_recover) { >>> + sigaction(SIGBUS, &action_old, NULL); >>> + need_recover = 0; >>> + } >>> +} >> Idem, Please add the word "huge". >> >