From patchwork Wed Sep 11 06:49:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kundan Kumar X-Patchwork-Id: 13799881 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) (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 60904155386 for ; Wed, 11 Sep 2024 08:38:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726043900; cv=none; b=i7QOAGE0slOb0bjl20N6niYoqST3+whb6HVXXa3X8AsDzJGDaceBwF3QgVIzb5cmxztSpthao7viBrROZu2cgDG8KCV0dHp3rnjpb/yGD3JxSWcd/wwNVi+QAl+LARVpqtZjgsA4IMO72wzngn4qtj99R2uhUXwM3FaJZJx72zs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726043900; c=relaxed/simple; bh=dtlegLlU07witWvTzTwbtRmeFKQGBkFF+O7xn7lU2gY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=JzzN1CH+0g1QRQSH+5BkeT/e4k3JXl8HXUZM/Myoo2bm0dG5iA+Ssutb/ESyraFPJbQzZFWJee0k8sqdOE9rKIwhHfMsGkvqXlivaHD5QCuU2ebgYOauyIXUDp19mvsk3KrcqsPFKFmpyyw/ZH7M+xiyrkPJ+8YQ0H6hP+elgOA= 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=AFnfIKGf; arc=none smtp.client-ip=203.254.224.34 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="AFnfIKGf" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240911083816epoutp04329e2d6aff16fa4f37a1b9e4b3f72c32~0I8dZ6zU81125711257epoutp04W for ; Wed, 11 Sep 2024 08:38:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240911083816epoutp04329e2d6aff16fa4f37a1b9e4b3f72c32~0I8dZ6zU81125711257epoutp04W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1726043896; bh=CSqhCksDJDKePWzl3I60/6bY4Ms7uxfAgICqp6nPHOA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AFnfIKGfGd42bucbT3cVIFgghMxCvn7MTmUNnYRZ+mg3lHNX98WWiRpU2DdbdE/qs 1YoCU21N6TYIrRvyIYfbSolzfaByW0gfE+5fdn5/OvQbrhXBR13y3AbseT18lPm4EK M0XS7j7XpMBSBobeQX2lsjTBjPfS3rhqS/vFDmV4= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240911083815epcas5p39d028b0b9ccc26ed236b7f776cd76244~0I8dGSqBn0410304103epcas5p3h; Wed, 11 Sep 2024 08:38:15 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.183]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4X3Yqn4N9Fz4x9QR; Wed, 11 Sep 2024 08:38:13 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 13.8C.19863.5F651E66; Wed, 11 Sep 2024 17:38:13 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240911065722epcas5p29397d448658d52c5ef511138a6e7ed7d~0HkXMs0F00582105821epcas5p26; Wed, 11 Sep 2024 06:57:22 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240911065722epsmtrp1e586ff15c8486ca2663032f3d1f2934d~0HkXL8RR51549315493epsmtrp1Z; Wed, 11 Sep 2024 06:57:22 +0000 (GMT) X-AuditID: b6c32a50-c73ff70000004d97-a0-66e156f5850e Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id E0.8D.07567.25F31E66; Wed, 11 Sep 2024 15:57:22 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240911065719epsmtip105fd36ad2e4cb91dd35a8eb459bbf2a1~0HkUxBIUF0661306613epsmtip1K; Wed, 11 Sep 2024 06:57:19 +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, vishak.g@samsung.com, gost.dev@samsung.com, Kundan Kumar Subject: [PATCH v10 4/4] block: unpin user pages belonging to a folio at once Date: Wed, 11 Sep 2024 12:19:35 +0530 Message-Id: <20240911064935.5630-5-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240911064935.5630-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+NgFtrIJsWRmVeSWpSXmKPExsWy7bCmuu7XsIdpBj+my1s0TfjLbLH6bj+b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jVb3qQ5fpjQyr7m1J5FjPNPachN4j/+5N3EX9NadS0sgte2Jeg9ZQvb8DnTNUbgxZdz T+5c5nizTO4Ua9pmofjVetcuKrEUZyQaajEXFScCAKrd/qL4AgAA X-CMS-MailID: 20240911065722epcas5p29397d448658d52c5ef511138a6e7ed7d X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240911065722epcas5p29397d448658d52c5ef511138a6e7ed7d References: <20240911064935.5630-1-kundan.kumar@samsung.com> Use newly added mm function unpin_user_folio() to put refs by npages count. Signed-off-by: Kundan Kumar Tested-by: Luis Chamberlain --- block/bio.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/block/bio.c b/block/bio.c index d8b52bc54549..ac4d77c88932 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1190,7 +1190,6 @@ 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) { @@ -1198,12 +1197,9 @@ void __bio_release_pages(struct bio *bio, bool mark_dirty) 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); + unpin_user_folio(fi.folio, nr_pages); } } EXPORT_SYMBOL_GPL(__bio_release_pages); @@ -1241,8 +1237,8 @@ static int bio_iov_add_folio(struct bio *bio, struct folio *folio, size_t len, folio_page(folio, 0), len, offset, &same_page)) { bio->bi_iter.bi_size += len; - if (same_page) - bio_release_page(bio, folio_page(folio, 0)); + if (same_page && bio_flagged(bio, BIO_PAGE_PINNED)) + unpin_user_folio(folio, 1); return 0; } bio_add_folio_nofail(bio, folio, len, offset); @@ -1258,8 +1254,8 @@ static int bio_iov_add_zone_append_folio(struct bio *bio, struct folio *folio, if (bio_add_hw_folio(q, bio, folio, len, offset, queue_max_zone_append_sectors(q), &same_page) != len) return -EINVAL; - if (same_page) - bio_release_page(bio, folio_page(folio, 0)); + if (same_page && bio_flagged(bio, BIO_PAGE_PINNED)) + unpin_user_folio(folio, 1); return 0; }