From patchwork Wed Jun 5 09:24:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kundan Kumar X-Patchwork-Id: 13686527 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9708718FDAD for ; Wed, 5 Jun 2024 09:47:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717580854; cv=none; b=Ox+mKEG6lopT9xfR9MIqV4hSl/v6PsLTWn4ulinG0P1uT0DbQIgqxwkJAuqh2RBe5zzM6a2ePWfxf4uVfr7EnFvdXpFxFTdj3kaMEfQGbjy0OhsvjzQYt4YpJGd8XktQw/3HHG8+XOYveD59inavZSryVqyk1YtDXSThU7m+92s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717580854; c=relaxed/simple; bh=twWVhE0qODsH13l8jNlnYU6LMTSQAMjcBl9X8fIvn10=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=VpRDrPBZNfkWfH6Kx/ViSbAXiguyXAD0PrSY5XaAuIBgtzacaN7WxSSEC3hVF/rU7yqY56Y1sPyfMo3lYT7XRy1qO8qs7R9DkAerRHzdMPQb2P0dEZ0ERrONycG9odVuwG1H5MUFUJ1GP4KEgYt3F59PGljTsEVwPy7Wre8RvNE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=AoiKFC96; arc=none smtp.client-ip=203.254.224.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="AoiKFC96" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20240605094730epoutp03ca7ac9488d436ddee03440bf29df098a~WEq7-McvU1454214542epoutp030 for ; Wed, 5 Jun 2024 09:47:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20240605094730epoutp03ca7ac9488d436ddee03440bf29df098a~WEq7-McvU1454214542epoutp030 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1717580850; bh=vEiOcRtnbcv+SVB6C6T2s2ws1aVXj9VFiwsT7ZEL6UQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AoiKFC96jgTnImtRVM8PQA9OddAAdvNtlNKlnhJoLZp8hI90c4pcIep/7fWsE2/oD rMxOKMe5TrTG6+3s6Z7G9cHaMxPEijV3Hvqqj6QK0xjN9rEiI05qwG2OE6C78ynwmS dGLbwJUt7m07T8s9joH3TpasBjt72cYSlqrxMDa4= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20240605094730epcas5p1fa8ffcb50c36f69bdab51e7e6d383b1a~WEq7oqPOm0305703057epcas5p1E; Wed, 5 Jun 2024 09:47:30 +0000 (GMT) Received: from epsmgec5p1new.samsung.com (unknown [182.195.38.178]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4VvN0w3bw2z4x9Q2; Wed, 5 Jun 2024 09:47:28 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmgec5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 20.25.08853.03430666; Wed, 5 Jun 2024 18:47:28 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20240605093234epcas5p151b3b39b2f2e1567c6e4ceae6130c6b9~WEd49sY1W0833508335epcas5p1w; Wed, 5 Jun 2024 09:32:34 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240605093234epsmtrp2d559341e5b8690ae545f91b7432b48ec~WEd48gCJH0105501055epsmtrp25; Wed, 5 Jun 2024 09:32:34 +0000 (GMT) X-AuditID: b6c32a44-d67ff70000002295-32-66603430f1bf Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 44.23.08336.1B030666; Wed, 5 Jun 2024 18:32:33 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240605093232epsmtip2258d7d272d666f567578917b46da1492~WEd3ODD-G3189331893epsmtip2s; Wed, 5 Jun 2024 09:32:32 +0000 (GMT) From: Kundan Kumar To: axboe@kernel.dk, hch@lst.de, willy@infradead.org, kbusch@kernel.org Cc: linux-block@vger.kernel.org, joshi.k@samsung.com, mcgrof@kernel.org, anuj20.g@samsung.com, nj.shetty@samsung.com, c.gameti@samsung.com, gost.dev@samsung.com, Kundan Kumar Subject: [PATCH v4 2/2] block: unpin user pages belonging to a folio Date: Wed, 5 Jun 2024 14:54:55 +0530 Message-Id: <20240605092455.20435-3-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240605092455.20435-1-kundan.kumar@samsung.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJJsWRmVeSWpSXmKPExsWy7bCmhq6BSUKawZ014hZNE/4yW6y+289m 8X17H4vFzQM7mSxWrj7KZHH0/1s2i0mHrjF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Rdgqh85YkaD688HbL pqaYpHv7v4qXnZy6sFCJpTgj0VCLuag4EQBap/ns8wIAAA== X-CMS-MailID: 20240605093234epcas5p151b3b39b2f2e1567c6e4ceae6130c6b9 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240605093234epcas5p151b3b39b2f2e1567c6e4ceae6130c6b9 References: <20240605092455.20435-1-kundan.kumar@samsung.com> Unpin pages which belong to same folio. This enables us to release folios on I/O completion rather than looping through pages. Suggested-by: Keith Busch Signed-off-by: Kundan Kumar --- block/bio.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/block/bio.c b/block/bio.c index 7857b9ca5957..28418170a14a 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1166,20 +1166,12 @@ void __bio_release_pages(struct bio *bio, bool mark_dirty) struct folio_iter fi; bio_for_each_folio_all(fi, bio) { - struct page *page; - size_t nr_pages; - if (mark_dirty) { folio_lock(fi.folio); folio_mark_dirty(fi.folio); folio_unlock(fi.folio); } - page = folio_page(fi.folio, fi.offset / PAGE_SIZE); - nr_pages = (fi.offset + fi.length - 1) / PAGE_SIZE - - fi.offset / PAGE_SIZE + 1; - do { - bio_release_page(bio, page++); - } while (--nr_pages != 0); + bio_release_page(bio, &fi.folio->page); } } EXPORT_SYMBOL_GPL(__bio_release_pages); @@ -1342,6 +1334,9 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) } else bio_iov_add_folio(bio, folio, len, folio_offset); + if (bio_flagged(bio, BIO_PAGE_PINNED) && num_pages > 1) + unpin_user_pages(pages + i, num_pages - 1); + /* Skip the pages which got added */ i = i + (num_pages - 1);