From patchwork Mon Jan 30 20:18:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13121755 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 23133C54EAA for ; Mon, 30 Jan 2023 20:18:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 689606B0072; Mon, 30 Jan 2023 15:18:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 638D06B0073; Mon, 30 Jan 2023 15:18:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4DA0E6B0075; Mon, 30 Jan 2023 15:18:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 40F5E6B0072 for ; Mon, 30 Jan 2023 15:18:45 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E1589A0361 for ; Mon, 30 Jan 2023 20:18:44 +0000 (UTC) X-FDA: 80412578568.20.87B249B Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by imf16.hostedemail.com (Postfix) with ESMTP id 2085E180005 for ; Mon, 30 Jan 2023 20:18:42 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=hKmaa5zW; spf=pass (imf16.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.169 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=1675109923; 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=j/4S2TO195EZhvaFVO5pP2w+KNwU4ZdXZTJQBP7AkLA=; b=T62jF/pn9DxUjwK/RWLEVKgyYFb15F6V03D+VBiaBQX0msxrwHSXnxPIvCwCYJ46Weymt2 0gnanYY4WLQQmDSBJlPUBzuSQ5AxoUk+vOJmJ+oUXYZ+udK+T5F/mgChs4IPQrW/8JFxAD Gud2SdhO8jL+Q5pt0USBRv7rwzibDfk= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=hKmaa5zW; spf=pass (imf16.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.169 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=1675109923; a=rsa-sha256; cv=none; b=Ov41uwjvXyxIQvXMDVSHZRLaZnlKHDe1lqEnL07+3nuf+qVjVdoOWztzDHYuMgdD2aBIk3 prsgFvcY20KIzfe07J2npk5w2lhEI47W8zNDiBykw4w0t1eZhV5WPiagjbY/hUjkYbtyXr 7ZJdxhOKKNq0PZmzR37Q24fOWRvJMBw= Received: by mail-pg1-f169.google.com with SMTP id v3so8501010pgh.4 for ; Mon, 30 Jan 2023 12:18:42 -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=j/4S2TO195EZhvaFVO5pP2w+KNwU4ZdXZTJQBP7AkLA=; b=hKmaa5zWwzaA/eQzJXW/p3AbrjuCU1hJ1WqkvmCe5OjsEJy/zfYO3gyiHtXR/Nmicc QZYQqjBrrsHy42KLOqyKPLFiE5ljyx3lwnU1LSjg+iAeh/HHn2CxRLuBmV3I3qMAz3Cs Ne58gJfHTpr0l9umv4lK3maRT5u4n0kTDHo9ZkK8oU0BjWL11GtJTad04BQMCWmHBz73 nH6tcsBm9sz+Ea1dWSlI9Fiy3dis8DFNKppIY2bXLHu8vR2JqgBcaxoficz3AoWBJM+Z 2TO/3iaXYb46sgGXjY60MgE+Ka+7Z3DLxW15j0perrbJldV7bVy5hroX5c6xfkxUhZlH EkRA== 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=j/4S2TO195EZhvaFVO5pP2w+KNwU4ZdXZTJQBP7AkLA=; b=Lyvn/8ItHfNrq0yfTglMmQ5SYddBnby2sTaYB+tNoRW4j9rRp23+ZY8GjyTcR0+6Cj MaeDco1O2Rk4e4RQGk/KeCimDJ6cdIhaUbP5hEpXFnFEbztvfn0WDvg76IdtBLmpWShI RpYkBRU/j6V0kKPmJMqak9QDBTr2ZZBiIAFhg+xAo/Sjmmhh5LorIuqPEcoRmWStISTT E+HcAydxMRHqics5U3DK7DmIizw16qK0uRschzZWAm7GgS0m1C0/L5+eCX6cwCFrSfEc ptEwqGHE0sbo/RXJZKFiSGHFn3fzsxw1S8nyvWLEikZ9oPQBU2ZkHeBIQxjEDmEYlQbR oWpQ== X-Gm-Message-State: AO0yUKVHQqsqG9dCn4LhhwSRFZmpswFlOZ/LtmMs3n1jfItndJHy/Yk7 ICd8tO6heoX3PVS1iV9rXE3TENIWp88= X-Google-Smtp-Source: AK7set8Ihsg+3xvIHWQXAyP08XWpzy8TCdCFoKOEqxjzQ3NsmeF6Ie0PReDCSFAdVbc4D07D2h75hA== X-Received: by 2002:aa7:8c54:0:b0:593:93db:5f63 with SMTP id e20-20020aa78c54000000b0059393db5f63mr8994693pfd.23.1675109921811; Mon, 30 Jan 2023 12:18:41 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:937f:7f20::a8cd]) by smtp.googlemail.com with ESMTPSA id g9-20020a056a000b8900b0058d9730ede0sm113262pfj.210.2023.01.30.12.18.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 12:18:41 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, "Vishal Moola (Oracle)" Subject: [PATCH mm-unstable v4 1/6] mm: add folio_estimated_sharers() Date: Mon, 30 Jan 2023 12:18:28 -0800 Message-Id: <20230130201833.27042-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230130201833.27042-1-vishal.moola@gmail.com> References: <20230130201833.27042-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: hiqdk9a1ffe34a34rncuewcmeo1s35uh X-Rspamd-Queue-Id: 2085E180005 X-HE-Tag: 1675109922-777617 X-HE-Meta: U2FsdGVkX1+jkZ930oRNgAo7EMnkc5QSeyw6HXlUIYg15LZoGdJhPwLN9G3Mqp7veHNTkqLslRcNHF8OsK1zfRc5pXHnt/6pnI/DGbk5pbcjgie4WXEciplcope7ZvKtY4BcnKMzmQIIXM6e12ht/7ubo3tX2Q9NPzbRxfF39X12gdMt/5PgmLVzv8Dr0024f2hCXtMA160siWq2KWNNvxhkPriw/4X36D5VFLKJXj2HqEtxWujlPkc0/VgM/sr0O6FSOdC9SDZPAIBaI1bL7IUeXuhVttOwxjBT5XR3TfwGcw5GE4iRf73YupH93xy3i83kBLygvS5G/LjR8yo8F3+ZRYHjQqAI4C/bjVwgxuoaF4u+5k3OUFO/zhOkMmLhXPmQ/m0Y0AEAn1Q2l4Ik4aNu8zXQctHvWlQ7q1bUiQySQ6jVQPmNHzmyh28Dbl1Y+rHF6xvUZUjy3qJ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G7NvumtQuvZWiVtEXQMO3tFlvoukLbwCMsk/JMcH+jwDTHNyFNNzg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: folio_estimated_sharers() takes in a folio and returns the precise number of times the first subpage of the folio is mapped. This function aims to provide an estimate for the number of sharers of a folio. This is necessary for folio conversions where we care about the number of processes that share a folio, but don't necessarily want to check every single page within that folio. This is in contrast to folio_mapcount() which calculates the total number of the times a folio and all its subpages are mapped. Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Yin Fengwei Acked-by: David Hildenbrand --- include/linux/mm.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 27b34f7730e7..c91bf9cdb3d0 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1905,6 +1905,24 @@ static inline size_t folio_size(struct folio *folio) return PAGE_SIZE << folio_order(folio); } +/** + * folio_estimated_sharers - Estimate the number of sharers of a folio. + * @folio: The folio. + * + * folio_estimated_sharers() aims to serve as a function to efficiently + * estimate the number of processes sharing a folio. This is done by + * looking at the precise mapcount of the first subpage in the folio, and + * assuming the other subpages are the same. This may not be true for large + * folios. If you want exact mapcounts for exact calculations, look at + * page_mapcount() or folio_total_mapcount(). + * + * Return: The estimated number of processes sharing a folio. + */ +static inline int folio_estimated_sharers(struct folio *folio) +{ + return page_mapcount(folio_page(folio, 0)); +} + #ifndef HAVE_ARCH_MAKE_PAGE_ACCESSIBLE static inline int arch_make_page_accessible(struct page *page) { From patchwork Mon Jan 30 20:18:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13121756 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 6A4B7C636D6 for ; Mon, 30 Jan 2023 20:18:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 529396B0073; Mon, 30 Jan 2023 15:18:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DB286B0075; Mon, 30 Jan 2023 15:18:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2DE896B0078; Mon, 30 Jan 2023 15:18:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 198A16B0073 for ; Mon, 30 Jan 2023 15:18:46 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D9BAEC03C9 for ; Mon, 30 Jan 2023 20:18:45 +0000 (UTC) X-FDA: 80412578610.12.C6659B1 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by imf03.hostedemail.com (Postfix) with ESMTP id 0596B20007 for ; Mon, 30 Jan 2023 20:18:43 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="Wl7zEv/H"; spf=pass (imf03.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.182 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=1675109924; 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=Y48CKbE3JT22h7yWw1CaLB5y4wyl8IVKXFn03JqpXa4=; b=5O/lSx3fUsN7LuBShyEtyWp/+52kcxHl1h/MOQBFOau8JekDERT7TIn7Tl62qQnpy/d4st 4gsV9oOECbH69tJrP25ZhjBVcIMuN22AdU5QyV5cyZ5SNOIBAFza2z5Bz07DV8H6PcjGg6 14lCA3KCZs2XjFDjM06URhSPESaYpcA= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="Wl7zEv/H"; spf=pass (imf03.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.182 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=1675109924; a=rsa-sha256; cv=none; b=6uWjG+vaHlUomrIs380QZcPboELiQ/s4twK2AOpfYtDuB200rnR9lGuONO3xdGjhje7cuo 4N6psaV1epOMcKbNSTx7zZRRANMSgbGCo3nxrEEANKSGqPAK2xSDuBNN9VvYWq4VdX9Joz J7ZU15rLafCz+QGAYCKcq7pjroOQJVE= Received: by mail-pf1-f182.google.com with SMTP id n2so8705894pfo.3 for ; Mon, 30 Jan 2023 12:18:43 -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=Y48CKbE3JT22h7yWw1CaLB5y4wyl8IVKXFn03JqpXa4=; b=Wl7zEv/H7Ojm0N8EkHS/Tvyo9Ekr63AoEgevn1M8sPtkvvYppkidaB9fQ9hosG51Mz VAuNl+BCp+5Nvi3wGhMGBG6zoThzCELD4w39zuOs5I+v3HyrYzPZoJ7RFBKACOCMEUIR Gc4WkpzCH1Ber5EQQoJnVxBVHNek3ot3YGeqJwTyc2+4p68hlG9LBHmMyNKqD0ezp9r0 J132PTIIn9ZRd4wAFVkUahjshU0vA89lVPx1FwwChqRZpLp97jlinvFCla6xGd27tMwL ySmR6tewviI0124vTdnLIxgiZQIttehQNGUlE3I53cOGtvUDpBuptYhUExG9pqBz7tJ/ H8yA== 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=Y48CKbE3JT22h7yWw1CaLB5y4wyl8IVKXFn03JqpXa4=; b=ZoTb/gQR8qgGAH2elIiGn+1WRBdJ3CyLEBv/cuOOgrAL+k159oX8Hkkxiw5q0Jfxsd aEL+lBIEMfmXuvfQBTKOkmFk129yN2CbSB6wSMTlqFPko1Z/Z5A/YxMS8IBWknUnpEa9 i5GmgCXZp71rcyt7TnUe87HBiFzg2/gxPEt7srq/dRE+rJ2huV5VEEBUcx/ZgLsDi9p1 FHZcvV3ySUlJNyLosMsB0ZZzms1zOoht2ELdwXufT5iignlWhdk5O9MFTFJpOLK0/vet r5OFRqTT3XKnzzYTdh1aeLyubwha4jOQQ2fknogNMT+8yCBPBc23qcwBWgqdnotnLFv/ sb+A== X-Gm-Message-State: AO0yUKUhB68txErlutoTNbZzjL7Y5nZFffh6vx7Yx4pH2hXCXz3meB/T 5XCICmZYDwgb70B62zGKhOkvPDfz1xQ= X-Google-Smtp-Source: AK7set+DyQIA8npSLdFVb1C6aoLN+sbHw5JucCXJtvR5QA7iDsmOy5cg0rBq1nQf5Nj26FAkra7OTw== X-Received: by 2002:aa7:950a:0:b0:592:568a:1f70 with SMTP id b10-20020aa7950a000000b00592568a1f70mr8887370pfp.25.1675109922725; Mon, 30 Jan 2023 12:18:42 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:937f:7f20::a8cd]) by smtp.googlemail.com with ESMTPSA id g9-20020a056a000b8900b0058d9730ede0sm113262pfj.210.2023.01.30.12.18.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 12:18:42 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, "Vishal Moola (Oracle)" Subject: [PATCH mm-unstable v4 2/6] mm/mempolicy: convert queue_pages_pmd() to queue_folios_pmd() Date: Mon, 30 Jan 2023 12:18:29 -0800 Message-Id: <20230130201833.27042-3-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230130201833.27042-1-vishal.moola@gmail.com> References: <20230130201833.27042-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 0596B20007 X-Stat-Signature: mr5zjmcub5uarmpefawqxw9gkmjbaf56 X-HE-Tag: 1675109923-465019 X-HE-Meta: U2FsdGVkX1/lNnQhsXNHL00HGepiqssNUcN2Vcs6oQkldOGaF0fLlNRQuntvuD8uQURZXcHMm78Tv9+pMftYUIxlqKObBLG1zmh6E3XXH5fG0zRyv9RJnnWHkh9JATldr+u1W46nEkSxhCtDtqy431Rlr+5Rdv3txFF1J/BkiLSEw+d8RuR4cDKuCcI1y24tAQ4CV3rW817/KB5GS8mzshriQ995W9cbhI9f9/sxkvIo3noqp+yDjJEaiLf+cuGCmOhvBp28DYDMmA0wtFGEIGoLeXpeMbceRQJMtbwrY02TEswEss3IcfXOtZEK81Djutts3HnDgUK1Jiw8qeMkUn1dcil+8yOaGm6U1P5T7Ixiwt5y6oQWr3/fo+FXGSWuMwoM4rUGTnxZ85Wjbsbu+moi+gK8IEA6gXDnCzxesK8emufGDX6aMWsKkM+O/lhvOIOVQqQCff2Y0FSgZaE38vUjYjeYYv3X2+enNZhr08Fy5/V9Tjpq2BXxGZ/1ZM5TRRP/YZ0ONwy7HM81u9bIv6i46JU16gGxuwBt8OK96iYgebENF+/2ZQ7Ik0UKCrDzZn3bnhrUODocbSoKyjmLhao+e4MhCuWyUoHko9wGLvhowmpkjzecsn1MkloMw0TxbutLAIsLPF+gdE+puhIRmeLPoW+KUB4E5bFYMWbVCP+oyHgJ9SCIoj4kUmdqxePi4RNDeOZKbVUPA4ZHdLCLWVhaYecUN+LMBhYNDTRnlqgEqcUBHWrkmilHcGAwbhd4p40APvbAT0xYiFXmStqzlk4leCR7IX0ND29GS//S5T9mT08ZjxVPyERx/dWuT3uTPK7lw1KHgLJrjEiR1Kj2jH/5XGY2r7/V2VHygZdRNH1SwgCN8ucmT/kc7510YVfS0OFOto7gEFbI4VLcjz5TaAde5WKB44jc+XsLQWpa1buaxVi1zku0yLS7PErWrWgTFmafCBpi27sm7lCrmIg jQJntBCR VZSVdJERde/zF0tQQVmRDezj47+2VQY/4sJIBXt/bYife/37QCYTZ5s+l9SMqAicyfgpU/G9JuV6khn0al8nEJPMxae5jgYYYfgEiB7ki8gWvNzCZX7P+yUwj95fZg6Ppw5z7cwpCUsrV5xTOJlEh0d4XRMXH9G8jGKq5+UrwheHwHCd3JjOKn0FO3001r380gTknCJIKNpfU7oIG5eN2yIcovMRGqFYKAblqCOzLNjUhLCxmRCfUxYLEH53zxvgErP90wi2lDP2gxQCY+6DFQC1AYn/agVS1kAlbQHQQYCIXsXfXKbSpaQDFCYGR5tkZDba5fRcClZMuHvBE/9lpDXJJPH46ETwSKTVLT/IG0qPSQQ1F2Fphp6We1DjEpaJgPBiMvmXRkC6pmpcaI92pPVR+FPPGzGBWAeLOKDSYJtvbZu1iMdGo4i+6scr46uqYWrZf+MuegEbnsQGhzSP1EvIwC81VbYvJVCouD8eCUY7Zhgm9CDFov/ULz/kiHhnQQzUcUoHYcZXXfQr2eP3osObtu+TCMBSUEp3iTwNLQfgJF1YtJYRT4bHCx0TyfQqLQF3l5hoiJE8OHUMe2QlI+7UW/sNG3P+wsPA9i38c9tNdqirPyCDoeaLzoTDx+AwdYwQw/nMfCn6h239RgauM1SKrti4K8Wkmc5bL+X7ALSZ+C64= 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: The function now operates on a folio instead of the page associated with a pmd. This change is in preparation for the conversion of queue_pages_required() to queue_folio_required() and migrate_page_add() to migrate_folio_add(). Signed-off-by: Vishal Moola (Oracle) --- mm/mempolicy.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 7686f40c9750..fc754dbcbbcd 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -442,21 +442,21 @@ static inline bool queue_pages_required(struct page *page, } /* - * queue_pages_pmd() has three possible return values: - * 0 - pages are placed on the right node or queued successfully, or + * queue_folios_pmd() has three possible return values: + * 0 - folios are placed on the right node or queued successfully, or * special page is met, i.e. huge zero page. - * 1 - there is unmovable page, and MPOL_MF_MOVE* & MPOL_MF_STRICT were + * 1 - there is unmovable folio, and MPOL_MF_MOVE* & MPOL_MF_STRICT were * specified. * -EIO - is migration entry or only MPOL_MF_STRICT was specified and an - * existing page was already on a node that does not follow the + * existing folio was already on a node that does not follow the * policy. */ -static int queue_pages_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr, +static int queue_folios_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr, unsigned long end, struct mm_walk *walk) __releases(ptl) { int ret = 0; - struct page *page; + struct folio *folio; struct queue_pages *qp = walk->private; unsigned long flags; @@ -464,19 +464,19 @@ static int queue_pages_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr, ret = -EIO; goto unlock; } - page = pmd_page(*pmd); - if (is_huge_zero_page(page)) { + folio = pfn_folio(pmd_pfn(*pmd)); + if (is_huge_zero_page(&folio->page)) { walk->action = ACTION_CONTINUE; goto unlock; } - if (!queue_pages_required(page, qp)) + if (!queue_pages_required(&folio->page, qp)) goto unlock; flags = qp->flags; - /* go to thp migration */ + /* go to folio migration */ if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) { if (!vma_migratable(walk->vma) || - migrate_page_add(page, qp->pagelist, flags)) { + migrate_page_add(&folio->page, qp->pagelist, flags)) { ret = 1; goto unlock; } @@ -512,7 +512,7 @@ static int queue_pages_pte_range(pmd_t *pmd, unsigned long addr, ptl = pmd_trans_huge_lock(pmd, vma); if (ptl) - return queue_pages_pmd(pmd, ptl, addr, end, walk); + return queue_folios_pmd(pmd, ptl, addr, end, walk); if (pmd_trans_unstable(pmd)) return 0; From patchwork Mon Jan 30 20:18:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13121757 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 4BB9FC54EAA for ; Mon, 30 Jan 2023 20:18:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 79CD66B0075; Mon, 30 Jan 2023 15:18:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7234D6B0078; Mon, 30 Jan 2023 15:18:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 59CC36B007B; Mon, 30 Jan 2023 15:18:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 4CBA46B0075 for ; Mon, 30 Jan 2023 15:18:47 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 31D751C1756 for ; Mon, 30 Jan 2023 20:18:47 +0000 (UTC) X-FDA: 80412578694.30.AB7C072 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf26.hostedemail.com (Postfix) with ESMTP id 5731514000E for ; Mon, 30 Jan 2023 20:18:45 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=nRv3hsG1; spf=pass (imf26.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.173 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=1675109925; 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=8Nhbc0AgbHO5zV6t6mmHVD0PFRFqh3MKW7JYpBDIsYU=; b=PjwTleeS/3H7gmIYMvx+r+3aOVkGGGiihSC+aEBPS/JDvZqAoiuMl3crDVDeA9MihhcNpR EwDFFBVtVdHgnsKWr3H903ijHy5MevUhIQvZ8iFFE9+ExhYMrc9TiYakbbSSNdWP7rkkic PU2iu8Chm/6Qo6Ysmth3HFmW/bLZ4r0= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=nRv3hsG1; spf=pass (imf26.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.173 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=1675109925; a=rsa-sha256; cv=none; b=oqNe4dU0N2CKjrJHrcV2AsjBzZe42FpCQUM6vKQrlI8z7u2crMvUZlZ112AXoneKNcvV28 LC7v9fOkbcz5/Il4f9os9/O4wkVYSIqQvYfAvojMDLdKpfs9WXCfwSWeIZPYSz94G+bnz+ 3syXD9MmlqHO/+fGBTK1DvJH1ruQQlk= Received: by mail-pg1-f173.google.com with SMTP id 7so3590258pgh.7 for ; Mon, 30 Jan 2023 12:18:45 -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=8Nhbc0AgbHO5zV6t6mmHVD0PFRFqh3MKW7JYpBDIsYU=; b=nRv3hsG1oZEx1tRfncyxMeskGayFbaD3uykQ6nIJM9rxPmYih1WHusV9Y2O1iLGRxS +kfnhlN/Ocx15MTYrjdSPbVJHaKFKNxwXWvD+YgY48bzQyMiPXUvHKCZQdPqbzdCoKMg 5ulCiSiG+QWzAZG+KStlmxZjgubTxggZSPapErWiXtKuMIN7+8pR+3kjuqKU28bFnhuK nTGunLTXpfPWao7Lye+vchwTPWeu8qIkkQCZ56/K0Xkv1yYFPw/XIEmsZEi8M10Epuii LyEJ09MbQEhwhoM+A4VuUjzoif+UoeAX4nLv7Ng62tII1BOOJ3YgAmg6am0gdFHw+RU+ PgmQ== 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=8Nhbc0AgbHO5zV6t6mmHVD0PFRFqh3MKW7JYpBDIsYU=; b=YA271o5qgn96Zkceb/7QqfEDApfAD8ZVeT8QaTavAw+8y+/zHlGoo4mhosCTlbKaGz Bh7nnEFvqlPexLiPqH1Sk0gTUE235AkuKKxGxc2eJurqdXnMyIIoPqyyt6anRX65jmS/ Ljknh9v0ZB6tbFPmpa2mZjS0JgON1RT8U+3x7Ed1wMurm+TPFHn1KoxO7L2EeWYTG1/6 zZpPoynYbVzcrLQkUdP2+EsJ8tVUsV1kNAfLr3oiFf9fZIeEsvy4tH6yC5/do1c2IE9f g73nvpexyvwXsvilJ4Zo1akSrUjdJ2iB3thPvqICZ0PFGdWakpNdmeJjb/TXOzUTaG0l hecw== X-Gm-Message-State: AO0yUKUKTj9bRyIPk9tRLlTMRbt6rHl2p7l3RPJlvgd9iobv8Y0rU+0C urURqbl89YBebYD1J0x9y7+mWZG9lTc= X-Google-Smtp-Source: AK7set+YqzG592x28e6kZFTk/siUxYxEWaKBctpynci92iHX5sfOS9hsl3+DQ6yEMS9HJtV4dcMSig== X-Received: by 2002:a05:6a00:212e:b0:592:5eab:3402 with SMTP id n14-20020a056a00212e00b005925eab3402mr10171232pfj.28.1675109924061; Mon, 30 Jan 2023 12:18:44 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:937f:7f20::a8cd]) by smtp.googlemail.com with ESMTPSA id g9-20020a056a000b8900b0058d9730ede0sm113262pfj.210.2023.01.30.12.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 12:18:43 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, "Vishal Moola (Oracle)" Subject: [PATCH mm-unstable v4 3/6] mm/mempolicy: convert queue_pages_pte_range() to queue_folios_pte_range() Date: Mon, 30 Jan 2023 12:18:30 -0800 Message-Id: <20230130201833.27042-4-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230130201833.27042-1-vishal.moola@gmail.com> References: <20230130201833.27042-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Stat-Signature: cormw7kbe17ecxe1bdx97io4nh1awp17 X-Rspam-User: X-Rspamd-Queue-Id: 5731514000E X-Rspamd-Server: rspam06 X-HE-Tag: 1675109925-760110 X-HE-Meta: U2FsdGVkX18EyTcJTvvRGGr94wTI87HI3aRYvtmSy1yNn3Uv++F1VyPyh0XL6x4x5z58THHI5zfaXFVCGM6wKt5Ss4QcQOPsBS13oNNkGe5wI6VUDTsfHA5MgoN6+u4/P2EZ1lHtKchsV3LVoO0sWklsiqXfLFFVKGE4+HGy68sLyWiNMt0+VQf1pE4V4FfgcMWU8ECKFPWbf6+T4Tb78PEwSiKGm5o71rlNX/Yw7Rr8CKRNBkbmiiMP5nPWZseRE7xHZbC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5w8ccqY7UhxoFFvkMnKELWrd2J/N+Ywf6LOY+/Y/w199U1Pdq51eLKhENzIH8IIEbfOaUCDpcsnI9IuxhHfDgABfZGPaH9TYE+cIpbnVBlnaMNRayU4xsRzEFV6p4aUD8TEq5bNJCJKDCDjRO/eIC//WQ6MDBBjMzfXrYyFB0q8oWDnKgIq10sbqKaoE5fQ4afPVD0BKMG8hTx3ijMQWDO7BCmaf5+TY2telwamnfzVNd9z8AliWTnRLM0D+IYII9c7vY9uZGac+g9dbMk5lUGejvHJMSvCCja0A1eXtk/3ybujMtbpKlxX00BEMVtENJ694Ntk3sLsDC87Iopf4o= 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: This function now operates on folios associated with ptes instead of pages. This change is in preparation for the conversion of queue_pages_required() to queue_folio_required() and migrate_page_add() to migrate_folio_add(). Signed-off-by: Vishal Moola (Oracle) --- mm/mempolicy.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index fc754dbcbbcd..b0805bb87655 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -491,19 +491,19 @@ static int queue_folios_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr, * Scan through pages checking if pages follow certain conditions, * and move them to the pagelist if they do. * - * queue_pages_pte_range() has three possible return values: - * 0 - pages are placed on the right node or queued successfully, or + * queue_folios_pte_range() has three possible return values: + * 0 - folios are placed on the right node or queued successfully, or * special page is met, i.e. zero page. - * 1 - there is unmovable page, and MPOL_MF_MOVE* & MPOL_MF_STRICT were + * 1 - there is unmovable folio, and MPOL_MF_MOVE* & MPOL_MF_STRICT were * specified. - * -EIO - only MPOL_MF_STRICT was specified and an existing page was already + * -EIO - only MPOL_MF_STRICT was specified and an existing folio was already * on a node that does not follow the policy. */ -static int queue_pages_pte_range(pmd_t *pmd, unsigned long addr, +static int queue_folios_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, struct mm_walk *walk) { struct vm_area_struct *vma = walk->vma; - struct page *page; + struct folio *folio; struct queue_pages *qp = walk->private; unsigned long flags = qp->flags; bool has_unmovable = false; @@ -521,16 +521,16 @@ static int queue_pages_pte_range(pmd_t *pmd, unsigned long addr, for (; addr != end; pte++, addr += PAGE_SIZE) { if (!pte_present(*pte)) continue; - page = vm_normal_page(vma, addr, *pte); - if (!page || is_zone_device_page(page)) + folio = vm_normal_folio(vma, addr, *pte); + if (!folio || folio_is_zone_device(folio)) continue; /* - * vm_normal_page() filters out zero pages, but there might - * still be PageReserved pages to skip, perhaps in a VDSO. + * vm_normal_folio() filters out zero pages, but there might + * still be reserved folios to skip, perhaps in a VDSO. */ - if (PageReserved(page)) + if (folio_test_reserved(folio)) continue; - if (!queue_pages_required(page, qp)) + if (!queue_pages_required(&folio->page, qp)) continue; if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) { /* MPOL_MF_STRICT must be specified if we get here */ @@ -544,7 +544,7 @@ static int queue_pages_pte_range(pmd_t *pmd, unsigned long addr, * temporary off LRU pages in the range. Still * need migrate other LRU pages. */ - if (migrate_page_add(page, qp->pagelist, flags)) + if (migrate_page_add(&folio->page, qp->pagelist, flags)) has_unmovable = true; } else break; @@ -704,7 +704,7 @@ static int queue_pages_test_walk(unsigned long start, unsigned long end, static const struct mm_walk_ops queue_pages_walk_ops = { .hugetlb_entry = queue_pages_hugetlb, - .pmd_entry = queue_pages_pte_range, + .pmd_entry = queue_folios_pte_range, .test_walk = queue_pages_test_walk, }; From patchwork Mon Jan 30 20:18:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13121758 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 7E00DC636D3 for ; Mon, 30 Jan 2023 20:18:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B91E66B0078; Mon, 30 Jan 2023 15:18:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B429D6B007B; Mon, 30 Jan 2023 15:18:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D1806B007D; Mon, 30 Jan 2023 15:18:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 80C816B0078 for ; Mon, 30 Jan 2023 15:18:48 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 59EFA140B5C for ; Mon, 30 Jan 2023 20:18:48 +0000 (UTC) X-FDA: 80412578736.23.21D1BF9 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by imf02.hostedemail.com (Postfix) with ESMTP id 76D1080006 for ; Mon, 30 Jan 2023 20:18:46 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Uoo5nyF2; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.181 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675109926; 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=SSeBOBmV5irVttghOKU/WEyUh0YnA4r3UGGroMyochk=; b=WYe+r0mJD9KexTRa9J1HDIIuuZDDNHoz1o0FIpq+vUSVb+f1xrkzuPh5ir13K8yToVYn3P 6ehnLuhogopxyrN2er6vHp/85qenCMDnVyYLel/gjW9Il19Ue7YEiGJOzg52qIksAytA0e qYNA6l4svUrCiLZ29KO1I3Eq2tLaWmg= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Uoo5nyF2; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.181 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675109926; a=rsa-sha256; cv=none; b=wzEFcUg8OCPL4S0AFHPBFzkMWlEl5nEAl7W31ZGJKKbRfsduCb5Aag2SaqJw9amMwQFfUW uoUzfH80V4kYr8DlaTllghjqpRI0GqqdldwBaIkvj65pipWdwsUtqlHKHG1e5IjoXF0jcy ESXCDKndVvp+H62+vQh2XsImHCluGd8= Received: by mail-pg1-f181.google.com with SMTP id g68so8486452pgc.11 for ; Mon, 30 Jan 2023 12:18:46 -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=SSeBOBmV5irVttghOKU/WEyUh0YnA4r3UGGroMyochk=; b=Uoo5nyF2OvMxPs0CxInigN1mJkJMwm5kATVUZBZlY8FvxSKwsrCYPNOpgk9ixI1C13 jjmHWadhrt9csTXfa3+84oLpPKGjkm5nWzcKsmF3eCUMdqoCWKJzjSItxDE1yFsLl266 9YgCoQXUE60Y10w/pTt7qjpCo4MjYCMpgGlnTRfQpj0XPFYYYBG2zNd2r66nMD/Pmh/n 0Ujs1OUPo1skoLWFTbngUeBk9H47O+nou8ws2yllTFrC6eEE4HEPj4iGeUJUviOPlI4g /gvHSiUfmZYXMkFrMNKUMKPQvcCtnMffPqy38v0jcPg2BOydF1h0qE4YIIqwlenrzOl6 RCaQ== 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=SSeBOBmV5irVttghOKU/WEyUh0YnA4r3UGGroMyochk=; b=SndJNQBz1cIl8ndPh2UFzNKk8saMC70WAACuZtfgWuFfDSQsqX4g7zR9lyHWukPFq+ o0vjnJal8wHaVdcU0pi9jvbECOgC6vi7Dxy9+PDd4E7bdtFwbeEyj1zYIJeMW/oGzGHz QD59K9/iRwMUUH40bv/2F6Nj5c2zZ7c2o09mvaGcyHTQPD6t/GBuYIlkKrsH1q8Ys1W1 67FXYMp/Kdoc+aNrRXk/CLN0Y3JNNM59LCr9Si7rLWy7K4j0/XKADBrSYFxBwHaHC/u+ TVj0FwiJAVWx4kiexUaTj+B/jofAPtHCx1dorq/ranLHNgwfsHNgXpEGIBM8kUDqG2Fl XT6g== X-Gm-Message-State: AO0yUKXYOzMNcwj1BJp7qEgq7/qu014d7UzQMUzPVv1d99/HuIgnmeiP KATBwLpxCJaznk0J+mwPGTrXXucvUDY= X-Google-Smtp-Source: AK7set+DszPwpSPBVBkWWwuActthXmx+XqB/olsEL1Pq6RwXLA89syW3jS5kw/6r1MPLSHmjUCv5yg== X-Received: by 2002:aa7:8883:0:b0:58d:ca02:3fd6 with SMTP id z3-20020aa78883000000b0058dca023fd6mr12047476pfe.25.1675109925162; Mon, 30 Jan 2023 12:18:45 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:937f:7f20::a8cd]) by smtp.googlemail.com with ESMTPSA id g9-20020a056a000b8900b0058d9730ede0sm113262pfj.210.2023.01.30.12.18.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 12:18:44 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, "Vishal Moola (Oracle)" Subject: [PATCH mm-unstable v4 4/6] mm/mempolicy: convert queue_pages_hugetlb() to queue_folios_hugetlb() Date: Mon, 30 Jan 2023 12:18:31 -0800 Message-Id: <20230130201833.27042-5-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230130201833.27042-1-vishal.moola@gmail.com> References: <20230130201833.27042-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 76D1080006 X-Stat-Signature: jf4gha63gmckwc87y4gtisf9o4bo93je X-HE-Tag: 1675109926-164083 X-HE-Meta: U2FsdGVkX1+OPw/+X08g0ev3sVj17aB3lS7eTbNMrMD42igUtjcNKZYTHAf+AgIqiP0aztdfZ+tLoX8nQKsTkjQQntPv4WdvEfdwx3dL0YV4p8bCHkQR+WI8GyD3B1tYjOrKqeOamL85zhScGCj0b+IQXKTNjy5jbf5loe3fAOY30ydCjkZPgyPfFCFIvtWDbToUWUsqP3KzDsI522m+6pauNRY/0ByP5FMKnFdIGHIzCZxKp/gu4OopdoLAoAqRmnz0M3CQ6IOA+f/ue4c/ETQnj3KMgjKL28IC2P5Rncme4Yd9FY9NZs2dw22i880Ih93p+XOkMXbyJFBGmQjNT6wNfuSvDX2hFKbFKTGbP2w9aIVzvGpSM9GKA17TtVnrnlGGQOWwwAKfl5BWRGSBErjBvYIEUX7Su0NCfhaLsW2/VepQjNq89OWEv3/tbDrTs+aL0/d+M1GsV4ExXU468BWHeyrrxEr3s7rNy3qIaPqUSmrG3KSY+unNWRbYLHO+dpnn59RDNh75vy9uOTwPlljPP9cmmpGGoU15qIN70ZiGNhHPDBy/+u1RDOhbr2mI0WIImArKXPMJkH/kTPmvm8op+AYjPJN3GymFz5T7hRtn2nyeDJqe3VaPdnHPp8Ww0Q5y6KhQyMEdWRmUz76TqDXUzDw9nkrTaEGL3ckMbnLZWkAhbmsJNtJjmjqjLHUcelS2sO9BlKCTHn0sfYlU8jmCobwS39dDoUeqBooxqw1vzNRtPn+msQVdZLdwgHK1E3m9O/oz8KKPNzZXNhkaSso9bl8BmHY7rRNdqqD0V+BbB0NHEUA7KBkGVF4Giwo/nJwEHDi0/Jd/AIiY804rwdGsusOSkuvT6UsBtovDj+PqQtTBcuwaMooLqdV0P48wWw3CFjWByEocHBpaRybmegNXKtwhUKnRgs02BNwmY8o1s36uRvuYBLiES9hw6wX026+p38YNyGL3gCJqqj/ iN/lYyqP diUJckAecj3YRJkKoo7J7kapGpAc5LCOGYlCi7CGrbZoMdYp1YUfymsyB9TYCRQri+CjWtf4dGmRqrLtvOF05EuhRf57aIMiAjXQTb3ufhNM8W97FjV27K3+0MatFwI8BEew4PCYA3+MNh8dwmRY0g+MjpFkRQzX9KIwPKj/Do6PnmJoGCUDS3UqJhbM4V/vrVMdIhTsjPVNzpy7FORQrZJ72MAFeqxr4AAqK3OEdSWTfI+U64fJUb/HZPFrRyMnCBQ6am0W53RsHd7tHwEvY6+rAYJhbHflp0jFJdsal/VIdXo/8ePDiRMfTWXineOlmykmcZ6WcYYMbMXRWBKn12MNv0QhNRfo0mbV8jx8rLvrCkjxS3kMlnx3EnPoAo3Ua2BaavnwOLrBC3g5JocFUxM4/k7jvqJtNcjJ3+ogWWBfFUoIPgmRN+YBrc6EHkH4NcfQ0me1i2wHgK3mfsykzCbhe5uaE4ta39Q/+VLmqoASp+nVuZkKZhrlX8egny1z4mNyVkk2GkZf7yqhzRfsXOx0gaM2mWHuUp8HHo2D3kNSlKF2r6zsw2bh4VNLe1MAvHiwBOjNbJcnHfs0Pivn8QEh0tA== 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: This change is in preparation for the conversion of queue_pages_required() to queue_folio_required() and migrate_page_add() to migrate_folio_add(). Signed-off-by: Vishal Moola (Oracle) --- mm/mempolicy.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index b0805bb87655..668392493500 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -558,7 +558,7 @@ static int queue_folios_pte_range(pmd_t *pmd, unsigned long addr, return addr != end ? -EIO : 0; } -static int queue_pages_hugetlb(pte_t *pte, unsigned long hmask, +static int queue_folios_hugetlb(pte_t *pte, unsigned long hmask, unsigned long addr, unsigned long end, struct mm_walk *walk) { @@ -566,7 +566,7 @@ static int queue_pages_hugetlb(pte_t *pte, unsigned long hmask, #ifdef CONFIG_HUGETLB_PAGE struct queue_pages *qp = walk->private; unsigned long flags = (qp->flags & MPOL_MF_VALID); - struct page *page; + struct folio *folio; spinlock_t *ptl; pte_t entry; @@ -574,13 +574,13 @@ static int queue_pages_hugetlb(pte_t *pte, unsigned long hmask, entry = huge_ptep_get(pte); if (!pte_present(entry)) goto unlock; - page = pte_page(entry); - if (!queue_pages_required(page, qp)) + folio = pfn_folio(pte_pfn(entry)); + if (!queue_pages_required(&folio->page, qp)) goto unlock; if (flags == MPOL_MF_STRICT) { /* - * STRICT alone means only detecting misplaced page and no + * STRICT alone means only detecting misplaced folio and no * need to further check other vma. */ ret = -EIO; @@ -591,21 +591,28 @@ static int queue_pages_hugetlb(pte_t *pte, unsigned long hmask, /* * Must be STRICT with MOVE*, otherwise .test_walk() have * stopped walking current vma. - * Detecting misplaced page but allow migrating pages which + * Detecting misplaced folio but allow migrating folios which * have been queued. */ ret = 1; goto unlock; } - /* With MPOL_MF_MOVE, we migrate only unshared hugepage. */ + /* + * With MPOL_MF_MOVE, we try to migrate only unshared folios. If it + * is shared it is likely not worth migrating. + * + * To check if the folio is shared, ideally we want to make sure + * every page is mapped to the same process. Doing that is very + * expensive, so check the estimated mapcount of the folio instead. + */ if (flags & (MPOL_MF_MOVE_ALL) || - (flags & MPOL_MF_MOVE && page_mapcount(page) == 1 && + (flags & MPOL_MF_MOVE && folio_estimated_sharers(folio) == 1 && !hugetlb_pmd_shared(pte))) { - if (isolate_hugetlb(page_folio(page), qp->pagelist) && + if (isolate_hugetlb(folio, qp->pagelist) && (flags & MPOL_MF_STRICT)) /* - * Failed to isolate page but allow migrating pages + * Failed to isolate folio but allow migrating pages * which have been queued. */ ret = 1; @@ -703,7 +710,7 @@ static int queue_pages_test_walk(unsigned long start, unsigned long end, } static const struct mm_walk_ops queue_pages_walk_ops = { - .hugetlb_entry = queue_pages_hugetlb, + .hugetlb_entry = queue_folios_hugetlb, .pmd_entry = queue_folios_pte_range, .test_walk = queue_pages_test_walk, }; From patchwork Mon Jan 30 20:18:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13121759 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 06F64C636D6 for ; Mon, 30 Jan 2023 20:18:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 48E6D6B007B; Mon, 30 Jan 2023 15:18:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F0516B007D; Mon, 30 Jan 2023 15:18:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 241976B007E; Mon, 30 Jan 2023 15:18:50 -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 175136B007B for ; Mon, 30 Jan 2023 15:18:50 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A98961209F8 for ; Mon, 30 Jan 2023 20:18:49 +0000 (UTC) X-FDA: 80412578778.10.CC9F279 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by imf08.hostedemail.com (Postfix) with ESMTP id 8C69A160015 for ; Mon, 30 Jan 2023 20:18:47 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=PEUIZrC+; spf=pass (imf08.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.176 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=1675109927; 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=xJQ5OTdh+fc+ccMNlHyYjb+fYbFIfXaQUDxSd+sy4Ac=; b=fM7rzPYWEjVFaN9mu7ubpIAD19mJSXoCSGsFFtQtJ6FIvhMH6BX1WnZkr09hMdQV8FxSM1 +8vbzTmTH2U6joE2zoyanTITh7SYthSM13HBrnnum6W+XU2cumpfuzjajV/AWORYgSIXfU j3FxJXfdBOOxTz+wXR/oRECl3Isfr1o= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=PEUIZrC+; spf=pass (imf08.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.176 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=1675109927; a=rsa-sha256; cv=none; b=Y727xvo4GMraAnnBux4zvPZdMOgw9u3ma0ldvAYH5r+3Z0u0lZyn5IBw70MaXWlKRnuHTZ Ai6NrndyYvTlfnKsc9pj/KLO1JghH0IydRtFot8IGHj+N+M+8LTA85kY6TGu0qg6IxOqCe Z3bPICrk+PdSBgu9b71tsNv/qyyhmLQ= Received: by mail-pl1-f176.google.com with SMTP id d3so12844512plr.10 for ; Mon, 30 Jan 2023 12:18:47 -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=xJQ5OTdh+fc+ccMNlHyYjb+fYbFIfXaQUDxSd+sy4Ac=; b=PEUIZrC+RH5+9pYkh6XYzKYqbMb8jOHl+69QZ/Lb2+tXCHO+jqtbDIZKClYL68y3RO BbK/pZKsW5mscHpNz/jhxraDmx1IyeZPErllGnlJNJO99fUJZDIG01OCBA7AtlvXr2QZ tjXA4+oBey2Rie2dE8OW4bp/7ySNDizbDQGMfpcvuPSTBoblsldgyu8UYC0i/IncGdLQ N4ZuaojlXmmT5uNLUBr+NSJObiaW0CQ1NEu7yjMk7bToXSoQocoD0SAiNt7tFRgy3Zjt 73B1duMYfMdMKFMX36MZn7wGnh/osd/8fYOdi2jqhKZyca30g8842xjxn5NY0WfkiXn0 AMEg== 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=xJQ5OTdh+fc+ccMNlHyYjb+fYbFIfXaQUDxSd+sy4Ac=; b=KgXCfkWRJ5JQDOOr8x5KXZkkte8v5P7cIppicuh6hwDWEkjQ/A30zzwNJQ8SrVrqFl kK4/jEPXkjJ727HLiWSBzxN2Q3IIERsGe6F510bGn/Pt3sVeiXYknmG+q9YuZKmDkxsP quByNZV+TEdKBKZR3Ogv9TcRJEq5AsSyAcK099zzhj1cFpeN8IgTEkbY+kR5weLbQg1p lxVYlJyHkWy1zeop1ybhhD1k5w0EI7kEklDOGmzwQEogPVDD+Y71adzQxZyNoch1EqK9 6rpYzh9sktY24/ayJ4WrUqBxU7/GYx/UNlBxNd+u3Tpa2LuNdI0BRpfKEaHzU2jph/bv 1JhQ== X-Gm-Message-State: AO0yUKUcOvmitxHMaOew0P+4WEB+IcIXAyFVtH88gpKpv6KGPrIc1V15 inz7D2/ZN0lIDEbV5/mJqzg6rNGhBfk= X-Google-Smtp-Source: AK7set/3xtBWdaXl/BxR1DUewvgNkf3u0eTu5c7YIlED/AQZjc6fr+VgNbYD76m5b1zy5IDlpUgKzg== X-Received: by 2002:a05:6a20:4408:b0:bc:ae32:4d6e with SMTP id ce8-20020a056a20440800b000bcae324d6emr10770844pzb.54.1675109926167; Mon, 30 Jan 2023 12:18:46 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:937f:7f20::a8cd]) by smtp.googlemail.com with ESMTPSA id g9-20020a056a000b8900b0058d9730ede0sm113262pfj.210.2023.01.30.12.18.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 12:18:45 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, "Vishal Moola (Oracle)" Subject: [PATCH mm-unstable v4 5/6] mm/mempolicy: convert queue_pages_required() to queue_folio_required() Date: Mon, 30 Jan 2023 12:18:32 -0800 Message-Id: <20230130201833.27042-6-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230130201833.27042-1-vishal.moola@gmail.com> References: <20230130201833.27042-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: 4ozmhsi4gr7fc3n6t5m74yf9kupzsx55 X-Rspamd-Queue-Id: 8C69A160015 X-HE-Tag: 1675109927-341967 X-HE-Meta: U2FsdGVkX188QJo43W6aJ0PAdsk6m+m2d7wVN2NPkdlPA9HQmBALxnsQraMciqkjuACzd30+CpnqBBjbN1xzekdm/ZakitzQKBDBnZSiJ6TKycek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7r69Smo5JLxva9iuAgPAwHaOn9KO4iMcy5p20V8ceC3U467R4OnGBjKwQ5DycSJdegGNvbpoo3q0Rgx7LFqcXXuo3XUOdeUiRHBA8GLgqByp8k0XIBy2RLq/kzKLvogrd1IOPKl1alGKNL0kLedlexkwgt5OczN2oQkFH/1sV0jwVnIUwR2Z0V56CV0fpJ70qak7a64tTarQHwO0+ADuzAgn2NUTl3qjc6DOmB2/0qsFh5z04ZwiiJj8wKVPLQ5ChmUUfJie0QZEL4ZZiQ55UDm7ivrhGLGYu+a54MVjHgFgfgHZEoyB3UkQKq/1EbIRHVq1C0nw0MVVi/gs7329NA+mqWSYlgvXEEjuARtCAbSy3mG/my36vHzSw3CHuMDKj3Uaa11xuWA+6Qd0BgfBugTLksl8kQMp2rdIetRiojQku1jS02Te2xwVYZYXJrnHdwbduuBUynQ6w0u0kA+v/L2Bwh4tKJ2h5nLGY= 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: Replace queue_pages_required() with queue_folio_required(). queue_folio_required() does the same as queue_pages_required(), except takes in a folio instead of a page. Signed-off-by: Vishal Moola (Oracle) --- mm/mempolicy.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 668392493500..6a68dbce3b70 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -427,15 +427,15 @@ struct queue_pages { }; /* - * Check if the page's nid is in qp->nmask. + * Check if the folio's nid is in qp->nmask. * * If MPOL_MF_INVERT is set in qp->flags, check if the nid is * in the invert of qp->nmask. */ -static inline bool queue_pages_required(struct page *page, +static inline bool queue_folio_required(struct folio *folio, struct queue_pages *qp) { - int nid = page_to_nid(page); + int nid = folio_nid(folio); unsigned long flags = qp->flags; return node_isset(nid, *qp->nmask) == !(flags & MPOL_MF_INVERT); @@ -469,7 +469,7 @@ static int queue_folios_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr, walk->action = ACTION_CONTINUE; goto unlock; } - if (!queue_pages_required(&folio->page, qp)) + if (!queue_folio_required(folio, qp)) goto unlock; flags = qp->flags; @@ -530,7 +530,7 @@ static int queue_folios_pte_range(pmd_t *pmd, unsigned long addr, */ if (folio_test_reserved(folio)) continue; - if (!queue_pages_required(&folio->page, qp)) + if (!queue_folio_required(folio, qp)) continue; if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) { /* MPOL_MF_STRICT must be specified if we get here */ @@ -575,7 +575,7 @@ static int queue_folios_hugetlb(pte_t *pte, unsigned long hmask, if (!pte_present(entry)) goto unlock; folio = pfn_folio(pte_pfn(entry)); - if (!queue_pages_required(&folio->page, qp)) + if (!queue_folio_required(folio, qp)) goto unlock; if (flags == MPOL_MF_STRICT) { From patchwork Mon Jan 30 20:18:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13121760 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 4505BC54EAA for ; Mon, 30 Jan 2023 20:18:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8AB836B007D; Mon, 30 Jan 2023 15:18:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 85D646B007E; Mon, 30 Jan 2023 15:18:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 74BF96B0080; Mon, 30 Jan 2023 15:18:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 5511A6B007E for ; Mon, 30 Jan 2023 15:18:50 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 30DD2C03C9 for ; Mon, 30 Jan 2023 20:18:50 +0000 (UTC) X-FDA: 80412578820.09.705E017 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by imf10.hostedemail.com (Postfix) with ESMTP id 605AAC001D for ; Mon, 30 Jan 2023 20:18:48 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Tj3i6e31; spf=pass (imf10.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.173 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=1675109928; a=rsa-sha256; cv=none; b=ghK4jEl+qTMGisBABG41nRDsH+5bkTkRwdsuhUmB/a6Vk31pyQn4tcui38HsNTMkJ754Fo Jh04kqWbTNdJX8smHfH3pew/jy4gYj9cDYkl+t3DYMEyPVECOiOsCJyikjw7qU59NLHPoZ y5wIrr35GWc8m24ZDy0TtEs+wWdo87U= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Tj3i6e31; spf=pass (imf10.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.173 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=1675109928; 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=Rj/qU+zS2SpVSC06qhYsv6OtjuVRmpJHRc9Sl9s1IRQ=; b=3EI6iC2zllhC00+833/EU8HGwEMFxG/Al1FBXsL/w253TrE+G8PaWDam/5J8vz2iuWk1b3 vN2CliU4/py0hSPM/O3tGnp/iOPvjK5kPhcDNWG6TbIOOcsYeZAaP2V5eDuI1WAvwFT5zq yfrDytllBfL78EE+lNToen5hLl9tA8o= Received: by mail-pf1-f173.google.com with SMTP id ay1so8599358pfb.7 for ; Mon, 30 Jan 2023 12:18:48 -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=Rj/qU+zS2SpVSC06qhYsv6OtjuVRmpJHRc9Sl9s1IRQ=; b=Tj3i6e31rScg++PudsTthpoxV+1jPlpPlY3/2b5Bf0/UDddmvfwoSeZ+wYXRcuVc2s wRlQRVqhaPdfYKY1/JcUFWGAyeH43ttEzDrtWbqT+7iJn/MB4dHk+JXlS32nb7igoFty J9/9643gbLQ/ImSRTqG97EHjD5VvPpCXcog14K0EjqXA51AkRgjmIbWqnOfPPXFe65Ri MDyBz/g7XdxdVnoMxbYe2N6WuWw1NeC62o4FfTo4S/s3M+4uRlhzGZ/c6TYRKZXNODpk TDOT5lG0BDlRIhjVRNv7IIUn6wH7Sx+sBaVWNVUw/fpiys5R733Q1SifNCc1biGkBk2W r0CQ== 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=Rj/qU+zS2SpVSC06qhYsv6OtjuVRmpJHRc9Sl9s1IRQ=; b=faH7VMgQ5jNAosSv3klU0HeAaHdBWiW+qZItp9oXJt/3OAfzBWmoj0eGnkobWjnPJm GEVUTmcvDIe1Fo6eWfZr+Ii0L0gbArmUI1fSZMY5sfWbRlvbjcb/MrL9EPCDOMwEqrYL Zp0rfkhCVDVyL7arLQwv/uc8LOhlM2Yu2Kz4UNrfhx3xz4snN12OLujb99fu9UBXlaE0 57gPKucg3HwgRgXQISHuszqt4h0sS8wzBDyXGNc+oHApboM3W+4r2Q3LB+ydQGZWY452 SdBpatPi70x81qQrF8uYvzl2q6zCbWZ+hywEdq8z4KAYQvLjBPoKqlLOu3KP1KXvnrTC aENw== X-Gm-Message-State: AO0yUKVRArF1/QnGzJSUJJuqk3Exi0fLccrcX/H9KA8Uvb0tq9rM2tfJ QMZqTsw/SWpHRDJ2jvtV8o23xlGLEKg= X-Google-Smtp-Source: AK7set8JYge76j6ldf/cIJq9uWBWkQOUiCPeaBC+LTVdk7HzGHP97Ti5ETwPgNXR/shIaFwgkw06Cw== X-Received: by 2002:a62:3044:0:b0:590:64f1:8873 with SMTP id w65-20020a623044000000b0059064f18873mr7945965pfw.5.1675109927113; Mon, 30 Jan 2023 12:18:47 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:937f:7f20::a8cd]) by smtp.googlemail.com with ESMTPSA id g9-20020a056a000b8900b0058d9730ede0sm113262pfj.210.2023.01.30.12.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 12:18:46 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, "Vishal Moola (Oracle)" Subject: [PATCH mm-unstable v4 6/6] mm/mempolicy: convert migrate_page_add() to migrate_folio_add() Date: Mon, 30 Jan 2023 12:18:33 -0800 Message-Id: <20230130201833.27042-7-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230130201833.27042-1-vishal.moola@gmail.com> References: <20230130201833.27042-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 605AAC001D X-Rspamd-Server: rspam01 X-Stat-Signature: 16aoj6zrqd9884sgjzwf48m3gb5hwpce X-HE-Tag: 1675109928-809665 X-HE-Meta: U2FsdGVkX1+oC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p5nM8oITo0AgEUFVMIp216Jw8FIsxuc1StkOS7nZ6nR6+hPoDTtharaogcmgbwyUbVd24H8bIDyo9HIq7Int2SH3pHvIlFz8LdX+Gp9l0yn+s6n1WwLyup/9dJWuzUpK+X+e9DYtXdsWbOJLoQBBbW1TsofEMw8BDhjp/V5k9RZGTE/Tz7y5VIjuMT1typvA2m2tbWfshsL6j/CU47VGXWBe3TDujowf8yoI/6Q/kEGj9GcBFlneQFvEa0WBcVpFwv706pKYLLg83izppdGInVvtBnhSmWOHD8B8c8P2G4xMHvAUG4KSKOfzjPGeelV7FLvA54S/tnseILElnLfHPdBugWv7tkh706fYY32/0jC+eVQQbvgEpgRCWQtpedAhgGersLV7SGTZE91/AyajOOAvazPbPj+TDw/7IEIUGbv2o6cpociO4RgBrregC4YRK1nCcKN2Kr5d8mkltKSz3ds+BEJsTEkFOFTYB11/l+tS/se8SVyVIj0QsH7St7tl8g53ZX69g9eFrkrh/HDsUT7ycfpeMK6TviUvqoTrLEWrAHSMFqnPVXnh6kMvUl5MjRdHo= 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: Replace migrate_page_add() with migrate_folio_add(). migrate_folio_add() does the same a migrate_page_add() but takes in a folio instead of a page. This removes a couple of calls to compound_head(). Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Yin Fengwei --- mm/mempolicy.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 6a68dbce3b70..0919c7a719d4 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -414,7 +414,7 @@ static const struct mempolicy_operations mpol_ops[MPOL_MAX] = { }, }; -static int migrate_page_add(struct page *page, struct list_head *pagelist, +static int migrate_folio_add(struct folio *folio, struct list_head *foliolist, unsigned long flags); struct queue_pages { @@ -476,7 +476,7 @@ static int queue_folios_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr, /* go to folio migration */ if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) { if (!vma_migratable(walk->vma) || - migrate_page_add(&folio->page, qp->pagelist, flags)) { + migrate_folio_add(folio, qp->pagelist, flags)) { ret = 1; goto unlock; } @@ -544,7 +544,7 @@ static int queue_folios_pte_range(pmd_t *pmd, unsigned long addr, * temporary off LRU pages in the range. Still * need migrate other LRU pages. */ - if (migrate_page_add(&folio->page, qp->pagelist, flags)) + if (migrate_folio_add(folio, qp->pagelist, flags)) has_unmovable = true; } else break; @@ -1021,27 +1021,28 @@ static long do_get_mempolicy(int *policy, nodemask_t *nmask, } #ifdef CONFIG_MIGRATION -/* - * page migration, thp tail pages can be passed. - */ -static int migrate_page_add(struct page *page, struct list_head *pagelist, +static int migrate_folio_add(struct folio *folio, struct list_head *foliolist, unsigned long flags) { - struct page *head = compound_head(page); /* - * Avoid migrating a page that is shared with others. + * We try to migrate only unshared folios. If it is shared it + * is likely not worth migrating. + * + * To check if the folio is shared, ideally we want to make sure + * every page is mapped to the same process. Doing that is very + * expensive, so check the estimated mapcount of the folio instead. */ - if ((flags & MPOL_MF_MOVE_ALL) || page_mapcount(head) == 1) { - if (!isolate_lru_page(head)) { - list_add_tail(&head->lru, pagelist); - mod_node_page_state(page_pgdat(head), - NR_ISOLATED_ANON + page_is_file_lru(head), - thp_nr_pages(head)); + if ((flags & MPOL_MF_MOVE_ALL) || folio_estimated_sharers(folio) == 1) { + if (!folio_isolate_lru(folio)) { + list_add_tail(&folio->lru, foliolist); + node_stat_mod_folio(folio, + NR_ISOLATED_ANON + folio_is_file_lru(folio), + folio_nr_pages(folio)); } else if (flags & MPOL_MF_STRICT) { /* - * Non-movable page may reach here. And, there may be - * temporary off LRU pages or non-LRU movable pages. - * Treat them as unmovable pages since they can't be + * Non-movable folio may reach here. And, there may be + * temporary off LRU folios or non-LRU movable folios. + * Treat them as unmovable folios since they can't be * isolated, so they can't be moved at the moment. It * should return -EIO for this case too. */ @@ -1235,7 +1236,7 @@ static struct page *new_page(struct page *page, unsigned long start) } #else -static int migrate_page_add(struct page *page, struct list_head *pagelist, +static int migrate_folio_add(struct folio *folio, struct list_head *foliolist, unsigned long flags) { return -EIO;