linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mikulas Patocka <mpatocka@redhat.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
	 Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH] tmpfs: don't interrupt fallocate with EINTR
Date: Mon, 4 Mar 2024 19:43:39 +0100 (CET)	[thread overview]
Message-ID: <ef5c3b-fcd0-db5c-8d4-eeae79e62267@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2217 bytes --]

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@redhat.com>

---
 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))
 			error = -EINTR;
 		else if (shmem_falloc.nr_unswapped > shmem_falloc.nr_falloced)
 			error = -ENOMEM;

             reply	other threads:[~2024-03-04 18:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-04 18:43 Mikulas Patocka [this message]
2024-03-05  8:42 ` [PATCH] tmpfs: don't interrupt fallocate with EINTR Christian Brauner
2024-03-05  9:34   ` Mikulas Patocka
2024-03-05 10:10     ` Christian Brauner
2024-03-05 14:03       ` Mikulas Patocka
2024-03-07 10:47         ` Christian Brauner
2024-03-06 17:49   ` Jan Kara
2024-03-07 10:45     ` Christian Brauner
2024-03-07 14:59       ` Matthew Wilcox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ef5c3b-fcd0-db5c-8d4-eeae79e62267@redhat.com \
    --to=mpatocka@redhat.com \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).