From patchwork Fri Nov 18 02:14:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13047663 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8294CC4167B for ; Fri, 18 Nov 2022 02:14:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 058276B0073; Thu, 17 Nov 2022 21:14:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F24346B0075; Thu, 17 Nov 2022 21:14:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E0F416B0078; Thu, 17 Nov 2022 21:14:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D34A46B0073 for ; Thu, 17 Nov 2022 21:14:20 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9C4ACC0684 for ; Fri, 18 Nov 2022 02:14:20 +0000 (UTC) X-FDA: 80144943480.24.FE947A8 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by imf25.hostedemail.com (Postfix) with ESMTP id 405A1A000B for ; Fri, 18 Nov 2022 02:14:20 +0000 (UTC) Received: by mail-pl1-f179.google.com with SMTP id w23so3316328ply.12 for ; Thu, 17 Nov 2022 18:14:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3YDT/XAgh5QSXlyod86SZaadrvntYw6ff/cmVDaxdzo=; b=WIhEVv40bO8pPOe0T4T4maV1rYV4pai+d0aHe5h0r42FibWzau6xqjlbhDYj7fVP+/ YVbz1QBIEi5smOOlTRsnqvFnOSv1Un3EXZls7avo8RWt8GuSdf13vWB1vX+nyGT9q/EA T4uFXOL3nEQg/604IZpT78KAD+oBUy2DhDfpQmyGPPQ90V+476q3TDhM8JO5/eefRo39 Kc6oAfVStZxNFPpjkSEaVmtKQ/MwyY+KaTUq/ui8Z+wJ5NVT0RpHdPebMV2bUg0O0Yfb SscM0FktFuryyy6iQ7l4iU39d7doVgLL5n+BXTp0RKjfosJtcvVKIK7EIBdl3j/ynnVZ 8T3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=3YDT/XAgh5QSXlyod86SZaadrvntYw6ff/cmVDaxdzo=; b=SaBaO2pSmFYcChzvQlIdHGsEbDVe6dUiLNCa0UUFYBYLZCtQxh86Q6ueUBytW1+FCW wn69MxS3t8ssWnN/A524ggnQ9S/LaDit4WgTIBZojLyD91mWNq2aRuIFIpdk3xOEw1E7 cwIZy19vgBSKe3KPQdJOosrbGsADEmoVmOJoS0w1AvmLS0Onnh3R89AshD4uSAYq83xU rQsZvZZ2O3aUpVH5CnKr84a9iJRUtObu1Ry3rtdi47g3JYd6usoCwc27ib7W+6O42Cxa oXRrAYIKZaefhwjtm4+QVEINRVjserwpbwlO9v9ZV7HE/MlwqAmJc0Uxz3tKm2M3es8a Ra3w== X-Gm-Message-State: ANoB5pks3Ab7V/HAdsKBjMLROcVnseT1FmoZouC8pwXb63SbE2bfoYsy keXlVirjaXIdR3CkrFVC6p4TNpljcvS0HA== X-Google-Smtp-Source: AA0mqf6GjOQDWGuexUgf38gfQKvCyqZA7SD4wDQnxu1HJGFKP1gZXSLR4W2L7BYbOtRyfWYq70EdTQ== X-Received: by 2002:a17:90b:117:b0:212:f2be:bc38 with SMTP id p23-20020a17090b011700b00212f2bebc38mr11372286pjz.175.1668737658849; Thu, 17 Nov 2022 18:14:18 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::2c6b]) by smtp.googlemail.com with ESMTPSA id ip13-20020a17090b314d00b00212cf2fe8c3sm10678445pjb.1.2022.11.17.18.14.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 18:14:18 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, akpm@linux-foundation.org, willy@infradead.org, naoya.horiguchi@nec.com, tytso@mit.edu, "Vishal Moola (Oracle)" Subject: [PATCH v2 2/4] khugepage: Replace try_to_release_page() with filemap_release_folio() Date: Thu, 17 Nov 2022 18:14:08 -0800 Message-Id: <20221118021410.24420-3-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221118021410.24420-1-vishal.moola@gmail.com> References: <20221118021410.24420-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668737660; a=rsa-sha256; cv=none; b=tBRdYuRHJsFdOhuB/PRGdJtmSXV3rwFuprbtIzwmsn80U8Jf4WOlSGU9IFWHC9nvl3VL/S RYVJMh7kx2DGnz0DSnSZiVKQob5QkERS1d3agsejMPB+HV+2f2qeYUIcijsVJ3fSjYgjpR xO7l6i+gJWPJfa3HvLJvaUB2yBsP3Iw= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=WIhEVv40; spf=pass (imf25.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.179 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668737660; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3YDT/XAgh5QSXlyod86SZaadrvntYw6ff/cmVDaxdzo=; b=VLPsliOHTzS+7g9khFBPMn2XQ/ETkatUr9WpOhqrQcPoepEe0oAvzd6ZtsdkEzUjjsaaDc 70kg1kyTzEkBLqKNoc3s1pepQhiHJeOjgwA3LgF4wapRFzKgZHBZjLukq9SvY6b1K0KYz8 JY6FZqyc6l00ICP2nP+51H9AsK+Xx+c= X-Stat-Signature: amtwctqmmukppnb54suamsiaow9i5s6g X-Rspamd-Queue-Id: 405A1A000B Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=WIhEVv40; spf=pass (imf25.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.179 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Rspam-User: X-HE-Tag: 1668737660-63361 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000060, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Replaces some calls with their folio equivalents. This change removes 4 calls to compound_head() and is in preparation for the removal of the try_to_release_page() wrapper. Signed-off-by: Vishal Moola (Oracle) --- mm/khugepaged.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 4734315f7940..3f21c010d2bd 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1747,6 +1747,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, xas_set(&xas, start); for (index = start; index < end; index++) { struct page *page = xas_next(&xas); + struct folio *folio; VM_BUG_ON(index != xas.xa_index); if (is_shmem) { @@ -1773,8 +1774,6 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, } if (xa_is_value(page) || !PageUptodate(page)) { - struct folio *folio; - xas_unlock_irq(&xas); /* swap in or instantiate fallocated page */ if (shmem_get_folio(mapping->host, index, @@ -1862,13 +1861,15 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, goto out_unlock; } - if (page_mapping(page) != mapping) { + folio = page_folio(page); + + if (folio_mapping(folio) != mapping) { result = SCAN_TRUNCATED; goto out_unlock; } - if (!is_shmem && (PageDirty(page) || - PageWriteback(page))) { + if (!is_shmem && (folio_test_dirty(folio) || + folio_test_writeback(folio))) { /* * khugepaged only works on read-only fd, so this * page is dirty because it hasn't been flushed @@ -1878,20 +1879,20 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, goto out_unlock; } - if (isolate_lru_page(page)) { + if (folio_isolate_lru(folio)) { result = SCAN_DEL_PAGE_LRU; goto out_unlock; } - if (page_has_private(page) && - !try_to_release_page(page, GFP_KERNEL)) { + if (folio_has_private(folio) && + !filemap_release_folio(folio, GFP_KERNEL)) { result = SCAN_PAGE_HAS_PRIVATE; - putback_lru_page(page); + folio_putback_lru(folio); goto out_unlock; } - if (page_mapped(page)) - try_to_unmap(page_folio(page), + if (folio_mapped(folio)) + try_to_unmap(folio, TTU_IGNORE_MLOCK | TTU_BATCH_FLUSH); xas_lock_irq(&xas);