From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS151847 202.12.124.0/24 X-Spam-Status: No, score=-3.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, URIBL_SBL_A shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from fout-b5-smtp.messagingengine.com (fout-b5-smtp.messagingengine.com [202.12.124.148]) (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 dcvr.yhbt.net (Postfix) with ESMTPS id 941331F4CC for ; Tue, 7 Jan 2025 17:47:55 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (2048-bit key; unprotected) header.d=alyssa.is header.i=@alyssa.is header.a=rsa-sha256 header.s=fm1 header.b=2K2PF4tT; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=oEaJ8wqN; dkim-atps=neutral Received: from phl-compute-06.internal (phl-compute-06.phl.internal [10.202.2.46]) by mailfout.stl.internal (Postfix) with ESMTP id C5C8C114011A for ; Tue, 7 Jan 2025 12:47:54 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Tue, 07 Jan 2025 12:47:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alyssa.is; h=cc :content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1736272074; x= 1736358474; bh=8nrWRP4MlSimXWRMUAWoyrMAsk9lLT2hs9nQM64RWBI=; b=2 K2PF4tT9yRW7Xpac4CM658tDV1TUQiMETPjfVBM+CDUmmpAAPyJM+aB/l0zEgwsV 5IaRI7mYJYFHKjTxXTwAzaLA6Sa9+63k6U0/Rod18e65wS2tw46jGQLu4lAwaxnq suKVFMY52+sn74WXX90RpYvPeGdylHcZPbyozEIMolkMpZz6kLhlJGCgyPBUpSQo 3om9vwOQMkGxj4+oh2POG3SkWxtI9UIYuf46R/8kfyIqm1tzMBqvfk/Vv1kaXDe1 gjMXaH0YeFB63QEPPcZwt9UyYiRJy/rUrVJHzgtBO52jgEW1jCCPvd/WIFSA3QLD x69FpLt8WyvaQ/k4VmzKw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1736272074; x=1736358474; bh=8nrWRP4MlSimXWRMUAWoyrMAsk9l LT2hs9nQM64RWBI=; b=oEaJ8wqNaoWB69CpHgF5MJvCOtjMAIbRusHpjzj5Q33z 0e++kK0oJ8Z1/Vhuf93eNSX2F5yn7Ldb6Pbopp29WF/cuHsEkNe3e81RqkV7EsjY AFz7tPKZ8Ej9mzOvCLNVPm+CGJBvo0jzdzsZs5XHVgwWAlywB0pH6z92/wLkxeXx IMc5jAXNi54k9KqmnOaedxEnAquRT9oSUaILQHtbKEZihaTWTVnaDAvMTU0B2G+V HrOjTJ/fLChHczYWOS/b0aAGk+sSKm7y/ELyLJPH19SCG5sdAnyphu09VN3h8iRQ 6XhqNdTmChJ/rzC6PuJX4Tr3S3mHIPrg0Nbz6o69UQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrudegvddguddtfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhephffvuf ffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeetlhihshhsrgcutfhoshhsuceo hhhisegrlhihshhsrgdrihhsqeenucggtffrrghtthgvrhhnpefgfedukedvleeileelud efveehgeelgfegvddujedvtdffueeuveffheeljeekvdenucevlhhushhtvghrufhiiigv pedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehhihesrghlhihsshgrrdhishdpnhgspg hrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepmhgvthgrsehp uhgslhhitgdqihhnsghogidrohhrgh X-ME-Proxy: Feedback-ID: i12284293:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 7 Jan 2025 12:47:54 -0500 (EST) Received: by mbp.qyliss.net (Postfix, from userid 1000) id 7A20CD8F0; Tue, 07 Jan 2025 18:47:52 +0100 (CET) From: Alyssa Ross To: meta@public-inbox.org Subject: [PATCH 2/2] treewide: lose F_SETPIPE_SZ page size assumptions Date: Tue, 7 Jan 2025 18:46:25 +0100 Message-ID: <20250107174624.1504268-3-hi@alyssa.is> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250107174624.1504268-1-hi@alyssa.is> References: <20250107174624.1504268-1-hi@alyssa.is> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: fcntl(2) is documented as rounding up sizes to an integer multiple of the page size. When a pipe buffer as small as possible is desired, it's cleaner to pass 0 and let the kernel set the pipe buffer to exactly one page than it is to assume that pages are 4096 bytes. Currently, Linux doesn't support pages smaller than 4096 bytes, so this is a purely stylistic change, but I think it will help avoid future bugs caused by assuming page sizes are 4096 bytes. lib/PublicInbox/EOFpipe.pm | 4 ++-- lib/PublicInbox/LeiXSearch.pm | 6 +++--- lib/PublicInbox/SearchIdxShard.pm | 2 +- t/gcf2.t | 4 ++-- t/lei-sigpipe.t | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/PublicInbox/EOFpipe.pm b/lib/PublicInbox/EOFpipe.pm index 3eaa0e4e..9fe9f67d 100644 --- a/lib/PublicInbox/EOFpipe.pm +++ b/lib/PublicInbox/EOFpipe.pm @@ -10,8 +10,8 @@ use Errno qw(EAGAIN); sub new { my (undef, $rd, @cb_args) = @_; my $self = bless { cb_args => \@cb_args }, __PACKAGE__; - # 4096: page size - fcntl($rd, $F_SETPIPE_SZ, 4096) if $F_SETPIPE_SZ; + # 0: one page + fcntl($rd, $F_SETPIPE_SZ, 0) if $F_SETPIPE_SZ; $rd->blocking(0); # avoid EINTR $self->SUPER::new($rd, EPOLLIN); # level trigger for spurious wakeup } diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm index e20b13c6..909e16ed 100644 --- a/lib/PublicInbox/LeiXSearch.pm +++ b/lib/PublicInbox/LeiXSearch.pm @@ -545,16 +545,16 @@ sub do_query { # setup two barriers to coordinate ->has_entries # between l2m workers pipe(my ($a_r, $a_w)) or die "pipe: $!"; - fcntl($a_r, $F_SETPIPE_SZ, 4096) if $F_SETPIPE_SZ; + fcntl($a_r, $F_SETPIPE_SZ, 0) if $F_SETPIPE_SZ; pipe(my ($b_r, $b_w)) or die "pipe: $!"; - fcntl($b_r, $F_SETPIPE_SZ, 4096) if $F_SETPIPE_SZ; + fcntl($b_r, $F_SETPIPE_SZ, 0) if $F_SETPIPE_SZ; $l2m->{au_peers} = [ $a_r, $a_w, $b_r, $b_w ]; } $l2m->wq_workers_start('lei2mail', undef, $lei->oldset, { lei => $lei }, \&xsearch_done_wait, $lei); pipe($lei->{startq}, $lei->{au_done}) or die "pipe: $!"; - fcntl($lei->{startq}, $F_SETPIPE_SZ, 4096) if $F_SETPIPE_SZ; + fcntl($lei->{startq}, $F_SETPIPE_SZ, 0) if $F_SETPIPE_SZ; delete $l2m->{au_peers}; close(delete $l2m->{-wq_s2}); # share wq_s1 with lei_xsearch } diff --git a/lib/PublicInbox/SearchIdxShard.pm b/lib/PublicInbox/SearchIdxShard.pm index 7ee8a121..c12aef9e 100644 --- a/lib/PublicInbox/SearchIdxShard.pm +++ b/lib/PublicInbox/SearchIdxShard.pm @@ -26,7 +26,7 @@ sub new { # are small, make the response pipe as small as possible if ($F_SETPIPE_SZ) { fcntl($self->{-ipc_req}, $F_SETPIPE_SZ, 1048576); - fcntl($self->{-ipc_res}, $F_SETPIPE_SZ, 4096); + fcntl($self->{-ipc_res}, $F_SETPIPE_SZ, 0); } } $self; diff --git a/t/gcf2.t b/t/gcf2.t index 33f3bbca..28c69a01 100644 --- a/t/gcf2.t +++ b/t/gcf2.t @@ -110,7 +110,7 @@ SKIP: { for my $blk (1, 0) { my ($r, $w); pipe($r, $w) or BAIL_OUT $!; - fcntl($w, $F_SETPIPE_SZ, 4096) or + fcntl($w, $F_SETPIPE_SZ, 0) or skip('Linux too old for F_SETPIPE_SZ', 14); $w->blocking($blk); seek($fh, 0, SEEK_SET) or BAIL_OUT "seek: $!"; @@ -130,7 +130,7 @@ SKIP: { $ck_copying->("pipe blocking($blk)"); pipe($r, $w) or BAIL_OUT $!; - fcntl($w, $F_SETPIPE_SZ, 4096) or BAIL_OUT $!; + fcntl($w, $F_SETPIPE_SZ, 0) or BAIL_OUT $!; $w->blocking($blk); close $r; local $SIG{PIPE} = 'IGNORE'; diff --git a/t/lei-sigpipe.t b/t/lei-sigpipe.t index c01d9f83..f093dc5c 100644 --- a/t/lei-sigpipe.t +++ b/t/lei-sigpipe.t @@ -33,7 +33,7 @@ test_lei(sub { my $imported; for my $out ([], [qw(-f mboxcl2)], [qw(-f text)]) { pipe(my $r, my $w); - my $size = ($F_SETPIPE_SZ && fcntl($w, $F_SETPIPE_SZ, 4096)) || + my $size = ($F_SETPIPE_SZ && fcntl($w, $F_SETPIPE_SZ, 0)) || 65536; unless (-f $f) { my $fh = write_file '>', $f, <<'EOM'; -- 2.47.0