git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/4] xmmap: inform Linux users of tuning knobs on ENOMEM

From
EWEric Wong <e@80x24.org>
Date
Jun 29, 2021, 08:11 UTC
Message-ID
<20210629081108.28657-5-e@80x24.org>
In-Reply-To
<20210629081108.28657-1-e@80x24.org>

In cases where we can't (or haven't gotten around to) attempting graceful handling of mmap failures, Linux users may benefit from additional information on how to avoid the problem.

Signed-off-by: Eric Wong <e@80x24.org>
---
 object-file.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/object-file.c b/object-file.c
index 4c043f1f3c..4139a5ebe6 100644
--- a/object-file.c
+++ b/object-file.c
@@ -1027,8 +1027,14 @@ void *xmmap(void *start, size_t length,
 	int prot, int flags, int fd, off_t offset)
 {
 	void *ret = xmmap_gently(start, length, prot, flags, fd, offset);
-	if (ret == MAP_FAILED)
+	if (ret == MAP_FAILED) {
+#if defined(__linux__)
+		if (errno == ENOMEM)
+			die_errno(_(
+"mmap failed, check sys.vm.max_map_count and/or RLIMIT_DATA"));
+#endif /* OS-specific bits */
 		die_errno(_("mmap failed"));
+	}
 	return ret;
 }
 
Previous: Eric WongNext: Eric Wong
Message 11 of 15 in “gracefully handling mmap failures”
  1. 0/4 gracefully handling mmap failuresEric Wong, Jun 29, 2021
  2. 2/4 map_loose_object_1: attempt to handle ENOMEM from mmapEric Wong, Jun 29, 2021
  3. Jeff KingJun 30, 2021
  4. Ævar Arnfjörð BjarmasonJun 30, 2021
  5. 1/4 use_pack: attempt to handle ENOMEM from mmapEric Wong, Jun 29, 2021
  6. Jeff KingJun 30, 2021
  7. 3/4 check_packed_git_idx: attempt to handle ENOMEM from mmapEric Wong, Jun 29, 2021
  8. 3/4 check_packed_git_idx: attempt to handle ENOMEM from mmapEric Wong, Jun 29, 2021
  9. Junio C HamanoJun 29, 2021
  10. Eric WongJun 29, 2021
  11. 4/4 xmmap: inform Linux users of tuning knobs on ENOMEMEric Wong, Jun 29, 2021
  12. xmmap: inform Linux users of tuning knobs on ENOMEMEric Wong, Jun 30, 2021
  13. Jeff KingJun 30, 2021
  14. Eric WongJun 30, 2021
  15. Jeff KingJun 30, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.