Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2732525rdg; Mon, 16 Oct 2023 13:07:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/IS0i8VHtqrn0a31GnYd4iKobWnORMH8/9KqiqC6IJxdwdOTBJ05/ik2lSRG7bbS66H3f X-Received: by 2002:a17:90a:f007:b0:27d:114e:d4a3 with SMTP id bt7-20020a17090af00700b0027d114ed4a3mr167953pjb.14.1697486851748; Mon, 16 Oct 2023 13:07:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697486851; cv=none; d=google.com; s=arc-20160816; b=jpkMF+qDmLGG3BGqg84nofQSJ1+gqWcDMyjkdNt6g+r12ZQWcKx4qQfJUWBZoGdzg9 Dwi0zEIZUv09OYT+o2AoKlBaomh2GKY6AfAiq7I6w9x+RfRoI6VYeq0j1BumQSiMFKc1 wmi6lphwVThZPBf6V4OR4u/E23spVqM5GEyidPx/HGSgtbpt7EkBL22onYdc3ZW74nqG cbSvPfIKZVI5pK2BOxUgdEazvchgU8Vfxh8UGqBCfyLoQ8rVXxpUjlKkFDsqPDqLj7y0 ko+xkfH6LMri4QdQKfYYkaV3mK4kA8S0kmisQuKKKxwZlNTPOp3lxG1I2xOw+0ZNNHFu uyKQ== 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=vjFYTTptetyjp2cWLw2h5u7A70TW4Bkl9MqEU9zvv1g=; fh=8QxY+O3ixhfYmsFkOjVWPUpalTwBFBIvZrV0f3Brsxg=; b=cuNlt+sKY+FkJIZ/yT0qm3oAUiaa50xdtidVDjnxbtocKTXa2NfEDfW3+W5hdfMIZ/ /uhRE/8V2/kTE/m+O8cCpHDTg9UM/nmwf/7ZbhjKjZryO3pAAWXdksSKNRNSM/FuGO1c rPyP5D2D1/JpYnrcvd7pW0U0EHrpEUDTYaEGb20NDfyQrGqB6nQ3VwIaa2Y0nWXNtjhT Q831LM0ExI1LKF3u+efDbMUOeVhf1gP3UHq7NYHO+mDSTpyFbSvlxO2yD4S0TzaK0QES i8PJ5i75uIbGHwzDOWCErbM9bx3bhWoF18tjhM3hnpBDLZ+kTgo1jUamzs/3bM9lDfUB enog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RAElPC84; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id 4-20020a630204000000b00578c3b7af9fsi71198pgc.184.2023.10.16.13.07.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 13:07:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RAElPC84; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 9525380B1BC7; Mon, 16 Oct 2023 13:07:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233685AbjJPUHE (ORCPT + 99 others); Mon, 16 Oct 2023 16:07:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231221AbjJPUHD (ORCPT ); Mon, 16 Oct 2023 16:07:03 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11E8D101 for ; Mon, 16 Oct 2023 13:06:59 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-27d1a03f540so3655732a91.1 for ; Mon, 16 Oct 2023 13:06:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697486818; x=1698091618; 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=vjFYTTptetyjp2cWLw2h5u7A70TW4Bkl9MqEU9zvv1g=; b=RAElPC84O1IzaJtthHCnuhBPzH6pbi9XT9ZC8lp8Az361wv/rfbfiLh6ftiE1Xv3lr VLXbibwaRidhp5PDxrHRvCs5t18/ZyS52BA2xhzx0Ki+wjjObjWydsI265Spyv51Whrv xxoPeZ55koA8ygP6n0zXX6DbXUYoUc2DH0kQ/5UIk/DhywmKaT6jL7/e/LwBtta5hHcK thasI3Cg9OBZsuRrfG4BN4bMlISO7kz1UtvND2Mu+2iOrZkWLs6InBM+Ua8fcjPYsm21 yq3g5B7oDs1OZDCTiN8mgN4xNUhjOTwyryhiYCKfGe5q7DV64yWHdzAPf25LHZtB0Vmv jL8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697486818; x=1698091618; 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=vjFYTTptetyjp2cWLw2h5u7A70TW4Bkl9MqEU9zvv1g=; b=kMqjt5uz1im3lnfwEcHk/8sY2HtE9VOU3slx9voqWU8SARG+pOhOYi/pEq6Nf8H1KS UXB7yxZtTAh99spLR/BOdAxBs7tiYMSpvIk5YCHlObyJlOhIBBQZ8mwIadW/Qc9btHqv YiCQDRpfVg0z0g5Iy1hDdjSCSjekMh3QsOd5E3V0VDb6969vqeNg7UVqFSenjKSu85fq rZOqc4/ZP+0pTOrtszlcgES/3iHhge7eoLBx0YjsD6ziQOtqnKEFB05NKbLj+D3weVxr rAQP1gNAuuLytGK9yaXTHYhchL7OzAVh6HaM4mD0aBJ30DV7HooAcTYRFi1OgsX6ug6W S61Q== X-Gm-Message-State: AOJu0Yyd5W5LCTz5YdNJShTGgHa8aJdGLEguXmqgdN61NWQ0bjsnRpQV RygkqOyP66QAKypC37KZsCvmJg9N2H4= X-Received: by 2002:a17:90a:eb09:b0:27c:fc09:401d with SMTP id j9-20020a17090aeb0900b0027cfc09401dmr179801pjz.38.1697486818298; Mon, 16 Oct 2023 13:06:58 -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 t16-20020a17090b019000b002772faee740sm5162367pjs.5.2023.10.16.13.06.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 13:06:58 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, shy828301@gmail.com, "Vishal Moola (Oracle)" Subject: [PATCH 3/5] mm/khugepaged: Convert is_refcount_suitable() to use folios Date: Mon, 16 Oct 2023 13:05:08 -0700 Message-Id: <20231016200510.7387-4-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231016200510.7387-1-vishal.moola@gmail.com> References: <20231016200510.7387-1-vishal.moola@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 16 Oct 2023 13:07:25 -0700 (PDT) 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) --- mm/khugepaged.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 67aac53b31c8..fa21a53ce0c0 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, @@ -623,7 +623,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; @@ -1367,7 +1367,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