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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4A4ABCA0EFC for ; Fri, 22 Aug 2025 00:32:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZLSLUNBiq4HEKs9qp07psNfmlPQ/YUttBFlQkODjGJQ=; b=LqtZKHkEXtFNon 24IfMzm0kcfAkqgbh+V9wvPA5u5kAtIjY+x+Qc6VhWLtMIfNRqxCV5Mt4IJsJEL23SKI7rU3wraau jxFJnS25o9bSq+9EbK9NDbS2MZyRt04okrR72KHMQg2yIeVicb2hgdFuCny6xtjfkKbMsrBsb07lc Hd9qGhe7PW5y4wah+/Kko6/rfE5kTISqt2DCvfjIpASZeNAgyyQP1/chu4nqxGFvxKdp23Rw7aBUO zsQeO10Ksno/CW/2m7jUp48omR42chYAFA2NQIbsS9HkOKsMK8xmXo0RAQXgF1NK9Z6iJHKko6YNV am512cbzUAus8niZdtlA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1upFhk-0000000134k-0in8; Fri, 22 Aug 2025 00:32:28 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1upBZo-00000000NmH-40N0 for linux-riscv@lists.infradead.org; Thu, 21 Aug 2025 20:08:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1755806880; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hICKs+PYshPEfoclHwqOXtWPheskj6p8LyRcJkrFnX4=; b=d50BOTRb+SEcMJs+gPi21vd4ycSzxd+Hq6bmtV+XrL44+R89DB6hvtzUQNgULdNUcDSJVS 0goysmH283RP0xKSkgdmsR0QkSU5sOzbbYg3LDOKmhcFFui3QjMGy0RNsIGRAnFZWlO5Zp t1fmTshP+97z+qpiYMKOo/BrfLJTrNc= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-163-n_KKH4fONDyNVgQYWRYXNQ-1; Thu, 21 Aug 2025 16:07:58 -0400 X-MC-Unique: n_KKH4fONDyNVgQYWRYXNQ-1 X-Mimecast-MFC-AGG-ID: n_KKH4fONDyNVgQYWRYXNQ_1755806877 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3b9edf34ad0so613146f8f.3 for ; Thu, 21 Aug 2025 13:07:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755806877; x=1756411677; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hICKs+PYshPEfoclHwqOXtWPheskj6p8LyRcJkrFnX4=; b=iSE5lNDiBR3Ot8bdTU5XJE71bFpAyyF9DvPaYS1/b7wdSKGYDWjLcl98/M9TJ78eMN uPoTNS5JK2kh4btAdb9wlDU0tyxuGKIdyWsG/OsXiUfbuJTHQhh9wy4t/TwHuCKaNLom YMKrh1GMA/hQmllbP2VEGuK+3CvKTC2XAJvziOWJrVzdmLKLE+RhRhBVW5t8QwPxBCYM NAeuhNdZwI3rg5Y08sBHnwrhOOLoZLB0+fQ5IDMnO2oOjmJ3U0BACPEL9rM1Kw6qBYep ukNlRJrlrNM7CTMxg9Nb79FUqInOo3a7xDSF/YA65/kz2dCkaoR0WCHpH4iDf/OCZIg8 7kOA== X-Forwarded-Encrypted: i=1; AJvYcCUB/kb86NkbjtdigukU8vKhRSlsArTAI4L4La6A1S7UztP4kGpj/Lq8NRQM0N3z8Ox2f04K7O3kK+9MAQ==@lists.infradead.org X-Gm-Message-State: AOJu0YyWeFj5bbJtWrAJ6v2/9Ufcy5ivVKE5zRW05IRIewi5q8NosRsL iAQIgZxd/OZeeHsYKlJvJyvn7yo3+u7SfuQUAu2LJ9uVLPW3ra7APj538i3kxgFvxhSCBOVqDbq ZuvR7f7U7hxs+ytjrii92dzuwD///eIGL3xI8RXOZJe+Zw2us5mq76EndPqKCQBJs4LqiwtD6pd 3M2386 X-Gm-Gg: ASbGncvVO+++UY0/sDe0Ax+4To8T5yoWI1m00K0da5ZCsaCq1r+hVgnqbMtw7lRS3Pi HrWpPA9fUi8fzGL6zvuErjBXgpxMPxF7Z4tk8uvBdatxTjko8mS/bBSUpL+plBUGmdCRIUIg7GO tzyQqQ3RnrpiEd2O7ulfJbDYVyNjDI02BtoSeL2lI7UyBg4n82M+qETK4rqximxUQz8BxuY8DST 8Xhf0ZEiGnqmDvbEMXataD6R/J1NRtqQEMPxiIZYrFPfU7ljPwTQZTpPtxBNTN69W/HHkymGGWO uI6ZEj+ceWCByf2KpfhlAkqtyfFMU1dSKa08Ztb0HXeO1L7w779IkJYFq8GUiFIxf9BL3oOlc0W KT55q2f3ID9oDIe8KVoEegw== X-Received: by 2002:a05:6000:1789:b0:3b4:9721:2b2b with SMTP id ffacd0b85a97d-3c5dac17062mr195823f8f.12.1755806877252; Thu, 21 Aug 2025 13:07:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHgVLjhFaRrDh3LOBLGV7UmH7wFAxvy1IR++ErfO8cOP/XFU/ikMyZpM3bVU7Jjqctj1mhmFQ== X-Received: by 2002:a05:6000:1789:b0:3b4:9721:2b2b with SMTP id ffacd0b85a97d-3c5dac17062mr195797f8f.12.1755806876810; Thu, 21 Aug 2025 13:07:56 -0700 (PDT) Received: from localhost (p200300d82f26ba0008036ec5991806fd.dip0.t-ipconnect.de. [2003:d8:2f26:ba00:803:6ec5:9918:6fd]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3c4f77e968esm2903478f8f.21.2025.08.21.13.07.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Aug 2025 13:07:56 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: David Hildenbrand , Jens Axboe , Alexander Potapenko , Andrew Morton , Brendan Jackman , Christoph Lameter , Dennis Zhou , Dmitry Vyukov , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, iommu@lists.linux.dev, io-uring@vger.kernel.org, Jason Gunthorpe , Johannes Weiner , John Hubbard , kasan-dev@googlegroups.com, kvm@vger.kernel.org, "Liam R. Howlett" , Linus Torvalds , linux-arm-kernel@axis.com, linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-ide@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mips@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, Lorenzo Stoakes , Marco Elver , Marek Szyprowski , Michal Hocko , Mike Rapoport , Muchun Song , netdev@vger.kernel.org, Oscar Salvador , Peter Xu , Robin Murphy , Suren Baghdasaryan , Tejun Heo , virtualization@lists.linux.dev, Vlastimil Babka , wireguard@lists.zx2c4.com, x86@kernel.org, Zi Yan Subject: [PATCH RFC 18/35] io_uring/zcrx: remove "struct io_copy_cache" and one nth_page() usage Date: Thu, 21 Aug 2025 22:06:44 +0200 Message-ID: <20250821200701.1329277-19-david@redhat.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250821200701.1329277-1-david@redhat.com> References: <20250821200701.1329277-1-david@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: DxgDcp-VQuOQQf7Jx6KXBar-6MQx0Ur-5TnKzel8HkU_1755806877 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250821_130801_073968_F48E0A7B X-CRM114-Status: GOOD ( 14.20 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org We always provide a single dst page, it's unclear why the io_copy_cache complexity is required. So let's simplify and get rid of "struct io_copy_cache", simply working on the single page. ... which immediately allows us for dropping one "nth_page" usage, because it's really just a single page. Cc: Jens Axboe Signed-off-by: David Hildenbrand --- io_uring/zcrx.c | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c index e5ff49f3425e0..f29b2a4867516 100644 --- a/io_uring/zcrx.c +++ b/io_uring/zcrx.c @@ -954,29 +954,18 @@ static struct net_iov *io_zcrx_alloc_fallback(struct io_zcrx_area *area) return niov; } -struct io_copy_cache { - struct page *page; - unsigned long offset; - size_t size; -}; - -static ssize_t io_copy_page(struct io_copy_cache *cc, struct page *src_page, +static ssize_t io_copy_page(struct page *dst_page, struct page *src_page, unsigned int src_offset, size_t len) { - size_t copied = 0; + size_t dst_offset = 0; - len = min(len, cc->size); + len = min(len, PAGE_SIZE); while (len) { void *src_addr, *dst_addr; - struct page *dst_page = cc->page; - unsigned dst_offset = cc->offset; size_t n = len; - if (folio_test_partial_kmap(page_folio(dst_page)) || - folio_test_partial_kmap(page_folio(src_page))) { - dst_page = nth_page(dst_page, dst_offset / PAGE_SIZE); - dst_offset = offset_in_page(dst_offset); + if (folio_test_partial_kmap(page_folio(src_page))) { src_page = nth_page(src_page, src_offset / PAGE_SIZE); src_offset = offset_in_page(src_offset); n = min(PAGE_SIZE - src_offset, PAGE_SIZE - dst_offset); @@ -991,12 +980,10 @@ static ssize_t io_copy_page(struct io_copy_cache *cc, struct page *src_page, kunmap_local(src_addr); kunmap_local(dst_addr); - cc->size -= n; - cc->offset += n; + dst_offset += n; len -= n; - copied += n; } - return copied; + return dst_offset; } static ssize_t io_zcrx_copy_chunk(struct io_kiocb *req, struct io_zcrx_ifq *ifq, @@ -1011,7 +998,6 @@ static ssize_t io_zcrx_copy_chunk(struct io_kiocb *req, struct io_zcrx_ifq *ifq, return -EFAULT; while (len) { - struct io_copy_cache cc; struct net_iov *niov; size_t n; @@ -1021,11 +1007,7 @@ static ssize_t io_zcrx_copy_chunk(struct io_kiocb *req, struct io_zcrx_ifq *ifq, break; } - cc.page = io_zcrx_iov_page(niov); - cc.offset = 0; - cc.size = PAGE_SIZE; - - n = io_copy_page(&cc, src_page, src_offset, len); + n = io_copy_page(io_zcrx_iov_page(niov), src_page, src_offset, len); if (!io_zcrx_queue_cqe(req, niov, ifq, 0, n)) { io_zcrx_return_niov(niov); -- 2.50.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv