From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796512391; b=NNGUyz+0ed3wvTVOZzpeuWyHhg2NflFaLjyk9KwlqVFedwnrOnyFQGlL9MtxdWy/UlTx wblQw+1T6pgO0Nlzhj5LILVlysj3OvZSRBylcaNBXHEIHBcwgq560VjshSAwjwZszZuFy 4LRQoBpjso4QHB6KxSWA37ycqPShBNHgQbzFdDIXYFss9rcCe8z2c7SlS/sann38NO+iQ q/En6HdSDRKTUVSkus2PB8E8fP0va9BZIv9w15IiKlihfzuVxBeHm56aWhyuncTLwiITK g5brH/FTVbOmkDE/o1ZGdIu7FXzeypGbaTD5aCD4f1Z3vK7hazaTOGuhjWaKq6n+hrQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796512391; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=Br9gvDCfJhGHpGF7APh3K7cj/VemisS3dQlSvFM/kcA=; b=3IsHanpiHhyMxnTbU4bADSx/2K/NJd2zKf+7m5eCpEd7IjIBXkiUAauskI7icBxQxZ7O AzCbYTTwvrNV2NVW3RJoaqRY2gcr76HHbPouHKo5eDa5guQuLGmJdHly33KvS3+PA4Kzu gRUeXDnGUJSumZSCXfYITrNhASx4VeZqV6n0d5ND8Si1q8NaNRRBimWvSlF62NpSmP9cV qIuzk+ghUnlWd7pJVIMZiFILpDjfw374tdweT1oWsT5nziw6d+c444GNxqpdvxm5nfaUx L21JBWwn8ve5tux+K/+KpI2nE7YZiALvhCx6cGXOkpijUJkq5s9Pe9qGWHujL1ezwGw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=kernel.dk; spf=pass smtp.mailfrom=kernel.dk; dkim=pass header.d=kernel.dk header.i=@kernel.dk header.a=rsa-sha256 header.s=google header.b=P8QaW0xa; arc=none smtp.remote-ip=209.85.210.46 Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BFB5606A335 for ; Sat, 5 Dec 2026 23:13:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1BFB5606A335 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=kernel.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.dk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.dk header.i=@kernel.dk header.a=rsa-sha256 header.s=google header.b=P8QaW0xa Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-843cf077f10so3235666a34.1 for ; Sat, 05 Dec 2026 15:13:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.dk; s=google; t=1796512390; x=1797117190; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Br9gvDCfJhGHpGF7APh3K7cj/VemisS3dQlSvFM/kcA=; b=P8QaW0xaSSxwD0Jn+D7bY20n+BGdp2hHsBTG2xUHjAFMkdqkuRdLAYaN8gWgIosT8a 8y9kdwTzujx1QpblUDAk0FZ7rz0upB7EqE/UeemO5ToRSisJj6xemUZi+rquJdhS7no0 ugY0REDSvkKTjSNrXNeWhFaQfgg9e/l8MTOp1INV4oujB026MKV3hewWgA0lrb7j+SUM 0keTqmwRowcuQVDFdasnXDqYXY1V8j8gMmcOOg4YntMPDA7vKi2Pas7PGUVSRZFTAn2V +nW7Xi+vqrzKCv3rYIsLkK2V3zP90FwRGA/yjuNIWiyFSmKsaAYv6x0hYe9PJb2mT7r+ 65Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796512390; x=1797117190; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Br9gvDCfJhGHpGF7APh3K7cj/VemisS3dQlSvFM/kcA=; b=oyn02Iz1R2o9r+Wm3otCIK87//fmHfRyEtvfqULsmYreTEQD5eSq2ws42U2GcFKfIt ep7p27fEKfmYMGmzB575wlXxDoFhi+rEgrrKdmJE6WQyagGrjjl1XSGdGxr+ovSuadIh /eJuL2zjFUoMhehKrtw2s0AdoAaVlnz2QNEN7yeNxCQWH7MVuX6+YEqS9m893gk+LjGO gI4XqJQxyN6danwpsLet+sDtspJytQr3bBnhsr8tuHU0+iixSmXt1botWEABElydmKaW 5rWuzj33Ozr//zwRj3jEYoswrZm1g94X3py3hFUvcVsY+sLI3lP9FNn5/C23FKOvUUdn aLgg== X-Gm-Message-State: APuU4Z/ujUQtVVTkUZOjoGh5WmsRXriYsxJBzLhfBYAt005I3CBB3S2R GwSf97XdhnenMb46LSaLnBWvhr5L0sjqQadhwlQFYrUOes3rZAK0InDcmdKfL6ZxvNY= X-Gm-Gg: AZFdTZd+gJ2Gr5gbWgi+8Ax9OxamkOBIxAjg7kU1bV1ZK5abOveowYQkILK6TZU0GiH MJMw2afHA05oAsOUokqH/Xg+MTmAQ5FOYxUHm+KDQodMENmLlcntDoPCojIMPPP/KOON3AlWEDq pFPKbYZqVSovoamaKwUhQ1zfRJfdkn+jlntwCsGKIqpTKnWTnefaS6jvYIBhdsVG5X8oMWx2ocb FZ9WiNNXalbHbph9QlVvhr5iLO2c8kuZ5/KxJcADg/qEOJm4jah6YyXOjb+uxDU3mwuK4yagSna wkm1gq0bU7oH1eq3t8MIZbvj9VWpaGTW7SnVk2kcQ8ui7iVGhScfdmn8xKWl8YAj6P3Odil1EMT gngkr+cmVn5a4/r2CQih0fG15SRoyv/wpSSiCQEqGhfLcdhK9yIuNGnq4AqLcaiTcOM8VNt6eW3 MfypOoCDM9S+us9mfvPlXLCw1xsH8APk/J1byiIUpsFlW3fvi0iT/+GdI4SSCiC7LhNc/d41NZR T8ikZ+PMa6qNozBABRuc9ZdAaUlSp7sTAL/VWubPR1tDRJLrqOY5GQmbYG3Q3R3J33M24vGGDta JusyqLnmYX65F1WwQvy3aInNuOmo/LEa5b7BvnstELhrdi96CTZjeWkNF9bws+Tf+DvBZlE181F gng392sPdQx5fx/9Z+DaK8RzU1eaRb9strZRH X-Received: by 2002:a05:6830:2303:b0:862:ca2e:91a6 with SMTP id 46e09a7af769-863f89caf14mr6752643a34.19.1796512390087; Sat, 05 Dec 2026 15:13:10 -0800 (PST) Received: from r7625 ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-863f8331ff6sm6269737a34.22.2026.12.05.15.13.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 15:13:09 -0800 (PST) From: Jens Axboe To: stable@vger.kernel.org Cc: io-uring@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 7.3.y 01/15] io_uring/net: don't charge the folio offset to truesize for managed frags Date: Sat, 5 Dec 2026 23:12:51 +0000 Message-ID: <20261205231305.4158103-2-axboe@kernel.dk> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261205231305.4158103-1-axboe@kernel.dk> References: <20261205231305.4158103-1-axboe@kernel.dk> X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Louis Thiery Commit aaa55c8ff9147b1ce1ba50267aa9f080d469a963 upstream. Registered buffers backed by huge pages are coalesced into one bvec per folio, so bv_offset is relative to the folio, not to a 4K page. io_sg_from_iter() adds PAGE_ALIGN(bv_len + bv_offset) to the skb truesize, which charges the socket for the whole run-up inside the folio. A 64K send from 1.5MB into a 2MB THP folio adds about 1.6MB of truesize, and sk_wmem_queued fills long before any real memory is used. The visible effect is a socket that looks full: with a 2MB send buffer only 4 of 128 queued 64K sends complete before the sender blocks, versus 30 of 128 with the same buffer registered as 4K pages, and most pipelined send_zc requests come back short. Only the in-page part of the offset matters for how much memory a fragment ties up, so use offset_in_page(). This matches what zerocopy_fill_skb_from_iter() charges for the same data. Fixes: 57bebf807e2a ("io_uring/rsrc: optimise registered huge pages") Cc: stable@vger.kernel.org Signed-off-by: Louis Thiery Reviewed-by: Pavel Begunkov Reported-by: Brian Martin Closes: https://lore.kernel.org/io-uring/CAC+fX10wVVSqGnfCg+aazorsCxB34sUDV-XJiBPd6R3Kuqc-7Q@mail.gmail.com/ Tested-by: Brian Martin Link: https://patch.msgid.link/20261119232935.1708458-1-thiery.louis@gmail.com Signed-off-by: Jens Axboe --- io_uring/net.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/io_uring/net.c b/io_uring/net.c index 4b36883e101b..d9eecff5a935 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -1501,7 +1501,12 @@ static int io_sg_from_iter(struct sk_buff *skb, struct bio_vec v = mp_bvec_iter_bvec(from->bvec, bi); copied += v.bv_len; - truesize += PAGE_ALIGN(v.bv_len + v.bv_offset); + /* + * bv_offset is relative to the folio for coalesced huge page + * registrations, so only the in-page part of it matters for + * how much memory this fragment ties up. + */ + truesize += PAGE_ALIGN(v.bv_len + offset_in_page(v.bv_offset)); __skb_fill_page_desc_noacc(shinfo, frag++, v.bv_page, v.bv_offset, v.bv_len); bvec_iter_advance_single(from->bvec, &bi, v.bv_len); -- 2.55.0