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 2586529CD for ; Thu, 13 Oct 2016 12:54:03 +0200 (CEST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP; 13 Oct 2016 03:53:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,339,1473145200"; d="scan'208";a="19142071" Received: from irsmsx109.ger.corp.intel.com ([163.33.3.23]) by fmsmga006.fm.intel.com with ESMTP; 13 Oct 2016 03:53:57 -0700 Received: from irsmsx155.ger.corp.intel.com (163.33.192.3) by IRSMSX109.ger.corp.intel.com (163.33.3.23) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 13 Oct 2016 11:53:56 +0100 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.196]) by irsmsx155.ger.corp.intel.com ([169.254.14.133]) with mapi id 14.03.0248.002; Thu, 13 Oct 2016 11:53:56 +0100 From: "Ananyev, Konstantin" To: John Ousterhout , "thomas.monjalon@6wind.com" CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] eal: avoid unnecessary conflicts over rte_config file Thread-Index: AQHSJM/EwJfSODvb8U+A/Wix3wcjyaCmNfaw Date: Thu, 13 Oct 2016 10:53:55 +0000 Message-ID: <2601191342CEEE43887BDE71AB9772583F0C1256@irsmsx105.ger.corp.intel.com> References: <20161012212917.10760-1-ouster@cs.stanford.edu> In-Reply-To: <20161012212917.10760-1-ouster@cs.stanford.edu> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] eal: avoid unnecessary conflicts over rte_config file 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, 13 Oct 2016 10:54:03 -0000 Hi John, > Before this patch, DPDK used the file ~/.rte_config as a lock to detect > potential interference between multiple DPDK applications running on the > same machine. However, if a single user ran DPDK applications concurrentl= y > on several different machines, and if the user's home directory was share= d > between the machines via NFS, DPDK would incorrectly detect conflicts > for all but the first application and abort them. This patch fixes the > problem by incorporating the machine name into the config file name (e.g.= , > ~/.rte_hostname_config). >=20 > Signed-off-by: John Ousterhout > --- > doc/guides/prog_guide/multi_proc_support.rst | 11 +++++++---- > lib/librte_eal/common/eal_common_proc.c | 8 ++------ > lib/librte_eal/common/eal_filesystem.h | 15 +++++++++++++-- > 3 files changed, 22 insertions(+), 12 deletions(-) >=20 > diff --git a/doc/guides/prog_guide/multi_proc_support.rst b/doc/guides/pr= og_guide/multi_proc_support.rst > index badd102..a54fa1c 100644 > --- a/doc/guides/prog_guide/multi_proc_support.rst > +++ b/doc/guides/prog_guide/multi_proc_support.rst > @@ -129,10 +129,13 @@ Support for this usage scenario is provided using t= he ``--file-prefix`` paramete >=20 > By default, the EAL creates hugepage files on each hugetlbfs filesystem = using the rtemap_X filename, > where X is in the range 0 to the maximum number of hugepages -1. > -Similarly, it creates shared configuration files, memory mapped in each = process, using the /var/run/.rte_config filename, > -when run as root (or $HOME/.rte_config when run as a non-root user; > -if filesystem and device permissions are set up to allow this). > -The rte part of the filenames of each of the above is configurable using= the file-prefix parameter. > +Similarly, it creates shared configuration files, memory mapped in each = process. > +When run as root, the name of the configuration file will be > +/var/run/.rte_*host*_config, where *host* is the name of the machine. > +When run as a non-root user, the the name of the configuration file will= be > +$HOME/.rte_*host*_config (if filesystem and device permissions are set u= p to allow this). > +If the ``--file-prefix`` parameter has been specified, its value will be= used > +in place of "rte" in the file names. I am not sure that we need to handle all such cases inside EAL. User can easily overcome that problem by just adding something like: --file-prefix=3D`uname -n` to his command-line. Konstantin >=20 > In addition to specifying the file-prefix parameter, > any DPDK applications that are to be run side-by-side must explicitly li= mit their memory use. > diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/com= mon/eal_common_proc.c > index 12e0fca..517aa0c 100644 > --- a/lib/librte_eal/common/eal_common_proc.c > +++ b/lib/librte_eal/common/eal_common_proc.c > @@ -45,12 +45,8 @@ rte_eal_primary_proc_alive(const char *config_file_pat= h) >=20 > if (config_file_path) > config_fd =3D open(config_file_path, O_RDONLY); > - else { > - char default_path[PATH_MAX+1]; > - snprintf(default_path, PATH_MAX, RUNTIME_CONFIG_FMT, > - default_config_dir, "rte"); > - config_fd =3D open(default_path, O_RDONLY); > - } > + else > + config_fd =3D open(eal_runtime_config_path(), O_RDONLY); > if (config_fd < 0) > return 0; >=20 > diff --git a/lib/librte_eal/common/eal_filesystem.h b/lib/librte_eal/comm= on/eal_filesystem.h > index fdb4a70..4929aa3 100644 > --- a/lib/librte_eal/common/eal_filesystem.h > +++ b/lib/librte_eal/common/eal_filesystem.h > @@ -41,7 +41,7 @@ > #define EAL_FILESYSTEM_H >=20 > /** Path of rte config file. */ > -#define RUNTIME_CONFIG_FMT "%s/.%s_config" > +#define RUNTIME_CONFIG_FMT "%s/.%s_%s_config" >=20 > #include > #include > @@ -59,11 +59,22 @@ eal_runtime_config_path(void) > static char buffer[PATH_MAX]; /* static so auto-zeroed */ > const char *directory =3D default_config_dir; > const char *home_dir =3D getenv("HOME"); > + static char nameBuffer[1000]; > + int result; >=20 > if (getuid() !=3D 0 && home_dir !=3D NULL) > directory =3D home_dir; > + > + /* > + * Include the name of the host in the config file path. Otherwise, > + * if DPDK applications run on different hosts but share a home > + * directory (e.g. via NFS), they will choose the same config > + * file and conflict unnecessarily. > + */ > + result =3D gethostname(nameBuffer, sizeof(nameBuffer)-1); > snprintf(buffer, sizeof(buffer) - 1, RUNTIME_CONFIG_FMT, directory, > - internal_config.hugefile_prefix); > + internal_config.hugefile_prefix, > + (result =3D=3D 0) ? nameBuffer : "unknown-host"); > return buffer; > } >=20 > -- > 2.8.3