From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <thomas.monjalon@6wind.com>
Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52])
 by dpdk.org (Postfix) with ESMTP id 733E45A49
 for <dev@dpdk.org>; Tue, 17 May 2016 18:40:47 +0200 (CEST)
Received: by mail-wm0-f52.google.com with SMTP id g17so40942333wme.1
 for <dev@dpdk.org>; Tue, 17 May 2016 09:40:47 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=6wind-com.20150623.gappssmtp.com; s=20150623;
 h=from:to:cc:subject:date:message-id:user-agent:in-reply-to
 :references:mime-version:content-transfer-encoding;
 bh=jauLHGUG+FguuPhGVnOJ/h8cdmykghAUJGRaIo5ILZI=;
 b=yEQuMpkarlUoLyftriNa8QyPkFHB+dvVd4oxud25Rs7XUTOlzQkwrDYXF3HfCAViQZ
 eGTpYXhKXbmRZ9Q3wGE4NI33TV7InTYtV+W2/QPJVtyTONKexWN+Wt6pNWLtwYHA/UCy
 njzUFX+hQIo9v5vAp6+nj/MAS8cqicNLvgnd+1adNjl0TIdp/wOrOECoe7oQyDbWp3GM
 Gt1HV3LGrlVJ+TqME+F4oHoH0asTpaUqCwVYjU4EKNhI+92E2F3ABv3h4ySWPS33gFs/
 JEjekl2H+jCANcRy1t+2+CSzhNOOWxu0uMNnQUWt7senopQ1lAdMB7NymndvyTApGMji
 6Y0A==
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:user-agent
 :in-reply-to:references:mime-version:content-transfer-encoding;
 bh=jauLHGUG+FguuPhGVnOJ/h8cdmykghAUJGRaIo5ILZI=;
 b=mtHFtoPW6JajcJVt3RYU32pUQhyUZt0YFfOSAjh6pRgqFc1Mv0/UdnDtcWbrfT7mzB
 3glBKmOz83fhE43OW2Ky22Z9QrGnNVdCBRjKS7O59DauPSj4i3tIchWAuBnk7W7oXW6D
 vXzCxINXYRdwHlkJO+uI3wtzS6QXDYZzyT8uDpSRxM1Sy/KvCHiVACQK9SzAA+YDTTaa
 /w5l0ZkuFBZ7crOs7Uwi7Dnkw/M5Gw7ILwMt6JhLecIaGHMHU2s64cRtoGYtT0C6IE+8
 ABp/f7e+Xt81S7wd1U3DOA80mJXZWVdkH0/9TYhMAapXfNPEZ1VkBiqLeuQ4wLUG1SZI
 q71A==
X-Gm-Message-State: AOPr4FV89R1MKsWiz+kmi3b4kEXm9pAQ51HHOj7rpjiAprGhRAGai8Kws2MJYfk3rWemPIwF
X-Received: by 10.194.201.37 with SMTP id jx5mr2466317wjc.60.1463503247253;
 Tue, 17 May 2016 09:40:47 -0700 (PDT)
Received: from xps13.localnet (guy78-3-82-239-227-177.fbx.proxad.net.
 [82.239.227.177])
 by smtp.gmail.com with ESMTPSA id u6sm4051501wjh.2.2016.05.17.09.40.45
 (version=TLSv1/SSLv3 cipher=OTHER);
 Tue, 17 May 2016 09:40:46 -0700 (PDT)
From: Thomas Monjalon <thomas.monjalon@6wind.com>
To: Jianfeng Tan <jianfeng.tan@intel.com>
Cc: dev@dpdk.org, david.marchand@6wind.com, sergio.gonzalez.monroy@intel.com,
 nhorman@tuxdriver.com
Date: Tue, 17 May 2016 18:40:28 +0200
Message-ID: <1671292.hQI6ccxuUZ@xps13>
User-Agent: KMail/4.14.10 (Linux/4.1.6-1-ARCH; KDE/4.14.11; x86_64; ; )
In-Reply-To: <1463013881-27985-1-git-send-email-jianfeng.tan@intel.com>
References: <1457089092-4128-1-git-send-email-jianfeng.tan@intel.com>
 <1463013881-27985-1-git-send-email-jianfeng.tan@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"
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 <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Tue, 17 May 2016 16:40:47 -0000

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?

> +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".