From patchwork Thu Jan 16 14:22:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiguo Jiang X-Patchwork-Id: 13941744 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC246C02183 for ; Thu, 16 Jan 2025 14:24:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 620646B0082; Thu, 16 Jan 2025 09:24:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D1176B0083; Thu, 16 Jan 2025 09:24:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 44A086B0085; Thu, 16 Jan 2025 09:24:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 283FB6B0082 for ; Thu, 16 Jan 2025 09:24:25 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C7E2A160D6B for ; Thu, 16 Jan 2025 14:24:24 +0000 (UTC) X-FDA: 83013535248.18.BDDBE1C Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2073.outbound.protection.outlook.com [40.107.255.73]) by imf17.hostedemail.com (Postfix) with ESMTP id C20A540013 for ; Thu, 16 Jan 2025 14:24:21 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b="YWuBm8/d"; spf=pass (imf17.hostedemail.com: domain of justinjiang@vivo.com designates 40.107.255.73 as permitted sender) smtp.mailfrom=justinjiang@vivo.com; dmarc=pass (policy=quarantine) header.from=vivo.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737037462; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=crrv/tOdc2eByuj1Fn39dy0uupovD94Fz5rUmvlwxDk=; b=n/22zid0qerEZs+lWzX1SJYih4VXVFiFc2EdZLwe0gMZJXNffPURkuibQnaS5LrN8W9ObQ 9hPx5KLNzHO9MknRkun6/zq6aIi8s4YUiF9cEgizLui36mc+Kazcqd21/B1juX7fKsEvJy 84VjJhUfxMN6iT8wm1cY/AcdkEFsZqs= ARC-Authentication-Results: i=2; imf17.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b="YWuBm8/d"; spf=pass (imf17.hostedemail.com: domain of justinjiang@vivo.com designates 40.107.255.73 as permitted sender) smtp.mailfrom=justinjiang@vivo.com; dmarc=pass (policy=quarantine) header.from=vivo.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1737037462; a=rsa-sha256; cv=pass; b=6/rMKYV03lWr6QdwLq7csbt+ld962DamH1qIMciTtUr2fymJM+vZ6KHGccj8gsQMDkwVHx 69YvwQ2x8jaflxGgnMz+A5iLyYJyHE1B3DrEH+6XzYNMQ5kpyeAgH7XQrHMeujvk0PUvhA XfjR2ljWLKrHHXH5NF+etZVuJ1Lb0A8= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RMf9RImoB+xOrT9nBuIl6pILzDMeT+a74iRSDU2MqJrT24Lb7jZeDZFjLrCXBYyUjxkY66KIANbtK6vNdR7olzmQmEeK1LLQmiSSYMbciWcX3B2+x5tlWorY8l7piGESTgGu67ZYPTBAAS1vOu3sC2K8UMTZyMvivT1ugT4lzhPD0hkh7RvPMq7LfGAmmXdnsUvKHr2qcn/dLMxizgXMfZOkDipXVKqkqYszdOCab8avyYimL/mcwpHMRYSSoKQ9Ok/LtCl1dNP56lytgg4K8ZKbyxO4STzXAfgRn9k59nslmVZpP3cgGtUH73Kuei9Blgv+m71HGxriOuMOBXGpsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=crrv/tOdc2eByuj1Fn39dy0uupovD94Fz5rUmvlwxDk=; b=y+JMLIjWefP8twaiJxbP/Qge2q45zwm7MVLG62ul8IO7Tvcr75F1bw5k18fVxTU9Brm/nP9dbltAVT/U9ZIyYEd5Vja5TiouJYhzLtp9569kPNCWN8y4+mIeuxHuWWc3bcLXzvanumyEmCxW+CJMWqsYt1Uy4zMR3yR1tSIQ1Wxeeo7PMFJGqPigcU+YqsKRglWmtuGpWcB6qH5sNCWzpD9hA3AT7vR9a+zMbMUwi2dcUUX+9MG5ir6XR7JCZhAuUQj24d0AxHhPtgZ6DIB+rhHbzzGve1qZkOx0wcP+5+t8K2c0kq9QE/ybKjJjzcL8rCarsOg13MfY4pNi2NW94Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=crrv/tOdc2eByuj1Fn39dy0uupovD94Fz5rUmvlwxDk=; b=YWuBm8/d9c3/9gqDwGqeHAMvMqi7jMsmxS2BVnujy0ydDVlCNQOz/GqFzjXsSgZvpgLvhUA6aHxi91FT8g7+qtvoyNw+ztTM5h83vm8VSMKwB46A5j7AsuTfU3Q4Vd5gS/9ECxVA6vEWmcIL1Pg7FzB5Uwc4L1oWFjzwCYRSPT90mQtaCaxSZiEUtuciabgx8vQ5ukIeGvmMHF/zxvLnP1jLmPFzIJ1lUmfvQS6GLZngsBUj+Y2AoYUP8FXL7VnC4VUG9xBwV0MqkFmQ27J3LCkweZyHmakGagFgr9fiQFZR41Y7O54TAq7XOiNF5p/mSOIb3VJCo/c+17gHR3qE+A== Received: from JH0PR06MB6849.apcprd06.prod.outlook.com (2603:1096:990:47::12) by SI6PR06MB7101.apcprd06.prod.outlook.com (2603:1096:4:248::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.6; Thu, 16 Jan 2025 14:24:16 +0000 Received: from JH0PR06MB6849.apcprd06.prod.outlook.com ([fe80::ed24:a6cd:d489:c5ed]) by JH0PR06MB6849.apcprd06.prod.outlook.com ([fe80::ed24:a6cd:d489:c5ed%6]) with mapi id 15.20.8356.010; Thu, 16 Jan 2025 14:24:16 +0000 From: Zhiguo Jiang To: Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com, Zhiguo Jiang Subject: [PATCH] mm: memcg supports freeing the specified zone's memory Date: Thu, 16 Jan 2025 22:22:42 +0800 Message-ID: <20250116142242.615-1-justinjiang@vivo.com> X-Mailer: git-send-email 2.41.0.windows.3 X-ClientProxiedBy: SG2PR02CA0002.apcprd02.prod.outlook.com (2603:1096:3:17::14) To JH0PR06MB6849.apcprd06.prod.outlook.com (2603:1096:990:47::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: JH0PR06MB6849:EE_|SI6PR06MB7101:EE_ X-MS-Office365-Filtering-Correlation-Id: 5032659f-4372-418b-6b64-08dd3639751d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|366016|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: 1N+CB9aB4c6EyyYjhF7E8nz0W1RcWmTmolIWCdwOl7OWoE8Hq/3jVWFi8sqnNb31YMLXwDCKgbEHFW43Y++L2y6Qn5yBqBXYuVjmXX2/Kezgr7/VVJG2BrQ6Y5sb9/0z5q6rgQGYkEnTVgQ8tpbjrhMMZ+c/WCT4Jenk1N6+teqt8uj0W6//0tZaVYLGqi3wTRQlBScEeyUCS7ffVWADT08qv20RV/pDyQLgwsZIuSIYYiMOckZFvyqSd8afDxVpLnCy7Zuq1isPNSZmp1E10wb1NQDW4v85OvD2AY2f0nPN80wTEJJSSZgWeptoQlIoMSRbdBSP3wxQUvTth/t2pWIdyWP++q88SHnrI4ekN353YdFM/FQjzIRnnBi66EraUY+W+TuTCku3khhsXHyNkr4G89yJoykG+IjW8OMjnPT5hi0LfufwkvQJfDcuURD9cl2S0OKmE/FCX6q1MEMPvuas7CHhS3809si1vr2ZGD+sTuDTuKMAFVW//E491STmxgN8BSiOjRXkJsG1YBw/oRl/yDx5LvS9SwpLp9g5mVLfsUhMqICeosCRk8zcIpZ8tvJkeoXER95zsJQRw+WEkA4HBDVQ9Pr556vNIDLAB0yg9VBVoeyOKg7XdD5U9F8kvyM0txPwNU4GSpTQGj0XhDAZdRs5i2KOI3i2SjY5fc9EdHhHx+crv4U7PLJ075WPijpxBEZrCEBEowv5WeZNhqJ+n7MkQ36AP5wig41BlzVMLXRsoo36q5JJlYJK+/ZSo6mLvSjA9kM4uW9ulWmIyl8OfLodlAwY6x6cNxEVqNh5ffXFuaSI0SXetITbq23C4nosLhrAlPh80+/apqbJuFdGVJVmN0PUz5qUp2PfEq71Yc0CBZxq3sz+gdPJS+rwT80/Za4qm9q9M7uZS4HUKnYj71V2jlGxDRC9G1ZTR1xzGpr8hdXTgh2vGXi76nClDPn9lRLg8Nb41X5ynKx/z80kH1S8iz/jwMqiLCfXd6v2WMPHAmKWRlsA8JFzbj3bMaCWpyWYOltihRJajafvgH0ICq0lxi4HdBUiFKWUA0R5srf7K0DiogVmsn8TkyK1ZksbpwB+4E0LtVaZATLay32ZX2ZFnEQCN/+ZSY2xwgJZatIThsdS8bL+5RSbvCoWJm7HKmlZJodBNRuQezoD0dUlNedNWDfq04uu0203tD3HEDpLd4o9TnggHP8gG7tejKZ14B6CsLVmMkwZHv71nZDca8Jdl0L3wwFpGNHEQVynmPH3gRMY8XWSJM6sSP/Z8KZKmLq0deNwW9G2cRCor6hG1/ocRHH0Gok6mDXzoPYIJsIyd81RBqWtxwy1u+lRKvElxe0eyct5Ubn4+wfBi4ypD/0sY8ObFYu7NFNDcRfm09fYm7778uxGkaCpIDlr6EPxj1vrOhFC8a1lDM3iHrke5HE34qYLDVezZB4R94BxjC5r5hC2SvnUA+tuhw6L X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:JH0PR06MB6849.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(366016)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FDZUYp4kchBVwLCpV+uZm56c6qwbMJWIc2PHXuCNNNC3DQpytHiwDwJsqG/OK81d0YWoIP8FZyKBxWNB0JJhKnbwYjxbxXj9K70LNgvvwebQyjxAqRdcnb6N+WB91e1/DZfdNU0zFsNYWoVaqNPbYKyjHV7n1t9AzM9cyErwAi3Rue8oYgd3GedAytce9L83VeYoZM4McIT2J6QHEJQX66AyJfHJw1V2q2z25M6UagIDlfc31QT1JlZEbeuvo09c54kOctqKYIDBYb8yr3olwlc5ez/iu3r+T04fDhiBQXanzA4KAxHibouKhFdcqGII7ny+WZpkyBnfaTyyVg7PxsuVv4fKoM9xNK9an39al5BwW6Poxe36IGqTzT0JJqRviSEocPE1Wlsk/49biYojwJm+wbiZq5rr8dr1H16Sc/TbOlqP5kzxvjJK59O1FZfFujFVLPhkvgfS04gDwlTT6iRDwXwjNH93I6z/fMiRk2h7yxhJwC+IQHhqIPY/nXVfIILLeuIf2Uzuvsz6iGKTrXR0r3Fi0k5pqP8nIjDNva1cnWMKAjlf2DtMq/h7feT/jgQLRp5wNFdi+ZC/YEOX4h2CoYxJOut+klZM6nxwUduzWAqhsX0XUn5p1voCqV1iNWBI0Rpz3Hd1NkDd6H23C7xhqPdHoAy1gAIl2mOUbcEv3SRSlcQkEWTx6XQc0eXy66redPYZwkwzYLF4xsUrTi7IDAowTEnP8TZQ7cbVhgSy2ZDIol673gNCUJS1gojMTvqvb2OK03x00BoqwPgkBAVazL6RYBF11XZWsX4h/0Bn1TYT7yhlvor44712JKVJHySM7TMbWoSSrvxYBkIW67iR/CCwOz2XjcZqNJR/k/Rx7+KhMf3tJQ4LcONWDN3ShhhSFYo5YOZBawifhK8v9iCdzrBtsJ9Yl+8+ZFx9ntwlh8NbyfoC+mqRKu7iRK4v/QwDtIt0aE7TWuzfFE623ZRZURaKwwYzXdva6bgt3hcB+XRw6tOEkMKbgLNnNmoImlbUpwZLYe8OzDVLq/TJ0dGXulgaGFwoEI072tBsNpqg5ZxkgyyPoqVRDrcONAXEVIjZ9uSY4+QyOfMz+ARk2m1dFzFiMmyQ7IQ29sbaR3mhfuWjkty+vmOLD2Madtp/Xso6BkQ/sOZJHv0T0Y/9hm7r+cN3dic3TrzI4MyM5EOnwnyK8s3KNmY3OMHH3W6TrstixZDC3R1DCQrVlw3jz88pQWZ/jy9vTcniHP8mHJk+e32MiH2QwlHF/xuQQZwLED2MdbfPUA/lpfT6Pcq9/d0/ynxHIBswasd6cZbELugmKLipMPFwMVbXCtisHAiyQWVmzTk40dTKl2YJuG283LZmlqCBKlzM/E6wZ+NOBDhM+OmJGuJFR+2uW52JLFqmbBlgwCW+fiQNJUzmnEDTzoDCA/3RcP4Lhuc66VN9NZsFvRIog/QAefxMEEiSGz5WozOZZnS7E2gYyxWq1VMLufw3OyTLaVxEvDERNnDe7cb4P+0WLYdvo3rSOV4eRpPoUjO29X03+kvSnyhjGKQNLvhZ3KbICBcn2F1nI0lqYLbVTpCiNmL63gdtCDI2G57N X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5032659f-4372-418b-6b64-08dd3639751d X-MS-Exchange-CrossTenant-AuthSource: JH0PR06MB6849.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2025 14:24:16.3606 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iGQZoVSshmWSQXb5xDeIWucR5xQl7K+t8lB8yjkvmR1mPBQocwxdBR+VuCMPmmfvmV5IJkt5u3I6eAPjpHAKvg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI6PR06MB7101 X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: C20A540013 X-Stat-Signature: xpf1u6863qobfeyrht5ogf4rf8xf5djh X-HE-Tag: 1737037461-94994 X-HE-Meta: U2FsdGVkX184dbMzGucqCntzXnDnpq4XcJemQ3YCF3OMGS5RzbLr0BAE03GCvOo3+xstImZeTRcBiOfrRVIHzjYG+ljVz3AG+ASyrFx/9kO2ojRW38OPAA9Mz7FrltphAh80x5472UGEI+xj+4mpLupt1y72UI1aiZ7AFsMX5VxWbpLezr0sTkjMk7mXTxjC+//MgUCogkOqsp2MCshvgS7G7pMHTngTO3YDHNuL6nV0MfYP0OieAH/VKYiKXP94+TuFVK+8qgPordbcEhSDd6sAyOd1qhUeg30VLEzIv0kEr/dreBNh68I0AItUnLVRxO+xENIBm5f9EsHvZ6uNp4waBJdZrpQm3Ky/EMjd2WV9zgqGzDDBZXHq+TLYHxUPicAiE950bv4+8tbtsaKRgkp+cV+3LkXv4URrcBlyqfgIGugiksCWThBD8meMVOOY6gw+2ToN9W/ARM9vQqdr3usxtsM+1g0sb5aIbrkO3+VPp40SmbhRu03/Za1HnH7CSOwa71v1xYxpmjOmlJ2SYzNI1bn7+RecvoU+2GH9D6dTYvJEe8I/RwpSyxOOaShE3f8qzu0GFAq8MjIkcbL+l04i7QfRTuaiy3LEtsZISwgsvWlISsdrUQzYF2I6eJfp++1QO92UCC2XrGROyOTBFxYEnvINptwkeYpniXoUTs19rRvGoLksP8uA9O+m33fjbp3yROFs82Kx3nvVES4El3m0j1X4PyGs2xUy2xpFO834SM6Wvaxxv/yduTjF7RtJHtVLH/dl/mIotDqXZfpotUnJBkBTgivCf24gbmucJqcLTWVfKGsRaZP0SHO6uMTgbu6bnKg5jTTSuz7hiv7hxiPwem8mgK3kNCWdiHEjkltSjBw3hNBDRHYHkdUtA3DZF8CR8lSVLCp2bG/IQ17X25StANMLXcB9hrlglhAjswpzbTTOoPel+3ns0H4t4QaQPHa5MFonGAa6RQ2d2JP 2Afj9cfs zo3APJmRR37f7F7/BsJ2IhZMGcjSXGu5lUCtE30ACS258feAjMjOHWtLnmm6acajctYUhNvDnFkrz6jrt/MaKmz/iIFuWp7+8P0nYgo7pTp6uGfryYugHls6AvBXUHLyM6OAamGPI/h7wIIa90Akp+tUNGZvW3GK+SenluLpVfPy8hU/qMvlBGMF8q1NRJrGW+YABZBVKvKFAQ0Nf/CMRJpqswbL8SLYQo1o8q5TfBnYertRagBW3z7SIseOTHAPgPMXcQ/k6YZjyNdJUCFusrz903HQjZdye9SISgHDF7kmLIKmamtRpupvouzeR2HxHhnWL6PedPTvivZAyXGP4NdmdWg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Currently, the try_to_free_mem_cgroup_pages interface releases the memory occupied by the memcg, which defaults to all zones in the system. However, for multi zone systems, such as when there are both movable zone and normal zone, it is not possible to release memory that is only in the normal zone. This patch is used to implement the try_to_free_mem_cgroup_pages interface to support for releasing the specified zone's memory occupied by the memcg in a multi zone systems, in order to optimize the memory usage of multiple zones. Signed-off-by: Zhiguo Jiang --- mm/memcontrol-v1.c | 4 ++-- mm/memcontrol.c | 11 ++++++----- mm/vmscan.c | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/mm/memcontrol-v1.c b/mm/memcontrol-v1.c index 2be6b9112808..9dc398e9d5f9 --- a/mm/memcontrol-v1.c +++ b/mm/memcontrol-v1.c @@ -1377,7 +1377,7 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg, continue; } - if (!try_to_free_mem_cgroup_pages(memcg, 1, GFP_KERNEL, + if (!try_to_free_mem_cgroup_pages(memcg, 1, GFP_HIGHUSER_MOVABLE, memsw ? 0 : MEMCG_RECLAIM_MAY_SWAP, NULL)) { ret = -EBUSY; break; @@ -1409,7 +1409,7 @@ static int mem_cgroup_force_empty(struct mem_cgroup *memcg) if (signal_pending(current)) return -EINTR; - if (!try_to_free_mem_cgroup_pages(memcg, 1, GFP_KERNEL, + if (!try_to_free_mem_cgroup_pages(memcg, 1, GFP_HIGHUSER_MOVABLE, MEMCG_RECLAIM_MAY_SWAP, NULL)) nr_retries--; } diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 46f8b372d212..e0b92edb2f3e --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1945,7 +1945,7 @@ static unsigned long reclaim_high(struct mem_cgroup *memcg, psi_memstall_enter(&pflags); nr_reclaimed += try_to_free_mem_cgroup_pages(memcg, nr_pages, - gfp_mask, + gfp_mask | __GFP_MOVABLE | __GFP_HIGHMEM, MEMCG_RECLAIM_MAY_SWAP, NULL); psi_memstall_leave(&pflags); @@ -2253,7 +2253,8 @@ int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask, psi_memstall_enter(&pflags); nr_reclaimed = try_to_free_mem_cgroup_pages(mem_over_limit, nr_pages, - gfp_mask, reclaim_options, NULL); + gfp_mask | __GFP_MOVABLE | __GFP_HIGHMEM, + reclaim_options, NULL); psi_memstall_leave(&pflags); if (mem_cgroup_margin(mem_over_limit) >= nr_pages) @@ -4109,7 +4110,7 @@ static ssize_t memory_high_write(struct kernfs_open_file *of, } reclaimed = try_to_free_mem_cgroup_pages(memcg, nr_pages - high, - GFP_KERNEL, MEMCG_RECLAIM_MAY_SWAP, NULL); + GFP_HIGHUSER_MOVABLE, MEMCG_RECLAIM_MAY_SWAP, NULL); if (!reclaimed && !nr_retries--) break; @@ -4158,7 +4159,7 @@ static ssize_t memory_max_write(struct kernfs_open_file *of, if (nr_reclaims) { if (!try_to_free_mem_cgroup_pages(memcg, nr_pages - max, - GFP_KERNEL, MEMCG_RECLAIM_MAY_SWAP, NULL)) + GFP_HIGHUSER_MOVABLE, MEMCG_RECLAIM_MAY_SWAP, NULL)) nr_reclaims--; continue; } @@ -4351,7 +4352,7 @@ static ssize_t memory_reclaim(struct kernfs_open_file *of, char *buf, lru_add_drain_all(); reclaimed = try_to_free_mem_cgroup_pages(memcg, - batch_size, GFP_KERNEL, + batch_size, GFP_HIGHUSER_MOVABLE, reclaim_options, swappiness == -1 ? NULL : &swappiness); diff --git a/mm/vmscan.c b/mm/vmscan.c index 5b626b4f38af..9d198bc4e543 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -6610,8 +6610,8 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg, .nr_to_reclaim = max(nr_pages, SWAP_CLUSTER_MAX), .proactive_swappiness = swappiness, .gfp_mask = (current_gfp_context(gfp_mask) & GFP_RECLAIM_MASK) | - (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK), - .reclaim_idx = MAX_NR_ZONES - 1, + (gfp_mask & (__GFP_MOVABLE | __GFP_HIGHMEM)), + .reclaim_idx = gfp_zone(gfp_mask), .target_mem_cgroup = memcg, .priority = DEF_PRIORITY, .may_writepage = !laptop_mode,