Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tGq21-001Adq-1y for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Nov 2024 01:42:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tGq1y-002x6L-7G for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Nov 2024 01:42:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tGq1x-002x6C-TD for pgsql-hackers@lists.postgresql.org; Fri, 29 Nov 2024 01:42:51 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tGq1w-0005VK-P3 for pgsql-hackers@postgresql.org; Fri, 29 Nov 2024 01:42:49 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 4AT1glCB397219; Thu, 28 Nov 2024 20:42:47 -0500 From: Tom Lane To: Matthias van de Meent cc: Robert Haas , Dmitry Dolgov <9erthalion6@gmail.com>, pgsql-hackers@postgresql.org Subject: Re: Changing shared_buffers without restart In-reply-to: References: <23998.1732820235@sss.pgh.pa.us> Comments: In-reply-to Matthias van de Meent message dated "Fri, 29 Nov 2024 01:56:30 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <397217.1732844567.1@sss.pgh.pa.us> Date: Thu, 28 Nov 2024 20:42:47 -0500 Message-ID: <397218.1732844567@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Matthias van de Meent writes: > I mean, we can do the following to get a nice contiguous empty address > space no other mmap(NULL)s will get put into: > /* reserve size bytes of memory */ > base = mmap(NULL, size, PROT_NONE, ...flags, ...); > /* use the first small_size bytes of that reservation */ > allocated_in_reserved = mmap(base, small_size, PROT_READ | > PROT_WRITE, MAP_FIXED, ...); > With the PROT_NONE protection option the OS doesn't actually allocate > any backing memory, but guarantees no other mmap(NULL, ...) will get > placed in that area such that it overlaps with that allocation until > the area is munmap-ed, thus allowing us to reserve a chunk of address > space without actually using (much) memory. Well, that's all great if it works portably. But I don't see one word in either POSIX or the Linux mmap(2) man page that promises those semantics for PROT_NONE. I also wonder how well a giant chunk of "unbacked" address space will interoperate with the OOM killer, top(1)'s display of used memory, and other things that have caused us headaches with large shared-memory arenas. Maybe those issues are all in the past and this'll work great. I'm not holding my breath though. regards, tom lane