On 17/10/2013 09:24, Pekka Paalanen wrote:
On Wed, 16 Oct 2013 19:29:47 +0200
Olivier BLIN <olivier.b...@softathome.com> wrote:

[...]

> Having a small tmpfs is likely a common use in the embedded world, and
> it would be nice to avoid such obscure crashes if possible.
> What do you think of using fallocate() when supported instead of
> ftruncate() in wayland/weston?

Hi,

I think this would be a good idea. I have hit the SIGBUS myself before,
and did not know about fallocate() and friends.

Does the glibc fallback still avoid the application dying on SIGBUS if
space runs out?
Hi Pekka,

I have tried inlining the internal glibc fallback in my uClibc-based test application, and it also avoids the segfault, since it is using write() on the fd instead of writing on the mmaped file. write() will just error out with ENOSPC, and posix_fallocate() will forward this error code.

And actually, the glibc fallback is smarter than what I initially wrote, it is not filling the file with zero, it is just writing one byte for every block (with means for each 4k page on a tmpfs).

So, it seems to be a good compromise to use posix_fallocate() instead of ftruncate(). posix_fallocate() is more portable than fallocate(), which is Linux-specific and exposes flags which we do not need.

I guess we can just use posix_fallocate() instead of ftruncate() for all shm allocations, regardless of the kernel version. For resize operations like shm_pool_resize() in wayland-cursor, we can also use posix_fallocate() to initialize the extra space when growing instead of using ftruncate().

Thanks for your feedback

--
Olivier Blin - SoftAtHome

This message and any attachments herein are confidential, intended solely for 
the addressees and are SoftAtHome.s ownership. Any unauthorized use or 
dissemination is prohibited. If you are not the intended addressee of this 
message, please cancel it immediately and inform the sender.
This message and any attachments herein are confidential, intended solely for 
the addressees and are SoftAtHome.s ownership. Any unauthorized use or 
dissemination is prohibited. If you are not the intended addressee of this 
message, please cancel it immediately and inform the sender.
_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to