Message ID | 20231020183331.10770-4-vishal.moola@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp1250824vqb; Fri, 20 Oct 2023 11:33:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHBMkgVcKSWha1icrQbNFhJzPzqex1uRl3FEdrqCntjqyASsLeYfTy6meuvqxdmrAg5dyAx X-Received: by 2002:a17:903:84d:b0:1c5:ea60:85c1 with SMTP id ks13-20020a170903084d00b001c5ea6085c1mr2336700plb.12.1697826838745; Fri, 20 Oct 2023 11:33:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697826838; cv=none; d=google.com; s=arc-20160816; b=io/Y/fVA4EEpVLk6kDWL3dFCAc49UjCUMMM1oWKE8L5q4zTrboktY6tyHrYHLlQmno lgADYRPNBdJc4hkTQ+4C628qmczoYjjJwA/d0Uq8HOn9hNdRefoJ30e2e6K2MlTY/Q6e YX1Ce+vhIrkwgQdLZdrMZ/0l96tSf0EWd6TyYER1to3HH66Bg+1gTgUJTO2voK/lyNP5 OVP14gf0AySFY8yXELLbtVZ0LKA4/muXeE3BBKqBGArU1wJsGPZnnyxAjIUvmi7ykwKT nhO2729fIRlJ7iZPdbqwwMDiBo/OjkH4BYL2CTJ+ZFcYktJ9K2jDxHZsdYeVA8zaYqcg KXUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Q/rAUjlYbudj5wnw8lHkufWutUwYDRgsClPJWjawwgo=; fh=7/CAuSL69czuKxmprrQ2LqZp7RdmRmfdoO9Rvi8OHzQ=; b=mCS5dbKLbg8OkaoYvYLhB6jl+zwJID8Np2mW2pRulB0z6UkNb81XRhfnQLNjvwKWwR ebPncbBVZeAv9lRanasjYrxtBgsM44x9H56BTxWE6JOHSXMsVqzq++IlKm3C5nkgA7/K kU8HBBbIXHDYf/ZJRmYhnBM9x5Epj4g1GOZMt3nOklZbZ/TSni6bvrNcKOkABMYqVEsP n/tRP957QKKkfX3N0CSzCbRrovfNtGksnchPnwXtFa/OSy+jImvgCFHJQLOHX1UpYOce Y6WR8Mea3/71nrlx/WNDlJMY4qDFt60As6Ru1ukQI2soNTH7SPHrVA81P10sBYshMs7z 3dJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VH+0CnjM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id j12-20020a170903024c00b001c72c893ac9si2492957plh.104.2023.10.20.11.33.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 11:33:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VH+0CnjM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 9788E8315541; Fri, 20 Oct 2023 11:33:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229787AbjJTSdw (ORCPT <rfc822;a1648639935@gmail.com> + 26 others); Fri, 20 Oct 2023 14:33:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbjJTSds (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 20 Oct 2023 14:33:48 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CEFA1A8 for <linux-kernel@vger.kernel.org>; Fri, 20 Oct 2023 11:33:46 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-6b5cac99cfdso1054410b3a.2 for <linux-kernel@vger.kernel.org>; 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=vger.kernel.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=VH+0CnjMk9UQe/XogDr4e3WlaCk4NdyH46es8n3wMSx1EKeVd1oygRkYQV1ou956FI PSjOBcNMMYmIIIJIg1gNFUIlUxK1Mr5/drJnX2c+he51Fy0nZXajkRwpKSYuO6kIAWdG o3lihQaC7FRsnPtmCMf0sXUyxn1mfPbByh450gEqi7SuAXsRt1OxFEpZAfh6ZbYbNldS O//lADm9/p2bAtqRo/0J5eZTyaIT1asGObyvR7Wi/U4tvFP6poDs3PePyrE0qXagmPtm LS2VJRqa5k7S/udB61F/KY2ljLhHubwzDXh/W0BG0JszY+xDp0yPM3fc1WDlbj4e8dgk WnRA== 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=M+wN21SnBMo2Wi//noFdAa6m4uRC0lkbVwVIkQRQ2zlekN8JQKPeBLqSgBFyQ1ecev VxtfJVjz+kc729qFnuSlDl3fHIKh3RZMZLPRBu2u1Zml14pCYU3uP7sSE6m5WReayWKw hp+bNzeSzegmkeOP/XuqCOr+wS0Ex2V2VLYx9ankpAj7s/she1toVN3lLSarHuLaaFaM aTU9neCa5h1tdF5KobUYCDFJAwEyO8cWn+guK3oWtJLSecTyfX3/y+9m1npxVJuc/c/T y5Ug4Z0f6jiWOmbwuoYFDcng85RUjEW9L4OJEPHtEtLmsX08HHnhlLAjMcO7bALn2pk8 HW6Q== X-Gm-Message-State: AOJu0YyqAGBOAmWT5fYiKtp2KZ5pLghXiwSjIn9jwXO0iavHiPg2GlIb 0hTW1WHviSixs9HJ6XVg6WcxJvlaqpA= 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)" <vishal.moola@gmail.com> To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, "Vishal Moola (Oracle)" <vishal.moola@gmail.com> 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 20 Oct 2023 11:33:57 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780300475485931849 X-GMAIL-MSGID: 1780300475485931849 |
Series |
Some khugepaged folio conversions
|
|
Commit Message
Vishal Moola
Oct. 20, 2023, 6:33 p.m. UTC
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) <vishal.moola@gmail.com>
---
mm/khugepaged.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
Comments
On 20.10.23 20:33, Vishal Moola (Oracle) wrote: > 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) <vishal.moola@gmail.com> > --- > 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; > } Reviewed-by: David Hildenbrand <david@redhat.com>
On Fri, Oct 20, 2023 at 11:34 AM Vishal Moola (Oracle) <vishal.moola@gmail.com> wrote: > > 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) <vishal.moola@gmail.com> Reviewed-by: Yang Shi <shy828301@gmail.com> > --- > 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; > } > -- > 2.40.1 > >
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; }