Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp816973rwb; Wed, 28 Sep 2022 09:25:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7DUmhRAxk/nL/rV5UWhKrKC9t9aPPRCYWPQdpvCDigBfcFgBKkZBGnjFIAL/GaiXzq/sya X-Received: by 2002:a05:6402:2743:b0:453:ce66:56c8 with SMTP id z3-20020a056402274300b00453ce6656c8mr33245602edd.157.1664382318505; Wed, 28 Sep 2022 09:25:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1664382318; cv=pass; d=google.com; s=arc-20160816; b=Om7wxCT2/VqU78S+L9vfoEoRjULwRUowZD51EYb4JtjgA9+fkgxDwkVXZG9z1GZJ/d 1NWXA+6X4o6sxlZJNJ6hs2l09YBszCm4I+pHRpd+cQDYU1iTYSQtKjFw+Z6wmk5+Dwdf TQjFmds8W9TDGxlMEg5gmo/VlLaCtwZ9M2iXHPJfqJXWujX7p0CKzBMV1nnbvYsRC7BK bF+yBZ+vwuXnAZ7DbRBP+TJ57Y5mEWGACSXS/g6PsncbipAc/SciGrYEJcp1QM70ma1g R+e40Kryh7ZngCAizdMH47IYrYu93PBbw7mwnyQZlkLJuh/nXyiUKltAwuGrJ7o4GTBF W79Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-id:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature; bh=XUJmyCi0B3H+vL2e0NDxdiHnxd7q0zFClWiHQIU4DGk=; b=qGcN1jPjrL2x1wpDXA9zjIQen2Bch0qnh5MR7fm+FrW/hiskTwmvlr8YI7eEL17Yl8 KT7RQ3Mk3QkEAZCzJFcBGUz+4Qv7sfzu1QRRQb8zCYURlgx/h/baBQbIr5lVVXFayVKX 44ZeSOjex1IBCdD3JCRUU9pUXyaTFLj1gabJuA2OL0WV05qBcjYWJplB6Kbkn5ekJ+48 Qs0bDrfvUJMU9Dp0s3J8wrtUse4RPKzmvNQQApJ8qnMHkFohiJ4wPPI6XrofnB4gCpRM 9Hr+RY/uwflS9UnHyGy5KD3tir2Bul5DBbxDl/235lLVhxEWTQ7zar5jEnl13mH1j4xH 5qCA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=Zbb8P8Ds; arc=pass (i=1 spf=pass spfdomain=fb.com dkim=pass dkdomain=fb.com dmarc=pass fromdomain=fb.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y15-20020a056402270f00b004486d3bcacdsi6086940edd.5.2022.09.28.09.24.52; Wed, 28 Sep 2022 09:25:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=Zbb8P8Ds; arc=pass (i=1 spf=pass spfdomain=fb.com dkim=pass dkdomain=fb.com dmarc=pass fromdomain=fb.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234603AbiI1QXL (ORCPT + 99 others); Wed, 28 Sep 2022 12:23:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234534AbiI1QWo (ORCPT ); Wed, 28 Sep 2022 12:22:44 -0400 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36112E6DE9 for ; Wed, 28 Sep 2022 09:22:39 -0700 (PDT) Received: from pps.filterd (m0148461.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28SA8bhs000802 for ; Wed, 28 Sep 2022 09:22:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : mime-version; s=facebook; bh=XUJmyCi0B3H+vL2e0NDxdiHnxd7q0zFClWiHQIU4DGk=; b=Zbb8P8DsewPZjPFe6Mu015maHObVAdlGoksqRfFbjX8CIvMn2J2pFEewOz1uHHSyVAEH gwtV1TSGv+ZYG4ihihdx1aIWLEQfmHnNf6pxnI8qjliV3GLGf+xayEri34eoeg9KVTYq huCOd+opiNqTsiVxnBeaj9RYR2Z9Yp3dBoo= Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2102.outbound.protection.outlook.com [104.47.58.102]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3jvg973kxr-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 28 Sep 2022 09:22:38 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jWp+zIJlhtOsN4wWSjX5zlJefib76KgqXjmqeY/o60y+FltsfZcz7ikdYIMjNfX6Ig1HkVUGabDY3GQI91UdkoIBNz+475K63K46KVsye7XbUJBN/dEUgykPQ8hx7M0kzO+QsHAae+DJFPlbcVEEAK8kgwgXLSAMsP/k2Q6QTgwr/U6gNG9L+0/BhAwednENasI6rRWwS88777NDyh7H5CC2hJxW1/WFOCOnGyGXtMn1nbs/Q38Mqswa1RVVWCrfO5bFJM5hVy9WBsPol1s3IIj1f4KaYgQycdAeIJ6x4miN9A9U2Wt4Dan3GN+AJ1xUvixpRlbn5njCMH8mBwPuVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XUJmyCi0B3H+vL2e0NDxdiHnxd7q0zFClWiHQIU4DGk=; b=aJ4E075RI9ooUr5F4DVD2Cqb5YcHaV6xVJwzhM1/igu2KQGFYVacBpt/BEi68j1fZoUc5olQo6Mc9VTpLFQofU0Rg68DXt+HkWjPGHdWYVhWBXgSrDjluxlvgpYF0JHODB3nQZduydiyAtJgPP7pV2eCipKVAcIC5E5iWxlu2E2EtqHNe09AOw+//TOZYpLa0bf+yEhTprWvOWubQRGd7Rg9H1WmPLbQmeWngxizhZQMQZHU7MLq3v4dODj0eM1oLxlEPEujP9g7QhPCWrqo+CrbU6HFZBbLUQ4VLdLowsU+C5t487SfXXcUXS5LxkAahpe3XaDNyuIcfe1WBHNJcw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=fb.com; dmarc=pass action=none header.from=fb.com; dkim=pass header.d=fb.com; arc=none Received: from CY4PR15MB1734.namprd15.prod.outlook.com (2603:10b6:910:19::14) by BYAPR15MB3430.namprd15.prod.outlook.com (2603:10b6:a03:107::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25; Wed, 28 Sep 2022 16:22:35 +0000 Received: from CY4PR15MB1734.namprd15.prod.outlook.com ([fe80::fc7c:15c:9a61:e445]) by CY4PR15MB1734.namprd15.prod.outlook.com ([fe80::fc7c:15c:9a61:e445%12]) with mapi id 15.20.5654.026; Wed, 28 Sep 2022 16:22:34 +0000 From: "Alex Zhu (Kernel)" To: David Hildenbrand CC: "linux-mm@kvack.org" , Matthew Wilcox , "akpm@linux-foundation.org" , "riel@surriel.com" , "hannes@cmpxchg.org" , "linux-kernel@vger.kernel.org" , Kernel Team Subject: Re: [PATCH 0/3] THP Shrinker Thread-Topic: [PATCH 0/3] THP Shrinker Thread-Index: AQHY0wWiHnM2ldg5NkO9z8Pn4WWMYa305SCAgAAh24A= Date: Wed, 28 Sep 2022 16:22:34 +0000 Message-ID: <73C02F96-49C7-4C1F-AF10-F6A61F1D68A4@fb.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CY4PR15MB1734:EE_|BYAPR15MB3430:EE_ x-ms-office365-filtering-correlation-id: 62360618-bfe1-4cee-16a9-08daa16da6d3 x-fb-source: Internal x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: NgLsJnYB/m+V2Yvl1rX9d59GByjbUhKT1CKTBEQe/VogVWDFBm3xlVbuBCzm348TnlkcLlDE5jIMTOrMIB+lznYg9IgukL7h0cMeA/xpSHflQqE0RXvoxcK4l05PkaW6UebI94uXr6LyKfwXox8ajijnH6xoGRPuogJLHolUVAERKHTFXPHb/coIGOL0Fn6FOVR07nM9UB5vttFhRj4xu9iY2HTRipA8PGSSsIEPERUaOaafHf7BzUHz2UBUqxYcHgtMTj2za25G6MiPHc2CEW0jXz3smrO201UUCw5Qh95uXTKuUltjXquCZmu/DyvbHHoF3FOplOYd64LMk+qwZLicNrv1imObjZZpKYrdsLCKdwLCMPhzfmM5hELCrLcLJ/wruwwvYoT9xMS53N0A8qKoHb0NZ3ToihYawmXiUNfQAO/XwSD3lrrsm8VEomYX2BzE/dFEV3j1gs76RacG1MJRKL/3Zm8BKLLWGRDJp9tLpxcUlLyyZwP/T4n0vVj5kVdKVW9/wP5AypC/gUs23Zg3/1/Art4DluecywHUjzS24Vce8UZRDrV+KSSh+Hz1OoobtewNzONdVIrLQ/Z1EwHxpWip0QUEnPscuYAZemWNVyT8uKbQUDCDP6fEPZVgtL/d7YK6iDna7MFaf1hxmHyZO6qGww3R9iXJCOjK/CbQI31EG/NUOFRBWe8FzeXShBguPTqNuLiem1jg/FW56yIbJ8iH+x8ho77jE+WMXOHPzmDdOY2zjvw4dad0O4YGpphEf78c4KPGW759fK4Ri2MBnpJ+iUXShQW0PdsYUno= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR15MB1734.namprd15.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(346002)(376002)(366004)(396003)(136003)(451199015)(36756003)(41300700001)(186003)(6512007)(2906002)(6506007)(8936002)(2616005)(122000001)(38100700002)(5660300002)(38070700005)(6916009)(83380400001)(86362001)(33656002)(54906003)(6486002)(71200400001)(478600001)(4326008)(316002)(8676002)(66446008)(76116006)(66556008)(64756008)(66476007)(91956017)(66946007)(45980500001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?KYqxgSEZKY+ITuoS2uqORK4VmhkXjojfcJs6yO99aDXz9Xk2iQ8ueE4In9l+?= =?us-ascii?Q?eWwyQFPa335Q9TVGSJ9Q7q6H5mFoJpIol9rTubgkrum4kgIrwqc1FdUZ8NN4?= =?us-ascii?Q?o6aHgxwVrenN8USTnWLzM6OrRSMxWdRpJoHgQTlcoW7wgJt/AHZFs5ULYJis?= =?us-ascii?Q?vU3zfh5etza79A/NoRuGLVe01AosomhNHLXl1ylsxbJ7+q+R1IAuxO9Xdoxu?= =?us-ascii?Q?JlzIarEz98YslcOvRFXFigWiU65nP9kjxe5c8X9q2uL2Zd6buGqjAp1Xbp4B?= =?us-ascii?Q?buomHeV6c+0ciM+KUF4GpruAhwEkn45RP28lV5qhwOeMWZEzprrKeV3504Ul?= =?us-ascii?Q?Cxz6PYtZmHnkYHR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lKEy6ze85?= =?us-ascii?Q?S8j+r+EYhZZwcRAQrbdzS4rwCfDHICjZlgtMQma+DEDNR9F6sbGtR7AKwREu?= =?us-ascii?Q?jsqPbjhU1Si4TW+kc8BdWQxidUl7oyrJZDCxUGCvrMG+QJyehcsekqsnuj/4?= =?us-ascii?Q?GGWkuIOnraiGujbTwM9fRwRWxtazGh8FuKNHorJ4sBRSpptLSxhaR+AR/Jd3?= =?us-ascii?Q?/O5IQul9UMernV8h/83jJ/LdeVyGigX0JPTgjh70EfQqOmnQRqtwGVnWQODR?= =?us-ascii?Q?OUFQod9CMUSj1cfXCP0VaXBuHEw9C9MZlpXWstFvreZiwqlPKIui/az6YVN0?= =?us-ascii?Q?p3Sw7t9a9DmBTkhd6LjVb75KgmaaWf9efrCUsn7aYF7it+LcShP6mFcDbFn5?= =?us-ascii?Q?UI3h/luUlY24srVW98rVhBQ=3D?= Content-Type: text/plain; charset="us-ascii" Content-ID: MIME-Version: 1.0 X-OriginatorOrg: fb.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CY4PR15MB1734.namprd15.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 62360618-bfe1-4cee-16a9-08daa16da6d3 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Sep 2022 16:22:34.8549 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ijjixC0bEqff9kYqplGacedvUkifzWM51/1lH8G9PHJbl2d4212F1wUd7VxMjLxn X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR15MB3430 X-Proofpoint-GUID: i4W5bj3yOKBhNd5WIywyArZSM4PY4r5t X-Proofpoint-ORIG-GUID: i4W5bj3yOKBhNd5WIywyArZSM4PY4r5t X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-28_07,2022-09-28_01,2022-06-22_01 X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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 Sorry about that. The diff to the RFC: -Remove all THPs that are not in the top utilization bucket. This is what we have found to perform the best in production testing, we have found that there are an almost trivial number of THPs in the middle range of buckets that account for most of the memory waste. -Added check for THP utilization prior to split_huge_page for the THP Shrinker. This is to account for THPs that move to the top bucket, but were underutilized at the time they were added to the list_lru. -Refactored out the code to obtain the thp_utilization_bucket, as that now has to be used in multiple places. -Multiply the shrink_count and scan_count by HPAGE_PMD_NR. This is because a THP is 512 pages, and should count as 512 objects in reclaim. This way reclaim is triggered at a more appropriate frequency than in the RFC. -Added support to map to the read only zero page when splitting a THP registered with userfaultfd. Also added a self test to verify that this is working. -Only trigger the unmap_clean/zap in split_huge_page on anonymous THPs. We cannot zap zero pages for file THPs. Thanks, Alex