From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80A13C54E41 for ; Tue, 5 Mar 2024 14:04:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C196E6B00BE; Tue, 5 Mar 2024 09:04:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BC88E6B00C2; Tue, 5 Mar 2024 09:04:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A68F36B00C1; Tue, 5 Mar 2024 09:04:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 953ED6B00BD for ; Tue, 5 Mar 2024 09:04:31 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A3294C0EEE for ; Tue, 5 Mar 2024 14:04:30 +0000 (UTC) X-FDA: 81863155500.09.E1BCA90 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 6559840126 for ; Tue, 5 Mar 2024 14:04:02 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ApfH+2uc; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of mpatocka@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=mpatocka@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709647442; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=aUqJp7Tz54/mZg3h4LVetsuvTHNQsDWjWKBoM6zc2vw=; b=BCind0nRMaZSOvjaARLNM9DLo8SfI/WFRp52t7krrT8lv7ATuDiUXTSbWTYIQmuURsoA/c RpKAlfXXZ7iaXl2SuCP9+SpfY7wi59RxHvpq+GWeiPLHQ9x3NnRGRk4d7EYFL5NSasqQI+ AHoeyBf00xuERTfM2Rv54R2k05v1ymI= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ApfH+2uc; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of mpatocka@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=mpatocka@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709647442; a=rsa-sha256; cv=none; b=eSzwINq7SIJ6lBIlnLVbDMpij/6V+KLCYtFU+Rx7lBo4pcIRxRx2kWICMYwugwWnaJbpBg R1S5tfMClZdaosdx8QVeLVjcYJPnLKz/ddzioygnj6zxxBiuMQYCMPOaik9c6l6Yzg4fIu Zu7exQ5hjknl4vpl/TiUJWvdRCV+8g8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709647441; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=aUqJp7Tz54/mZg3h4LVetsuvTHNQsDWjWKBoM6zc2vw=; b=ApfH+2uc9S6I6AM1i9C/ZYjRHy0l477Ce2qIBrg6bA2FbH8EP4ijM6K0wM6EUgCY/aZHPO ErIAUbeCm7zz7lFTonXFRxJ6z/4VQ5b6EZ9S+Y89Aa0gA6E0fE1W+iUO8lntGPc9hEtqh+ DPKn5L9rj5vZW8ltVfvtQ0V6QBnTdcg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-689-v9wFYUOUMkOe-e5Gw-9onA-1; Tue, 05 Mar 2024 09:03:54 -0500 X-MC-Unique: v9wFYUOUMkOe-e5Gw-9onA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EEC9584B063; Tue, 5 Mar 2024 14:03:53 +0000 (UTC) Received: from file1-rdu.file-001.prod.rdu2.dc.redhat.com (unknown [10.11.5.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E5FE51C05E1C; Tue, 5 Mar 2024 14:03:53 +0000 (UTC) Received: by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix, from userid 12668) id CE99E30C1B93; Tue, 5 Mar 2024 14:03:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix) with ESMTP id CA5AD3FB4E; Tue, 5 Mar 2024 15:03:53 +0100 (CET) Date: Tue, 5 Mar 2024 15:03:53 +0100 (CET) From: Mikulas Patocka To: Christian Brauner cc: Hugh Dickins , Alexander Viro , Jan Kara , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] tmpfs: don't interrupt fallocate with EINTR In-Reply-To: <20240305-zugunsten-busbahnhof-6dc705d80152@brauner> Message-ID: References: <20240305-abgas-tierzucht-1c60219b7839@brauner> <84acfa88-816f-50d7-50a2-92ea7a7db42@redhat.com> <20240305-zugunsten-busbahnhof-6dc705d80152@brauner> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 6559840126 X-Stat-Signature: ojsapoecuzg7xw5mdizxw8bb9qq1qhy9 X-Rspam-User: X-HE-Tag: 1709647442-674658 X-HE-Meta: U2FsdGVkX1+f5J+fM+mNTebjQkSiNR+y43Uog30TWWdD1oQdeNa+6+cz5l3ACge/PW5O+mFRJiLeM6BKSR360u3qp68k5Vv42qiZptgTrB8KXYFMTJA9rQoJzk0ojYSka+uX/JnTGl58dya2crzHoMYm49ZNNpxEQ0qGbRdCWBVwBQFZuMuhNlrJj9hk3kO0Q8qnm+hDZXbsbSU/zlkLDmb43y8HtQ8w1rFlO3mRHrpRoovOgsbDEvf/+RSjDdH+iaHJ8/0VzkFHcKkFRdqrTiT6v84xNuJFPWbOT1+v5k149GVHaEYIDqH73u20fj0tdWS2z1G4yJ5USDNJU4ivIn/elmI8neWBPIh6iHa23B6vmoZpjUAJr7/6oSHn2eOT7FAPDJ4zXPt8dp4AqsCvOsDGs1P1XVBS+dUNWrBFBcrZamyJS+x+3A9h8ckyheI10COe90fnq9gLFOng50sEIve944QMcFlr4SzR/u1Jz2aG2YqmpmVNgFuiZayRueVgqY7987vMFbyNuxza534fqoUlzfI17/bmtVYslvt5Os/MiYRipxfzhXINlVtyCF2nE68tITo0zxUpb7d0+JZBK0YE75q8kpMN2/rkP5nVMNewLl3Zjx11UfS4vd0e0QR56xPT0gSzaKLOp98WVJaCH8FyLBrgBShPIBx/aEMYeKRNeLUGs3ZqR3h9C3lA+1ywGIDWuxOAbeAXk6mz2UsNjikSN8vOuSsnuGYYkn8f9WwyGlXwxfyUV0hhm9yjsCcoXW06rQBCF/6MSZ15TzPsLzuukyx08G8L0tLR8plrH/tFQMt9pHCc7e01E0pRgCeMHabTEhF7E5pryXUsFOoMfi7/CHGNmNdIEsBYAXADeSI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Tue, 5 Mar 2024, Christian Brauner wrote: > On Tue, Mar 05, 2024 at 10:34:26AM +0100, Mikulas Patocka wrote: > > > > > > On Tue, 5 Mar 2024, Christian Brauner wrote: > > > > > On Mon, Mar 04, 2024 at 07:43:39PM +0100, Mikulas Patocka wrote: > > > > > > > > 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? > > > > ext4 fallocate doesn't return -EINTR. So, userspace code can't rely on it. > > I'm confused what does this have to do with ext4 since this is about > tmpfs. You said that applications may rely on -EINTR and I said they don't because ext4 doesn't return -EINTR. > Also note, that fallocate(2) documents EINTR as a valid return > value. And fwiw, the manpage also states that "EINTR A signal was > caught during execution; see signal(7)." not a "fatal signal". Yes, but how should the userspace use the fallocate call reliably? Block all the signals around the call to fallocate? What to do if I use some library that calls fallocate and retries on EINTR? > Aside from that. If a user sends SIGUSR1 then with the code as it is now > that fallocate call will be interrupted. With your change that SIGUSR1 > won't do anything anymore. Instead userspace would need to send SIGKILL. > So userspace that uses SIGUSR1 will suddenly hang. It will survive one SIGUSR, but it hangs if the signal is being sent at a periodic interval. A quick search shows that people are already adding loops when fallocate returns EINTR. All these loops will livelock when a signal is repeatedly being delivered: https://forge.chapril.org/hardcoresushi/libgocryptfs/commit/8518d6d7bde33fdc7ef5bcb7c3c7709404392ad8?style=unified&whitespace= https://postgrespro.com/media/maillist-attaches/pgsql-hackers/2022/07/1/20220701154105.jjfutmngoedgiad3@alvherre.pgsql/v2-0001-retry-ftruncate.patch https://lists.nongnu.org/archive/html/qemu-devel/2015-02/msg01116.html Here, Postgres developers hit the same problem with retrying (they have 5ms timer): https://www.postgresql.org/message-id/CA%2BhUKGKS2Radu-1Ewhe1-LEj19C-3XAQ7wnkQMb4e9E9q9ZXSg%40mail.gmail.com Mikulas