From patchwork Wed Aug 16 15:12:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13355385 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 B8656C04A6A for ; Wed, 16 Aug 2023 15:12:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DBFD8D0001; Wed, 16 Aug 2023 11:12:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 28C04280021; Wed, 16 Aug 2023 11:12:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17CA88D0047; Wed, 16 Aug 2023 11:12:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 08F4A8D0001 for ; Wed, 16 Aug 2023 11:12:53 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C39C0140DE0 for ; Wed, 16 Aug 2023 15:12:52 +0000 (UTC) X-FDA: 81130310184.29.DDDE6CB Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf01.hostedemail.com (Postfix) with ESMTP id D26FB4022A for ; Wed, 16 Aug 2023 15:12:14 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=WlknXyZu; dmarc=none; spf=none (imf01.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692198735; a=rsa-sha256; cv=none; b=jj8g+YfGtaUMGtSzpHqRitXwiFY6XsZg5D7JrQDZB82loE4hzJAewM2BELmrM0eCj7IftE xgpsEk1DA9OD2GKxmbuOAQdks4pw2mcquzJ+uj1z+ZZp/GRF1BZpTJ6Zbdf3o1dPmcih/P Cxl3DqlzQCfh2mukN0ICfYpbOXo9zlE= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=WlknXyZu; dmarc=none; spf=none (imf01.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692198735; 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=0vtiyxjxIiaXbIAeymWG2xctwrMSMhwhXh76m1ko6N4=; b=S8mMP+ooB/C0/KS+gnK27v1SR+GvuOd5GZE6bJGZK8Rktj5WNlHzk04igWSm/txNKk0L5U wg3gZ0CTxn1ztjzGoUsB6qnpc/tahoh14CJpWsjYEzZ8aWSHWUspxgMxa1DqwJWUlaKaa/ sandiLCEj/sUZw1fOmrG+aEIfNC+NHE= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=0vtiyxjxIiaXbIAeymWG2xctwrMSMhwhXh76m1ko6N4=; b=WlknXyZuozWr/mDoG17T9epOii ow7iLBULSWgdtKs8v7Xqw+ORWhqJ0TVudIUNaiSUnJv0Le1gaUH4UbGA/egB13UsHJWAd+q3A4+qj vfScYM+JAWQKn32132LyvsY+nJnvK3H1IHLzxrxPnQFXx9hdfiq0wvorG0K4efZcBmD4gLVaxkrrV zzsjJi1rNKgkFoUi8NdO8FL4R5fp2WVf/vS9zNlRplQqX7HRVNMIZ1mzOGXJluJrSfatef2H99k9w nkW0bJujqUFiIrBZW2OBrJRLcN1d7FxXyOeGPDoIbUjp/anNBCDqdizH/GuVm0VUlVzQ4a943byHm oj9MbNvg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qWIBv-00FL96-2R; Wed, 16 Aug 2023 15:12:11 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , Jens Axboe , io-uring@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 13/13] mm: Convert split_huge_pages_pid() to use a folio Date: Wed, 16 Aug 2023 16:12:01 +0100 Message-Id: <20230816151201.3655946-14-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230816151201.3655946-1-willy@infradead.org> References: <20230816151201.3655946-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D26FB4022A X-Stat-Signature: wtjus6ddg81eyfkwma5my4uuizp9o8fe X-HE-Tag: 1692198734-689677 X-HE-Meta: U2FsdGVkX1/v+zU9Khhk4HNVBTkvo0v2yVIwjwmlDKs6lWQk7zLB1SpvTVHQsiAAVYdW9PibExCrj5OplecDUC2GNcbva8hElCbhbdBD/dPZlxax9YXXb2uMMF9t/2gsljckGQNC/6il96PHZ4LS531NF552nfdFGFT6IiKWMVPVOnY7H9ehvvl2CgVBkhofSBijPTHk2siqs1BU9HiS6E7Bl0G3JF7rODpkUHEq2gk1NU7I3c9BVZEDC4T/PzsnyHD61zT/QNbjK1aIHM5di6NgFp5IQQMGcLk2zkyPX/n3gAM7EapV6hd5ebzYfeMXRW4eIPlZNStNpN1H3rzIxE2pLoCOCy57u3cGJ5ULEv0y1k+P/zq7N11n6YsUgtvE/FwABRPlr54BYtLtpLLtxf+OolwfkLKAkZ1cdw/KSgy1BQG+3MhLJIlwd8l+dJCUrIVtemQVAJKHpgvNaFI7l3fb73UQFRx5I4/ZiBX+Kvru8omxypm1OroATa/vmWwerKUbbRZlFnNQ75YhFxGh3+ca3n8NfgiKWLBPiWII7ta5zQFhLkmAkR0RLhRCraJu71x4JgcBsQBO4VQR3N9HmMBw4PXx3zIPJvTGyUZlXJ/2AjHHabYEm9Zeinb00uc+zg1H5Ael6k/7J8RbZjkRbljxLBAPLiBd0mIunNc6JIPYqFpjyod8s6gsbdBxXWl2T7Jar0rLDu0y77dtUowLTgASHyT9VbRTZ1cJ6ZEyGeIQGNc2ogarb4jdSKkU+UTAH07NrvosYMJvHXN4bOu+32ox0fy5KoDf9oKOei7+7CSogHC39oNGFrfe1TMDYyLLqst69kaBk83V163pRlAJivqXku0Ghb8Neo+RIP5aW4E9ZC49d9Uvtf0r+TTa6SjsbI1mDMOalX7a/vuPVw1m66XPmbZNLiMf6fxRC/20YVgiAOFs3d8bZkRiAIKK/WVOD1jgJAEBm7xx25l1N0H uSU5poHb 6swm/zLb+2sdj/NpEkVBDnuzhhc+QNCJZhzmKP0yxI2XMtzpcLTpdREpY9Z4VVAJE4TdeNlcJPjPbayhTeEhJIrGXPmUIpdH3gcUnYryAnze1EEXxmCk0/CzwpPgcvkCgtjeL+6ZAlEYNAKgw0NQ7l/Bnih/oFlR5xVS1xWRY6cH1FV5WN47cesTgTITT5prvKP9qgnEjyoJgShIIS5Fq+YHq9reDr3CMy/un X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Replaces five calls to compound_head with one. Signed-off-by: Matthew Wilcox (Oracle) --- mm/huge_memory.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index c721f7ec5b6a..4ffc78edaf26 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -584,14 +584,11 @@ void folio_prep_large_rmappable(struct folio *folio) folio_set_large_rmappable(folio); } -static inline bool is_transparent_hugepage(struct page *page) +static inline bool is_transparent_hugepage(struct folio *folio) { - struct folio *folio; - - if (!PageCompound(page)) + if (!folio_test_large(folio)) return false; - folio = page_folio(page); return is_huge_zero_page(&folio->page) || folio_test_large_rmappable(folio); } @@ -3015,6 +3012,7 @@ static int split_huge_pages_pid(int pid, unsigned long vaddr_start, for (addr = vaddr_start; addr < vaddr_end; addr += PAGE_SIZE) { struct vm_area_struct *vma = vma_lookup(mm, addr); struct page *page; + struct folio *folio; if (!vma) break; @@ -3031,22 +3029,23 @@ static int split_huge_pages_pid(int pid, unsigned long vaddr_start, if (IS_ERR_OR_NULL(page)) continue; - if (!is_transparent_hugepage(page)) + folio = page_folio(page); + if (!is_transparent_hugepage(folio)) goto next; total++; - if (!can_split_folio(page_folio(page), NULL)) + if (!can_split_folio(folio, NULL)) goto next; - if (!trylock_page(page)) + if (!folio_trylock(folio)) goto next; - if (!split_huge_page(page)) + if (!split_folio(folio)) split++; - unlock_page(page); + folio_unlock(folio); next: - put_page(page); + folio_put(folio); cond_resched(); } mmap_read_unlock(mm);