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 4vv2PhaLmwd2MlmsXH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pO3qDUcTk3Mqsh 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.