xwayland-shm: block signals during fallocate
posix_fallocate() does an explicit rollback if it gets EINTR, and this is a problem on slow systems because when the allocation size is sufficiently large posix_fallocate() will always be interrupted by the smart scheduler's SIGALRM. Changes since v1 - big comment in the code to explain what is going on Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Ian Ray <ian.ray@ge.com> Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Acked-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
parent
512e75a23b
commit
4cfee39872
|
@ -28,6 +28,8 @@
|
||||||
#include <dix-config.h>
|
#include <dix-config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "os.h"
|
||||||
|
|
||||||
#include "xwayland.h"
|
#include "xwayland.h"
|
||||||
|
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
@ -139,9 +141,17 @@ os_create_anonymous_file(off_t size)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
#ifdef HAVE_POSIX_FALLOCATE
|
#ifdef HAVE_POSIX_FALLOCATE
|
||||||
|
/*
|
||||||
|
* posix_fallocate does an explicit rollback if it gets EINTR.
|
||||||
|
* Temporarily block signals to allow the call to succeed on
|
||||||
|
* slow systems where the smart scheduler's SIGALRM prevents
|
||||||
|
* large allocation attempts from ever succeeding.
|
||||||
|
*/
|
||||||
|
OsBlockSignals();
|
||||||
do {
|
do {
|
||||||
ret = posix_fallocate(fd, 0, size);
|
ret = posix_fallocate(fd, 0, size);
|
||||||
} while (ret == EINTR);
|
} while (ret == EINTR);
|
||||||
|
OsReleaseSignals();
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
Loading…
Reference in New Issue