* bcachefs CLI: question on use of mlockall()
@ 2023-12-19 4:07 Thomas Bertschinger
2023-12-19 4:17 ` Kent Overstreet
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Bertschinger @ 2023-12-19 4:07 UTC (permalink / raw)
To: linux-bcachefs
The mlockall(MCL_FUTURE) call at the beginning of the bcachefs CLI
tool seems problematic in some cases. When running commands as an
unprivileged user with the default mlock limit (8 MiB), it can cause
ENOMEM failures, for example:
$ ulimit -l
8192
$ fallocate -l $((1024 ** 3)) test-image
$ bcachefs format test-image
...
error opening test-img: ENOMEM_fs_other_alloc
While this can be worked around by running the bcachefs utility as
root, or by raising the default limit, I think commands like this
should work for unprivileged users under a common default configuration.
I wonder if the mlockall() can be targeted to the scenarios where it's
really needed, instead of applying to every bcachefs command? Some
ideas on how to target it:
- only call it if running as root
- check that getrlimit(RLIMIT_MEMLOCK, ...) is at a "high enough" value
first
- or, only call it for subcommands that actually need it
Any thoughts / comments? Would a better, or complementary approach, be
to reduce the amount of memory mapped for operations like 'format'?
Thanks!
- Thomas Bertschinger
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: bcachefs CLI: question on use of mlockall()
2023-12-19 4:07 bcachefs CLI: question on use of mlockall() Thomas Bertschinger
@ 2023-12-19 4:17 ` Kent Overstreet
0 siblings, 0 replies; 2+ messages in thread
From: Kent Overstreet @ 2023-12-19 4:17 UTC (permalink / raw)
To: Thomas Bertschinger; +Cc: linux-bcachefs
On Mon, Dec 18, 2023 at 09:07:47PM -0700, Thomas Bertschinger wrote:
> The mlockall(MCL_FUTURE) call at the beginning of the bcachefs CLI
> tool seems problematic in some cases. When running commands as an
> unprivileged user with the default mlock limit (8 MiB), it can cause
> ENOMEM failures, for example:
>
> $ ulimit -l
> 8192
> $ fallocate -l $((1024 ** 3)) test-image
> $ bcachefs format test-image
> ...
> error opening test-img: ENOMEM_fs_other_alloc
>
>
> While this can be worked around by running the bcachefs utility as
> root, or by raising the default limit, I think commands like this
> should work for unprivileged users under a common default configuration.
>
> I wonder if the mlockall() can be targeted to the scenarios where it's
> really needed, instead of applying to every bcachefs command? Some
> ideas on how to target it:
> - only call it if running as root
> - check that getrlimit(RLIMIT_MEMLOCK, ...) is at a "high enough" value
> first
> - or, only call it for subcommands that actually need it
>
> Any thoughts / comments? Would a better, or complementary approach, be
> to reduce the amount of memory mapped for operations like 'format'?
Perhaps it's time to delete it, since our run_shrinkers() path is now
also considering swap usage?
The idea was that we really don't want to be swapping, since generally
memory usage will be dominated by caches that we can evict from - we
would rather have the mmeory allocation fail instead.
But I think we can just delete it if it's not working properly, since we
also have shrinkers running in the background via a thread too.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-12-19 4:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-19 4:07 bcachefs CLI: question on use of mlockall() Thomas Bertschinger
2023-12-19 4:17 ` Kent Overstreet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox