From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id D75163F9 for ; Tue, 9 Dec 2014 17:06:55 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 09 Dec 2014 08:02:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,545,1413270000"; d="scan'208";a="651007394" Received: from unknown ([10.252.15.213]) by orsmga002.jf.intel.com with SMTP; 09 Dec 2014 08:04:12 -0800 Received: by (sSMTP sendmail emulation); Tue, 09 Dec 2014 16:04:11 +0025 Date: Tue, 9 Dec 2014 16:04:11 +0000 From: Bruce Richardson To: Neil Horman Message-ID: <20141209160411.GA5844@bricha3-MOBL3> References: <20141209152634.GE28871@hmsreliant.think-freely.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20141209152634.GE28871@hmsreliant.think-freely.org> Organization: Intel Shannon Ltd. User-Agent: Mutt/1.5.23 (2014-03-12) Cc: "dev@dpdk.org" , Karmarkar Suyash Subject: Re: [dpdk-dev] DDPK use of MAP_FIXED in mmap 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: Tue, 09 Dec 2014 16:06:56 -0000 On Tue, Dec 09, 2014 at 10:26:34AM -0500, Neil Horman wrote: > On Mon, Dec 08, 2014 at 07:02:38PM +0000, Karmarkar Suyash wrote: > > Hello, > > > > In DPDK when we use mmap why are we passing the MAP_FIXED flag when Linux man page itself says that the option is discouraged? Any specific reason for passing the MAP_FIXED flag? > > > Because theres nothing wrong with doing so. The man page says its discouraged > because it creates less portable applications (due to the fact that not all > operating systems support MAP_FIXED). Given that we currently only support BSD > and Linux however, and given that MAP_FIXED was added to POSIX for > XSI compliant systems, it seems like a reasonable thing to use, as we will most > likely never run into a system that won't support it > Neil > Whatever about portability, I thing the best reason to avoid it is given in the quote from the map page given below: "If the memory region specified by addr and len overlaps pages of any existing mapping(s), then the overlapped part of the existing mapping(s) will be discarded." i.e. an mmap with MAP_FIXED can silently discard an existing mapping. This can lead to some strange behaviour for the unwary. /Bruce > > > > http://linux.die.net/man/2/mmap > > > > MAP_FIXED > > Don't interpret addr as a hint: place the mapping at exactly that address. addr must be a multiple of the page size. If the memory region specified by addr and len overlaps pages of any existing mapping(s), then the overlapped part of the existing mapping(s) will be discarded. If the specified address cannot be used, mmap() will fail. Because requiring a fixed address for a mapping is less portable, the use of this option is discouraged. > > > > > > Regards > > Suyash Karmarkar > >