On Mon, Mar 04, 2024 at 07:43:39PM +0100, Mikulas Patocka wrote: > Hi > > I have a program that sets up a periodic timer with 10ms interval. When > the program attempts to call fallocate on tmpfs, it goes into an infinite > loop. fallocate takes longer than 10ms, so it gets interrupted by a > signal and it returns EINTR. On EINTR, the fallocate call is restarted, > going into the same loop again. > > fallocate(19, FALLOC_FL_KEEP_SIZE, 0, 206057565) = -1 EINTR (Přerušené volání systému) > --- SIGALRM {si_signo=SIGALRM, si_code=SI_TIMER, si_timerid=0, si_overrun=0, si_int=0, si_ptr=NULL} --- > sigreturn({mask=[]}) = -1 EINTR (Přerušené volání systému) > fallocate(19, FALLOC_FL_KEEP_SIZE, 0, 206057565) = -1 EINTR (Přerušené volání systému) > --- SIGALRM {si_signo=SIGALRM, si_code=SI_TIMER, si_timerid=0, si_overrun=0, si_int=0, si_ptr=NULL} --- > sigreturn({mask=[]}) = -1 EINTR (Přerušené volání systému) > fallocate(19, FALLOC_FL_KEEP_SIZE, 0, 206057565) = -1 EINTR (Přerušené volání systému) > --- SIGALRM {si_signo=SIGALRM, si_code=SI_TIMER, si_timerid=0, si_overrun=0, si_int=0, si_ptr=NULL} --- > sigreturn({mask=[]}) = -1 EINTR (Přerušené volání systému) > fallocate(19, FALLOC_FL_KEEP_SIZE, 0, 206057565) = -1 EINTR (Přerušené volání systému) > --- SIGALRM {si_signo=SIGALRM, si_code=SI_TIMER, si_timerid=0, si_overrun=0, si_int=0, si_ptr=NULL} --- > sigreturn({mask=[]}) = -1 EINTR (Přerušené volání systému) > > Should there be fatal_signal_pending instead of signal_pending in the > shmem_fallocate loop? > > Signed-off-by: Mikulas Patocka <mpatocka@xxxxxxxxxx> > > --- > mm/shmem.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > Index: linux-2.6/mm/shmem.c > =================================================================== > --- linux-2.6.orig/mm/shmem.c 2024-01-18 19:18:31.000000000 +0100 > +++ linux-2.6/mm/shmem.c 2024-03-04 19:05:25.000000000 +0100 > @@ -3143,7 +3143,7 @@ static long shmem_fallocate(struct file > * Good, the fallocate(2) manpage permits EINTR: we may have > * been interrupted because we are using up too much memory. > */ > - if (signal_pending(current)) > + if (fatal_signal_pending(current)) I think that's likely wrong and probably would cause regressions as there may be users relying on this?