From patchwork Thu Feb 29 15:29:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13577264 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 1D183C54E41 for ; Thu, 29 Feb 2024 15:30:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA5116B0081; Thu, 29 Feb 2024 10:30:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A548A6B0098; Thu, 29 Feb 2024 10:30:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 945326B0099; Thu, 29 Feb 2024 10:30:28 -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 859426B0081 for ; Thu, 29 Feb 2024 10:30:28 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3899C140402 for ; Thu, 29 Feb 2024 15:30:28 +0000 (UTC) X-FDA: 81845228136.20.3244A0E Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf20.hostedemail.com (Postfix) with ESMTP id 066E01C000E for ; Thu, 29 Feb 2024 15:30:25 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=cL8bTEsm; spf=none (imf20.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709220626; 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:references:dkim-signature; bh=bAKAkZk+qSIw1+iqewnd4x1oxxP5WogLoQn9URtGMBg=; b=wgfZLNqdmmmbJ8QqcWlqP2oVkCIDbFWnblQk75u7ATmrEfEUUIku835+j+vARECXNvsVNw s8ID5n7R+/4X4nI4kplW74+u9dlRRmzWMk1MT1x7mJX2baTDKaoRiIWyVyjcS7aWMQfY4P t0ol1Vk9K0n9M8/e2ZLKB0UsrlYKMRk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709220626; a=rsa-sha256; cv=none; b=dcbHaqcBdZA1+/NtMIVxUvy2aCrbvuLwFxubNAoms3EWxJcj+PTrZS/bY5eXKbwIXqoYVF PxAE06HN0VxKAxj8fVOiwF7qoAehwkskJ9FaLQqnzP3X8LzcMmSj7w/OEZo+jFNg2ZOV+P QIWs8w9m5UBMEku2rv+qbnR0HD8/rXE= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=cL8bTEsm; spf=none (imf20.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=bAKAkZk+qSIw1+iqewnd4x1oxxP5WogLoQn9URtGMBg=; b=cL8bTEsmDqhZ5rv+/yt8Adwb1F uIWlK3xR34MTSyS0HvmIAZ+knzARroDub1dw38LdgYpC/2mH6SL55dYSSqLxGWKdSVrKZdiYRH3/q K8+WQN23h6NWbrBSF/VX6x9a2wCu1k5hQtz7P6vosq2f5lXBZ8a2Hatu469MKwV2gWCtERIb82SW1 tnT3QuP0NGCG1VOXiQa54rqhIsfZICaQN9cgquFRDBOqCAGaGfUyTVcxQ23j+MJqONMjWQXcHHoCj WO6B7zI8OVSKvj1kx4Eq1ZwA9BAfLbqJ6QDIboO0Lnmo6yusaMO9UdHbI0s6m5pSaQD1fMm65MxT8 WHIfp+Ww==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfiMZ-00000008NbB-3oyh; Thu, 29 Feb 2024 15:30:24 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton , linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH] mm/mempolicy: Use a folio in do_mbind() Date: Thu, 29 Feb 2024 15:29:45 +0000 Message-ID: <20240229153015.1996829-1-willy@infradead.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Stat-Signature: 5b3cei43tcwacrhwn6sihzw5asruk687 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 066E01C000E X-Rspam-User: X-HE-Tag: 1709220625-664498 X-HE-Meta: U2FsdGVkX19s8deRLqW0e3+RYHA/JuqTisze2tnPMe6j6CFwP5Z1Vfm4o0OVpCLxtiiwbukJMPLGFRVqBICEaWjYhXuQGPV1mA7ctgfkPSntr/sMadW4YSMNPP1i8Q5wNV4PZnPloVqrvfjStnH1b3hmh2gvfyqWJGUy0iDzYot79hsjUQe0YEJJ5KXP5CQPlbobb1/ZN/aIkeeQNUaB3LcdtBcB/LHNRARaNfaLInSOSSI/+9GUOv4YTtGfjocnQUV3uZjdksNAQx/5gNFn0eN+/EiTpMpSy9BZq9RJBbvILkgGRwwZxA2UJcs2Jnv4QV4l/6dELlq5nv8q+fTowyft+vGRTggRL3uDO9me/iCt944xmrOZrLHPisZYCI6EJlIn9EUa8up1wJz8sKy9VhLZ876q+h+bozDMl2shbx3eI/pRFYlqS3iwOdo01GtCs0ntMZ9oy+XCyBd/iZmab7CffczXEtLNIW/ziF+4sa+notbCEeWJ7YHMFapxlK9Ub7WcRTLquMVjLzFGuasGzoLca60ACFN8yN0EAsGxCqmo/TNGC3gaqiQqMBerR1SaQrnWnhSAsNxEjOHVZxYKshl4pG+nfB43B8BRM8RW1D44sgx0MT0YX9MWBp0yBXUiozoShEXxuGrmtzwSYPsalyl9nJ46LPQKRLlQGVV2skqvUrZLe9OXKzaYIv8oZ+IE5D2+rCW0lWHE6mzhuuwW4pMvdVO8Ftsx49xBWlYssfm6vxO69IewTIyjOxT8ep9Ffs4cykatHTybNbgHzo5KFvLB+f8kLdBU5bP+pmDXRA3eRU8KEI0WBVWOINdvSA1/DA5b3RT+bhBNQP9vO8DWnECLDpAN4b8mwsWtej/i7DwX12ivMWZSZ/cyal0I+2JeFqqQQn2wxXblsDMEzfoUOEC+M7lgNghF 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: List-Subscribe: List-Unsubscribe: We actually add folios to the pagelist already, but then work with them as pages. Removes a call to compound_head() in PageKsm() and removes a reference to page->index. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Gregory Price --- mm/mempolicy.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index f60b4c99f130..adc036980713 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1356,29 +1356,30 @@ static long do_mbind(unsigned long start, unsigned long len, */ if (new->mode == MPOL_INTERLEAVE || new->mode == MPOL_WEIGHTED_INTERLEAVE) { - struct page *page; + struct folio *folio; unsigned int order; unsigned long addr = -EFAULT; - list_for_each_entry(page, &pagelist, lru) { - if (!PageKsm(page)) + list_for_each_entry(folio, &pagelist, lru) { + if (!folio_test_ksm(folio)) break; } - if (!list_entry_is_head(page, &pagelist, lru)) { + if (!list_entry_is_head(folio, &pagelist, lru)) { vma_iter_init(&vmi, mm, start); for_each_vma_range(vmi, vma, end) { - addr = page_address_in_vma(page, vma); + addr = page_address_in_vma( + folio_page(folio, 0), vma); if (addr != -EFAULT) break; } } if (addr != -EFAULT) { - order = compound_order(page); + order = folio_order(folio); /* We already know the pol, but not the ilx */ mpol_cond_put(get_vma_policy(vma, addr, order, &mmpol.ilx)); /* Set base from which to increment by index */ - mmpol.ilx -= page->index >> order; + mmpol.ilx -= folio->index >> order; } } }