From patchwork Mon Jan 30 21:43:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13121907 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 00CCDC54EAA for ; Mon, 30 Jan 2023 21:44:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4070C6B0075; Mon, 30 Jan 2023 16:44:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 38D4A6B0078; Mon, 30 Jan 2023 16:44:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 22C4E6B007B; Mon, 30 Jan 2023 16:44:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 10DC66B0075 for ; Mon, 30 Jan 2023 16:44:01 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E3AAE1A070E for ; Mon, 30 Jan 2023 21:44:00 +0000 (UTC) X-FDA: 80412793440.11.2EB582B Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by imf13.hostedemail.com (Postfix) with ESMTP id 1A02820015 for ; Mon, 30 Jan 2023 21:43:58 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=WG8BHcH4; spf=pass (imf13.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.46 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=1675115039; 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=hfgb6gximncpFcsdfMQZVX+G30+IO/lhUGcO4BdjekA=; b=D8O/ViGUFRMQfJGoxesMQQoC7iGgtxrTzpG8LuG2baQuuc9O61fE79m2PBpjdViOPgTHmY Fp0Qz7lqPtDNkJbk1DF2qIGBqpRhYaezs9xd9nCoC7fCkDLEgP1NcFiz7ze78D87WpMnjv b33deo7nZjbK1h1JRAW4R7tq5c58F5Q= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=WG8BHcH4; spf=pass (imf13.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.46 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675115039; a=rsa-sha256; cv=none; b=ckmELlmO4VgE/Jt2DALYO3gCiZCpp1eftVjso5OYYqj+OC9SkafASTIOuHsGLctAFmsFgB AGzmD7NqYut9nHRe1UKTRkIG8VcgnpehLcmejwx+/w4bsA84+GnXc6UIJG5tKk8TBuLtv4 a2d8DHx2C3qjvtVcOPnb3Pp04iwFDwE= Received: by mail-pj1-f46.google.com with SMTP id cq16-20020a17090af99000b0022c9791ac39so4573169pjb.4 for ; Mon, 30 Jan 2023 13:43:58 -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=hfgb6gximncpFcsdfMQZVX+G30+IO/lhUGcO4BdjekA=; b=WG8BHcH4b1Q2VPyQkFR4MwsGeXdQ+pi68nFKuACv3H2cq9hquUdwYMOwfn5Clg75vW tdaTbnzo30g1mw2TSnN6h8Y6lgg1wtmy7ON2KRh8nI82wfIkH/LpFE2K2KGn9m0dQnK+ EdiAMPBmX4di1Eob2v/sMtOoZQFb9TFmKbcFfBiMNz2GkEqkfEVm7j6AQvMvVO3QspMi i3x8iytVYGMWkQPh+NbcLozKU0gaNSS4IQgHkklSFDruW2i0iL46jgpRRq1X8wOYNoNT 7PD2lsqw+ZNG9C1EUsY6JUPymqtXQAJyQWkqCphkWagIz21CNTfeNJSRmt5MinrcDjBU JrcQ== 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=hfgb6gximncpFcsdfMQZVX+G30+IO/lhUGcO4BdjekA=; b=XtGwqaxXO7ZPzOgApQwpYY9FQ1EB8kgBWsH9bp98lbDVSdZV6tFkuogvRLfumB8afi wzkg9eB5oZWzguQs6FQeYF97kLs0M1ws8Ue50AMe2kPeH4ip9ffC36FcqHDsXfCKAU26 qaGUsw1NJ1mrTQKLUfQeFgMUKewM0SyRhKZFvFLLNjVav6KkQcFCbjhxtVtlHTgDZIPd hlu6uS5QN9IZFegY9q3GSH16h+AnAU/bSuwqoOsYcmNJQmLsL1ajYeUloU6yDBy5ez97 7f8SMJ+LXo0ZW0QP54aLJCQVAvPQ1lOf8VPmp3R6qERKRFiebFfT7joxJCyM1bHQPSEB FZWw== X-Gm-Message-State: AFqh2kpH44nJao7eR5zgIwM3qx706hjhLhCNcv7J+8IBJK+THd3Cl4NS 3Ctw10H/hkXm9m5Msg7NOI1xITQwaJY= X-Google-Smtp-Source: AMrXdXui3s7CpN8ff+PUDq7P7VExTnu8iNhcubhGWvTur95s0s6deUUCtdeQOmlXVeR6u10FVmghBg== X-Received: by 2002:a17:90a:2f89:b0:219:6619:848a with SMTP id t9-20020a17090a2f8900b002196619848amr53344104pjd.36.1675115037864; Mon, 30 Jan 2023 13:43:57 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:937f:7f20::a8cd]) by smtp.googlemail.com with ESMTPSA id d5-20020a17090a628500b0022bbad75af6sm25156403pjj.1.2023.01.30.13.43.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 13:43:57 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, willy@infradead.org, linux-kernel@vger.kernel.org, "Vishal Moola (Oracle)" Subject: [PATCH mm-unstable v2 3/4] mm/migrate: Convert isolate_movable_page() to use folios Date: Mon, 30 Jan 2023 13:43:51 -0800 Message-Id: <20230130214352.40538-4-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230130214352.40538-1-vishal.moola@gmail.com> References: <20230130214352.40538-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: ap68wmp118re5qr7g9h5mtyj9puh65nf X-Rspamd-Queue-Id: 1A02820015 X-HE-Tag: 1675115038-784403 X-HE-Meta: U2FsdGVkX194LciuCRdc23NlUkUAKRWqrpagvFwU6r92M+H0/uI7Lo6Ctiwk6u4K7EmaReQ7lhjuL3GJ3bg1Hnm4U9d5yqrowuNrNhP8KyY7X8166IlO4wpPZfOTt5+rYK4N9DYvxs4vKGhaeyf6SN8cMnrLZ1W22kg3RiczJG9+YizJz2oztYdNR63kOZzfNzR97OwYLMzm1p1oO2ukz7rGZoa2sarVNWzfdZfpsC4xdrshl2VNEzwNlHfVOk0fYzZdPtbf9O5c3tY2JurhbJ/SD6J+hGTGdCK84rr+enLxXCTOf/TsOIa5Xb+gOvjHpQXXCV5Bzgh4N+BeLh4JIMjr+n49WCCCwG/qN+9xZjW9w4JNe1GQn2oZ+4TJuJjsD9kbV2hYlBxDaPFatkZFNuX2iSAi9QdJUUKiFqSvav2hwm9ECPgd4lWK/dkhIonhi5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Li4nwvkKMo1RxkjA/lfCf3eLuRgcRjZVghB7qJfM7wBJIyZagze5u8WZeYcNli7q6Cw== 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: Removes 6 calls to compound_head() and prepares the function to take in a folio instead of page argument. Signed-off-by: Vishal Moola (Oracle) --- mm/migrate.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index fcb2e9fa1953..c20d9f531db4 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -60,6 +60,7 @@ int isolate_movable_page(struct page *page, isolate_mode_t mode) { + struct folio *folio = folio_get_nontail_page(page); const struct movable_operations *mops; /* @@ -71,11 +72,11 @@ int isolate_movable_page(struct page *page, isolate_mode_t mode) * the put_page() at the end of this block will take care of * release this page, thus avoiding a nasty leakage. */ - if (unlikely(!get_page_unless_zero(page))) + if (!folio) goto out; - if (unlikely(PageSlab(page))) - goto out_putpage; + if (unlikely(folio_test_slab(folio))) + goto out_putfolio; /* Pairs with smp_wmb() in slab freeing, e.g. SLUB's __free_slab() */ smp_rmb(); /* @@ -83,12 +84,12 @@ int isolate_movable_page(struct page *page, isolate_mode_t mode) * we use non-atomic bitops on newly allocated page flags so * unconditionally grabbing the lock ruins page's owner side. */ - if (unlikely(!__PageMovable(page))) - goto out_putpage; + if (unlikely(!__folio_test_movable(folio))) + goto out_putfolio; /* Pairs with smp_wmb() in slab allocation, e.g. SLUB's alloc_slab_page() */ smp_rmb(); - if (unlikely(PageSlab(page))) - goto out_putpage; + if (unlikely(folio_test_slab(folio))) + goto out_putfolio; /* * As movable pages are not isolated from LRU lists, concurrent @@ -101,29 +102,29 @@ int isolate_movable_page(struct page *page, isolate_mode_t mode) * lets be sure we have the page lock * before proceeding with the movable page isolation steps. */ - if (unlikely(!trylock_page(page))) - goto out_putpage; + if (unlikely(!folio_trylock(folio))) + goto out_putfolio; - if (!PageMovable(page) || PageIsolated(page)) + if (!folio_test_movable(folio) || folio_test_isolated(folio)) goto out_no_isolated; - mops = page_movable_ops(page); - VM_BUG_ON_PAGE(!mops, page); + mops = folio_movable_ops(folio); + VM_BUG_ON_FOLIO(!mops, folio); - if (!mops->isolate_page(page, mode)) + if (!mops->isolate_page(&folio->page, mode)) goto out_no_isolated; /* Driver shouldn't use PG_isolated bit of page->flags */ - WARN_ON_ONCE(PageIsolated(page)); - SetPageIsolated(page); - unlock_page(page); + WARN_ON_ONCE(folio_test_isolated(folio)); + folio_set_isolated(folio); + folio_unlock(folio); return 0; out_no_isolated: - unlock_page(page); -out_putpage: - put_page(page); + folio_unlock(folio); +out_putfolio: + folio_put(folio); out: return -EBUSY; }