From patchwork Fri Aug 30 07:52:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kundan Kumar X-Patchwork-Id: 13784717 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 379AB16C440 for ; Fri, 30 Aug 2024 08:52:16 +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=1725007939; cv=none; b=E5Ny8/fcvcP3alTNYzMq8muU96IyfuxxDCwoA4v6lUE9BuCc+mxHiswrZJU5W16KKWtrovA74DZ/mUCr2yS0Xh7IHMUzmH+t8tm4lyfVS+nJiIUf7CoKZrA0TJcig12w3s3n72GsviZxaJ0gvZnTe9XdAMWvMUBcDdWyYs7ijdw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725007939; c=relaxed/simple; bh=aeBS7gdL/3xjmQbSjOYfKzO1dajt3Jh0zH2ttufKAz4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=JIK1UmCZlKEGErpnfjIyfw+e1viRil12FJ+l+9UTCQ+HH+36BMjT36b23Hm1lRLU7GFF3UNz9VRr6Yoqcc2EKTdKshhP7Ir8TCA5VoxD6K5wO2q+1LmUhzZsdFlHOcgShYUmHzL70lKgcV79jmzcozAGJhw57D6Qm5PZnfylarI= 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=nA9eQO0z; 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="nA9eQO0z" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20240830085215epoutp0323130bf6b319bf40bf9ca6de48f7ddfb~wdZPWSOzt3166031660epoutp03K for ; Fri, 30 Aug 2024 08:52:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20240830085215epoutp0323130bf6b319bf40bf9ca6de48f7ddfb~wdZPWSOzt3166031660epoutp03K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1725007935; bh=A3CIaU/ZqoxuRMztzhjVWSU/nQ9Qy22m5o8A1GcGoK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nA9eQO0zadkjnScz8SffLaCCFQgiDGhJy+QWU/YILef5eXjHJgeZdQykXs5iAgbaG eXaK/z/QG5R1zApM6s7OaEhYjKrmF20igmFr72odNWRFbBLAjw5XN8JK4FW4IdOHFO M+6hkxWW/VCLMMPyJGGggGXL5gHcCSL++GXo3xrM= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20240830085214epcas5p2bbcdf7ff77c415b62c6726a4efce5923~wdZOu9Ncc1050210502epcas5p2M; Fri, 30 Aug 2024 08:52:14 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.178]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4WwBjS4SKXz4x9Ps; Fri, 30 Aug 2024 08:52:12 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id BA.2C.09640.C3881D66; Fri, 30 Aug 2024 17:52:12 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240830080048epcas5p24013512a19c099ed51930f4ab0736ff0~wcsUZLKG81057810578epcas5p2W; Fri, 30 Aug 2024 08:00:48 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240830080048epsmtrp2f95aa7702866d175a9479a4ae576770e~wcsUYPT5b0971409714epsmtrp2R; Fri, 30 Aug 2024 08:00:48 +0000 (GMT) X-AuditID: b6c32a49-a57ff700000025a8-de-66d1883c8d96 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id FC.58.07567.F2C71D66; Fri, 30 Aug 2024 17:00:48 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240830080045epsmtip26b477c40f9f2a41430fcd2ebdc743b28~wcsRzP2KI2504325043epsmtip2k; Fri, 30 Aug 2024 08:00:45 +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 v9 1/4] block: Added folio-ized version of bio_add_hw_page() Date: Fri, 30 Aug 2024 13:22:54 +0530 Message-Id: <20240830075257.186834-2-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240830075257.186834-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+NgFlrHJsWRmVeSWpSXmKPExsWy7bCmhq5Nx8U0g7ZN8hZNE/4yW6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MBT9sfTlJKrl379+my6rpf6PXMp1+ZiqrIBu/7ekSRi2/ XgVLHuW32x7v6K7+8liJpTgj0VCLuag4EQCLrsE09wIAAA== X-CMS-MailID: 20240830080048epcas5p24013512a19c099ed51930f4ab0736ff0 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240830080048epcas5p24013512a19c099ed51930f4ab0736ff0 References: <20240830075257.186834-1-kundan.kumar@samsung.com> Added new bio_add_hw_folio() function as a wrapper around bio_add_hw_page(). This is a prep patch. Signed-off-by: Kundan Kumar Reviewed-by: Matthew Wilcox (Oracle) --- block/bio.c | 23 +++++++++++++++++++++++ block/blk.h | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/block/bio.c b/block/bio.c index c4053d49679a..f9d759315f4d 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1016,6 +1016,29 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio, return len; } +/** + * bio_add_hw_folio - attempt to add a folio to a bio with hw constraints + * @q: the target queue + * @bio: destination bio + * @folio: folio to add + * @len: vec entry length + * @offset: vec entry offset in the folio + * @max_sectors: maximum number of sectors that can be added + * @same_page: return if the segment has been merged inside the same folio + * + * Add a folio to a bio while respecting the hardware max_sectors, max_segment + * and gap limitations. + */ +int bio_add_hw_folio(struct request_queue *q, struct bio *bio, + struct folio *folio, size_t len, size_t offset, + unsigned int max_sectors, bool *same_page) +{ + if (len > UINT_MAX || offset > UINT_MAX) + return 0; + return bio_add_hw_page(q, bio, folio_page(folio, 0), len, offset, + max_sectors, same_page); +} + /** * bio_add_pc_page - attempt to add page to passthrough bio * @q: the target queue diff --git a/block/blk.h b/block/blk.h index e180863f918b..6afee998e80c 100644 --- a/block/blk.h +++ b/block/blk.h @@ -540,6 +540,10 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio, struct page *page, unsigned int len, unsigned int offset, unsigned int max_sectors, bool *same_page); +int bio_add_hw_folio(struct request_queue *q, struct bio *bio, + struct folio *folio, size_t len, size_t offset, + unsigned int max_sectors, bool *same_page); + /* * Clean up a page appropriately, where the page may be pinned, may have a * ref taken on it or neither. From patchwork Fri Aug 30 07:52: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: 13784563 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) (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 2410C1662EF for ; Fri, 30 Aug 2024 08:39:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725007169; cv=none; b=sEtYJf9XuMqfVsM8VNhhr6br9IvLsqEPtyjjvVMBOj1dWyQEnrAH5dvf9jXqnKv/G2k9jxsHqLz6hFTBCFE2zzIvi+UUNJ3idfHn5QxUEpTWms4luU6GJlD/u4F00jI67jCYy1ofrv6Bi6E/V5PYDvRMKg9D6V0LtaPYiGJpCOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725007169; c=relaxed/simple; bh=IaKXwVGJRjEnRA6slngATyDpmxhDCZeE9AcAifOLCuA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=fIBn1KFKq6GYIw1wifPAaoghRlVlrB/diWRx2JJZN4yuBm2RNyeZxSbC2F4GNKhjN5LfOjW57gkwn/EO6zT/PRA9JtBdk7CEFkPIO+K7QargD5zEL0nKO43r5657XDOIk6thf9TDNi05qmVs/8Hu7lHc9MjgKI/031mT2g2SqzA= 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=K1KL6fzS; arc=none smtp.client-ip=203.254.224.24 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="K1KL6fzS" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20240830083919epoutp0196a66204313978b7056396a3c04e7983~wdN8jj8IJ3142131421epoutp01D for ; Fri, 30 Aug 2024 08:39:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20240830083919epoutp0196a66204313978b7056396a3c04e7983~wdN8jj8IJ3142131421epoutp01D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1725007159; bh=s3pkBUV7KVMdvBn9edCjXcLRnM+hwZCrBgmJhdACGOg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K1KL6fzSvhNo4vr5Xpt6P+xI59pA/NmyESLjHrmVQHHCJu1j7sxCX39ovWFBMmAQS HoNWFc/w8eWaqfjjd1739TB3sOh1jzaf6FK/F/eDJZ3lGWLuRV7U9KKiLuVj9DcxDw U2a3ElQ9laIbDPAPjFzgfHxVfIE4fEyoI1OyHbwg= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240830083917epcas5p32c06a3b1b137b8fc920a5b01082b055b~wdN7iZ08A2112921129epcas5p3B; Fri, 30 Aug 2024 08:39:17 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.182]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4WwBQX15Wyz4x9Pw; Fri, 30 Aug 2024 08:39:16 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id F1.56.09642.33581D66; Fri, 30 Aug 2024 17:39:15 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20240830080052epcas5p459f462c6a2cd2b68c1c28dcfe1ec3ac2~wcsYGx7hL0243902439epcas5p4s; Fri, 30 Aug 2024 08:00:52 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240830080052epsmtrp18b984c566973940a163a80be233f5201~wcsYF9Cyw1314913149epsmtrp1b; Fri, 30 Aug 2024 08:00:52 +0000 (GMT) X-AuditID: b6c32a4b-879fa700000025aa-de-66d185331093 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 21.43.08964.43C71D66; Fri, 30 Aug 2024 17:00:52 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240830080049epsmtip2e39e7e4357d8f6e2e40225de7668e849~wcsVm5vI-2259122591epsmtip2L; Fri, 30 Aug 2024 08:00:49 +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 v9 2/4] block: introduce folio awareness and add a bigger size from folio Date: Fri, 30 Aug 2024 13:22:55 +0530 Message-Id: <20240830075257.186834-3-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240830075257.186834-1-kundan.kumar@samsung.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version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uM7/6v6VPc/a/P3/4f1ci 85GMWxvefZgnZNTEt7ytuuadJo/xrA/Pn6l8MZ7Sop62ff6xb+4xb05YypZx97Fc+dE7tfiE zZI7N5rtC79er5yr8uRTaWjWhHr/nPzOOGPGhlM75l/9Y9a8w/TwvohKP7fNf81uJhbN191h WPH8ae9p3qO9O3aeyW3KuXVfiaU4I9FQi7moOBEA2OeX/PkCAAA= X-CMS-MailID: 20240830080052epcas5p459f462c6a2cd2b68c1c28dcfe1ec3ac2 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240830080052epcas5p459f462c6a2cd2b68c1c28dcfe1ec3ac2 References: <20240830075257.186834-1-kundan.kumar@samsung.com> Add a bigger size from folio to bio and skip merge processing for pages. Fetch the offset of page within a folio. Depending on the size of folio and folio_offset, fetch a larger length. This length may consist of multiple contiguous pages if folio is multiorder. Using the length calculate number of pages which will be added to bio and increment the loop counter to skip those pages. This technique helps to avoid overhead of merging pages which belong to same large order folio. Also folio-ize the functions bio_iov_add_page() and bio_iov_add_zone_append_page() Signed-off-by: Kundan Kumar Tested-by: Luis Chamberlain Reviewed-by: Christoph Hellwig Reviewed-by: Matthew Wilcox (Oracle) --- block/bio.c | 79 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 18 deletions(-) diff --git a/block/bio.c b/block/bio.c index f9d759315f4d..c8fc97b42410 100644 --- a/block/bio.c +++ b/block/bio.c @@ -931,7 +931,8 @@ static bool bvec_try_merge_page(struct bio_vec *bv, struct page *page, if (!zone_device_pages_have_same_pgmap(bv->bv_page, page)) return false; - *same_page = ((vec_end_addr & PAGE_MASK) == page_addr); + *same_page = ((vec_end_addr & PAGE_MASK) == ((page_addr + off) & + PAGE_MASK)); if (!*same_page) { if (IS_ENABLED(CONFIG_KMSAN)) return false; @@ -1227,8 +1228,8 @@ void bio_iov_bvec_set(struct bio *bio, struct iov_iter *iter) bio_set_flag(bio, BIO_CLONED); } -static int bio_iov_add_page(struct bio *bio, struct page *page, - unsigned int len, unsigned int offset) +static int bio_iov_add_folio(struct bio *bio, struct folio *folio, size_t len, + size_t offset) { bool same_page = false; @@ -1237,30 +1238,61 @@ static int bio_iov_add_page(struct bio *bio, struct page *page, if (bio->bi_vcnt > 0 && bvec_try_merge_page(&bio->bi_io_vec[bio->bi_vcnt - 1], - page, len, offset, &same_page)) { + folio_page(folio, 0), len, offset, + &same_page)) { bio->bi_iter.bi_size += len; if (same_page) - bio_release_page(bio, page); + bio_release_page(bio, folio_page(folio, 0)); return 0; } - __bio_add_page(bio, page, len, offset); + bio_add_folio_nofail(bio, folio, len, offset); return 0; } -static int bio_iov_add_zone_append_page(struct bio *bio, struct page *page, - unsigned int len, unsigned int offset) +static int bio_iov_add_zone_append_folio(struct bio *bio, struct folio *folio, + size_t len, size_t offset) { struct request_queue *q = bdev_get_queue(bio->bi_bdev); bool same_page = false; - if (bio_add_hw_page(q, bio, page, len, offset, + 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, page); + bio_release_page(bio, folio_page(folio, 0)); return 0; } +static unsigned int get_contig_folio_len(unsigned int *num_pages, + struct page **pages, unsigned int i, + struct folio *folio, size_t left, + size_t offset) +{ + size_t bytes = left; + size_t contig_sz = min_t(size_t, PAGE_SIZE - offset, bytes); + unsigned int j; + + /* + * We might COW a single page in the middle of + * a large folio, so we have to check that all + * pages belong to the same folio. + */ + bytes -= contig_sz; + for (j = i + 1; j < i + *num_pages; j++) { + size_t next = min_t(size_t, PAGE_SIZE, bytes); + + if (page_folio(pages[j]) != folio || + pages[j] != pages[j - 1] + 1) { + break; + } + contig_sz += next; + bytes -= next; + } + *num_pages = j - i; + + return contig_sz; +} + #define PAGE_PTRS_PER_BVEC (sizeof(struct bio_vec) / sizeof(struct page *)) /** @@ -1280,9 +1312,9 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) unsigned short entries_left = bio->bi_max_vecs - bio->bi_vcnt; struct bio_vec *bv = bio->bi_io_vec + bio->bi_vcnt; struct page **pages = (struct page **)bv; - ssize_t size, left; - unsigned len, i = 0; - size_t offset; + ssize_t size; + unsigned int i = 0, num_pages; + size_t offset, folio_offset, left, len; int ret = 0; /* @@ -1322,17 +1354,28 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) goto out; } - for (left = size, i = 0; left > 0; left -= len, i++) { + for (left = size, i = 0; left > 0; left -= len, i += num_pages) { struct page *page = pages[i]; + struct folio *folio = page_folio(page); + + folio_offset = ((size_t)folio_page_idx(folio, page) << + PAGE_SHIFT) + offset; + + len = min_t(size_t, (folio_size(folio) - folio_offset), left); + + num_pages = DIV_ROUND_UP(offset + len, PAGE_SIZE); + + if (num_pages > 1) + len = get_contig_folio_len(&num_pages, pages, i, + folio, left, offset); - len = min_t(size_t, PAGE_SIZE - offset, left); if (bio_op(bio) == REQ_OP_ZONE_APPEND) { - ret = bio_iov_add_zone_append_page(bio, page, len, - offset); + ret = bio_iov_add_zone_append_folio(bio, folio, len, + folio_offset); if (ret) break; } else - bio_iov_add_page(bio, page, len, offset); + bio_iov_add_folio(bio, folio, len, folio_offset); offset = 0; } From patchwork Fri Aug 30 07:52:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kundan Kumar X-Patchwork-Id: 13784564 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) (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 B4FE11662EF for ; Fri, 30 Aug 2024 08:39:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725007172; cv=none; b=dis+lTZLB7LwVWsNUlLkys0eIv8yPYHpdXym5jfJCSXG2uKzb6GHx04TFRY+kcISjxIqOFni1yYr0UOsvP3o2S7A4ireF845HwSAihfoMrhQdAnaAXngCaWxUan4a364/19ICKy9WFfZoz6G3CYjn1aNwVHTcJrO7A43SfpU11g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725007172; c=relaxed/simple; bh=n2HUi6PFCGAkq0mstaYuRZAybzk7iMZWOVRW7SRVuMo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=kcwaR7eZpqWaPJ6CjSgbD838/ak5KKZaCsUUxJCTmY9gsJsMvknN2jqDSoZOwYA9UF6agtTQCegRBxehmk5Ik+XhGQD5VglZs4niw+hzMjtub2jvinHEEdqv9rZDKZErRxYRpyJ6uyG79z8k6faeNvvRLaNiR7+UUssrLrdfO6g= 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=tB70YN9e; arc=none smtp.client-ip=203.254.224.24 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="tB70YN9e" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20240830083928epoutp01c3aaa84cfa0189039260329dbaa84bbf~wdOFDoQL53095930959epoutp01x for ; Fri, 30 Aug 2024 08:39:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20240830083928epoutp01c3aaa84cfa0189039260329dbaa84bbf~wdOFDoQL53095930959epoutp01x DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1725007168; bh=0QdpAren0i/GWvhy3FyOVRnoFaWVPDnsAUuF7B3DNWM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tB70YN9e3hTSF1+m2molvdWz2TNR8mdexPYUsyzzosedS9pkF5Y1MHnrEnvt+yYsr Kn+mdFBdp9FJAyIprJ7Hj2rXJ+QrC66vhTKXskl7DfwOPsGskDOEj3Ak/f7/M4Vyih rfnun4xF1AWn72Gp6BoMgyefgltW0MFF2eDtnmo4= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20240830083927epcas5p2a1401afc46cdc94e447c8b4d80b7b18e~wdOEd2hCN2102921029epcas5p2h; Fri, 30 Aug 2024 08:39:27 +0000 (GMT) Received: from epsmgec5p1new.samsung.com (unknown [182.195.38.175]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4WwBQj1SkYz4x9QC; Fri, 30 Aug 2024 08:39:25 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmgec5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 49.73.08855.B3581D66; Fri, 30 Aug 2024 17:39:23 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20240830080056epcas5p40dc8e28fb3b0cc8314b2194d953191ef~wcsbyn8Bt0244102441epcas5p4a; Fri, 30 Aug 2024 08:00:56 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240830080056epsmtrp2e663df72d3c40afec3da1e9243f2cb99~wcsbw-VsT0971409714epsmtrp2c; Fri, 30 Aug 2024 08:00:56 +0000 (GMT) X-AuditID: b6c32a44-15fb870000002297-f6-66d1853b7f5c Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id AF.58.07567.73C71D66; Fri, 30 Aug 2024 17:00:55 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240830080053epsmtip29b90d05c3a3b3a92b44843ad1d4c544e~wcsZTV4Yp2259122591epsmtip2N; Fri, 30 Aug 2024 08:00:53 +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 v9 3/4] mm: release number of pages of a folio Date: Fri, 30 Aug 2024 13:22:56 +0530 Message-Id: <20240830075257.186834-4-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240830075257.186834-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+NgFtrAJsWRmVeSWpSXmKPExsWy7bCmhq5168U0g2tvmS2aJvxltlh9t5/N 4vv2PhaLmwd2MlmsXH2UyeLo/7dsFpMOXWO02PrlK6vF3lvaFjcmPGW02PZ7PrPF+Vlz2C1+ /5jD5sDrsXmFlsfls6Uem1Z1snnsvtnA5tG3ZRWjx+dNcgFsUdk2GamJKalFCql5yfkpmXnp tkrewfHO8aZmBoa6hpYW5koKeYm5qbZKLj4Bum6ZOUBnKimUJeaUAoUCEouLlfTtbIryS0tS FTLyi0tslVILUnIKTAr0ihNzi0vz0vXyUkusDA0MjEyBChOyMzp7F7IVXOataHvZwdbAOJ+7 i5GTQ0LARGLVtlMsILaQwG5GiWkXQroYuYDsT4wSj/dOZYJwvjFK/Jn5nAmm4+C+B4wQib2M EqefrGKGcD4zSrw4Nw+oioODTUBX4kdT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XnawNTDO5+5i5OSQEDCROLjvAWMXIxeHkMBuRon711rYIBIyErvv7mSFsIUlVv57 zg5R9JFRouPKWuYuRg4ONgFdiR9NoSA1IgK+Egs2PGcEsZkF3jNK3F4iDWILC9hJLHpxhAnE ZhFQlTi74R/YTF6g+IJzW1gg5stLzLz0nR3E5hSwl9gyvwesRgiopuXqIiaIekGJkzOfsEDM l5do3jqbeQKjwCwkqVlIUgsYmVYxSqYWFOem5yYbFhjmpZbrFSfmFpfmpesl5+duYgRHhZbG DsZ78//pHWJk4mA8xCjBwawkwnvi+Nk0Id6UxMqq1KL8+KLSnNTiQ4zSHCxK4ryGM2anCAmk J5akZqemFqQWwWSZODilGpiSDbm3HGpev+Knz6L+dbGTZn/kP1Xdt2N+5Y7A5bO04xnfNXuc f3FbbVqMvXhUgVBnwikGgZAAhc6pCffEdt+ZUyFWmPTu3wbmP49nGX4Pkv+XOrto/cEVt5gr ltx5IF8vHs//7JBFyZv0omkBSzZHCOX/Pnas7S/z1DUda3Q2WsR/2GZTFfvvb+VBVuMW2f3T lpq/ErpfENaqpfng1xzhJbPNhC5bO00o6fd+e4lBbpblEr70yxauHTPEI+0WNnws5xBYe1h2 ns7xLvUv2k4rH4t8UNFxscyPdzR8Hcudks55ds4Mqy3su4ztyh2/CjZo8UpO3qDUcTk3Mqsh 4cMZr/mfHhdnt7+dkTV1xgklluKMREMt5qLiRACfJmNN+QIAAA== X-CMS-MailID: 20240830080056epcas5p40dc8e28fb3b0cc8314b2194d953191ef X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240830080056epcas5p40dc8e28fb3b0cc8314b2194d953191ef References: <20240830075257.186834-1-kundan.kumar@samsung.com> Add a new function unpin_user_folio() to put the refs of a folio by npages count. The check for BIO_PAGE_PINNED flag is removed as it is already checked in bio_release_pages(). Signed-off-by: Kundan Kumar Tested-by: Luis Chamberlain Reviewed-by: Matthew Wilcox (Oracle) --- include/linux/mm.h | 1 + mm/gup.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 6549d0979b28..3de55d295cb9 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1597,6 +1597,7 @@ void unpin_user_pages_dirty_lock(struct page **pages, unsigned long npages, void unpin_user_page_range_dirty_lock(struct page *page, unsigned long npages, bool make_dirty); void unpin_user_pages(struct page **pages, unsigned long npages); +void unpin_user_folio(struct folio *folio, unsigned long npages); void unpin_folios(struct folio **folios, unsigned long nfolios); static inline bool is_cow_mapping(vm_flags_t flags) diff --git a/mm/gup.c b/mm/gup.c index 54d0dc3831fb..02c46ae33028 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -415,6 +415,19 @@ void unpin_user_pages(struct page **pages, unsigned long npages) } EXPORT_SYMBOL(unpin_user_pages); +/** + * unpin_user_folio() - release pages of a folio + * @folio: pointer to folio to be released + * @npages: number of pages of same folio + * + * Release npages of the folio + */ +void unpin_user_folio(struct folio *folio, unsigned long npages) +{ + gup_put_folio(folio, npages, FOLL_PIN); +} +EXPORT_SYMBOL(unpin_user_folio); + /** * unpin_folios() - release an array of gup-pinned folios. * @folios: array of folios to be marked dirty and released. From patchwork Fri Aug 30 07:52:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kundan Kumar X-Patchwork-Id: 13784565 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) (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 744541667F1 for ; Fri, 30 Aug 2024 08:39:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725007182; cv=none; b=pZDTnc8lkSY9UgPSbT6DQYasajdcuTqeOyN05k0tnM/5Zb1iqAIW5a+AFlsrOa8QRet+MVA4BUVzaUJ3FPC+B5KLaqjYscdG7ye9TZ3B99rM5dnkdNGq5sWAztdz0zCU6krZc4lR7IJd56wTMa11Zv8NNRCPIeBiop9+a3wLzaA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725007182; c=relaxed/simple; bh=ByjhQZNBrmtwvjzAKA7p8qjIQOlMQlAbGUvLshQ7ARw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=mAXe0I1VENQrwFEt3NsXVh7WJB2QoCfrdn6UMXFpXvVFrhDZyDpBcHhYNMjc43lfs7JLDMv01Hq/nCZyVZJJU7tD0ABnAxcTSRgJgEUAToPE7mu9TvJdPhPKhSzDpdMv8IimrgiQfWMD2skitSeQVznBkV4fKxiihbgFOTE3hyk= 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=qvO7M0za; arc=none smtp.client-ip=203.254.224.24 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="qvO7M0za" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20240830083938epoutp01c96eefad86c6f836417ebdc8ce115e88~wdOOzu_qJ3142131421epoutp01J for ; Fri, 30 Aug 2024 08:39:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20240830083938epoutp01c96eefad86c6f836417ebdc8ce115e88~wdOOzu_qJ3142131421epoutp01J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1725007178; bh=N908WA4PL4Ey099voGw4MaeeUDI9efP2rV1ZprSvzt0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qvO7M0za+FStJCqu7++ddqJjJUlG0WAYkqACCyxtcn7SCNu3ijl18bikW+j1ojZW1 1QBr67aLmlRqLB8SEW4ReZw5+awVFODx19MZtfhC5rQjOVTbH/0ovLyNVKmvG8iVUU 01ZLJXDEFfZIRxUvi1jDG8Nj7tYkDWhII5kyKZGc= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20240830083937epcas5p2ab2ae74b72ea51598cc5b2a9fc4adb2e~wdOOG0DFO2838628386epcas5p2I; Fri, 30 Aug 2024 08:39:37 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.178]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4WwBQv4YQ0z4x9Px; Fri, 30 Aug 2024 08:39:35 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id D4.69.09640.74581D66; Fri, 30 Aug 2024 17:39:35 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20240830080059epcas5p4c880e8052b5f8e70077746a947442e56~wcsfKp96m0511305113epcas5p4W; Fri, 30 Aug 2024 08:00:59 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240830080059epsmtrp178975af7d8e9c25c30d65169a7efae1c~wcsfJ5fcs1337013370epsmtrp1F; Fri, 30 Aug 2024 08:00:59 +0000 (GMT) X-AuditID: b6c32a49-aabb8700000025a8-00-66d18547954c Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 21.AA.19367.B3C71D66; Fri, 30 Aug 2024 17:00:59 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240830080057epsmtip20456ba5999e517d47785a2aa3a608810~wcscytv882259122591epsmtip2P; Fri, 30 Aug 2024 08:00:56 +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 v9 4/4] block: unpin user pages belonging to a folio at once Date: Fri, 30 Aug 2024 13:22:57 +0530 Message-Id: <20240830075257.186834-5-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240830075257.186834-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+NgFlrPJsWRmVeSWpSXmKPExsWy7bCmuq5768U0gxOLFS2aJvxltlh9t5/N 4vv2PhaLmwd2MlmsXH2UyeLo/7dsFpMOXWO02PrlK6vF3lvaFjcmPGW02PZ7PrPF+Vlz2C1+ /5jD5sDrsXmFlsfls6Uem1Z1snnsvtnA5tG3ZRWjx+dNcgFsUdk2GamJKalFCql5yfkpmXnp tkrewfHO8aZmBoa6hpYW5koKeYm5qbZKLj4Bum6ZOUBnKimUJeaUAoUCEouLlfTtbIryS0tS FTLyi0tslVILUnIKTAr0ihNzi0vz0vXyUkusDA0MjEyBChOyMz5OaWQr2MNRsehBD3sD43O2 LkZODgkBE4n3My6ydzFycQgJ7GaUOPp7BzOE84lR4vG8tQjO2zWTmWFaTq07wgqR2Mkocejc RiYI5zOjxKr9Cxm7GDk42AR0JX40hYI0iAi4S0x9+YgRpIZZ4Cm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eHhICJxKl1R1i7GLk4hAS2M0rcbFsMlZCR2H13JyuELSyx8t9z doiij4wSX35cZepi5OBgE9CV+NEUClIjIuArsWDDc0YQm1ngPaPE7SXSILawgI9E96KNLCA2 i4CqRMPLZjCbV8BO4mDjCnaI+fISMy99B7M5BewltszvAdsrBFTTcnURE0S9oMTJmU9YIObL SzRvnc08gVFgFpLULCSpBYxMqxhFUwuKc9NzkwsM9YoTc4tL89L1kvNzNzGCo0EraAfjsvV/ 9Q4xMnEwHmKU4GBWEuE9cfxsmhBvSmJlVWpRfnxRaU5q8SFGaQ4WJXFe5ZzOFCGB9MSS1OzU 1ILUIpgsEwenVAOTb9S+HZs+LU7ufmkrqZ50lq86O6/mrfbZCuGm783rb9gr7bjhn/VV+/Ne o0s6mgtYJ79+9N4/X0Mwy+DEpKuFJwv3ubwXE3y1yMhdXOfYg3KOPU+3L2zb878iXsCutqXu XcmbvbcXX5zkwm8SGWgn0fl3wYEtsdasXV9/XeezmvR3zcVz/0Q2Jam5mYh4HXr/nHmBo+UU Tn3dO6obeZXcgv4xvs3ZPaPcSCwr91S/8N1XfLJqJ5bv5fKSNCxc9SCBU07jrpH+ebPQquoJ bzhKr8z6MlPGbfOKB7P4f3btjHploTBB/tTJO3y7vPwY1m3VXm13RSMgsOTF+xS7W7Ybt6// zyk6++siZhM/+ZW7lViKMxINtZiLihMBs2C7kvUCAAA= X-CMS-MailID: 20240830080059epcas5p4c880e8052b5f8e70077746a947442e56 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240830080059epcas5p4c880e8052b5f8e70077746a947442e56 References: <20240830075257.186834-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 | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/block/bio.c b/block/bio.c index c8fc97b42410..1babe30f3a84 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);