From patchwork Sat Jan 14 00:15:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 43656 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp36984wrn; Fri, 13 Jan 2023 16:24:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXuniykUq8+R55AgYfWfM8f+oeUr3YQOBip/znF7UxfI8Trnd92gb51Rp3bkw3f5lvs3jkYC X-Received: by 2002:a17:902:c948:b0:188:a6ea:279f with SMTP id i8-20020a170902c94800b00188a6ea279fmr112109078pla.12.1673655888504; Fri, 13 Jan 2023 16:24:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673655888; cv=none; d=google.com; s=arc-20160816; b=VkC09E2MEyS+nLjZSD63KaYar4v6ta3/K1p11T6vUYWqSoudXVmc2q6mvdOc+b6rHt EJvsEkwfv+aYuoqvxzotqdTi1VOn5hCtJ6jFIg6mlxXE06VPwVJtILnloCB1BYRIobJi ZLW2qc7rUKdO+FeR3oLg+jU9tG46gaEETyg+P9kCVO/qBGIETJFsfuuW5k06/P3L2rUy KRZ0ygP0RYrvjTClY1885b1iEhUNYl6kjF3oYO3HfvY3F44m5LlnUYb+W+JutWsWtdga vsFdE4TyGjsxp2eXsmvYeBrduBM6/Iy82L1tcWqnzABVd+iu0IWQG6drRH5jvapJiwrW NIlg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=/KjcC4vdn0F8bwHPm7aH8/jU0gejjB6PredV8xmX1m8=; b=QcsTLTvjAL/iV8aYumlGsVmBWSiGtXsKLIDsMsCM3nAOsRlLjvgZCl0cNOt43aAYUI +k+m/VjR0njpD2jS8Ar0bdeNuW9Ov2hR4x8iuFjMiBRVWP1HZti6yY6YRc47GnV7VzDP ZSGHGsSq+S00tXkLMtRW+hb6LOEWpUU5RKprYuYmRlzh85r2ZRQ28tegPR1nqEC1MtuS I45vrTXsQVBd1X1hsqhVf/ZDucHBffITra962quCTz167LiOsUMPoCb3VA+EdYk5qxLy BgkYMdjYDWikS+MCuRKbiu8A/cVEdFa0zCDMhsdyKMO1a+SPvjyDN4wxHhlgaUF3xVsj aswQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=arrSrn4L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h6-20020a170902704600b00192ebe69b0bsi20381336plt.81.2023.01.13.16.24.08; Fri, 13 Jan 2023 16:24:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=arrSrn4L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229567AbjANAQe (ORCPT + 99 others); Fri, 13 Jan 2023 19:16:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231131AbjANAQb (ORCPT ); Fri, 13 Jan 2023 19:16:31 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2095026E6 for ; Fri, 13 Jan 2023 16:16:28 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id w3so25028574ply.3 for ; Fri, 13 Jan 2023 16:16:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/KjcC4vdn0F8bwHPm7aH8/jU0gejjB6PredV8xmX1m8=; b=arrSrn4L+VBsJd77YJD8ctZh/KRnLsYulABJcTjOdPsLbpnHB3YR44IYBDCjYNq1tG 3kqEV2HjQiFgS5hPnM8e8aawAgoxrBDhUsejPDYvPmE8paMVjPiOAbxZGVsipLE0ORKF umVciZnOpsYKRccyQtgnMCi3LYllnDGScc8QmsyFH71obCJGtIhWvmdObv73mUrf05Hv orHDT5xtJjnIXsb+3dGi+z5yDIIfVmP3t9zt7pW2CeaCwx9zRdG1ZKMGEYC2CaPxyzlY VClZOxqKTSbQdPwuVkHoXgR6QpWzTXUxyAUCATUb7wnkrZaPmHSz3BhyfLtutzOd8SDJ sH3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/KjcC4vdn0F8bwHPm7aH8/jU0gejjB6PredV8xmX1m8=; b=YFdUGAypNFkiIJ+gSmikxFR9CLUfE61+Slq4W3yTdD0ZIDzJyE+OrMt1Wn7/gNsTMc bLTDMuWgckrXxWB2Q+w9PNGDHQdMcPVjZbhayfGX2hDW4HltfnF+8Rdd/RMMmrSGOJ9k 6NEZ/evMao3zcRsHCwG5UyvQHbhfcnaD+iBy0nQG6cOpJsMLIz02O8jgLFDLdN/IpAeF uQLQS4CA3ImlDDMIsEFv+26op3wXM3+QY+N9Rok4mEJX6sZ8RoJRLl4I48bYTDHu6g+U oj7wEaSWEiRwspYXkcF1HNFQDYwNL1KwzNzdu7C1Dkt0kVu0NspDraxkiGUv2egKjwcq SZIw== X-Gm-Message-State: AFqh2kpSSKu7lJEoBsBX47ED1TgaIGXnuq2PztA1daHKyi6D2Gaf01Yh IP06QEFCExAh2TiGTvjfr/s= X-Received: by 2002:a05:6a21:3944:b0:a3:754c:2769 with SMTP id ac4-20020a056a21394400b000a3754c2769mr96572284pzc.40.1673655387606; Fri, 13 Jan 2023 16:16:27 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::2e58]) by smtp.googlemail.com with ESMTPSA id nl5-20020a17090b384500b0020b21019086sm4064541pjb.3.2023.01.13.16.16.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jan 2023 16:16:27 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, "Vishal Moola (Oracle)" Subject: [PATCH 1/2] mm/khugepaged: Introduce release_pte_folio() to replace release_pte_page() Date: Fri, 13 Jan 2023 16:15:55 -0800 Message-Id: <20230114001556.43795-1-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 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_NONE,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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754955396881673163?= X-GMAIL-MSGID: =?utf-8?q?1754955396881673163?= release_pte_page() is converted to be a wrapper for release_pte_folio() to help facilitate the khugepaged conversion to folios. This replaces 3 calls to compound_head() with 1, and saves 85 bytes of kernel text. Signed-off-by: Vishal Moola (Oracle) --- mm/khugepaged.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index e1c7c1f357ef..4888e8688401 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -492,13 +492,18 @@ void __khugepaged_exit(struct mm_struct *mm) } } +static void release_pte_folio(struct folio *folio) +{ + node_stat_mod_folio(folio, + NR_ISOLATED_ANON + folio_is_file_lru(folio), + -folio_nr_pages(folio)); + folio_unlock(folio); + folio_putback_lru(folio); +} + static void release_pte_page(struct page *page) { - mod_node_page_state(page_pgdat(page), - NR_ISOLATED_ANON + page_is_file_lru(page), - -compound_nr(page)); - unlock_page(page); - putback_lru_page(page); + release_pte_folio(page_folio(page)); } static void release_pte_pages(pte_t *pte, pte_t *_pte, From patchwork Sat Jan 14 00:15:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 43658 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp37216wrn; Fri, 13 Jan 2023 16:25:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXsdgHhGbjMGpIADRFrew2qmZwxvbgWGv2qWQC8tpwAa+8ZgYfz3ns03Ptve8ELzUAs+5a2S X-Received: by 2002:a17:903:40c8:b0:189:ab82:53f5 with SMTP id t8-20020a17090340c800b00189ab8253f5mr66674978pld.40.1673655929950; Fri, 13 Jan 2023 16:25:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673655929; cv=none; d=google.com; s=arc-20160816; b=bidgqt8XDuI/5TQx38gKVMTo+ypsgl1h2TlT50EeH3RvG4woAVvbOuMyqbKaIid8C7 2/YzMDkPwuMKriXmUIP82Mfz57YQJ541kBR4b+s6LzkU/sc1lCHP/RjQrbYRmWTcvuA6 QbiGWwJYyhYffon1pVYmsnKvT0g9tbKr3LatKCsdRE1KNA3u29QeP+tIQV3ur1GGVvFH RN8qomDKD7ko/ruQ7riIPFec0+ekhm0NQgulZiXn+cHEzLSJLdfyESsDV766IpNCfwb3 UBMbYwe6yZHx5tJOrPaj+1q5p1Tw1JGc6QqHb4RGwjGGo6nI96cxnsNB7x+UrbeAANT8 MuHA== 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=R11gpIsoLjoJPx/bJDZSX3qFzcN1YPIoVj3Kg++9jRA=; b=gFPhYbidcpREL5j6OJ+I+V2oCcSkXSy0vx4tT28yKPwlwU7uF0E1Yd5knuGsBwXoAg wWD2giA+QdpoQCPWUxRaPHoImh5kvlXm9gUuJauZIwiSnL874Mb7BBQyGILneUZthU83 O7sMP1DhKWgF5k9MK2YJhVr9e12mi+xnIgsZDq9xdH4aAatLqDlZTJp7KAW+ltUzIDKb ld/L0BR1f3I8TWNVyluDjmDbihy4CKO1ghZkUudAC6Ql7uqABnsjS2FKU4zmChrpPdGa MTNOjaaEGANokODfigoJzJpSWStbqGq+KNgF6sms8P4A/qSQMK4hq8qi9s/GKDvFyFtQ CARQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=P3XFIbjS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q16-20020a170902dad000b00193f8c6a020si13673101plx.111.2023.01.13.16.25.18; Fri, 13 Jan 2023 16:25:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=P3XFIbjS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231322AbjANAQi (ORCPT + 99 others); Fri, 13 Jan 2023 19:16:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231142AbjANAQb (ORCPT ); Fri, 13 Jan 2023 19:16:31 -0500 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19DBD26F1 for ; Fri, 13 Jan 2023 16:16:29 -0800 (PST) Received: by mail-pl1-x62b.google.com with SMTP id d9so24997105pll.9 for ; Fri, 13 Jan 2023 16:16:29 -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=R11gpIsoLjoJPx/bJDZSX3qFzcN1YPIoVj3Kg++9jRA=; b=P3XFIbjS9O2iFLNHs9KwE1VQ8werQuyrNARUhLmH0lCVNRZJ2rk7sgZT+Zn/CV3aO9 n8NosQbbujPD1yTLzY2UtT/orCnuHWy7JhAv4QCSPiGNheHs2ZNcWCweXjNj0NCFqodH Xz2SipLoimvA1UTBTssbm8XWZ8xtLfiLHZwIdk9wyWIUkEEnyVwoQOahZlGWgFgcbv1v vdMyCUandgKkyl6eDOY3ntLLrn6MzeGGOX03JuITzAcChJZuNGQh9FnQ05DZoIPVVoeT fH3iJEksq5Dz+dM+HeaMJPuXGVstuBYeICD8N7ANsSkrBqLXmgyUzhVmF9vR2+cf6V9N DOKQ== 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=R11gpIsoLjoJPx/bJDZSX3qFzcN1YPIoVj3Kg++9jRA=; b=aZGpfvk/wkE8tbmR0j/PO34m9DeBixGDuBL4lPdE7C2ju8WkUkj3wECnUzJIgpuC+D k3jDx7w+izq/EXuPSGQG12bja8Kff22hE/Vr0l+Pk/gU2no+tmYXXvMexTBdvNsJ2VSi WQ043haAMvFiovc0iK545+cJmGTmPoQLgeLU4301JNtvF+AXPt6uZ5AAmg3y6ImRJzjA rCLa9KErIbxVPWujtd2ctuex3lELuZPCpmlxbgeMCANhhUi9LxjSCMffNaapk2+Ejryq fWf0HW2bBdwaLIChCXjComdsOw7lH/KepOkpvSP4MYhrFxkwFWGz9KqKsNQUCWkMnK+W KTSQ== X-Gm-Message-State: AFqh2krqx7Bgv21W7KlrwCmO1khlDOBmzojKvlc2x+vfFDca6u7QMV5J Qii7dmVgs2fEzA5zuO4IxlY= X-Received: by 2002:a05:6a20:43a2:b0:b6:71f6:a4c0 with SMTP id i34-20020a056a2043a200b000b671f6a4c0mr9808650pzl.1.1673655388607; Fri, 13 Jan 2023 16:16:28 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::2e58]) by smtp.googlemail.com with ESMTPSA id nl5-20020a17090b384500b0020b21019086sm4064541pjb.3.2023.01.13.16.16.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jan 2023 16:16:28 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, "Vishal Moola (Oracle)" Subject: [PATCH 2/2] mm/khugepaged: Convert release_pte_pages() to use folios Date: Fri, 13 Jan 2023 16:15:56 -0800 Message-Id: <20230114001556.43795-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230114001556.43795-1-vishal.moola@gmail.com> References: <20230114001556.43795-1-vishal.moola@gmail.com> MIME-Version: 1.0 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_NONE,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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754955440712809588?= X-GMAIL-MSGID: =?utf-8?q?1754955440712809588?= Converts release_pte_pages() to use folios instead of pages. 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 4888e8688401..27d010431ece 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -509,20 +509,20 @@ static void release_pte_page(struct page *page) static void release_pte_pages(pte_t *pte, pte_t *_pte, struct list_head *compound_pagelist) { - struct page *page, *tmp; + struct folio *folio, *tmp; while (--_pte >= pte) { pte_t pteval = *_pte; - page = pte_page(pteval); + folio = pfn_folio(pte_pfn(pteval)); if (!pte_none(pteval) && !is_zero_pfn(pte_pfn(pteval)) && - !PageCompound(page)) - release_pte_page(page); + !folio_test_large(folio)) + release_pte_folio(folio); } - list_for_each_entry_safe(page, tmp, compound_pagelist, lru) { - list_del(&page->lru); - release_pte_page(page); + list_for_each_entry_safe(folio, tmp, compound_pagelist, lru) { + list_del(&folio->lru); + release_pte_folio(folio); } }