From patchwork Fri Oct 20 18:33: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: 13431019 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 29D50C001DF for ; Fri, 20 Oct 2023 18:33:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 80BCE800BC; Fri, 20 Oct 2023 14:33:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7BCA980044; Fri, 20 Oct 2023 14:33:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68502800BC; Fri, 20 Oct 2023 14:33:49 -0400 (EDT) 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 56EBC80044 for ; Fri, 20 Oct 2023 14:33:49 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1DFB51A0673 for ; Fri, 20 Oct 2023 18:33:49 +0000 (UTC) X-FDA: 81366688578.24.52C35A6 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by imf17.hostedemail.com (Postfix) with ESMTP id 4329240003 for ; Fri, 20 Oct 2023 18:33:47 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=WBYSAKp5; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.169 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=1697826827; 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=Q/rAUjlYbudj5wnw8lHkufWutUwYDRgsClPJWjawwgo=; b=SAT6LzmdehaZiR4tKk4RqPO16D+GmKhlHwXjktt6p2wh//Y4j1CbUKCBIToS+AVDC983jK o9BaYDiniZXTbHIqsfur+rO/OfN6XcOKyVFILb/lGv7tvw3t4Y14i2LvZTeR0WgxsClNzv VDaaJn1jQVmow10oG2s8NiLkfF+xvMA= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=WBYSAKp5; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697826827; a=rsa-sha256; cv=none; b=zCTMkwPko0ge9p5I8Gkq+Pa38P5dd7gbBO04ID33Jmb+VxwZLVZzg3o8sM3OT5EFAj66iK tKMaSQG3BHwVXMem0T9gHtySr8/haWPOTG+r4pF76pEhyiUIt967s56dftCm0eEbzEn22g 0XuR9oLnKyIqcNe7wqBi0ftWp984++0= Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6b3c2607d9bso1064084b3a.1 for ; Fri, 20 Oct 2023 11:33:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697826826; x=1698431626; darn=kvack.org; 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=Q/rAUjlYbudj5wnw8lHkufWutUwYDRgsClPJWjawwgo=; b=WBYSAKp5e0k5+sJ82wqzPxPiUv9i622raqy7L/ddlGSrE7TWAeC+Dfz90dXzCohzNr ImWe+bBUpNrSna198oVSlAcpqwm/wQ8AmmwVe94jA3fiDeyZWGY2kzD2uCm3PKUO2va/ /R38fl0NwMIDfZHFBJZO6Y/n1P5bTrYMbEOatlUt9MsFF41/YAHzI0M7hJ8P66v1GIwd yWnknbnUwhK6lRaRspDEIitC7ixru5itquExk758kcZiC9saQxvrQ9doEAmXe/QcD8b4 a5k1ivoR+GZPXJIBfsGk7aR9WM042KObfVRPuSLcFL9emAZgpdnIyRKD9OW0uBUEU8VH 56zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697826826; x=1698431626; 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=Q/rAUjlYbudj5wnw8lHkufWutUwYDRgsClPJWjawwgo=; b=bbCIdiwITkDwtA7/G1npIio7aKGXxId/qiWuYvTJe+yQvKoENS3sbOAQXbA7pkwOTQ Ursj1YxNRnsgRgmIJut5v0VQunvVLcXp7IOC0WHI2dRqt4NwAnYV5gqmK6LlPTHKJPi9 c+KUCh2lGKWfg6ih8MjYBI1e3KiFQwRhXR7Vn51I3dZDDteucfFSO/La8LuiRevQGfnA jmIeWyBMPMtByxCL/LA2pUNqZyDIH6stg1spYpBuZZSkBmkPzK8Df0q6vo8A6L8FZLkj UZecGFjXGKygD8YxR4RAX7b9ST+q4CN26AFlHSJdkJpMfInbTvs7LrakqL+5aeygT0Z/ E9Og== X-Gm-Message-State: AOJu0Yzz/sgWMiNaaT7QCPv6Rtsh8dL98gwK9ENXx/I6qgE7W6B8kONz jTUe3+XFfdSTuBe2FhzigwByYb+JO/Y= X-Google-Smtp-Source: AGHT+IHyGeFVYpw0wd/VaSvhNfJGFkjxPCXQo0amteeNn2H2xRJuWdIEmOzTNv8bZATyXXNSf6XFFg== X-Received: by 2002:a05:6a00:2341:b0:6b3:2106:94b0 with SMTP id j1-20020a056a00234100b006b3210694b0mr2956504pfj.23.1697826825800; Fri, 20 Oct 2023 11:33:45 -0700 (PDT) Received: from fedora.. (c-73-170-51-167.hsd1.ca.comcast.net. [73.170.51.167]) by smtp.googlemail.com with ESMTPSA id z14-20020aa7990e000000b006b4ac8885b4sm1911345pff.14.2023.10.20.11.33.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 11:33:45 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, "Vishal Moola (Oracle)" Subject: [PATCH v3 3/5] mm/khugepaged: Convert is_refcount_suitable() to use folios Date: Fri, 20 Oct 2023 11:33:29 -0700 Message-Id: <20231020183331.10770-4-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231020183331.10770-1-vishal.moola@gmail.com> References: <20231020183331.10770-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 4329240003 X-Stat-Signature: 393g1pcawy8kww3onfz1t3umbsi96fxb X-HE-Tag: 1697826827-942734 X-HE-Meta: U2FsdGVkX1+Rb1UM+N0WNipJa3am+RumF0bI18xNqq4jlJyyZs8xaM7LoXPR1ffJoG9qsb9Eonoyceld3kSJD/wNWd3aSmgYIw3v0nR/8uBaqpAy9qz2/FAl6Nii8kvHWBApvb/QIOvFduG4T5lmnNSoWoOP007vcbSztGPEjHfnd18tfVrmO2w4X/lUXfjti0+SBlyh3gjDv1F2zh60fjx4AW8/NX0+Od5Nur618iPkhLeDWq0cecBtI8+DHsbIDTXYpBMm5IZsR6qUbqsr58LWtMl97BhxtdcRogDI/pVWcT8AOUQceaS/2t9hVjRZh1452agu6CpBR+vg1sdsu4zWdwmQkIbwYFxCOw1eMPD+TuWcZCV1iLvR1e2bPB0bWh20QN6Y2jb/YSwPwd54yCbAFctumgT+PwJ68j1X7CsXYZzKUtxKsSn4JUl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9b4j58gf7JT79POMGLuUcXpGhQHOV8YwagIcJkguzaqmr1ybpYXiNseuOXzoboZ1IJJcvg== 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: Both callers of is_refcount_suitable() have been converted to use folios, so convert it to take in a folio. Both callers only operate on head pages of folios so mapcount/refcount conversions here are trivial. Removes 3 calls to compound head, and removes 315 bytes of kernel text. Signed-off-by: Vishal Moola (Oracle) Reviewed-by: David Hildenbrand Reviewed-by: Yang Shi --- mm/khugepaged.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 6c4b5af43371..9efd8ff68f06 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -524,15 +524,15 @@ static void release_pte_pages(pte_t *pte, pte_t *_pte, } } -static bool is_refcount_suitable(struct page *page) +static bool is_refcount_suitable(struct folio *folio) { int expected_refcount; - expected_refcount = total_mapcount(page); - if (PageSwapCache(page)) - expected_refcount += compound_nr(page); + expected_refcount = folio_mapcount(folio); + if (folio_test_swapcache(folio)) + expected_refcount += folio_nr_pages(folio); - return page_count(page) == expected_refcount; + return folio_ref_count(folio) == expected_refcount; } static int __collapse_huge_page_isolate(struct vm_area_struct *vma, @@ -625,7 +625,7 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma, * but not from this process. The other process cannot write to * the page, only trigger CoW. */ - if (!is_refcount_suitable(&folio->page)) { + if (!is_refcount_suitable(folio)) { folio_unlock(folio); result = SCAN_PAGE_COUNT; goto out; @@ -1371,7 +1371,7 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm, * has excessive GUP pins (i.e. 512). Anyway the same check * will be done again later the risk seems low. */ - if (!is_refcount_suitable(&folio->page)) { + if (!is_refcount_suitable(folio)) { result = SCAN_PAGE_COUNT; goto out_unmap; }