Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp103866lqb; Tue, 4 Jun 2024 06:28:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU3VDkeL1hrIeDNw55FzASnSF05Mzey2VrVT2ZQgwW3v+3jzNUllvx0c/la1zsMS288uNJxJQn8zZkmAZpbeMeZZRpgly5OEbnc4hNvgw== X-Google-Smtp-Source: AGHT+IE7cLuxMrv/BD1zkViDkFxMdwWIyLDAOkiWmBq4eleOl+Q+Hq6l3+ebMyRLL40xpEnOVq0m X-Received: by 2002:a17:907:9018:b0:a68:a4c9:9945 with SMTP id a640c23a62f3a-a68a4c9999dmr565638566b.21.1717507717424; Tue, 04 Jun 2024 06:28:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717507717; cv=pass; d=google.com; s=arc-20160816; b=FSKpHAZLZn4g/WbE20bAe5U5WZ9rSNFLW24fvEugFXKj2By1+phw4AKs3TY5OWV5iB 7BG4k8P1Lv/3Ofe/I6HUhObJUYB0OpXIRFfBYWICUjXAhxtPRrK5scCzAGWci6LIK5q1 /u+DBneLAvDmk5iYHkN3U6EQ26JKpVz9/xmGeOUuRGUEra10Hc9GF4jZOna4T6XVJnjx HxVJtBZiSGFPfT9onCop8tEkJmBBb33ibt1nWkMQL7+iwQLZHlQ9xzKbOBlkVqAFO+QP b6YjUOgmj/D0+brnJydePaP9W6+q1xJyPUqSU5sXNf2hBNoO5Jws1bT7P8GzOX+kdZYn pxWw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature:dkim-signature:dkim-signature; bh=T7H+zBd5uiJxAyzbcMOhCgD45FH3MnrN+m8PM8GN1RQ=; fh=z5xTUq7n9It90uf5x/GAZjOWmdmlUmoVmK3Z9ewSC70=; b=tls+4EQyB0rf9KzpdvG4kFrQygOC2tyoJGSWNF5Hk46FOewqfneB6CptnSGt4M6hzK f179X6XNqpbAZ4au0eiBJDW+YW+qD21P8+asKVQ4vmACdJpi56kJpOhaTY+NjDwDDh90 kVP4notDOa02SBwPpHaAFrNZgxIgAshHqMqA+K8jKzDSfpq6ka4+Ay4+JAX0P6p0plB2 +FQvavZjK91q6c7Ov8iFytMPLwmX7yM1kHHmfs83bTooTIcZC8xmBgGLt2bXSCk9DBvA oxNXV6o/CH392F8z6Zr7QYeujYfOEz4P/mPvNSzoOYJeUz6GQ3t/VZhnketBR+dEF01B VhhQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=i8oC+bxd; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=i8oC+bxd; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-200703-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200703-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a68dff63f3fsi304984866b.863.2024.06.04.06.28.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 06:28:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200703-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=i8oC+bxd; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=i8oC+bxd; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-200703-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200703-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A43001F218D4 for ; Tue, 4 Jun 2024 13:27:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DAAE146A9B; Tue, 4 Jun 2024 13:27:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="i8oC+bxd"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="gCbHatkm"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="i8oC+bxd"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="gCbHatkm" Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B19FB12D758; Tue, 4 Jun 2024 13:27:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717507663; cv=none; b=TeTGY3IBzJ/IX4p3mCfIQH3xybRdzdRJZcxHtSzracFFEgeDdS2z1JEGwWXEHM5O0kuVDuF52xkBbclJprOUGf1ShMncwxganlwpRPMA1CZ+Kx4Bc3mEzo0a+8aV9oGzCUePar8Ro/vA9HJXK919un7iv9rvaPBcTtIpNXnPmg4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717507663; c=relaxed/simple; bh=0Qy9AXHwqX38SWa8PE1Y+JZuC4siUhSC1/pt4wv78i0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VYA0Uwlsdw/Qsagy8Woxkk6S6ekTgUNnujjliclo4MLn/ccjKCMAYjtX5EA75eLa779gcDuT38O2i1JW3/aFFDbLJdoUfdJyBw4WPO8iTSus+IYUP8sgCwuIISBXTpSCULEh5TG8qMJeFWKmuCvSeRAX0BTdOR3fPgvLIFSEVnc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=i8oC+bxd; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=gCbHatkm; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=i8oC+bxd; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=gCbHatkm; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 93B461F7EB; Tue, 4 Jun 2024 13:27:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1717507658; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T7H+zBd5uiJxAyzbcMOhCgD45FH3MnrN+m8PM8GN1RQ=; b=i8oC+bxdH2LA0/2V2JUJqQo63efBps5CBWsXAENWvsLVyPsPZeM4C2QFAkhXKGiP7tpQwp ypdwyEP19VnUPEsugrb6lKuthOrDaHN2VOIRIbJ6lp3YLCsN4HIPjjwPstIb+gT1gD1bZp EOKDyI/E7i1JPhsCnvcUYfVuGID57yM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1717507658; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T7H+zBd5uiJxAyzbcMOhCgD45FH3MnrN+m8PM8GN1RQ=; b=gCbHatkm+GDg8CyHq5ji8eBAXu5QeIEp24DQHcwn//y25tWDFDZmBbeO2PLJUXvNetOLwI wgU/vbxemxVACxCA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=i8oC+bxd; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=gCbHatkm DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1717507658; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T7H+zBd5uiJxAyzbcMOhCgD45FH3MnrN+m8PM8GN1RQ=; b=i8oC+bxdH2LA0/2V2JUJqQo63efBps5CBWsXAENWvsLVyPsPZeM4C2QFAkhXKGiP7tpQwp ypdwyEP19VnUPEsugrb6lKuthOrDaHN2VOIRIbJ6lp3YLCsN4HIPjjwPstIb+gT1gD1bZp EOKDyI/E7i1JPhsCnvcUYfVuGID57yM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1717507658; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T7H+zBd5uiJxAyzbcMOhCgD45FH3MnrN+m8PM8GN1RQ=; b=gCbHatkm+GDg8CyHq5ji8eBAXu5QeIEp24DQHcwn//y25tWDFDZmBbeO2PLJUXvNetOLwI wgU/vbxemxVACxCA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8822013AB9; Tue, 4 Jun 2024 13:27:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id hls1IUoWX2YUfAAAD6G6ig (envelope-from ); Tue, 04 Jun 2024 13:27:38 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 08289A087A; Tue, 4 Jun 2024 15:27:38 +0200 (CEST) Date: Tue, 4 Jun 2024 15:27:37 +0200 From: Jan Kara To: Max Kellermann Cc: Jan Kara , axboe@kernel.dk, brauner@kernel.org, viro@zeniv.linux.org.uk, hch@infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] fs/splice: don't block splice_direct_to_actor() after data was read Message-ID: <20240604132737.rpo464bhikcvkusy@quack3> References: <20240604092431.2183929-1-max.kellermann@ionos.com> <20240604104151.73n3zmn24hxmmwj6@quack3> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Level: X-Spamd-Result: default: False [-4.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_RHS_NOT_FQDN(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_THREE(0.00)[3]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_SOME(0.00)[]; RCPT_COUNT_SEVEN(0.00)[8]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DKIM_TRACE(0.00)[suse.cz:+]; MISSING_XM_UA(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:dkim,suse.cz:email,suse.com:email] X-Rspamd-Action: no action X-Rspamd-Queue-Id: 93B461F7EB X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Flag: NO X-Spam-Score: -4.01 On Tue 04-06-24 13:14:05, Max Kellermann wrote: > On Tue, Jun 4, 2024 at 12:41 PM Jan Kara wrote: > > Well, I can see your pain but after all the kernel does exactly what > > userspace has asked for? > > That is a valid point of view; indeed the kernel's behavior is correct > according to the specification, but that was not my point. > > This is about an exotic problem that occurs only in very rare > circumstances (depending on hard disk speed, network speed and > timing), but when it occurs, it blocks the calling process for a very > long time, which can then cause problems more serious than user > unhappiness (e.g. expiring timeouts). (As I said, nginx had to work > around this problem.) > > I'd like to optimize this special case, and adjust the kernel to > always behave like the common case. > > > After all there's no substantial difference between userspace issuing a 2GB read(2) and 2GB sendfile(2). > > I understand your fear of breaking userspace, but this doesn't apply > here, because yes, there is indeed a substantial difference: in the > normal case, sendfile() stops when the destination socket buffer is > full. That is the normal mode of operation, which all applications > must be prepared for, because short sendfile() calls happen all the > time, that's the common case. > > My patch is ONLY about fixing that exotic special case where the > socket buffer is drained over and over while sendfile() still runs. OK, so that was not clear to me (and this may well be just my ignorance of networking details). Do you say that your patch changes the behavior only for this cornercase? Even if the socket fd is blocking? AFAIU with your patch we'd return short write in that case as well (roughly 64k AFAICT because that's the amount the internal splice pipe will take) but currently we block waiting for more space in the socket bufs? Honza -- Jan Kara SUSE Labs, CR