From patchwork Tue Jan 24 01:22:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13113242 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 53910C54EB4 for ; Tue, 24 Jan 2023 01:22:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B671B6B0072; Mon, 23 Jan 2023 20:22:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AEFA86B0074; Mon, 23 Jan 2023 20:22:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 969266B0075; Mon, 23 Jan 2023 20:22:19 -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 846DC6B0072 for ; Mon, 23 Jan 2023 20:22:19 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 56184AAEC6 for ; Tue, 24 Jan 2023 01:22:19 +0000 (UTC) X-FDA: 80387941998.13.12F23E1 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf09.hostedemail.com (Postfix) with ESMTP id 8C260140003 for ; Tue, 24 Jan 2023 01:22:16 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Szcl6AW6; spf=pass (imf09.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.177 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=1674523336; a=rsa-sha256; cv=none; b=M4rAvw4g/GiPnXZ4CBJFUgsgpAuE/834miuHVfVWJ/sSs6MQyn/8xrqCPhwJN9OsuXc6vf rcHsGPq/9bsLxPwlFZIVrCbjjZjyTzFvRe5/IhlnZuOZbuOn6A7P4hsKmZvhBY3h/ue+xP FyseqqUi3vKW2QNO2l4clY1utt9WolA= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Szcl6AW6; spf=pass (imf09.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.177 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=1674523336; 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=g4yYO75/EwQZJYH40lk5sQ9ghbUufbuHyMXdhMR3QCQ=; b=VL6sPixwCJCR8y+5e3Ymgv47/sFiuw6n0Yn8joOy3zM+8kmxAAPn7dWw6uQwTouT0pAVUl pPjDni2+h3R/3x50M9340Mi2QZB0NO6FVIju+R2GbCEn81MgCxDQ+hvQMveX0t5Aj+44k/ l6EMmgngiD9OGlVGh46i0pUxuMy5/KI= Received: by mail-pf1-f177.google.com with SMTP id w2so10175840pfc.11 for ; Mon, 23 Jan 2023 17:22:16 -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=g4yYO75/EwQZJYH40lk5sQ9ghbUufbuHyMXdhMR3QCQ=; b=Szcl6AW6otWDqobuZJtGwtF7glIsetJ71TVMtKHGZGZCFaMHizeHwXV0GBU46ckXD8 AN03PI7hEuIMhWD4c1RA5sz5Wtm0fMxgKre5TWnzTXjzlDSiM160wux/hWv/nzN1CHUP R4EnE3slgjF0R/6ei4HCL+ijvHGjHIqm07siw61r2CmMthT9q78b3av8tIsayCUVJdIX Wn9VAjNm+k2HfFN9Obbc/ey33I9I4xxPmyFz5bNRWXizKCXMsohhMOA5Zi4XFNzY/717 gPoldZwss7g2sYCp+RKJRKbjpWnwlpDf34GjSqD+FxKsv2ctHsqvnkUUIpjvVyeOlSps j9Vg== 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=g4yYO75/EwQZJYH40lk5sQ9ghbUufbuHyMXdhMR3QCQ=; b=dZPMqMIUa3X710Q0AspR9LDKZUe57r9Y4DNOH8o7spPrYAdouqS7rNDoXBMQIFi1Wp aAO2jxroPmmeUD/m2Twdp8NruJa7XuOdNGpEWeJDvmimcXkaJQwh0ycBllVgsSRU8GjV o4IB4+VvcopG4D0q/377GS+yZ0wcd41T9jYPGftZVaJad0evqIZt5b32BFwFfKE3NP2n iTNjryp8GTZV/0bCdEk1zBrwvU1jnCdLdFgm26yyMIBY6pgCtalpJcfOP+VbX2Q2392S ia9cVU40gkzrxTqDXeMSAGejMQtDN7mkUwLBq2EMIK3l3zWsiP7kQN9iPBPnnVNtcqbX Fn7g== X-Gm-Message-State: AFqh2koc6Jxu74wUxWmOqz/N1qzT3m6rBa9e4+AUiWRi6o1CVlVvPyNO NtI7vTOapmTTgE+fsaFBbS88imDCBRE= X-Google-Smtp-Source: AMrXdXvHdIldO2gQfEASMMQES9OCx71pQy0FZT6R+4tjFAeePnD43v8oa4X1PBOCFGYQ88pQyytS3w== X-Received: by 2002:a62:e911:0:b0:578:ac9f:79a9 with SMTP id j17-20020a62e911000000b00578ac9f79a9mr23724189pfh.15.1674523335209; Mon, 23 Jan 2023 17:22:15 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::4e4b]) by smtp.googlemail.com with ESMTPSA id 68-20020a620547000000b005825b8e0540sm213335pff.204.2023.01.23.17.22.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 17:22:14 -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 v2 1/6] mm: Add folio_estimated_mapcount() Date: Mon, 23 Jan 2023 17:22:05 -0800 Message-Id: <20230124012210.13963-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230124012210.13963-1-vishal.moola@gmail.com> References: <20230124012210.13963-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 8C260140003 X-Rspamd-Server: rspam01 X-Stat-Signature: ftzxbmpsp6kta3dkugmjtcmojrfogfbd X-HE-Tag: 1674523336-207564 X-HE-Meta: U2FsdGVkX19L289L2YYAvcESxCy8AxLXeeASi2SqkwZeDGgVyZtN79zY2mODtaG6GHFXBkvYNbmup1acJD2lk5vd2OHWNkz2DmN572dt9/4Kn7BasTMsLEdwac2us9XVQsyJZde1ezYAvugMN/71k5BFLlk3RvzW+z6rw4CMpocuGJvoh3Nl4Gr2shpa9P0fUYs1WLHyWOxaILQWv/HRbmIbQ1DbnFZj98y+ig1djgXR4FGOEQf62NI5+GgfFHE6OqL5iWAMP3/hEKQiqOD0/lHO7/1ZP+acvUbR5BMWWBTP8cYby6oID0InMge2OcNASzzs0I3nrql6gDjlKwC3poccCE0vfVYPj1CceTVaJVOh/o9AFvn3FmBbHiwiQ2UyHODmgRU23aE8UVith6DHDnAOUt6xNmdSemCIK+u7rseGKKQLYhBQYNivGAHWi5pZAoVIY3CPhRFSxiXKd4mwB0YS/cD54MRRslOrlKp21pk9LZPTM/o2YWJmTkebTIUNRLqTtBB0P1Ic1vRd0z0VfiLyJQlKKLnP86CIrmBjU4hf920+9NFZDMVV6n6mWPsWBe3nZkHXxp2QF0E61ODLCPCtJgU4lK70W2Ud9AW5FD2izfGyfCv1GXcR/iGGqb1slgOvxKxByyanMj/LYI+JSA4ECb2SBDyXMDpYYkraVug0BHDC3iO834PUconiNtr5tKUmbEQ/0WnERi07/NL/AhaA/o2YHRphB24jOEcizJhBouTRpDEjn0UDlSswagf5wALfd67NCvZVY18XmatX4cagARImaemPzodJ+NAbZHDZ/b5B16QQRAGJvAmpj8ZrQVlklbPioaP36G3bWW5KDsTZN+ajFADLGhSA5TzAw/zBZgAVC+neBVN4Uze6goRIJr+n88O25ZOODk2+YnKK9KJtgSp6oBvuIOkwh9luhxfFRh8xtZa9dY2FxpXoudrEunIbPYB1CmIyU4IN3Mk Qn9x0SjO EnfYbCayR8WQuriB+O4NMhzh7FHwozJQeckikGloojV7JHy08WCMgHG0DAEIO1qF8dqe10s5Je+gnvgT2DftZi8VJoX/8Hz31VfnifBrT409/rv08DgfzePMaexF9kbRirE7mdqpLyzpq7NIL6PWb7Zl51FB3QwoMstXBNCx4QsqmoWxFHpqxQpKkxiUNr3vz1FugMtboqwvcm4vK/T4jwYKq1r7Qny5xunyFy5SIfXKIVWd6mABOae5FuCTUDf3H09v26W5MdQdAkq6wKf0iv6pnItbxNQv3QWe8O+OH8kldXlIFBGd9fx0qeMcGF9VRFcSIerKcwmKLsLht5b80ta9eO8ma5jm5gc8HH/VF3QnXMd0Yi2xsVFonxVdQlgd0G/attwSTO/QziSs0ugB2ZrMn5LwtV0GkIM8bKPgPkmaG9Z/ePO4Wn5RHW9o1oswRzMd2CUP4sZSxkWxTfKYV4EawzJMu6DQtW12wijikIQF2CLWwBQ8JOGQuRTyJhyavc9nf2Vrn4TR8CnFypvnpj/togABzNdDreKOrpKq6KxGB2j54+TIrcGpypnxdYW5YfI9jCK0xMaq4SFTfpwfGMW0wOg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000662, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: folio_estimated_mapcount() takes in a folio and calls page_mapcount() on the first page of that folio. This is necessary for folio conversions where we only care about either the entire_mapcount of a large folio, or the mapcount of a not large folio. This is in contrast to folio_mapcount() which calculates the total number of the times a folio and its subpages are mapped. Signed-off-by: Vishal Moola (Oracle) --- include/linux/mm.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index c9db257f09b3..543c360f7ecc 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -875,6 +875,11 @@ static inline int page_mapcount(struct page *page) return mapcount; } +static inline int folio_estimated_mapcount(struct folio *folio) +{ + return page_mapcount(folio_page(folio, 0)); +} + int folio_total_mapcount(struct folio *folio); /** From patchwork Tue Jan 24 01:22:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13113244 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 CA18FC05027 for ; Tue, 24 Jan 2023 01:22:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C9F806B0078; Mon, 23 Jan 2023 20:22:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C55166B0075; Mon, 23 Jan 2023 20:22:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E5CC6B007D; Mon, 23 Jan 2023 20:22:20 -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 8DD4A6B007B for ; Mon, 23 Jan 2023 20:22:20 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5C1E9AADF4 for ; Tue, 24 Jan 2023 01:22:20 +0000 (UTC) X-FDA: 80387942040.05.596D113 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) by imf01.hostedemail.com (Postfix) with ESMTP id 8E28F40008 for ; Tue, 24 Jan 2023 01:22:17 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=AQFA3PSK; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.179 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=1674523337; 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=1khdYzxT7PMCcz7jBx9VZXJLxnPij2EE71ujrUVxn1A=; b=stzwgsb7StErMa+MbvN56V7z1zDJ/MFHZdya+RlGC7JZb5USJEjNRu4oTFuOj6zzTTxIBL yAdyTMbzlk8na7TKGwJaF6Gwz/bCc6EskqD0g9OG1oyFVErdgMQXRf/d0GvFDMw9i6ihgI 5iCfvklvQhYHxJH15FK/F2kopXMjctQ= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=AQFA3PSK; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.179 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674523337; a=rsa-sha256; cv=none; b=3LeG4SFlLWnuWZPXvMFCrqTkWA4WG2T4XlNPUYR3a202nymUX4BoSe60K0sUlBmVWmBrCs KVnnXhIuKglmQ8luFJtTth5lMBA2WnekFwosNMURcs/m2U2QRg5KE5KXahrrCMqHnKNhJe 1xhVQay7dv2FSXZO+m0GeuFB4TWIo1o= Received: by mail-pg1-f179.google.com with SMTP id e10so10333138pgc.9 for ; Mon, 23 Jan 2023 17:22:17 -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=1khdYzxT7PMCcz7jBx9VZXJLxnPij2EE71ujrUVxn1A=; b=AQFA3PSKomBpZe5gurflYfaoGq6UO7+JSQrD/eFXn7DBVKYwU0lAuRqrv6GxCbLet2 ZYY3M1EU7g5+hFtI0ELOwlQINs/vbumoHskfRHq5wnlvKsUF/l+Wu9dTzLGCbeC+yyLZ 1IQGEjtGmR9Qv/BmzIV6kz5BRs1XM+FvZ9xTyoltiC/Jbz7hp1uo/CqieYoyGHbCRZkV cQuSasuhjAi4VrOVZ8FspI81LB1vNTSUlHIKh4KN4Ho8vG5ViS7RiguK2VdNCAheBcmT 7yDjGx0eTBYwv9ulybCtiSf4t7DyfDQSO5+r6WLwoWyfqrKcDBphe0mryJEh58FaiuZK FTow== 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=1khdYzxT7PMCcz7jBx9VZXJLxnPij2EE71ujrUVxn1A=; b=R43mpWyajaPN7y9dgvQkep5BCdKmT4I8+fn34qLQ4ZlP+IbBOwULlZGVBod+f4rudx B6q7fYP3vHVwEmcu2iwetSiByXOGr7i37nAMhfEA+SWnPRtronuhWGLA0X1R1Fe5lxQi v+vcfsf1FSbDSB3mfDW7lz6C320TCrOEU45mNJbWWwlNOHtvqusV7ugMxm0tZJ/GVHXP Z9V3Fmf547RT4G1571D/IZqb12gsXcD/tmxTzPwFMsbWjdQDdD3LuANRdrigM9xpI3NF ldarNpyZdkY+5nyb4s8bgfxRQ3I7Q4HLWk7+RHcBkw01qCGrNIsvReiNA0vZltCAD1on C5Yg== X-Gm-Message-State: AFqh2kqLgmxva0hq7RwZ1rBCEt+pTZx5dexvsRGd385kdG9+7i3eHrT/ fn3VYnVEhg2JcCDslsyZGfn//Wn7tos= X-Google-Smtp-Source: AMrXdXuX4J13uTAEIumzs2XPLcTlVHJgPNwGg7gH1qZU0DCzEzh0s6K/AVoOfbakTeWPmmGphfpZhQ== X-Received: by 2002:aa7:96f7:0:b0:580:c223:90e9 with SMTP id i23-20020aa796f7000000b00580c22390e9mr28511220pfq.6.1674523336159; Mon, 23 Jan 2023 17:22:16 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::4e4b]) by smtp.googlemail.com with ESMTPSA id 68-20020a620547000000b005825b8e0540sm213335pff.204.2023.01.23.17.22.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 17:22:15 -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 v2 2/6] mm/mempolicy: Convert queue_pages_pmd() to queue_folios_pmd() Date: Mon, 23 Jan 2023 17:22:06 -0800 Message-Id: <20230124012210.13963-3-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230124012210.13963-1-vishal.moola@gmail.com> References: <20230124012210.13963-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 8E28F40008 X-Stat-Signature: 8dk9ts1hsbxf9i6ahq6iunhrfcggmxsa X-HE-Tag: 1674523337-1120 X-HE-Meta: U2FsdGVkX19tOwlo8B5xsnoV7R9Mo7e9U1XLZsAgpu1oEHaAwQLbyNI13akm/X/JtBBwJ3UCRC1HrzA8IWiA+ly4/ndIfxB+ydgYtfHArciVDGYWOExWkEIOn/jIrb8ebfC/kvwgZeDm7Y5x5/F9x+oFZ1K25rvMH8BVGhMrxXT8adPCxO8uShbckJbl8nsf0MB+hDqK8zcs5hBsLGgOFzvZhghQUuUztaH8GUqekWi0mjt0KAxahktjVsVHPWYuvfyb8voHGhunD4KgFZ7aqx2bub2WP2WoXnV61Fj252YbiBGYE4kgXHL7o+HL3Zj6bi9g25Zv/SJo6EowDjWsmWRuTJ7P77NDi5swIJhiGIPs3OYwlXqQRHmbKcaU5+C/aXZzHq5ujW3Po7yYJrlIW9gxmbRSAaGrLUPGL0/c54Kjg8ar8/+6tvS+HAdvFqS6O4Q8GByk3JS1EcUwmjhedCtOsswZVYrfGSJxISbLxdF0ENtzRfr15fNBybtrSAlZWDqrggzLvs0Xl2Mn2n+xj+kHgYevjcLYuN/xJR74LlGiTDdL0o610xeGOP0mlNBcd+jPr6UiQl2wuLSRVUyETmlKCO8ApUaBT4E+ILwwF479n6ka59MjJ5AqNx35a1SVkrpFaV9rGDJ2kg04e1glDn5ygGbmFbwbc/xuASi0e/D/TokrGVULUfSAoIOYJkdG7URoxCKq/l2HK3TWIZP/WLLzmFkF45d9/f2kbqgiAvb0RQSIPK6U5XXdDPIhLLbIw+aZxuy8ybnvtKSOZ4o706Y0GQyHGQdS2IWJYgsOMIsUxvO6X5jsca51O3sbEVR/edJdca9Eqrs7DQwPMZs7jbWzmTx8lrqollgBiQV0cqPKYBpqxWwKXw/LrIty5bsc99rn29PmiDqxhPn60gdOHwfTxJGXGdye80+TVB8HYOooEpin6eKFHVhk3h7omnTDSpd14XpmukDe2uU9CUv gYwYEwab GgPeBqR34+NIRWeQC4XKKnsMaryFXA8JMY6aypFBzc6kFIPd9tiFfvW143zw+e5U6kVtyEzdJB2af7dx0x27ZmWwEmRRswooQi8C6BtmCg3EDvtUK4XMdnbU5S087uE8Yo+tM/8AzkfjfAB5qXkQtl5yVBvkk/z8vO0ReM53hS6YuiMbGZsFEDtQxCLXqDkQ+jzsyC+/oQq3Pgu0gHHGI9Di9pXqE0dcaDLO4DIbviKlkPJYhw3L9XYVxSzTBwKokip7pYGgHsaGu4KRaxQAmiwjzgwDJAksHyB+UnRPRZphnxDl2oqEU64Vn2HTxsuNHO7CJ2zc/+m/iT2YMNA83jhODMPtymUUuqfY6VzBrSmYBlKvhI3uCe0j8AqpavlRkBpCqAv7j2YAydZRmHOGBlEnMmw54DmlJ4F7HMZooGebRjKdi/OumYZ6zar4Lf+aRfm/xWwt4vFQzkMbJ/7PtwHElRGcOEcGdJvfAmbzi9a/eCD00BLLGGHgwdL5N89oo7kGYWEc1l5BwDQ0VOhkZG/VykSQiLVDuW0fYvCEgQD/wFBOFluVGt9QIYoDJuth38nSsfo03JkSFjOl3wksz5ulgDw== 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 fd99d303e34f..00fffa93adae 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 Tue Jan 24 01:22:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13113243 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 5DA2EC61D97 for ; Tue, 24 Jan 2023 01:22:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 96C896B0074; Mon, 23 Jan 2023 20:22:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8CDA96B0075; Mon, 23 Jan 2023 20:22:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 720BD6B0078; Mon, 23 Jan 2023 20:22:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 566F86B0074 for ; Mon, 23 Jan 2023 20:22:20 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 32CD41C4297 for ; Tue, 24 Jan 2023 01:22:20 +0000 (UTC) X-FDA: 80387942040.29.DDC8469 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf03.hostedemail.com (Postfix) with ESMTP id 6C37C20010 for ; Tue, 24 Jan 2023 01:22:18 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=qBPhBTvM; spf=pass (imf03.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.181 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=1674523338; 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=8vZic6jN1vVBvksvwJz1xQpCGfyGjrm+SSW90x/iIgk=; b=dEnypk6pnZsSpEt7mUixtNZ4JcjGlsjun6iieSycv5DC7d/Dmm6O2hQmzGBrei9lpZvYlG q6U7cttsw5BnqyO1g0/kKK+5Nr4R9gTH6bh10mp0Xu3vsPcglKEzVwwclBz8vKBkHVG9/I XXMNi7Q5LxMJNGw1ShwzHRoHDCpYKMA= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=qBPhBTvM; spf=pass (imf03.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.181 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=1674523338; a=rsa-sha256; cv=none; b=V1wZtY00capocjJdFCXbYh39HYjOdnNo1r5Nn2gjloqJ6VpDWf+tfFUODahVJewnRU9RKM ii23717QKvjn0tRWd8UNI8Tf2x7cmwVJZrGHzT+/6x10AgHEcnZE4539563JpgnL1b6AsC jvrcHA9WhEPxa6QomprAf1SWk50B02k= Received: by mail-pl1-f181.google.com with SMTP id z13so13263191plg.6 for ; Mon, 23 Jan 2023 17:22:18 -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=8vZic6jN1vVBvksvwJz1xQpCGfyGjrm+SSW90x/iIgk=; b=qBPhBTvMV2Owf9VhJgprVatzzsuTmrmdgujWu+ZXhk/taMI+CI//vfjdnStMaEicO+ eRgtXHtbKN7WoA1D0BW1aQx3ngg0C6oyKnkPB2n8LbLYUDvFVEEsQvMko7UurU0FYDrP rgmkiL0x6/F6KFse2M+VNc9uZfljnpTYBKUgzeZ1yUHeJQjjeCbIDNUZ/Lip+HXAfpnO 4tlP4om8xgFnrzu1DFjHz/F68qaZoC4b7pEDtOxU940nWGKICHTJUPqT20Z07wsTUnI0 pg4tdKzTzZA53en87NnjKZ8kjpBE7Zm2e0Jw98pVKixaY+TCAziFoR/c+QD2ckTpoMq2 fkaw== 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=8vZic6jN1vVBvksvwJz1xQpCGfyGjrm+SSW90x/iIgk=; b=o10e5wxS2D3HHfyooX4KkN+3pb99AJqo1Ja7V4m9BKpJT4ggtf3Ka87xZHDiUWk/yp Qugfb0twi+OodCiXz/cLxRmQubmi8pD2IbMIs9ZJVLNFVH5sAf2aGxMJyWt8IsAfPNgs SOxc/sS7A1iadZhwy9zaUlT2AaQavjm7fSui8FnNKz/Xgyk0m/SA6NPb+WqFDlGVpYQd JBphIueWRWSVRRIGJO0Pz2zyFF3zJFT/PGRg8z/4U5EEGKSCMt66dEYuYdV76pUk+mDp YAzqoRT5DKGzzHL1CpfeI8wlQQil9azp5V/Vrz6uiBelGiYwWpHuArICJEBFB/PCQ1ly 1Awg== X-Gm-Message-State: AFqh2kr4jSKDJ9S+D0B6zKuT1+n0HK14NVXOtyUYFNEP1xEPY8oAi8Q4 7BKPyvhRHY5AMQHR0/dWpebIewg7U6c= X-Google-Smtp-Source: AMrXdXudmDodnBv1VMH7m3m7RLcq8yi1x0STxfkEaumfHAX7TMVdKWRHhpFOBALkU+Vbi6tmSMYlaQ== X-Received: by 2002:a05:6a20:9597:b0:af:7762:3c29 with SMTP id iu23-20020a056a20959700b000af77623c29mr28570275pzb.10.1674523337108; Mon, 23 Jan 2023 17:22:17 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::4e4b]) by smtp.googlemail.com with ESMTPSA id 68-20020a620547000000b005825b8e0540sm213335pff.204.2023.01.23.17.22.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 17:22:16 -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 v2 3/6] mm/mempolicy: Convert queue_pages_pte_range() to queue_folios_pte_range() Date: Mon, 23 Jan 2023 17:22:07 -0800 Message-Id: <20230124012210.13963-4-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230124012210.13963-1-vishal.moola@gmail.com> References: <20230124012210.13963-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 6C37C20010 X-Stat-Signature: g5isnbf83ibixhjerqcmibi9nerr4m1x X-Rspam-User: X-HE-Tag: 1674523338-196461 X-HE-Meta: U2FsdGVkX18QZcIBi1HA9LQZqjKG+2Xh8D3luGbUW+8OOJIjAcGiiBtBc1nULqtewLeo/DLpTiGvPGTQt23fgz5p6L0bb6SVnkm35VnW0kdX4EbJecmFbiBp6SCobXWCYInby9haifmb81i+qPWHPfWyLfrVd3GitFP7PVC1Jec7nQZfxmP92hLQqTWmCF3fvA/raAALaftmxR00ZRMSNuctII/lWWHx5Lb0pk+ncmtlLsWPKneXieMPBC2a5PtLmvsRCt43r7h+q0tGgaxyzCIohtm8fYjZ/ZYTxgK4l6usW2+gU/7D6bf+8DH5d8lHAcxBqa5ubHVP64WmZERPr3+DRaXsQ7wJ5GEuQcoKrwa74/6n0qZRB6+p8kjD+hiWxtkRa0OCFHzSJ3vGsvH2iPniLhzaYRFcs+2mN3WdNoayKNXgwYh3U2U57UDQMAP/LevtIbRXdbKAb4+EH5t64j1OxYTBNZuHN3Lelh7vT6tQUS+xItLNp4I4hk63vm/XsZ0+Pj6Va8zuxvPRN00mJRr2wV49s4fpFwVmdRsSWUsUEhpdgSF0kNpz+tesnYaZdlZ3kerx9ufjgQTRm4ZUZR6RWI9R9LB+1qfhYtxUuCjvC3o9SVzdVr2FStYdbgl0mNZQi6+csz73kgUBu8SqWR7zO0zOfybZYDDDcajO7XFpY/fyrnB4J/a26HY33iKo4MIBVOwMI1edJD0bsp/mefykwuK5MAzeVKI5qyKxqVFrzM/tJA/n/VhyEtgnNsBdlNWTmWw5W8v0BhdS0JdluJJit3om1Q9h34yR5i0tmiXgK5jCNH2N0wnrh6HzO3UOSP6yGFT/U4GBbDc7/PZ4gBtBmQTmeK4yEM4Ds9G0t59itgUuqNMNRMiz9V+mhB/Am2wj34k3cA2w+wh5uKiyy/CKLtmTHxQudABShJ9uVXvrk+x8bCMQEFLQ+CAyXLC7ngAo6OJp/6W4KZ4RO9b Zjx/nMqG tDH0QHK8rfK4tt6G8rj4d9GTq+xyH2EQvkspldtdTC2hAkj4YSn/JQJVh8PUKkGCfOeKeAI14LEhGI8k/boAzxWfRmQXefH328DV9r3J3KCId7U/YoflZ2wVtIODRaJSfn74YJ2zEeAevE2oL/xZj5quDaO5SJNOMqsGGA9278ZsnExNw8PhQTlR7gjmFd1lLowsBpcsjEcvtsfocbWbE8m1mr/XyhmtX019BLVs2rHXBuYKXw+oJ6RPsSCR75nPn0srZ+aH6301Jns4El4CocszfCOeSI13SxBxK0nECawp4QD42t6btaUvRfN9Lb780G05gztvvx1nbepRIb2JsHhAmIflmzdvFyV9BXqzuEr3xTrha6wbFchTN6bnbNvPAm3fBuHJh56bi6V004mEMeqHj6NTMe9NfNKdhdZGITOjuqLaN2FTaCGRo31MpvTCeFRV9EmPMjELq2dsvjqxqa4BM3p86hy20uVlL0WFRZRt63+Yo+tbrf2zugIV5oJlL6lfHCXwKADxIx1M9/XBSpIj7X76sjjTpa/ycMEmXiPjPCHyLgc3YsaPFFdRNwmln6lG6ywLnp6gyoA/Bl9VlM4GIRQ== 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 00fffa93adae..ae9d16124f45 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; @@ -703,7 +703,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 Tue Jan 24 01:22:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13113245 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 09145C54E94 for ; Tue, 24 Jan 2023 01:22:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E1016B0075; Mon, 23 Jan 2023 20:22:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 993886B007B; Mon, 23 Jan 2023 20:22:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 795866B007D; Mon, 23 Jan 2023 20:22:21 -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 61F5C6B0075 for ; Mon, 23 Jan 2023 20:22:21 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3B121120273 for ; Tue, 24 Jan 2023 01:22:21 +0000 (UTC) X-FDA: 80387942082.26.A5F6721 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf29.hostedemail.com (Postfix) with ESMTP id 68457120009 for ; Tue, 24 Jan 2023 01:22:19 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=lC28+7oh; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.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=1674523339; 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=Sz4HU32GWbuxfmIkQjW0u4ISqBHZ5RIiVnsfOJ2Lp54=; b=KfcVD7riKhkNmAFa0MFNKtAsGnENc7Ta5eoYJ4T+8pkq/S5OtvTwyO0Q0e8NA0IlEuVvrq qBo1cl7kcbN11LPLYSMx/OdfhYakNwzFKyxZzLEvVFUmS6cGEMeKQNlhkEMqTUpNNKDm7g i+Wb6fi7g5sPgy3o0iv2hoc04c8P7ug= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=lC28+7oh; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674523339; a=rsa-sha256; cv=none; b=nO/eN4FAjWeu0DW5eTHx+n2IOAiLCR2znvtMjCQ3NtzW98xgEZO+UhY1KmDxYOcQkBphxl HLfU8ViwMX/d2pBVrNoGCw6/SQRNj3No5a8y2Nhj0+9WI8up3sB6BZ2mADQQMxNMv0CCnv OqBfH8a7BIBxx2Nx2E1hd1aw2GsgOxk= Received: by mail-pf1-f181.google.com with SMTP id x4so10219566pfj.1 for ; Mon, 23 Jan 2023 17:22: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=Sz4HU32GWbuxfmIkQjW0u4ISqBHZ5RIiVnsfOJ2Lp54=; b=lC28+7ohH3L7RY2bT2i8tSpTM0xlFz3lF6bAgzWUGWWmFuxCK9elPf2m6zudfvrEGg C0P+RSe+ZqsLvrnAo/JiYETRIQ66yDmYy1Y+7m15EK3VYcvv3JnlHD7zTuXxrywpBwQd 9vHqfvl85thXMoCB+qYDT5sRsYpyOmjbSf5RadBW37gCwnBEzxoAHepyNfuXCw3YMT1d P6nO/DzbweEpICN9rva8V8Muh+vEGKcmGeavnWMFEJSIl5BcYihei18T9xvc3bRKoguG cdMZ1rBREAS4SrcIYWfHIGtpcBBJoUpS1fYsZShm49witX7KWcPvTkXRYtg1UZjBWUSm 109w== 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=Sz4HU32GWbuxfmIkQjW0u4ISqBHZ5RIiVnsfOJ2Lp54=; b=bCE84gSNxnxhrX0MFw66XXSRuSKLae59tCReuAazI1pit1fya/TfEjj5AzJ+XQeb/7 suOKkl4MQSaz8w+6aLtI6ACuO9cLNIfaLR6SSr/oU+gQPmHK/9QpZzUAxd1Iu68hCZY2 Yv22tw8UT5LIRSmCYHE27Mp/t/SMiRMzoh2ASu2ivBLjDyoHsIKT9Ee3YXn2ENaM4ITp 0qqwEf6Z+EtIY0ZMbCaVplv+1G3N4uwY51fSW5TSUcxeB72j0lkCZfbnWc7XXb0HHhOi HFtK5nbeGzhvpiB7LMrwLF6t4p6XlJJipHH/pPVOWtAbVXm83odxNvYtBQbhkkMzuDpH wVAQ== X-Gm-Message-State: AFqh2kqTuraErxfUTl/LXNDh6xXYsFeRr5LfZ3LkFZmORNsQlvd6PSB7 1j/u767vAjP5aY1cTdb3qkX+aIvjfn8= X-Google-Smtp-Source: AMrXdXtw7DPU0fDVIuSIik2FPwLQBTsSwI80gyL0ccUmEB45ha4+fG/kppN5E/z9R4rdHRg23IBUug== X-Received: by 2002:a05:6a00:3006:b0:58b:5f9d:c2fe with SMTP id ay6-20020a056a00300600b0058b5f9dc2femr27661373pfb.29.1674523338114; Mon, 23 Jan 2023 17:22:18 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::4e4b]) by smtp.googlemail.com with ESMTPSA id 68-20020a620547000000b005825b8e0540sm213335pff.204.2023.01.23.17.22.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 17:22:17 -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 v2 4/6] mm/mempolicy: Convert queue_pages_hugetlb() to queue_folios_hugetlb() Date: Mon, 23 Jan 2023 17:22:08 -0800 Message-Id: <20230124012210.13963-5-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230124012210.13963-1-vishal.moola@gmail.com> References: <20230124012210.13963-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 68457120009 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: nj3moqxhqc9qbughx3ew3kcs189h5qrw X-HE-Tag: 1674523339-385987 X-HE-Meta: U2FsdGVkX18GTZxsIfgjrzVQdD+YYqllmhuSO3hrFZjKyeBUwyYo62vki4Qyhl1D80o42C6JpMjOLCxqu8OHUM9B1xsp4mJwmC7n/pVVdiUxczSabCHudbtVnlBJSIiamBUhKF5kOznDyaJE3LYfU7AoyTTf+ig3cUc4uzt78YxQCDJ9oO+gxf3XFxIRj2HKYa00Kn/7T+fFOmufm1XiCzMbVgAMLVTlPFgoBdmpmny4Qw+9pk7za5HKL7bX1f0TznX39Z5LxWfHEa8zTPnyrEi1zsv2yDWf117HPrGZbYzTi32SM006kN+oHy71vgWzau3RrR2LM8SNGCsQ6f6ANZCnSITjMs/F7FFLJSQdo4soePU7Xev165hJMhYVYFgXAkL5h5WUFaHNRbQskIOckf2MQP3KLZ7v3YtkXPdvrnEDInqcFcjRuj7MNGQqJZvYpY6mJ73HkJnI2PSlXVAgOSKEY0AmWGQUTDYEi9zx7L984jStMiIDIR/UfXQ1IK1elA/BEYB8qTp1eRptodchXAC0gHk+RUmWyw3tdefPGvbPvsLU4pcwv2v2tW2R0xmTfC4NitMGHBuSP0xj4ywnJ9WrjzDlc5d/idUm1m2+ZcjfqHACUilwdDpuDKVWG5zz/F74o2x0JKXgb4kr2kJTsje1GnlU1IAGSUBYekA38uHY7ToeRQNv+MCbaHoa3hNBQFvTaBDP448etOK8snKfAxJHvpvwNLvPAOhjZ5ZSqDdueKZ62tVkP3vZDrS18qi0ANqHEq2bRiXpjROeA4LVa+U/aI0EkGpw7hv2BrAskcMrQgo+VGPQJ78ITz9YP475NUaJ8qMxfMTGouUn3Vl1sg9D85/oYY316saL0ir5jme1lXTyYKObvaKZ4raElut9uUsuRW+TjE250sDU7eZ2TlmSBP4JU0y9xqgO26BaFYQ5fPBZr1MCX4COpX4n0Sc66Pm/SU0Dp34NLfOd156 ySzxu4cF yGn/WJgiXIsOL1lQsJeFf5kZgGaUKlcztFXoVdm46i0XCjnS9v0MEryEJfPwG+pIrnBqh8i48FwzPoQfXh3LthrvHLdt34srmXJGThOpb7R5omSAb6jeDb2DQyKvaL2S2TX2HtEBkbJfoBG4jYvK4v86prp8G0IGD3xKFu7Yw4NuImlguFjthyzrDv3NBWggj2YamXNGjDM/6pb6uYQnLzrpfzhjJEYvSKKpNB4Cg/ht/2pztgMd/FxqQKpRFqn1KQdfwpnJfXOT+vx0AEfH9eAuOLN2bLaX+bXr0I+r3yCq/a6304hYatAWOA6mQN80xAvHTKS0pe1CMtRcZTIY4wERs8c2NjZXu/v4SJsJOBtaSBdI3RC4XQHPdmsG4T/Vwz8VRvTpusQo3S2okkJaRNacm2ir11pVTCm7RwgJypIqOrcYpjQY0R8ER0u6R4Q/rGogx4zTnP3VmupV9jbQ3/ihPcLhyMHvgdNAa5s4RKQR+w86l3t2+dIGvqIprmiQvkJ9Tm/dK8LoKiw/7a0Y+1HAD1hmhqONKbIImV5llhasKA4Y8oLdNJSxdwOrmz/yRX77WUdYI2y1tksTuYW5QC3RK3Q== 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 ae9d16124f45..ea8cac447e04 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,20 +591,27 @@ 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)) { - if (isolate_hugetlb(page_folio(page), qp->pagelist) && + (flags & MPOL_MF_MOVE && folio_estimated_mapcount(folio) == 1)) { + 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 folios * which have been queued. */ ret = 1; @@ -702,7 +709,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 Tue Jan 24 01:22:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13113246 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 52E8DC25B50 for ; Tue, 24 Jan 2023 01:22:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 637D96B007B; Mon, 23 Jan 2023 20:22:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 599D86B007D; Mon, 23 Jan 2023 20:22:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4122D6B007E; Mon, 23 Jan 2023 20:22:22 -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 2DA086B007B for ; Mon, 23 Jan 2023 20:22:22 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id EAFBA1C5EF1 for ; Tue, 24 Jan 2023 01:22:21 +0000 (UTC) X-FDA: 80387942082.22.A4DDC14 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by imf08.hostedemail.com (Postfix) with ESMTP id 315C816000A for ; Tue, 24 Jan 2023 01:22:19 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="ZP/5bObP"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.51 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=1674523340; 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=nE+3UuHIJTsmxu1JqArGmSE4JP62IBIElITMZZ15/p0=; b=u2K0b6OXimoYx7XFbk3Zc7Fi8UI+rHcdQrUQ8JIV6kePa0DvfGfate2PHcdNWwcZNPGe3T yMet+gJ3K0k2RWeaiF1BcP2fLFTNYfUciGPC1NgoysRLcJxt1meEf8+Qy+5pyy1LPyy+io fGQvAbDnYgmK1rA8t7+8GUYpETxAJhY= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="ZP/5bObP"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674523340; a=rsa-sha256; cv=none; b=rZJRS6/5FzT9gHTp5AjHgg6ILf60ShOkG6SRF9f3Eq9PoVDjfC6YhMNc+/CwIDDC3HaV4v HaeOaREfGu1TOgHnXpudzH/dM/sp+1HgCvX1aR4g4qBNXqik9l+6yoUVlvy86YfCCT4bBp TC6p4FGTkhtoB6JXLEjXYqMYR9206eE= Received: by mail-pj1-f51.google.com with SMTP id k10-20020a17090a590a00b0022ba875a1a4so10007389pji.3 for ; Mon, 23 Jan 2023 17:22: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=nE+3UuHIJTsmxu1JqArGmSE4JP62IBIElITMZZ15/p0=; b=ZP/5bObP5pqsvaY9t0h8rIoT9dI9iJBk3mx62rI2nojE2rF17RJDpgzpAJ838bLs/U 6kRuTVVhRzVrpXQBJQ78n2+00oBc8IN+Qr4UmE90EnJV14gUU4AKy9lGkW4u4LtenMm7 nNmyb7o9J1AjOT0Yzvb5W29TbD6D52DH1LSYkfBlcnUV7VBOl5yKEIAG1RBVMFbc663g RLNNMG4tMyd0Qw6zqvgCGsrHo0cHg2hi/rBgbW25Jg1UoelSwenfNsqRSAJzZSPNwYsY HOZe0gaG/lQCzN42ApROK0PrZ8T/HL5yRfeRvFK0HwVF97BGf3YOY1mK9uyGsG2s0OVf zR2g== 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=nE+3UuHIJTsmxu1JqArGmSE4JP62IBIElITMZZ15/p0=; b=fmnTZbxdcPHb+gy3IX4W6VqungdpVBHeyolMNkLsy7xUmRkAlxMKtinYlUl20oqh0B +IQQfd3apzBD+jcg9kQHwN6dtmpUXupIgTPV2GzQrh8x6aAsDKnYRbk3eYYVHW2e0LPG MIm33i5CL6e4Q8H2mxAOPXRYNvRursbBTfvs6GrN5ltfZ8Ej1NxAQhti70ehsTojLhRu aKvzsAy4hvnkzNpUJaPp1MH6eQXsh1YDWykR6FmN+7COFzuIY5mozW+9zlag8/1KIC/S +vPM8O1nCww0bJRY3bJSOcU8yNa2eXiwpsIHUAnBYg3fFf81e03TMGfhi4GlwLjiDzbj 0F3g== X-Gm-Message-State: AFqh2kr2j2tccYpylGjIqtoth760ohdiLEYX1r2YHXD/h7dlyEZVwDI8 LER3GrAmzwj6z4BMldUIFYFalwtfQXI= X-Google-Smtp-Source: AMrXdXs0B1T1RoQ7VAB/8nsyU5key1ZZZZtdA3fPrHEjotnA1Vx130RbBWsgiLsAjdttNXdx7IZk6Q== X-Received: by 2002:a05:6a20:4407:b0:b8:66f6:6263 with SMTP id ce7-20020a056a20440700b000b866f66263mr38103651pzb.23.1674523338995; Mon, 23 Jan 2023 17:22:18 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::4e4b]) by smtp.googlemail.com with ESMTPSA id 68-20020a620547000000b005825b8e0540sm213335pff.204.2023.01.23.17.22.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 17:22:18 -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 v2 5/6] mm/mempolicy: Convert queue_pages_required() to queue_folio_required() Date: Mon, 23 Jan 2023 17:22:09 -0800 Message-Id: <20230124012210.13963-6-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230124012210.13963-1-vishal.moola@gmail.com> References: <20230124012210.13963-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 315C816000A X-Stat-Signature: 3ujnq636rjf9rpjzn9syahr8aurdr8xz X-HE-Tag: 1674523339-317192 X-HE-Meta: U2FsdGVkX1/dvYNV59ZiM7p5v/k4AeCKW3ja5URn+DQZTXJlFT45vYmab+xMczsfvtyyzFgRjZtKA3UEvL9jHFJx0GmWUKyttRi7vNMZc7p580miQ5KP/RA8Ia6Faf95bZqELRAJC60zVG42GPjmNItj2gRg8dnGWlhbLn89Qt4wsJv38m2zZHNgTxT6CPAOm9FV1O/XQqi+Joqd3BTfm26dzrinqecM46uJTnUQ1rsmxQt0mux7sHseSheka/OpIOPEFhUiEQi7UKaMOgkzKGZ3cdEDwSw3rfFCR+eGQK4uQ1si0tfcHlOBoaeoRSry6Oce4Ra+hl4uZktH8DM6pW5F8jFxaD8vwH44s6UfkXM4if0GDbjd9USShiY+TF09cSDIGwi7DAyYvPJjLIXyaK2uT+LNnjGEeff1uYV7kAXonfBDgSe0VdQeSUVrSecEGUsp+tyX5P1BewHeNlT0mONPsuqlfNXz0tKlb+Zg+IKQC+EH5hUOZIYF941BY2y9uW2E9/s2we0pIEemAfW3dr6mq+MGJm2kalDdCfAUJqukWnjiDBf83y1aSNMYk8kF5kXBuGDPcPcMJ/XsdIV3ZZcDouYWCZXrYYmj6R7oFx4g4Lw6o+Lcuw2Xq0rV8gadMrzXMJ0fMFMQAjQJX8AiS6i3kInJJ67KpB00lk9wm9KGdcIsTxrHTX+XAIG8/a6oYDN1LK0OfGjwDgF0Geluc4ONbZRqOwVnKEeulZpL6/StMqgtsUDXxFvxDCBGr/60ynMdsM8o95/1R74BD+z2cRF1GlDiyhEKNVDoSojnWKXMogxe9m/vSY2Xo+im8loLESNMmx/OM8L6pi/I3DduwXUOOIgaAwzEJQYYC6Dpz3DMqeQNnB6ysuYCtW/QwdNZri1E4Jbptm5Pj/Uudd5fztNHhT3o6gpduYhpMUbDHfsi58zyGDWjHTqCpsS5Nk2q0HeLnYS1P8e1i7qN5G0 RVkKMKbX /4llrXoQGb3QOscHEgw5vO+m5Z/MtCCOjbxpxfD1glDv/8qu3qQCtZ8M9mR4zvGFGhhWlM9M2rPw4oSA/M2nV4+ABbtqN/pOJYW38KAvsgUa0tt/hF5Sj25dX5WcCO88CVNDGkg616H+8OAbx/GqqWf/T4YcfEjPq7VJeCqmo2eUa73zRvh6unz0sV5/ZIE7T6B+jfu3q1e43y/kq9yobZcHiOe9gMMDZwTc8YNuZjrTXZPKjp4ceN/Z6RCnMsPf1qYHPmRz2bdAEzlDnR0gGi7Rg0x3MrGPc+Z9wEuaTPDKJSDC56gTPfUIMawlyBCvnX9Z/FbEk/CEXFcywKy2sowUc+MXOTGqu1PWJZYECOIQhrGd7zG+WsRXn6j2nLdJ2DLgElvX29otxZ45UYaPk34SAf6R1NxkbLsOq/nDq97iyVHR9wqDf9FfLiXpOKIJarM9ZcphXDplCZICpFRl3gM2zxizcWwDa/Jpr13W2sZ9VhCentRUEKTjwoNXoQako2uE+PHvHfqzQNxf8Ur/4bNk6V9VeQi5tO7Sh6WdArH2uAuV7OzsZ9Vrd1Tv4UG3BGQ9ufNHI/8cVtC2wOALObfNjRA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000071, 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 ea8cac447e04..da87644430e3 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 Tue Jan 24 01:22:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13113247 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 8DAC5C05027 for ; Tue, 24 Jan 2023 01:22:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 611576B007D; Mon, 23 Jan 2023 20:22:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C0F26B007E; Mon, 23 Jan 2023 20:22:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3509B6B0080; Mon, 23 Jan 2023 20:22:23 -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 141BA6B007D for ; Mon, 23 Jan 2023 20:22:23 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E0FF7160999 for ; Tue, 24 Jan 2023 01:22:22 +0000 (UTC) X-FDA: 80387942124.20.75D0A58 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by imf03.hostedemail.com (Postfix) with ESMTP id 233192000D for ; Tue, 24 Jan 2023 01:22:20 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="C/U/++SQ"; spf=pass (imf03.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.180 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=1674523341; 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=aN57XfC0N2Z9PnMQ9nUjXYfVmJE2FGzydu2ZVvrzX3Q=; b=Y5y7ARii5ZZcFD8f7naajmSB6jYYWFV79HpZd90mg3IJEm6Y1g2m0fX3wNYpKT5/yqPoUc IpGcUqo2yw993eus1sRrtXg1eo3QptpH/FgzWfTt4eNBhsS0qPMlxXwh2U/NiBPnlLaL/Q 79JQB+3Y0SGTzO8bPmyFgEgp89WzOJs= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="C/U/++SQ"; spf=pass (imf03.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.180 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=1674523341; a=rsa-sha256; cv=none; b=x3gfT03sM2cfLCMCaejF+6/gfRiCP/e5BBH/KJ4sknYmiZXFRVKQPDETHQMs66LqZ8Ao7s atqp4ZmSes1E3O2HcuuEp6NxEPwK7WnqwO8ZYCh4bJSlwQmnEanXUo0yzCPVF2nVJhs3rs Bx5fopqCvFl//XuePvCavW7IEs64i+g= Received: by mail-pg1-f180.google.com with SMTP id v3so10351537pgh.4 for ; Mon, 23 Jan 2023 17:22:20 -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=aN57XfC0N2Z9PnMQ9nUjXYfVmJE2FGzydu2ZVvrzX3Q=; b=C/U/++SQ2raDEJiXZtLwp/aQPJIL2snP32r34/JamWV0YT5a5TsRoxvkNwbqlG+WDL Ps9wGzMk2fiKNQXMr2OEKdhMvvQfUMMtwtVHTbBPYYhV8nQcLx8qaQELNcPzo8v7Ttmf VmKiBt4Qr55YGjL0lwWS3LlD/Buk97PMiEpFshtmKPPbhX+1xEZd87JnVl7KpInH2k5c R2I/J6j7A0NCijafjBjis/f0LP6dYdH2w6/hgAka5LvRlZ5Tg5e//B6nTlGW6Z+W2fGt UmVFycoXRWSqB05rk6sYjNnEASAC57l7Sc6+Gmba8spUW3oIL05EE51CkXLabKhrLqo4 V3iA== 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=aN57XfC0N2Z9PnMQ9nUjXYfVmJE2FGzydu2ZVvrzX3Q=; b=qGKtMBk1cS6zNJbmQlcDgmbSrbSAYmcJtsvn6R0YzpZdA1uSFj3nZ9QN2N+AE/33lY O9fuEOPIiAbnhMsJiD2CwZkrmN3yn6jwnLguBlBDiUsBECKq2W/dKjVJggpUzWGOSFbM 5NAlxb1TMb3lgBpS4i7JE+UjqY089yFJVjyZzrV3OgUwCV3dZrGM3TZrHjdvRQSgciSG 5pY6/GEETwog/wUDaVhf5pja+6iDpaR31zrjg0UA8E6LDj2Ks/BLnQvSfbF0TDE3nkgU du9DkjhPo2TWltMA/hZGMBOpUI3I+Ww7y+KX6AaQsDIf8Th5cSGQNSa0iigKCgW7xU7p hvYA== X-Gm-Message-State: AFqh2kpDsrJSNgYjN4qdS3wqzHdtKwLWhLDRFEnA5WmycfSHAJ4TD4p3 nf2i/CJHeSaMmsyNFcnJ7FJTkvZOjCk= X-Google-Smtp-Source: AMrXdXsUcKBht35TPhoeIdubPl8bcQOBoTQINC0wEB8tAeEYBIKQ/4JjGSme0DY/zIDwqcq5kn6xZw== X-Received: by 2002:a05:6a00:2986:b0:58c:8bdd:2e3c with SMTP id cj6-20020a056a00298600b0058c8bdd2e3cmr28301423pfb.20.1674523339887; Mon, 23 Jan 2023 17:22:19 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::4e4b]) by smtp.googlemail.com with ESMTPSA id 68-20020a620547000000b005825b8e0540sm213335pff.204.2023.01.23.17.22.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 17:22:19 -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 v2 6/6] mm/mempolicy: Convert migrate_page_add() to migrate_folio_add() Date: Mon, 23 Jan 2023 17:22:10 -0800 Message-Id: <20230124012210.13963-7-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230124012210.13963-1-vishal.moola@gmail.com> References: <20230124012210.13963-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Stat-Signature: du4k7eg5cukbra7zf6pptam4c38ojape X-Rspam-User: X-Rspamd-Queue-Id: 233192000D X-Rspamd-Server: rspam06 X-HE-Tag: 1674523340-126497 X-HE-Meta: U2FsdGVkX18m7lpmhpToTWBt+VJIgjvZJf8BSOV/NK0vfXyAxpPEF6sXM0kogOIkDk5KhZ+m1dv6aD0cseaz3yUGuvQmfF6Xljpk8YcYfmBh4c31BMVC9V5SjmGoso7rGYX4NCLuliOXfQqQbmu+bMFS1tvoOOJiPtxRv2sV7o88WuFcMrHH9Ayy7DQNj+eHOQu0lEpJ0yXQzBz1H1ayDjVSL2UAB0b2EgRmEcGNJS22LD/chcGrFTbXA0BIfW8ml5rWkatK7+w935rFtvnz0j6oRMwfBFf6my6lZFuv26W5pvdpb72bvpNjW+fU2/QkOkSE7XVEpe3OQ2G3x6rVDTVBt1C+jN4s4GvV19HLxcJL+FXE8pOSSheAGJHm7X6b/pSGGZ7an1HCaB/GvLHpPz9UwGzdPk63OEQpMEZE/4Qd1/lDZ0V7y3a1wMNiZuZa+N3g0R1NKRNubjZ5RuHZsB7bnMxDI6nrdDzEOT6TVGYmg0ijEwp/wEdDQ0z5by6E1QXQvb/Ypt6yBt1Vck1CpQkvsMk0994QYhspedf0s2Pv5RaEpseWi52Ld15CXvZT87ud/RGX190oDayXx5YIaJRbH6q3oE6uySmT86BE6Y2YGpBZFkyHr0m71wjSRg/6FJsHWhV8+QbRFHlAb+auRFl67WWkOQcwjg1zbcN+3s7X8saUggZcRzU4JnIYoZLTSZeHoIvo3Hc1TOci1O4trjq2iREJ9EmA2J0buDK+dtTuG4I37PjIg0GFu0e9zW5ZMrgUtV0M03Bhmul0MmRDSh4lFrlBVi1/jjVPqqZskQ6N2yVuH0d+fjQY6NhW3M5L1pzLiF+GZY5a041CsHw1ysoDgpmY1fRqGuKc60BAKsabZuJlyGNuf4oq/VjEIXDDgHvkH0FNK8sWf1AYCbiaECICgrwP1n61AcZYyA5hGLse5PZT7GPaSfRx3mqpvrFexB3ULDoConE30GKXKFe p9Dhfuvo gHL6Dhl03CVW+mgMWTYNhJ2oxvRBnz27t1vm4g9Ew1EM/ZmivsVC2KAanWsSxheAJ8SCfb8NRrcrq52cV2LVK2dnnZXfXzl/Nst6DhbsZAoAwoZ61WfdnTplr+CKKvnnRmVj/3aaaeHjQNN5VpDd7UXT7djgPCLS+z5UbO1WDpWwBK7i4QaOhvSPuZzEul6hp1UfvOt8xrABsrEYfUNq81XBDQ5Ft3jrYX6f+JsgRqd1P2iKePtdhsoOgKeMM+2ql5QaaFOf9oGe9o62WAnKWFL5YcvxOUMKD05bnxU/4PUDidVPAh/agcCiMmFXhR8QPgaPolVyFjmO+T/Tr1abUaZI5Ce1F50mDpTiIIgrc+gPxtWAsvVe7SaE5MJHy+nUh9wXDbd8deZa3EieYgu8o6UJ2ui/3xli02tWb0yVBYBN4J73z/1Eh5OvJn0zloGJzzgvZcDwbkCwg8Q6yVZ1HkS7XigQuDRVppWiicHQ+If4EksWBsjaV5Pdg7ZkMPO1qXueUwzn0fpRSYa10pKSCzy85/uvfx25xsIDyYmzUgodzdtGmhE+/UOUl5NNGbv49+WtQRkVfLGUxxz+ykX+mKQhwhw== 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) --- mm/mempolicy.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index da87644430e3..9bb4600c4294 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; @@ -1029,27 +1029,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_mapcount(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. */ @@ -1241,7 +1242,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;