From patchwork Fri Nov 3 14:01:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161315 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1056396vqu; Fri, 3 Nov 2023 07:05:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEcRrjWeXz/MY8F6nYf0IjhNSADu5PjDVQoSOnR0UnW/Ikw5vRWFcyASqP5TjPSa4PwKSCm X-Received: by 2002:a17:902:c1c1:b0:1cc:ae1a:b0b8 with SMTP id c1-20020a170902c1c100b001ccae1ab0b8mr674757plc.44.1699020300315; Fri, 03 Nov 2023 07:05:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699020300; cv=none; d=google.com; s=arc-20160816; b=YS7nkZWUfjUqnlllL2w+r6Knj3/Q6XgRpyMgFdpTkn0M6GmUPuw7Gs+L6VAEqDySE3 T3lD8NN+MsnLz12fBXN8EHs0joTDIIfCMQlg98O1DNZoT1dLx1VZ2JBLyhZ6Ed8cZmPh Pq0pq+1zG4AQXAyqUXODVFBw8z9SboA2vQdyDO8aH0q0GwPsX2dRN2kFJOY1Tzs6719u muN2x92TryEL4+GxlYoku9jtItq9x/bTpXQqmB72mk3ppaSJbOZJAia59gd9BP5g0c8N sphSTDdrUsOCuQxS4jevH9EuTIuyXU7Felcrux7ulni/ZLMUH5xwT5Mh4ZrTsQdjIx9o /aSQ== 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; bh=8+J3qRxOBK8DBKSlvlbT9kzwQm4rIUsyVkkfO9bjcqY=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=ZhvknsIN8i0ro2YRYnNffcnrhDyh559wOIzVo9Bb5TKENQRbb7EBzb+TmuN5VPUxKA nGziRchi3b7irsTrmgHpwQd6OYc8UF6hmv8Il8P0Zu3CaNI9Tc1YWmhgJ3JtJF6d4eof kz+Mnb+paK/JLjBdwuOtKJtWk8WqsfzIpZRVftkfzyrTWGgwDFLy2dUZYMXbSOn8PYW3 fU1ZMe9UzYCa8A7inCRrjttKzhzNlw+SWj/ERl1jyJz7p1QI9rpROvqiwoQokGiJgZpY /CmtS22dWrvQySyVf6NkLNIv9bVb2aDWYsYYMQ6kVXWEpZPz9drT85dSXhmKWm/lH/Lv MABA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id lo13-20020a170903434d00b001c9d4d2460fsi1559231plb.30.2023.11.03.07.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:05:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id DD93D81F4735; Fri, 3 Nov 2023 07:04:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377775AbjKCODw (ORCPT + 36 others); Fri, 3 Nov 2023 10:03:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233366AbjKCODt (ORCPT ); Fri, 3 Nov 2023 10:03:49 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B5D2D4F; Fri, 3 Nov 2023 07:03:45 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SMMsk23mLzVkbd; Fri, 3 Nov 2023 22:03:38 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 22:03:43 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 01/18] mm: add mm_counter_folio() and mm_counter_file_folio() Date: Fri, 3 Nov 2023 22:01:02 +0800 Message-ID: <20231103140119.2306578-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:04:39 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781551910924598830 X-GMAIL-MSGID: 1781551910924598830 Introduce two mm counter folio functions mm_counter_folio() and mm_counter_file_folio(), will be used folio conversion, and it saves a compound_head() in mm_counter(). Signed-off-by: Kefeng Wang --- include/linux/mm.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index caf13e94260e..f5f76504b212 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2583,19 +2583,29 @@ static inline void dec_mm_counter(struct mm_struct *mm, int member) mm_trace_rss_stat(mm, member); } -/* Optimized variant when page is already known not to be PageAnon */ -static inline int mm_counter_file(struct page *page) +static inline int mm_counter_file_folio(struct folio *folio) { - if (PageSwapBacked(page)) + if (folio_test_swapbacked(folio)) return MM_SHMEMPAGES; return MM_FILEPAGES; } -static inline int mm_counter(struct page *page) +/* Optimized variant when page is already known not to be PageAnon */ +static inline int mm_counter_file(struct page *page) +{ + return mm_counter_file_folio(page_folio(page)); +} + +static inline int mm_counter_folio(struct folio *folio) { - if (PageAnon(page)) + if (folio_test_anon(folio)) return MM_ANONPAGES; - return mm_counter_file(page); + return mm_counter_file_folio(folio); +} + +static inline int mm_counter(struct page *page) +{ + return mm_counter_folio(page_folio(page)); } static inline unsigned long get_mm_rss(struct mm_struct *mm) From patchwork Fri Nov 3 14:01:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161317 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1056524vqu; Fri, 3 Nov 2023 07:05:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGjeLo2xdXoqne6cZNk7hLUWNgudv0kjZPY4EM7UvJPOaqPbmIujduDq2ZaIggaBLUruWGW X-Received: by 2002:a05:6a00:1da8:b0:6c3:3795:dd66 with SMTP id z40-20020a056a001da800b006c33795dd66mr4136790pfw.16.1699020309421; Fri, 03 Nov 2023 07:05:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699020309; cv=none; d=google.com; s=arc-20160816; b=sw9rysJTcBM7PtcRFesT+EYzIFCq4MbjOb4F5EkE02X5fhNpLXDhzZYb+d7IameIGX usmK1Fq20XIcNmAv1xHw3yRynBxvW5JUwbgchyX2s/XAXm5YYAwLyCIfGgt7h9E2qOJ+ 6B7ixSCpL/TVFT03q4d3+uX97MPP7In3dXTea2kXgikv4tngrZZOLOudTQ1hYZscIzLH wx1CUmBYeHCw3i4X4mspDRKoRAJnUdk/amny7MWp0tMHb36Q/gtDzWFHUDFLDvzobo8S bGLd9XQDf/uoE546xkNmhfLryY7KAjCYkuzsgkvCMXBwKTAyij3s55liIfjFrQ5n/FuS WAWg== 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; bh=KcfQLTNeQLYbZjj3Vfq0pzF4qAjIfyux433LLT/5H3c=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=PxVcZpCv+XAc04MEs0lkmqwFu/8F1/LohE1rs93zt+h0tKgohL0LIZQDAHURG5SfuY Yr5M6z7Aq+H8z3n3Req3qKITaRvJjv5BExkSWdZR96fIWriMS1HGXmWQQ+G9IuENVP7O 3PbikLKyCk1kefJI0yx7RXLHEiTJTpvwS77NtSWw7qgCE5Rn7KO886m1Pnu+MG7C6bTy bEVgTdYhQOVFoUd7Ewn33fLgk9wzSwK+RoT31UGXiNT3unPOS3HDJN+X9+Ry7hVD0wTI reUbsrZn8BqrGIN3zhjrfbX69TqQC+NzNhTS+uRyM1JMt9l7rpLRPCDcRNJH3NFyBQPd Disg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id o13-20020a056a0015cd00b006c3398b42f2si1575116pfu.79.2023.11.03.07.05.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:05:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id E348C829E90F; Fri, 3 Nov 2023 07:05:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377790AbjKCODz (ORCPT + 36 others); Fri, 3 Nov 2023 10:03:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233470AbjKCODt (ORCPT ); Fri, 3 Nov 2023 10:03:49 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48355D56; Fri, 3 Nov 2023 07:03:46 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4SMMmm5jbnzMmKq; Fri, 3 Nov 2023 21:59:20 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 22:03:43 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 02/18] uprobes: use mm_counter_file_folio() Date: Fri, 3 Nov 2023 22:01:03 +0800 Message-ID: <20231103140119.2306578-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:05:02 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781551919773901777 X-GMAIL-MSGID: 1781551919773901777 Use mm_counter_file_folio() to save one compound_head() call. Signed-off-by: Kefeng Wang --- kernel/events/uprobes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 435aac1d8c27..e2d3c89cc524 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -188,7 +188,7 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr, dec_mm_counter(mm, MM_ANONPAGES); if (!folio_test_anon(old_folio)) { - dec_mm_counter(mm, mm_counter_file(old_page)); + dec_mm_counter(mm, mm_counter_file_folio(old_folio)); inc_mm_counter(mm, MM_ANONPAGES); } From patchwork Fri Nov 3 14:01:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161307 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1055667vqu; Fri, 3 Nov 2023 07:04:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHRde6Bhhel2ZJ1jYkghsevCctfvXDg+H/YYkh7ZIzNrZazTD9CSWzd03sUqQ2lgPnJmkIR X-Received: by 2002:a17:90b:4016:b0:27d:47b4:785f with SMTP id ie22-20020a17090b401600b0027d47b4785fmr17160661pjb.18.1699020254026; Fri, 03 Nov 2023 07:04:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699020254; cv=none; d=google.com; s=arc-20160816; b=WV/G7p9zNMjNBi/vNKRz7LZ4SY+ZIymNzau7yyPRA1yG79gx2tguH4TIjqwfRzCjfz AHUU0l/D9RyAmVFq5AI14TQS33R8pBh5K5moyuhg4/NrLBQ4WY93VikxACeq82C4W9xD pCHJph9DdovNU+3y65NdzVu8awFEwfn6l2v2mnADxTDwIgzC6uz7zxILe7lgEIuxublH ZC/EgFqb9vhidgBFQmJZVlMOaoyuWKYLOss7BWFfPEiAup1+VGXG/fHf/ALcH8yizdhu pFJ0WWbBpJU8ByBdr7kT0CkCOIdDW2eHkElDNkU6p7X3vLdH/pta7ngjW0nb/+VmkyZi kjHw== 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; bh=vvPUq4pcW2H7sJpunngQLYXQwnMIWBCnxO4qS0TOoUQ=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=KgAsRNNY+CODX6NkgTlkkykGFDN8hj3k5d55IdFLcgfGFHp8y2Ua/sQptZCFahj9PH 79IMxwn40H/B8Nhf3W4cUUcn6ker15mNDPYCcI5ldxIWOhwwk1nSoOrm/QugCeVzT+WX oyfXz5REJsLi7Erhmqyu9C1KL4JjrPRKQ7s0291Bn46ZmztI2KsZ7VGZxEb1jzTBmwe6 jgLQTU4EBs5QJSiTeTKl3H+DK8J9k8wtDk8mznSYuR3ZHSBAmEtjSwn0ZgHtCVWMjmEQ XKm9qtl93vSJi7pY86nLY4NWVZw3A6i9ERKa1qRRcapA+humNXRdy9zEqt/GLuiBXy9f 6FQA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id nv18-20020a17090b1b5200b00280277d721dsi1656938pjb.83.2023.11.03.07.04.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:04:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E659882CB50D; Fri, 3 Nov 2023 07:04:02 -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 S1377792AbjKCOD7 (ORCPT + 36 others); Fri, 3 Nov 2023 10:03:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377735AbjKCODt (ORCPT ); Fri, 3 Nov 2023 10:03:49 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 528ECD57; Fri, 3 Nov 2023 07:03:46 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SMMsm4StwzvQKT; Fri, 3 Nov 2023 22:03:40 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 22:03:43 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 03/18] mm: userfaultfd: use mm_counter_folio() Date: Fri, 3 Nov 2023 22:01:04 +0800 Message-ID: <20231103140119.2306578-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:04:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781551861667415444 X-GMAIL-MSGID: 1781551861667415444 Use mm_counter_folio() to save one compound_head() call. Signed-off-by: Kefeng Wang --- mm/userfaultfd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 96d9eae5c7cc..e47aa6c91ef8 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -121,10 +121,10 @@ int mfill_atomic_install_pte(pmd_t *dst_pmd, } /* - * Must happen after rmap, as mm_counter() checks mapping (via + * Must happen after rmap, as mm_counter_folio() checks mapping (via * PageAnon()), which is set by __page_set_anon_rmap(). */ - inc_mm_counter(dst_mm, mm_counter(page)); + inc_mm_counter(dst_mm, mm_counter_folio(folio)); set_pte_at(dst_mm, dst_addr, dst_pte, _dst_pte); From patchwork Fri Nov 3 14:01:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161306 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1055423vqu; Fri, 3 Nov 2023 07:03:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNhXuRrMxWAZ2qtjtaxg6AShWr5RHMShm97Bo0xtF3g8sUqdN56lRjihx2Mc+CWD2//D8Y X-Received: by 2002:a05:6a20:42a5:b0:140:6979:295d with SMTP id o37-20020a056a2042a500b001406979295dmr22352408pzj.2.1699020239252; Fri, 03 Nov 2023 07:03:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699020239; cv=none; d=google.com; s=arc-20160816; b=AKn+WAd/Jr1HAhgDvqzqJgaY0iLdyRf+aRuKzbdl0mCUgy0WFTWAC8W0UnRCgVKJQL +JkXBryNfH/VNnIBKwwQYR5QZsGlvQ1AnZ9xMNlh3ydue+vMgJ0niXYOH/6FdpxUqQ2w sBNtUNc6J1fOjZS29MibjOwlCCbx5d3zYLN69n8B+JtS5L+LPoZGDQtyR17TSiA51WmH R6N1puIZvkJmYvPpSnjkHsFA3YIhtv/NcEh0/n23QaBFgau7VpLxt7noTgjJuIEVs8au jtTVn1Ivm+D9hqxPm8n5L1vxF8OX2Hzzgk+PMtjB6Fnf5tPBFwrAvBfkGEJg8RrFXWVN 5F1w== 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; bh=kykwL6Mmf1y36nJByARdqQ9uHESO9i+gC6/3JI+7xuE=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=sUkzk1k4Atp8to6n+TsZCUS5hdEkA1r3TDk60ITZybcfQz9/SreH6oX36L3AXy0ur+ 5NFifWSdkZChZvhQW300QnXG4CGlIvjAeKDIgHoFzzLZf6TAU6/abnziwWr/vphf0pZe 0ho69aikw5vh5H6FsTu1zzjpwuDWnARVsmOWVe480ysp4xN7CDpcMoQHSoJSvgq6TWK5 5/uIpbarJtL3Pm2W91X0TRAD+xQrCbs+M/xJJNwEulnFjyDA6076HxDrWCkbxlDgOy/U 6Qm9kIF6PFMYQ7ksSZnLIShg4QKSCHb4Uk5tCCVFnscfHAm1PL/1c9atqqc9P/43lleU ufqg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id l4-20020a63ea44000000b005694a4640afsi1574656pgk.95.2023.11.03.07.03.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:03:59 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id CBDB1803E498; Fri, 3 Nov 2023 07:03: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 S1377842AbjKCOD5 (ORCPT + 36 others); Fri, 3 Nov 2023 10:03:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233909AbjKCODt (ORCPT ); Fri, 3 Nov 2023 10:03:49 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C22DDD4E; Fri, 3 Nov 2023 07:03:46 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4SMMmn4xy3zMmLd; Fri, 3 Nov 2023 21:59:21 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 22:03:44 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 04/18] mm: rmap: use mm_counter_[file]_folio() Date: Fri, 3 Nov 2023 22:01:05 +0800 Message-ID: <20231103140119.2306578-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:03:57 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781551846140587981 X-GMAIL-MSGID: 1781551846140587981 Use mm_counter_folio() and mm_counter_file_folio() to save five compound_head() calls. Signed-off-by: Kefeng Wang --- mm/rmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/rmap.c b/mm/rmap.c index 7a27a2b41802..9d77975eaa35 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1678,7 +1678,7 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, set_huge_pte_at(mm, address, pvmw.pte, pteval, hsz); } else { - dec_mm_counter(mm, mm_counter(&folio->page)); + dec_mm_counter(mm, mm_counter_folio(folio)); set_pte_at(mm, address, pvmw.pte, pteval); } @@ -1693,7 +1693,7 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, * migration) will not expect userfaults on already * copied pages. */ - dec_mm_counter(mm, mm_counter(&folio->page)); + dec_mm_counter(mm, mm_counter_folio(folio)); } else if (folio_test_anon(folio)) { swp_entry_t entry = page_swap_entry(subpage); pte_t swp_pte; @@ -1801,7 +1801,7 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, * * See Documentation/mm/mmu_notifier.rst */ - dec_mm_counter(mm, mm_counter_file(&folio->page)); + dec_mm_counter(mm, mm_counter_file_folio(folio)); } discard: page_remove_rmap(subpage, vma, folio_test_hugetlb(folio)); @@ -2075,7 +2075,7 @@ static bool try_to_migrate_one(struct folio *folio, struct vm_area_struct *vma, set_huge_pte_at(mm, address, pvmw.pte, pteval, hsz); } else { - dec_mm_counter(mm, mm_counter(&folio->page)); + dec_mm_counter(mm, mm_counter_folio(folio)); set_pte_at(mm, address, pvmw.pte, pteval); } @@ -2090,7 +2090,7 @@ static bool try_to_migrate_one(struct folio *folio, struct vm_area_struct *vma, * migration) will not expect userfaults on already * copied pages. */ - dec_mm_counter(mm, mm_counter(&folio->page)); + dec_mm_counter(mm, mm_counter_folio(folio)); } else { swp_entry_t entry; pte_t swp_pte; From patchwork Fri Nov 3 14:01:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161328 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1088580vqu; Fri, 3 Nov 2023 07:47:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGm3Q/ENvvew87Ec0DQFBgz9pMqty+r2DkB8xLlp+1JL5uYDE6hHFxvxJivS52qf6CZO/27 X-Received: by 2002:a17:902:c951:b0:1cc:70dd:62e7 with SMTP id i17-20020a170902c95100b001cc70dd62e7mr9984389pla.32.1699022853448; Fri, 03 Nov 2023 07:47:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699022853; cv=none; d=google.com; s=arc-20160816; b=KNcZRaG44BPD4ms8WrPtfQjT8OyBVxsm4drso+YwOzKX7v0i7CTmx7KttAanDoEP/M 7ch+9JsP5++vNKZ25X0WiuHf2pA9Ys5jTJkk3IKfyyiv/lZW2n8mFi4dLuFOS3UK30BR Flp3W2Ayl1vaKSBlZBmPfVdcDgF9DwVNeQzhgN1xR0Y88SJ36V0gGEsp5Z14Ugjluc4s 6nkqmAfnN5i2QrgBPfQ2cBbWEi+VuqLuxX2wVYMqtBVtAViiYuY6puIvopVjJCx9k6+N NOb+PbdEBIp6XIOUba4Uqnegwh9P69AnajQoq0dv/ORB75HL3tXR9JTQq/MH72NOWNaN Oq9A== 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; bh=NB5R7sYpytkiUmaxuKrNkniyxkHRPvjeB+cXDTFDb28=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=CvPBElToS7ZiYB0+C9xCxqCvU8u2tVY+WDoPuIhgIw3nyAJE1KHR2DDy+Ats1W98W3 vhnqoYBqxS5doRCFfOINn3FH1HQZ1mamNdJGbGcdY8ekyBX4eEfPnzdWeNX3+BAPfc6x VgoK1T90XYzFpxQ1+YjhYgE42nCBhn90HUSadbknLqIfxnZJb28/kL7eTCquxNZ+ZfnR m9axVW0Y1RvhloBwdt0kK7j8YBXavXzfXyh9xuwlzz1Msxs+JSLUo2qOLQ+lLfHrDZ6h 2G8XGq3JIumxpjBOFlEhjcDsEMcSa2uikN+GB1dem7PvxGWxnFN5d9UOE5d532JcqQYx vcnA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id o6-20020a17090323c600b001cc6529c7besi1578189plh.88.2023.11.03.07.47.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:47:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 65F088095014; Fri, 3 Nov 2023 07:46:03 -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 S229729AbjKCOp4 (ORCPT + 36 others); Fri, 3 Nov 2023 10:45:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377817AbjKCODz (ORCPT ); Fri, 3 Nov 2023 10:03:55 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45AF9D61; Fri, 3 Nov 2023 07:03:51 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpP4lT5z1P7Sl; Fri, 3 Nov 2023 22:00:45 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 22:03:45 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 06/18] mm: huge_memory: use a folio in __split_huge_pmd_locked() Date: Fri, 3 Nov 2023 22:01:07 +0800 Message-ID: <20231103140119.2306578-7-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:46:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781554587363513039 X-GMAIL-MSGID: 1781554587363513039 Use a folio in __split_huge_pmd_locked() which replaces six compound_head() call with two page_folio() calls. Signed-off-by: Kefeng Wang --- mm/huge_memory.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 34001ef9d029..054336ecab0a 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2117,6 +2117,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, count_vm_event(THP_SPLIT_PMD); if (!vma_is_anonymous(vma)) { + struct folio *folio; old_pmd = pmdp_huge_clear_flush(vma, haddr, pmd); /* * We are going to unmap this huge page. So @@ -2130,17 +2131,17 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, swp_entry_t entry; entry = pmd_to_swp_entry(old_pmd); - page = pfn_swap_entry_to_page(entry); + folio = pfn_swap_entry_to_folio(entry); } else { - page = pmd_page(old_pmd); - if (!PageDirty(page) && pmd_dirty(old_pmd)) - set_page_dirty(page); - if (!PageReferenced(page) && pmd_young(old_pmd)) - SetPageReferenced(page); - page_remove_rmap(page, vma, true); - put_page(page); + folio = page_folio(pmd_page(old_pmd)); + if (!folio_test_dirty(folio) && pmd_dirty(old_pmd)) + folio_set_dirty(folio); + if (!folio_test_referenced(folio) && pmd_young(old_pmd)) + folio_set_referenced(folio); + page_remove_rmap(&folio->page, vma, true); + folio_put(folio); } - add_mm_counter(mm, mm_counter_file(page), -HPAGE_PMD_NR); + add_mm_counter(mm, mm_counter_file_folio(folio), -HPAGE_PMD_NR); return; } From patchwork Fri Nov 3 14:01:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161325 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1087765vqu; Fri, 3 Nov 2023 07:46:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGv8Eg5NKiibFYXPCirslWe3GVhsP/kIX49rX83jXoLAo4xUcwR8iEn89J3CRk1kA2yNIec X-Received: by 2002:a05:6a21:7785:b0:180:db7b:23f2 with SMTP id bd5-20020a056a21778500b00180db7b23f2mr16329668pzc.61.1699022776237; Fri, 03 Nov 2023 07:46:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699022776; cv=none; d=google.com; s=arc-20160816; b=dLsboecsx3aH0t8mkRWsM77Z9x39cu8C4FRrizCjja1dCDd+DzaAvdweSPpVGDdnDU cBhSuOXT06cYARzxXhtTzbYtkStJaMTrWFnLpn+V5sm1TwsGp4lUik+VggQv9K1sm7OM dQQ0M2n0Xs9lVvlLTMhKgNhOfCufZ5YPMcUIudp932nbXW6tA7QEQ1DR6dDd+SzF4Y60 nwipG13zLF4ZYQncLLPzbS2GGufAG/KJGpLBEvcZzcaf2FRxPCLqRBBmuNHYL06qfpfs GNMQ2GyDML1XZotQ2XgazjQhWBjRJSX99wiKMwKdnnG2FoqJkl+KMV6lKrtyaZoG2AEU yoUg== 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; bh=/HAJ8XbTBaLTFFDB1GrLQZOkpvtPmYqj4jF+Og1D+HM=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=xnCalo9kNsfTmExVIyMWnBFxljIqS6lw3POLs3LRbtnmRxaupq8+vaANryfZpKcrYG 69HIrMC04JIDf3Kk2ZeeuHKD/uMZEEAqcSwc5qNzbOGpsodsPOWdSFVsElFUtwVeIt9P 0QBEyQBPv7ZenHxBDgQlgq6FbCyr1d9ZfCtjZ0AXjRyLZo+YvY+OMDD+gS8YA780eqL9 aqSPs4jdd/pDX372tEkOj5dcgs3cYptV7cI5GchtfuOFPJcIz6d+iKqJS+LuPyh+b1Uc Q3qcUSLkKzuQore37Sq5n4L7ZbuAvAAgZG4iJU9Cb29yV3+lF2dlol52cNS4B41KQVaH YNQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id e24-20020a656798000000b00578ea9a0b93si1599047pgr.890.2023.11.03.07.46.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:46:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 22EAE829EA36; Fri, 3 Nov 2023 07:46:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229903AbjKCOp6 (ORCPT + 36 others); Fri, 3 Nov 2023 10:45:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377811AbjKCODz (ORCPT ); Fri, 3 Nov 2023 10:03:55 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45390D59; Fri, 3 Nov 2023 07:03:51 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpP5NHRz1P7nG; Fri, 3 Nov 2023 22:00:45 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 22:03:45 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 07/18] mm: huge_memory: use a folio in zap_huge_pmd() Date: Fri, 3 Nov 2023 22:01:08 +0800 Message-ID: <20231103140119.2306578-8-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:46:12 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781554506265264484 X-GMAIL-MSGID: 1781554506265264484 Use a folio in zap_huge_pmd() which replaces two compound_head() call with one page_folio() call. Signed-off-by: Kefeng Wang --- mm/huge_memory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 054336ecab0a..2dba4d3aa2d3 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1717,6 +1717,7 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, spin_unlock(ptl); } else { struct page *page = NULL; + struct folio *folio = NULL; int flush_needed = 1; if (pmd_present(orig_pmd)) { @@ -1734,13 +1735,14 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, } else WARN_ONCE(1, "Non present huge pmd without pmd migration enabled!"); - if (PageAnon(page)) { + folio = page_folio(page); + if (folio_test_anon(folio)) { zap_deposited_table(tlb->mm, pmd); add_mm_counter(tlb->mm, MM_ANONPAGES, -HPAGE_PMD_NR); } else { if (arch_needs_pgtable_deposit()) zap_deposited_table(tlb->mm, pmd); - add_mm_counter(tlb->mm, mm_counter_file(page), -HPAGE_PMD_NR); + add_mm_counter(tlb->mm, mm_counter_file_folio(folio), -HPAGE_PMD_NR); } spin_unlock(ptl); From patchwork Fri Nov 3 14:01:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161326 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1088047vqu; Fri, 3 Nov 2023 07:46:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF4PuNLT1yN5WISlSoijOm44739KOQh5uGaY0OwSQnkU3ZCL31yCY+mbXNZg9W/a2lTHqfJ X-Received: by 2002:a17:902:e1cd:b0:1c7:49dd:2df with SMTP id t13-20020a170902e1cd00b001c749dd02dfmr15680380pla.32.1699022802539; Fri, 03 Nov 2023 07:46:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699022802; cv=none; d=google.com; s=arc-20160816; b=0U+yu1kPBMCbIu2iGYjRW4NpQ0ufsrlzZCuIRF2/huF7DGWHNFljYJz0+1eTzX6hdg UTlo8GCSD8AD5k/1IUQQWTt+OCp57uW01/8NDL95E5jyX8Ii+0y3EeWZTGsHxqlUGIK1 WBC2pbF5omG0WvNMkLDqHa/S9McpVLVoy+pHCRIxg+QoNwmPeGUciWrXDbLmQgChhaGG 5AgbCwSa3ivfcbF621nn7adNA0hQ0f24C8OIHm+XUQNqvEZPpYDJ9J3cxv/jHRglSovZ 8bj955gIbPK321H41fjjdyOb/wav58CVSSH1Jdgfyw3+Kkl1Ew262tHTHFQOZA/p+mpl tuDg== 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; bh=BksiekM5fz6UlJeefImo+WZsurm9oK7d4R0JBiKe41Q=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=MZeCrBKBKra8HU6EyOcTg5NHhvQp+c8u6CccezG+uhcFORHGwy21ZI4O3c6njoq2if w/GUFmRzd8PLdavE2PnlAdKO16LEOLUY56HUzxOEFLDb1yHlnEIiaWaj2uLerUPj7JEr VCQDlGXZNdF7gasULrGqrc1vXHiLtvitPystg5J6X19gdYFOQD8RTIMM81+vhUbC5MTl EoTFk7U5U+HRckD5yjxbOozuBzUaDhFNho3vvmqWtojxavgCvXOJvGB2nl+vJto7BGvc u1LILNpOaF5m6a1rj9essLoADb170j1MWzFHNP5oZRKqTkHym9gSgLs0OSy/NQyP4fWe VDHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id ix19-20020a170902f81300b001c9bdaa81e3si1565548plb.633.2023.11.03.07.46.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:46:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id EB1268303A2B; Fri, 3 Nov 2023 07:46:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231510AbjKCOqD (ORCPT + 36 others); Fri, 3 Nov 2023 10:46:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377815AbjKCODz (ORCPT ); Fri, 3 Nov 2023 10:03:55 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46012D62; Fri, 3 Nov 2023 07:03:51 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpP5g8Gz1P7nl; Fri, 3 Nov 2023 22:00:45 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 22:03:46 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 08/18] mm: khugepaged: use mm_counter_file_folio() in collapse_pte_mapped_thp() Date: Fri, 3 Nov 2023 22:01:09 +0800 Message-ID: <20231103140119.2306578-9-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:46:40 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781554534543999946 X-GMAIL-MSGID: 1781554534543999946 Use mm_counter_file_folio() to save two compound_head() calls in mm_counter_file_folio(). Signed-off-by: Kefeng Wang --- mm/khugepaged.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 064654717843..a6805f4f6dea 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1630,7 +1630,7 @@ int collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr, /* step 3: set proper refcount and mm_counters. */ if (nr_ptes) { folio_ref_sub(folio, nr_ptes); - add_mm_counter(mm, mm_counter_file(&folio->page), -nr_ptes); + add_mm_counter(mm, mm_counter_file_folio(folio), -nr_ptes); } /* step 4: remove empty page table */ @@ -1661,7 +1661,7 @@ int collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr, if (nr_ptes) { flush_tlb_mm(mm); folio_ref_sub(folio, nr_ptes); - add_mm_counter(mm, mm_counter_file(&folio->page), -nr_ptes); + add_mm_counter(mm, mm_counter_file_folio(folio), -nr_ptes); } if (start_pte) pte_unmap_unlock(start_pte, ptl); From patchwork Fri Nov 3 14:01:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161327 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1088573vqu; Fri, 3 Nov 2023 07:47:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGZxoBMZ2YQpxt/0OAO+sj2Ah4ldk/Hy/gLRGgn9IYzmmGvX38rM+LzgI9e0qu48/rFexUz X-Received: by 2002:a17:90b:fc2:b0:27d:8ad:69f9 with SMTP id gd2-20020a17090b0fc200b0027d08ad69f9mr17978061pjb.2.1699022852965; Fri, 03 Nov 2023 07:47:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699022852; cv=none; d=google.com; s=arc-20160816; b=zmSaDfxN1l+GnmUQdC/YLJ/7WAJeEGAeLPEfU2dO3cXsQFC9AxHOTiEsSVfCFDLtiH TGJrtH7Vq97pk1vJr0kxG8rCF+3poKmwvwPxqlzD22I6jXEnNjGJkYvgKCXMkN/EP9Ib YhBlCVb4lkxFgGk10+hBmTWNplxuLofbfmS6wa9CPysnr2ZjO/8myvspvuq9GJfdh4JZ HsyP5zI0vb/VWtkOz7Ufkj0DQbpXMoMahxVQFqWC7OFnoVYhgecN2TLxviygLgEO92iR nvV27aGhdmu650JvcmJREKT/7pKnQurf3GwGT/vu1qh7pT6IV1fvGA7s8IwsO1XoShzZ ovHQ== 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; bh=ylqQuVj5ksYS6g4LV1U9DLXWq/46sIERK97vnxuNUQw=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=x0JLzyEiHldHYIQO96OzNrgx1ZgVFtchj7pfC75nEBiXBGajcHbYraUuUWPNyRBjur s1zo0pmmLKmhsM+x4TvcJjOI5wAZ4vboCRaOpHlL7dqk7NLNrK5zCU/uwSzUEX75eSnS GzDBbixrA32X3msn5lEd1mRUtqyGnuwJ+Md1EsBTQmkTuk3XbTV6sgYJHPORFBbC+qtM JlyeDDT0ZUP0Mq77S2YqNqm5w8Et1wt7iz+NRXU9Twm048dM7xYtLSn1TlyZPHF5SM8l 635gFeLAYeNGjbX+hneL9IkUSjR7NRxYAhK2+ilrSFYeXRGEKQFIJnZr5MMtsOg4nIhv 1RDA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id h5-20020a17090acf0500b0027d82c2b020si1644174pju.88.2023.11.03.07.47.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:47:32 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B42BB80747A3; Fri, 3 Nov 2023 07:45:58 -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 S229531AbjKCOpz (ORCPT + 36 others); Fri, 3 Nov 2023 10:45:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377812AbjKCODz (ORCPT ); Fri, 3 Nov 2023 10:03:55 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45563D60; Fri, 3 Nov 2023 07:03:51 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpP5yQNz1P7pR; Fri, 3 Nov 2023 22:00:45 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 22:03:46 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 09/18] mm: memory: use a folio in do_set_pmd() Date: Fri, 3 Nov 2023 22:01:10 +0800 Message-ID: <20231103140119.2306578-10-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:45:58 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781554586983826959 X-GMAIL-MSGID: 1781554586983826959 Use a folio in do_set_pmd(), which save one compound_head() call. Signed-off-by: Kefeng Wang --- mm/memory.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 1f18ed4a5497..09009094a5f2 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4313,12 +4313,13 @@ vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page) unsigned long haddr = vmf->address & HPAGE_PMD_MASK; pmd_t entry; vm_fault_t ret = VM_FAULT_FALLBACK; + struct folio *folio; if (!transhuge_vma_suitable(vma, haddr)) return ret; - page = compound_head(page); - if (compound_order(page) != HPAGE_PMD_ORDER) + folio = page_folio(page); + if (folio_order(folio) != HPAGE_PMD_ORDER) return ret; /* @@ -4350,7 +4351,7 @@ vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page) if (write) entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma); - add_mm_counter(vma->vm_mm, mm_counter_file(page), HPAGE_PMD_NR); + add_mm_counter(vma->vm_mm, mm_counter_file_folio(folio), HPAGE_PMD_NR); page_add_file_rmap(page, vma, true); /* From patchwork Fri Nov 3 14:01:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161309 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1055828vqu; Fri, 3 Nov 2023 07:04:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFkVzgvXJHx5jm38RuvkimaM+RjAV0xoFJHLsaT5TEgljh1KoYU6Yz7zm5bOwNjODNAPaeJ X-Received: by 2002:a17:903:2351:b0:1cc:37b9:4953 with SMTP id c17-20020a170903235100b001cc37b94953mr18244545plh.67.1699020264283; Fri, 03 Nov 2023 07:04:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699020264; cv=none; d=google.com; s=arc-20160816; b=k5rG44kwsxMuZBrKfiACgZx3ps2PhmGWy6OobLEvehb1VH51jakqw2nxjbmPcE9alV FvKae685NQE1qHBj3ERrB16omE2lSI8DfuU5LAx/xkwwnXSf85CHLQXP6Q56XZO07/PU B6J3rV3i/LNihx1nRHkvCnWV6btMQNJHin+aZVtJhi3y1Bo3yyQHgYh7O8C4HFJUHfcl MhTX76fFCiOzMYERNNNCaNymGilRvYVw7Je5zrDnMOMyWJyAPa20mYuhzqKCswGBSetT 35QmaSuRs3jTHa+0cFvLwyeZkP0tH+nLI8W9OombmJ63pDNvkx3pNSfGHVbxq9gvWnzI 4sFA== 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; bh=etASjzJe50wrJU9UBMk5yCoyKqr7D2lHehFpSzts/t8=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=xZLkGZQwiYgR5SW7cNVzoTcRIpw0T2dTmGyxfbbQQLeXPlh0EqyjmaBuA2Pj1iHIHV e4rFSwKhnkbFTwFWCN9a/eDT5ckc61MWTJBHDbX9v0vjAnzk15VRc6jjSjp5xj91S65w rVzXtc0kLcpQSzJd48aH+R86jEKUm33NhvHAigDywZa8D1MUj6R1zWs8IfAWR50T2v8l RXTXCqPSwMYUAmi5zGL1SET/U78hbacK0uThW+KlOFMGEZzP4YvGfK3QRS/N/ixCKVom kSM4vHlbEkVEFm/kmLNvd2P7yBCdb3C/ed1OJZQXzvAIIuFyugoM/6/pIXBeN6x9wdb7 w8QQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id h7-20020a170902f7c700b001c60de17b5esi1537724plw.118.2023.11.03.07.04.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:04:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 78E7582CB52D; Fri, 3 Nov 2023 07:04:10 -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 S1377872AbjKCOEE (ORCPT + 36 others); Fri, 3 Nov 2023 10:04:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377809AbjKCODz (ORCPT ); Fri, 3 Nov 2023 10:03:55 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4493BD57; Fri, 3 Nov 2023 07:03:51 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpQ084Pz1P7nW; Fri, 3 Nov 2023 22:00:46 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 22:03:47 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 10/18] mm: memory: use mm_counter_file_folio() in copy_present_pte() Date: Fri, 3 Nov 2023 22:01:11 +0800 Message-ID: <20231103140119.2306578-11-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:04:10 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781551872407132623 X-GMAIL-MSGID: 1781551872407132623 Use mm_counter_file_folio() to save one compound_head() call. Signed-off-by: Kefeng Wang --- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index 09009094a5f2..d35ca499bf1c 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -960,7 +960,7 @@ copy_present_pte(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, } else if (page) { folio_get(folio); page_dup_file_rmap(page, false); - rss[mm_counter_file(page)]++; + rss[mm_counter_file_folio(folio)]++; } /* From patchwork Fri Nov 3 14:01:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161308 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1055766vqu; Fri, 3 Nov 2023 07:04:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHZdOXZS/r1OCLlt/2OD8QrjSNx84DL6vLWkTGSlr+oh7KcLMQrkO41pW2PrlO9Y9wuXMGE X-Received: by 2002:a05:6808:249:b0:3b2:e520:dfce with SMTP id m9-20020a056808024900b003b2e520dfcemr21460475oie.58.1699020260642; Fri, 03 Nov 2023 07:04:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699020260; cv=none; d=google.com; s=arc-20160816; b=AcpOCuvkngG4C18Im7rYjZPn5Zj76nRUDV5GQaxfcmrt0ZIC9p/tX/KV4N8z+c+3nd q+B2DWYFsh7EqQI8JUWjKdwpVJFbSogh3gkS5+Oiuidiw6szdsegW9SpAqO0FQvHpOal gsM47gyhvN/3FtqwAIl62LYAyhrwZ3paDpoaiwN6s4LZZtpGtcKEHnGkPIhR42bCg8MD dARGkfuoOvCix5UlRPaVohCgHFDYjWUtMMS+530UJZzXHzoq1G+MMnDMDMs7d1KZ+Y/i 4Xy5tFuaJMcbPxGc2iTzrUEdgv3kEQi7jcs+wo1Wleya9kn2zWMpKbw/hdev2aZ8MG4S Kiiw== 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; bh=J/rSriB3aflAPXuP/oLdhUT4o9qoZ0PrxLn1lca2smA=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=vg1lE05+snjjSI9Inldip8w77pWFW70BAQlJ36XQEzfl6TIWMdAAvSYLyxj0+mkQ5N uJPlPDXlRHGLfJXvJgUMNt1xYQRkNtgs7M4BIY+Y3cOZRYlDnbeQm0YDXpeS+Ak7yqUC htRAaA+9Rv20G6qjsR9u2833VPH/P21DIAU5ck96qw6YRAC7S4ZXGk5h/K9H7f1oKusC 9vxkfTgJlDdmP6/aUR/JOuTis5VEs14GxH3SNZ6zWvzPhGrKsitpnjJk69mceyP5eIR/ h8uUN586+e5edXHouX3EcWID26SyE0LnB2BNpRPPFg9tb8e9BnqCDSgO9T94q7ywD33y ekrw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id w5-20020a056808140500b003ade71403desi719385oiv.331.2023.11.03.07.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:04:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 567EA82BB57D; Fri, 3 Nov 2023 07:04:16 -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 S1377886AbjKCOEH (ORCPT + 36 others); Fri, 3 Nov 2023 10:04:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377777AbjKCOD6 (ORCPT ); Fri, 3 Nov 2023 10:03:58 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54965D48; Fri, 3 Nov 2023 07:03:55 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpQ0R1Xz1P7pS; Fri, 3 Nov 2023 22:00:46 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 22:03:47 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 11/18] mm: memory: use mm_counter_file_folio() in wp_page_copy() Date: Fri, 3 Nov 2023 22:01:12 +0800 Message-ID: <20231103140119.2306578-12-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:04:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781551868673664460 X-GMAIL-MSGID: 1781551868673664460 Use mm_counter_file_folio() to save one compound_head() call. Signed-off-by: Kefeng Wang --- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index d35ca499bf1c..661c649afc22 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3158,7 +3158,7 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) if (likely(vmf->pte && pte_same(ptep_get(vmf->pte), vmf->orig_pte))) { if (old_folio) { if (!folio_test_anon(old_folio)) { - dec_mm_counter(mm, mm_counter_file(&old_folio->page)); + dec_mm_counter(mm, mm_counter_file_folio(old_folio)); inc_mm_counter(mm, MM_ANONPAGES); } } else { From patchwork Fri Nov 3 14:01:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161310 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1055877vqu; Fri, 3 Nov 2023 07:04:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHdFpiDZq12FcsQRTlJ/0PxypeimPeGnsGSuzmHrZIT89YGMunu0zKh4WG+Xkk0rS3c3hr4 X-Received: by 2002:a17:902:cecb:b0:1cc:4ff3:c837 with SMTP id d11-20020a170902cecb00b001cc4ff3c837mr14690344plg.68.1699020266949; Fri, 03 Nov 2023 07:04:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699020266; cv=none; d=google.com; s=arc-20160816; b=i6EnZ7QPGlcJgq1ZEmBcIdCQgip5c4L0sqkQxZWkW8tVBJ6n7dUddioPKL+EZUyydc BDaI1IQt+8+Nh3lnuMjmAG85Q3+z7tD/hISGRdjWHRRA3hV+pR9HGq1vRZxJZCrIZqh6 sr2jd7QBT3RDgaQYYUAKKeHmTKK/Nt2rDSOJIrJH3L8yjAITuUxW0MU5AaveAgy85FU7 DpVkywuQsynwANSu14BxGDPhaKR805Aq4/iAovEN/x3doqoHOKqHQJlna8I0atbYU8J4 faSSYMEYmhSr66xQZnYi1PKNVrh9LpYo3pq5L1u/ml6R9BRzAQq6xXYtxVeKOn3hWsU6 kGsQ== 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; bh=OeTPIw8gaHpYgTEOA5d0ZjkKIpqPK2yWIYgWH1aKTeY=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=GUtq1N5mh+vwSizK93MG5UnyBKEiVwry8uA3cFvdZl+ixUPfh0XhwK7wMk2Ln+Ac9q f5cfCgppMntFO1WXqeQVlYX3z2dO2OgB0dl+1lx2qNSf76RcS1ClnAxx85sNQ8qOFB5w 0Gj75LXt4c8lu9QUhyG8VAMbWlbw+j4TOK4kHjZj5yL2Xvysk+Xxm7hhGgbcZ3ZJkPno 8DtfuuB2T4Hs/jDiqk5uiwvD267eC9g/BjPhVCnkcmcQ9v+xf4UtKWmxUFTOl+vmdM7t uSEROt2sb4wpHIlgjIBuYk9MNbkqA2CSeNnHf1VmnscErE8qKGaH9rywXsLph6+mfoLN AZdQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id lb7-20020a170902fa4700b001c0cbaf6970si1505736plb.501.2023.11.03.07.04.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:04:26 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 74DE882CB52D; Fri, 3 Nov 2023 07:04:25 -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 S1377899AbjKCOEL (ORCPT + 36 others); Fri, 3 Nov 2023 10:04:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377788AbjKCOD6 (ORCPT ); Fri, 3 Nov 2023 10:03:58 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 791ABD4C; Fri, 3 Nov 2023 07:03:55 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpQ0kJMz1P7p6; Fri, 3 Nov 2023 22:00:46 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 22:03:47 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 12/18] mm: memory: use mm_counter_file_folio() in set_pte_range() Date: Fri, 3 Nov 2023 22:01:13 +0800 Message-ID: <20231103140119.2306578-13-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:04:25 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781551874986554923 X-GMAIL-MSGID: 1781551874986554923 Use mm_counter_file_folio() to save one compound_head() call in set_pte_rang(). Signed-off-by: Kefeng Wang --- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index 661c649afc22..2d90da70a1c8 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4414,7 +4414,7 @@ void set_pte_range(struct vm_fault *vmf, struct folio *folio, folio_add_new_anon_rmap(folio, vma, addr); folio_add_lru_vma(folio, vma); } else { - add_mm_counter(vma->vm_mm, mm_counter_file(page), nr); + add_mm_counter(vma->vm_mm, mm_counter_file_folio(folio), nr); folio_add_file_rmap_range(folio, page, nr, vma, false); } set_ptes(vma->vm_mm, addr, vmf->pte, entry, nr); From patchwork Fri Nov 3 14:01:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161314 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1056117vqu; Fri, 3 Nov 2023 07:04:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFjly/TOLu2bPMJApltLTcVjKlAClFwfMJW/Dak17/L0rengWGBC/keGyudjof4TlZiD3ga X-Received: by 2002:a17:902:c641:b0:1cc:2bd9:1b2d with SMTP id s1-20020a170902c64100b001cc2bd91b2dmr14208602pls.43.1699020282363; Fri, 03 Nov 2023 07:04:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699020282; cv=none; d=google.com; s=arc-20160816; b=bph77xvCYvanOHEHbgFeDgC1evMPBx9epNyNP2m2WTDcbfmuBpz2IFqXBxXqYqfF4M UbfIWdYVL2YOQ7f2yO3kae/X7eJCh4oxwKapGzba4LTggU0wlt7GJxN6HSS4He6B169a jujmRBHaYrAIcrVHv/Cro5h7MulpPfkxNHqXBBN/vrtxHYI4tDwD7c9uqe/psihW+ucE b9tlM13Ky14cbYAl0eFfq2oszPusfMCYQjVg3T5EzHsE7884siOUJuAbH4GTXBeqI5K3 ZphdRoySYfukO7CPpbmGymEH41jyKNPcdu5qLPXQZGHOBOmqMCdtZ9h5AOVeNxZf2v08 ryMQ== 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; bh=MdhMIc9GunfmcgvY7/8IJnElK+TVJK6hHFkN45VneUA=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=h6Z7jHjPczcGr2pGR8Ijx7zF5d0679+zqk9cbf5sBQF7RT0B/WOzC67WdOvq5I5n/N hgMwgEcCcaRKvVknUYvyHX4s5WbA18NPgiPTr63DJ0uMNh24WnK+90iWAPrJzGx543p0 e4MQE7f0H4fWCGsT3ssQiQ4ZTrmGBqOAv3i8e0YoBU+o5LzasZ3Xjw8eMc7vqAnEragl Cc+ENdcWe52vso8HinoW6DENjM2J+dbJQc7UpXFB1WPjNZbiHCqrpJ6kGjTHmbTNwFIV 6u4cVbT91qhR2xoh05HMtMf+H3foyu44qOLARhZo10owN0SYBwHOFhzpp33ih7Q9UBzP gzcg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id kg15-20020a170903060f00b001c62d93585csi1485122plb.611.2023.11.03.07.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:04:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C669182CEE46; Fri, 3 Nov 2023 07:04:32 -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 S1377864AbjKCOEO (ORCPT + 36 others); Fri, 3 Nov 2023 10:04:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377848AbjKCOEC (ORCPT ); Fri, 3 Nov 2023 10:04:02 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EEE8D4D; Fri, 3 Nov 2023 07:03:55 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpQ12P0z1P7pT; Fri, 3 Nov 2023 22:00:46 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 22:03:48 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 13/18] mm: memory: use a folio in insert_page_into_pte_locked() Date: Fri, 3 Nov 2023 22:01:14 +0800 Message-ID: <20231103140119.2306578-14-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:04:32 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781551891342277063 X-GMAIL-MSGID: 1781551891342277063 Use mm_counter_file_folio() to save one compound_head() call in insert_page_into_pte_locked(). Signed-off-by: Kefeng Wang --- mm/memory.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 2d90da70a1c8..584fe9a550b9 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1845,11 +1845,14 @@ static int validate_page_before_insert(struct page *page) static int insert_page_into_pte_locked(struct vm_area_struct *vma, pte_t *pte, unsigned long addr, struct page *page, pgprot_t prot) { + struct folio *folio; + if (!pte_none(ptep_get(pte))) return -EBUSY; + folio = page_folio(page); /* Ok, finally just insert the thing.. */ - get_page(page); - inc_mm_counter(vma->vm_mm, mm_counter_file(page)); + folio_get(folio); + inc_mm_counter(vma->vm_mm, mm_counter_file_folio(folio)); page_add_file_rmap(page, vma, false); set_pte_at(vma->vm_mm, addr, pte, mk_pte(page, prot)); return 0; From patchwork Fri Nov 3 14:01:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161312 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1056037vqu; Fri, 3 Nov 2023 07:04:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGtnw4vZog/vwGexu+Ot9Rd5zNRWNWdmH3o2XZHc50Cj0xuejzeLJ9f0ThVgZvtSVEGZFsq X-Received: by 2002:a05:6a20:4c05:b0:171:8e16:ea83 with SMTP id fm5-20020a056a204c0500b001718e16ea83mr17007420pzb.29.1699020278164; Fri, 03 Nov 2023 07:04:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699020278; cv=none; d=google.com; s=arc-20160816; b=KOKZcqwoHx5jJS6wGydqUTwN61+K3vEiZx0MV9AuQcRUKwdFBachPXeGp5yh3h+21j AV7ZoVLc4iX/D6yuSx++imc2tr0Rs879xu2fUeNLF7dBwiOTTrg2y11c1MSjpC1BeP6W T87UKuxUV7D4W9obUfmAZrMha3Fy4seByt/9LISYyL567g38AbW3O+b7s1CJ+fEq23vk PSGdKMMubt2ala5L4uTLqBET5rxvvJF6H4MsCuf1I4qUYsBcnilnCPxlqCt/YeglDFOz 7yjm7q/aBJ6jEGnqrQILALqjMSgzkjMcxYGAxnB6BCongxuK3InSKlUb2g9jX3RYbpF/ DL4A== 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; bh=81LlqxtowmFJT9OO5iZTzQqQILthz4G91XTOFcyCEIY=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=uMg+fl72fIYkirgn96y5QpAdatQQeCDG6aFUV9lQQav7Q/JdR7bp/iypzuBLPnE373 qGyuEE8K9RLKq+lMOoJVm1NnVT5TYGXvvATFZnolKueah/kSyGm9JWKkkTlnCAUsB+GX 4wrvS+n1i7qGsRh38+bjKlSb+wvToGTdaRem0aNtUeIjUwg98V/y6qcBLJmJiAFd4Yph V3+y+f3XyahW78y/WoTi7pLXmdzVKB74UBlrOQ84lFurmg8P/5HdEZcsnnQzgk8t2Qdu PX/z3LcekHiGrk3tFS25iOOqceXJpve3bMlRNX/fc1hxT/s7X+Tlj+SPhKvoXHbwLFPr yLBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id y14-20020a656c0e000000b005859e224617si1628683pgu.818.2023.11.03.07.04.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:04:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id DBF2482CC426; Fri, 3 Nov 2023 07:04:28 -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 S1377791AbjKCOEM (ORCPT + 36 others); Fri, 3 Nov 2023 10:04:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377781AbjKCOD6 (ORCPT ); Fri, 3 Nov 2023 10:03:58 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F403D49; Fri, 3 Nov 2023 07:03:55 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpQ1KByz1P7pc; Fri, 3 Nov 2023 22:00:46 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 22:03:48 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 14/18] mm: remove mm_counter_file() Date: Fri, 3 Nov 2023 22:01:15 +0800 Message-ID: <20231103140119.2306578-15-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:04:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781551887241330591 X-GMAIL-MSGID: 1781551887241330591 Since no one call mm_counter_file(), remove it. Signed-off-by: Kefeng Wang --- include/linux/mm.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index f5f76504b212..9353c5709c45 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2583,6 +2583,7 @@ static inline void dec_mm_counter(struct mm_struct *mm, int member) mm_trace_rss_stat(mm, member); } +/* Optimized variant when folio is already known not to be anon */ static inline int mm_counter_file_folio(struct folio *folio) { if (folio_test_swapbacked(folio)) @@ -2590,12 +2591,6 @@ static inline int mm_counter_file_folio(struct folio *folio) return MM_FILEPAGES; } -/* Optimized variant when page is already known not to be PageAnon */ -static inline int mm_counter_file(struct page *page) -{ - return mm_counter_file_folio(page_folio(page)); -} - static inline int mm_counter_folio(struct folio *folio) { if (folio_test_anon(folio)) From patchwork Fri Nov 3 14:01:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161316 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1056459vqu; Fri, 3 Nov 2023 07:05:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWrMVo291Z6iqJc9vN2iFnmvqWEjX/1sW3EulrpkrVWlaKFs+eewUOlcWxBWkQdB8J5lta X-Received: by 2002:a17:902:ec91:b0:1cc:3bfc:69b1 with SMTP id x17-20020a170902ec9100b001cc3bfc69b1mr16410308plg.24.1699020303524; Fri, 03 Nov 2023 07:05:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699020303; cv=none; d=google.com; s=arc-20160816; b=E2XiNpE4yXoSEmeSfDvh3fm7NSqUDvn8r1KNnmzaElBu53u5JQlqIXRmhygVQBzuft fu1ulZMmTqHAwuu4oWSazspN9CphM7vUXau2fRxkyL12VTYXjauOEKG3E+e9bvjmHXH0 D0wlvZakVsZ6eGn0NgbTPkNH+i8ElfS/xja+k50vJf8Wtw8YUV09g72K/mEyPDQyzD41 Ae7c+0R8XaC9EeOywc8hVXloeyoj/luDnxQ2/4Kq29klsuR1Kg1KMpLUg5jU+wYQVWpR +rrPDvgm/+cO2E0uUVM4jfk5WHJCxau/VdW013gltV7W5sLhnYQjAe0yjBSqtCy2jGgN 9ehA== 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; bh=ecal4P50fwrAghsjzr7+jLbx0qZqwlf5MiupE4LTgsU=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=OeiS88RyFv4w5ClJESt+g5VvTAW1jEMRwq6PmPdmaa3rNmBnuLLlHWKW/jS23Xhwwi pPHFIsws3tFn5gKTilbyoEg95huvgfmVXf7xKA+2+WrI52Gef6dOAe+dAgvy+CeL4iH6 vgMargpn9MCS3tuTT+ESMjHOwvP+tNM8byY3SEcuyZ991uqHfzXN3TtfgszjnBBGT7y+ WSaZ73q1VbgIsG1CafZ4vqSAvN5fLVyTt5gd3Bli4JRa6z/64oGpEAzlYeMNOHH3GrJj FHs30n0Y6M11pnMRn09LY2DTcZhzEtn6Mp7aYbeiNwMpH5/7KKUdUnpLA4Bx+GxFQNuG 5UIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id w2-20020a170902c78200b001cc2a6624e5si1503872pla.307.2023.11.03.07.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:05:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id A1EF6829F1EA; Fri, 3 Nov 2023 07:04:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377862AbjKCOEJ (ORCPT + 36 others); Fri, 3 Nov 2023 10:04:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377779AbjKCOD6 (ORCPT ); Fri, 3 Nov 2023 10:03:58 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61057D4B; Fri, 3 Nov 2023 07:03:55 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpQ1c3mz1P7ph; Fri, 3 Nov 2023 22:00:46 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 22:03:49 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 15/18] mm: memory: use a folio in copy_nonpresent_pte() Date: Fri, 3 Nov 2023 22:01:16 +0800 Message-ID: <20231103140119.2306578-16-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:04:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781551913988676957 X-GMAIL-MSGID: 1781551913988676957 Use a folio in copy_nonpresent_pte() to save one compound_head() call. Signed-off-by: Kefeng Wang --- mm/memory.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 584fe9a550b9..fcc04dce8e8a 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -779,7 +779,7 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, unsigned long vm_flags = dst_vma->vm_flags; pte_t orig_pte = ptep_get(src_pte); pte_t pte = orig_pte; - struct page *page; + struct folio *folio; swp_entry_t entry = pte_to_swp_entry(orig_pte); if (likely(!non_swap_entry(entry))) { @@ -801,9 +801,9 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, } rss[MM_SWAPENTS]++; } else if (is_migration_entry(entry)) { - page = pfn_swap_entry_to_page(entry); + folio = pfn_swap_entry_to_folio(entry); - rss[mm_counter(page)]++; + rss[mm_counter_folio(folio)]++; if (!is_readable_migration_entry(entry) && is_cow_mapping(vm_flags)) { @@ -822,7 +822,7 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, set_pte_at(src_mm, addr, src_pte, pte); } } else if (is_device_private_entry(entry)) { - page = pfn_swap_entry_to_page(entry); + folio = pfn_swap_entry_to_folio(entry); /* * Update rss count even for unaddressable pages, as @@ -833,10 +833,10 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, * for unaddressable pages, at some point. But for now * keep things as they are. */ - get_page(page); - rss[mm_counter(page)]++; + folio_get(folio); + rss[mm_counter_folio(folio)]++; /* Cannot fail as these pages cannot get pinned. */ - BUG_ON(page_try_dup_anon_rmap(page, false, src_vma)); + BUG_ON(page_try_dup_anon_rmap(&folio->page, false, src_vma)); /* * We do not preserve soft-dirty information, because so From patchwork Fri Nov 3 14:01:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161318 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1057814vqu; Fri, 3 Nov 2023 07:06:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmkFOXL4nhQRFdf3k6AyJNlDJsCK5NTHU1v6mxrkJGDeToFaVntBLeHtY3s9+4XGXCfST7 X-Received: by 2002:a17:90b:19d0:b0:268:ca76:64a with SMTP id nm16-20020a17090b19d000b00268ca76064amr18246236pjb.49.1699020390752; Fri, 03 Nov 2023 07:06:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699020390; cv=none; d=google.com; s=arc-20160816; b=nvlk5OXBzncOqlf/WXNX5VoghB1HvZCfAiEm9UkCVeVnXCMBgTOjZWlOnDa4mh/o0T U/WA0DZTc75+4TMxfsOVSdURvKeltsXUCjfwehIg4HU1cjKE9SVKP+7ko1ZfjzZw8kz0 GQ7SkB3zJyLx22kSljkO813IPrs/EZCl/BEZsBKd1CMZaBaYek++lcOZSKzfgOubvGPz APU3nfHf3/4ZKgZHa1BD5bkjE9lzzgrXF1+m3httSMIXbe9CreJqUTwyF5WDwURC6Btd geEjkN7qTKOZ+aJur5ah8WXyX/927OPXUg7HO+qZ2AFq0kI1Ya8UUk/5ZuomsuHG61KR NvJg== 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; bh=hFPL2wSMrPcu1hJjxD+4tynyVgkuYhp6u1rBQCBIGCw=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=Q1uRV1/CAyurJIWkMseX27HmHpp155r4t0df2vuhSiVtp1oVd0Q4fSMfA2PTez3baH Q6mZ2A7uS6vBut0RPLVaC6d1OvQsVwDwnX7Xrf60w7vf2fNMmfVYNgYX/gjEvrrb9i0j bpCmhvgfJk3Mll0n7J4mxIIv/FmPu963F6hewpkBFVLmCVtCu+lgRg8PNsif4wszbmwg GNs8smUwliykh4roinL73rnyMEhVnAQkckVmzuo72wf+rFWh9Vwb0Dz8KQBurg3t9xJw AY1aM25rElV9NilgMqS5Mynv1qPHRBIEn879UPgkMMIh2YAU97DRj6T5vpn3pWkbY5oq urVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id d23-20020a17090ab31700b002803e9ddb0fsi1736376pjr.129.2023.11.03.07.06.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:06:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 8BD87808D482; Fri, 3 Nov 2023 07:05:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377928AbjKCOES (ORCPT + 36 others); Fri, 3 Nov 2023 10:04:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377860AbjKCOED (ORCPT ); Fri, 3 Nov 2023 10:04:03 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9242D4F; Fri, 3 Nov 2023 07:03:55 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpQ1tzNz1P7pq; Fri, 3 Nov 2023 22:00:46 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 22:03:49 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 16/18] mm: use a folio in zap_pte_range() Date: Fri, 3 Nov 2023 22:01:17 +0800 Message-ID: <20231103140119.2306578-17-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:05:25 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781552004935148531 X-GMAIL-MSGID: 1781552004935148531 Make should_zap_page() to take a folio and use a folio in zap_pte_range(), which save several compound_head() calls. Signed-off-by: Kefeng Wang --- mm/memory.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index fcc04dce8e8a..9b4334de9bf0 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1358,19 +1358,19 @@ static inline bool should_zap_cows(struct zap_details *details) return details->even_cows; } -/* Decides whether we should zap this page with the page pointer specified */ -static inline bool should_zap_page(struct zap_details *details, struct page *page) +/* Decides whether we should zap this folio with the folio pointer specified */ +static inline bool should_zap_page(struct zap_details *details, struct folio *folio) { - /* If we can make a decision without *page.. */ + /* If we can make a decision without *folio.. */ if (should_zap_cows(details)) return true; - /* E.g. the caller passes NULL for the case of a zero page */ - if (!page) + /* E.g. the caller passes NULL for the case of a zero folio */ + if (!folio) return true; - /* Otherwise we should only zap non-anon pages */ - return !PageAnon(page); + /* Otherwise we should only zap non-anon folios */ + return !folio_test_anon(folio); } static inline bool zap_drop_file_uffd_wp(struct zap_details *details) @@ -1423,6 +1423,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, arch_enter_lazy_mmu_mode(); do { pte_t ptent = ptep_get(pte); + struct folio *folio = NULL; struct page *page; if (pte_none(ptent)) @@ -1435,7 +1436,10 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, unsigned int delay_rmap; page = vm_normal_page(vma, addr, ptent); - if (unlikely(!should_zap_page(details, page))) + if (page) + folio = page_folio(page); + + if (unlikely(!should_zap_page(details, folio))) continue; ptent = ptep_get_and_clear_full(mm, addr, pte, tlb->fullmm); @@ -1449,18 +1453,18 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, } delay_rmap = 0; - if (!PageAnon(page)) { + if (!folio_test_anon(folio)) { if (pte_dirty(ptent)) { - set_page_dirty(page); + folio_set_dirty(folio); if (tlb_delay_rmap(tlb)) { delay_rmap = 1; force_flush = 1; } } if (pte_young(ptent) && likely(vma_has_recency(vma))) - mark_page_accessed(page); + folio_mark_accessed(folio); } - rss[mm_counter(page)]--; + rss[mm_counter_folio(folio)]--; if (!delay_rmap) { page_remove_rmap(page, vma, false); if (unlikely(page_mapcount(page) < 0)) @@ -1477,9 +1481,10 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, entry = pte_to_swp_entry(ptent); if (is_device_private_entry(entry) || is_device_exclusive_entry(entry)) { - page = pfn_swap_entry_to_page(entry); - if (unlikely(!should_zap_page(details, page))) + folio = pfn_swap_entry_to_folio(entry); + if (unlikely(!should_zap_page(details, folio))) continue; + /* * Both device private/exclusive mappings should only * work with anonymous page so far, so we don't need to @@ -1487,10 +1492,10 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, * see zap_install_uffd_wp_if_needed(). */ WARN_ON_ONCE(!vma_is_anonymous(vma)); - rss[mm_counter(page)]--; + rss[mm_counter_folio(folio)]--; if (is_device_private_entry(entry)) page_remove_rmap(page, vma, false); - put_page(page); + folio_put(folio); } else if (!non_swap_entry(entry)) { /* Genuine swap entry, hence a private anon page */ if (!should_zap_cows(details)) @@ -1499,10 +1504,10 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, if (unlikely(!free_swap_and_cache(entry))) print_bad_pte(vma, addr, ptent, NULL); } else if (is_migration_entry(entry)) { - page = pfn_swap_entry_to_page(entry); - if (!should_zap_page(details, page)) + folio = pfn_swap_entry_to_folio(entry); + if (!should_zap_page(details, folio)) continue; - rss[mm_counter(page)]--; + rss[mm_counter_folio(folio)]--; } else if (pte_marker_entry_uffd_wp(entry)) { /* * For anon: always drop the marker; for file: only From patchwork Fri Nov 3 14:01:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161311 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1055909vqu; Fri, 3 Nov 2023 07:04:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjX1TW6ufVUhKsF7nkADl4nsxkggbqsRBmDvZAh4m670PKfbBQR5byGvpo5TGJ4zSRxZ6N X-Received: by 2002:a05:6300:8084:b0:180:d81b:65e0 with SMTP id ap4-20020a056300808400b00180d81b65e0mr13330659pzc.3.1699020268863; Fri, 03 Nov 2023 07:04:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699020268; cv=none; d=google.com; s=arc-20160816; b=Kj1nNDhQzkiTinZR33CpoebgCG1FY1yLMXl0bvSvrpGRyfTXqhHuuiYIYZOyUIlxId WkWmvAH7ySAfrQgUGQNKK17YzOFmzs7lpph6R3xfWoXl3ayZ6SzPvu7lvzPpIC6kfwF7 fDczNq2ViA2UXkXCcRRZMsxV3P8fei1PFBcHxWAm8fWGTWomjbwoJPXS0xJkAeV/pExR iK9EtOOPTd1Gt4aOr3/TtprHW6E000JYRCRguHjPJ0OtBP18YkSSfxc87Uc1wl0TycX9 yQDyuqnvNdOpRH7RLWqhARdnJU1yQaUh0bhmpJ7GYBr+2iFTdhMYlVtYsfsNw8Ytrna8 XHpg== 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; bh=ACB6BvRM+b+Bk9pCuWZqJNSMpJoUalDpqlkAQM+jcRA=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=AZlhzIOt7/QmoSBy0OVhFlsYsk3YFtjjVAvTqJrU0mKgi42entHb+hiL87WSIo4J24 HswE2rEojBbhg3P7pWuME56prlsoAyWF+V7/lc3hl5PRaKQqsfEliq5bIxhhhrLyBwVw rUMobqh+P6C1L607WO5QMpPs3O5baq3KT8SIFPevh6V3JuXrz7ZiMnNTNkID2HpXSxVK JSeF+/b8RlTTnGm1PN76R2NYG59r27r8trwLo4aiAWXwEBYs3rmEFAfa6VAJi+iIXI6d eZQQlPcpkhA1LSnAJ5iHAuFU85T51OUFJ5fGEmvGS+kr78/LI57R+ixN0u061c/zBJPC B/hQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id o185-20020a6341c2000000b0057d7cff25besi1545060pga.829.2023.11.03.07.04.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:04:28 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id BCCF4803E4B1; Fri, 3 Nov 2023 07:04:13 -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 S1377878AbjKCOEG (ORCPT + 36 others); Fri, 3 Nov 2023 10:04:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377813AbjKCODz (ORCPT ); Fri, 3 Nov 2023 10:03:55 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4703AD64; Fri, 3 Nov 2023 07:03:52 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SMMpP56DszrRgH; Fri, 3 Nov 2023 22:00:45 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 22:03:50 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 17/18] s390: pgtable: use mm_counter_folio() in ptep_zap_swap_entry() Date: Fri, 3 Nov 2023 22:01:18 +0800 Message-ID: <20231103140119.2306578-18-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:04:13 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781551877201669421 X-GMAIL-MSGID: 1781551877201669421 Use mm_counter_folio() in ptep_zap_swap_entry(), which help to cleanup mm_counter(). Signed-off-by: Kefeng Wang --- arch/s390/mm/pgtable.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c index 3bd2ab2a9a34..f4a53f5b0bcb 100644 --- a/arch/s390/mm/pgtable.c +++ b/arch/s390/mm/pgtable.c @@ -730,9 +730,9 @@ static void ptep_zap_swap_entry(struct mm_struct *mm, swp_entry_t entry) if (!non_swap_entry(entry)) dec_mm_counter(mm, MM_SWAPENTS); else if (is_migration_entry(entry)) { - struct page *page = pfn_swap_entry_to_page(entry); + struct folio *folio = pfn_swap_entry_to_folio(entry); - dec_mm_counter(mm, mm_counter(page)); + dec_mm_counter(mm, mm_counter_folio(folio)); } free_swap_and_cache(entry); } From patchwork Fri Nov 3 14:01:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161313 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1056085vqu; Fri, 3 Nov 2023 07:04:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGKpRPJUUb7t+6PbNIt7Ti4mLanoOBXwbUiAVJf2u02b5W7TZfMPElMQmccO+h15h2PJeW X-Received: by 2002:a05:6a20:3944:b0:181:8654:8260 with SMTP id r4-20020a056a20394400b0018186548260mr5783838pzg.39.1699020280812; Fri, 03 Nov 2023 07:04:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699020280; cv=none; d=google.com; s=arc-20160816; b=ABlWABOeI4yiyZTp0/yzSAoeLZiaOzVdDUsQM92xM92HtdJuMSltPNCwSOxdMWiKIg 4nydvzkBgHgatS3JGjbqSSw7nRpgCUS7WOVIRyHWwTu2Ic9DbBgYl2LsBUh0acsp7stQ HzfZPOkXpVBGZGuvqVkMX6EnyAzjBl6om0Ufnl/s+1gN9O0b0kW3H7fdPyngTLN2mY0I AP/G5BBh9wbUg86S6ylWliThHwtlSNOnmTDb9l6N9X5Upg/L8iVwkHdt/O3g4nhU/JAh oe8Yv6P1RL0EI3ZBijU84tMDlR6aLPgBc3DJfa+nxdg5skSIVbCzLi9pv+LEm+z6pTOp 5kBw== 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; bh=bT9rjnlJIBzoJO+q+XewwA19nOTPGvaL2JFKF5wptBI=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=yVAr6aoiBJx/0Qm4JEgcM+7sDaBANPBQ0kGbsu5YUfeVNitbXrC6tUqrwIxkmbUnJD wLebGedoFJbe8b9PXtnR4JC//ghtb3ripj418SUnx9TN5moE6PMu31Wkh3Sh9uBtWFw8 za+O+airuEO5QZsRUqvi9mojwQbWQX3wa2WSejI1K0bXmbjElkW7/DEkYKwzFWCbGcWh 6NurXY6RSUz6j7qkPQ5y84V8wd0eCAf8I1dZa2wr++Uo4jUQn4eFeLAxIDpXqTn5t80J kw5vjl8itMkfjKYgFqoLuP8MXfW29rs9JBXImOvept49kK2RoH6GspHNTR9zb4SjOD5/ XXpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id j12-20020a056a00174c00b0069100de2235si1623091pfc.187.2023.11.03.07.04.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:04:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 756B382CC431; Fri, 3 Nov 2023 07:04:31 -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 S1377911AbjKCOEQ (ORCPT + 36 others); Fri, 3 Nov 2023 10:04:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377806AbjKCOEC (ORCPT ); Fri, 3 Nov 2023 10:04:02 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA5E4D50; Fri, 3 Nov 2023 07:03:55 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpQ6QHWz1P7n0; Fri, 3 Nov 2023 22:00:46 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 22:03:50 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 18/18] mm: remove mm_counter() Date: Fri, 3 Nov 2023 22:01:19 +0800 Message-ID: <20231103140119.2306578-19-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:04:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781551889697432665 X-GMAIL-MSGID: 1781551889697432665 Since no one call mm_counter(), remove it. Signed-off-by: Kefeng Wang --- include/linux/mm.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 9353c5709c45..fd1a27bbdb53 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2598,11 +2598,6 @@ static inline int mm_counter_folio(struct folio *folio) return mm_counter_file_folio(folio); } -static inline int mm_counter(struct page *page) -{ - return mm_counter_folio(page_folio(page)); -} - static inline unsigned long get_mm_rss(struct mm_struct *mm) { return get_mm_counter(mm, MM_FILEPAGES) +