Date: Wed, 21 Oct 2020 18:18:50 +0300 From: Nick Kostirya <nikolay.kostirya@i11.co> To: freebsd-stable@freebsd.org Subject: Re: mmap and MAP_STACK Message-ID: <20201021181850.49126cdf@i11.co> In-Reply-To: <20201021141657.GJ2643@kib.kiev.ua> References: <20201021165311.186bd606@i11.co> <20201021141657.GJ2643@kib.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 21 Oct 2020 17:16:57 +0300 Konstantin Belousov <kostikbel@gmail.com> wrote: > On Wed, Oct 21, 2020 at 04:53:11PM +0300, Nick Kostirya via freebsd-stable wrote: > > Hello. > > I have question about mmap. > > > > void *OSMem::AllocateDataArea(size_t &space) > > { > > // Round up to an integral number of pages. > > space = (space + pageSize-1) & ~(pageSize-1); > > int fd = -1; // This value is required by FreeBSD. Linux doesn't care > > int flags = MAP_PRIVATE | MAP_ANON; > > #ifdef MAP_STACK > > if (memUsage == UsageStack) flags |= MAP_STACK; // OpenBSD seems to require this > > #endif > > void *result = mmap(0, space, PROT_READ|PROT_WRITE, flags, fd, 0); > > // Convert MAP_FAILED (-1) into NULL > > if (result == MAP_FAILED) > > return 0; > > return result; > > } > > > > > > When MAP_STACK is used, "insufficient memory" error occurs. > > When MAP_STACK removed, it is all right. > > > > Please tell me why. > Show ktrace/kdump output of the mmap(2) without and with MAP_STACK. > > Or provide a minimal self-contained C source that demonstrates your > issue. kdump with MAP_STACK. 87183 polyimport CALL mmap(0,0x1000,0x3<PROT_READ|PROT_WRITE>,0x1402<MAP_PRIVATE|MAP_STACK|MAP_ANON>,0xffffffff,0,0) 87183 polyimport RET mmap -1 errno 22 Invalid argument kdump without MAP_STACK. 93712 polyimport CALL mmap(0,0x1000,0x3<PROT_READ|PROT_WRITE>,0x1002<MAP_PRIVATE|MAP_ANON>,0xffffffff,0,0) 93712 polyimport RET mmap 547053568/0x209b6000
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20201021181850.49126cdf>