Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allocate shared memory instead of only reserving it #898

Merged
merged 2 commits into from
Oct 2, 2020

Conversation

DL6ER
Copy link
Member

@DL6ER DL6ER commented Sep 30, 2020

By submitting this pull request, I confirm the following:

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • I have considered, and confirmed that this submission will be valuable to others.
  • I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  • I give this submission freely, and claim no ownership to its content.

How familiar are you with the codebase?:

10


Use fallocate() instead of ftruncate() when resizing and/or creating shared memory objects.
This ensures we reserve the requested memory exclusively for ourselves. With ftruncate we only announce we want the memory, however, other processes can still take the memory when the /dev/shm is close to being full.

This has the effect that this PR ensures that FTL does not crash when /dev/shm is getting full.

In addition, even when the shared memory arena is full, there will be a better error message, like

[2020-10-01 00:18:42.812 13052M] Creating shared memory with name "FTL-lock" and size 48 (/dev/shm: 2.0GB used, 2.0GB total)
[2020-10-01 00:18:42.812 13052M] WARNING: More than 90% of /dev/shm is used
[2020-10-01 00:18:42.812 13052M] FATAL: create_shm(): Failed to resize "FTL-lock" (4) to 48: No space left on device (-1)

…ating shared memory objects. This ensures we reserve the requested memory exclusively for ourselves.

Signed-off-by: DL6ER <dl6er@dl6er.de>
@pralor-bot
Copy link

This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/ftl-hangs-when-reaching-out-of-memory/38688/21

@DL6ER DL6ER added the PR: Approval Required Open Pull Request, needs approval label Oct 2, 2020
dschaper
dschaper previously approved these changes Oct 2, 2020
src/shmem.c Outdated Show resolved Hide resolved
@DL6ER DL6ER marked this pull request as draft October 2, 2020 12:10
Signed-off-by: DL6ER <dl6er@dl6er.de>
@DL6ER DL6ER marked this pull request as ready for review October 2, 2020 12:13
@DL6ER DL6ER requested a review from dschaper October 2, 2020 12:26
@DL6ER DL6ER merged commit 184a457 into development Oct 2, 2020
@DL6ER DL6ER deleted the tweak/allocate_not_reserve branch October 2, 2020 13:04
@pralor-bot
Copy link

This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/pi-hole-core-web-v5-2-and-ftl-v5-3-released/40909/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement PR: Approval Required Open Pull Request, needs approval
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants