Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp227739rwb; Wed, 9 Nov 2022 23:18:55 -0800 (PST) X-Google-Smtp-Source: AMsMyM4ls+lVAORMEjlDcZNg1lh3dCM3Ybjsl/zdxXqljZ1SqKuSWk5F+e+Ptcl2/v48Cb8OQHkP X-Received: by 2002:a17:903:50e:b0:182:631b:df6f with SMTP id jn14-20020a170903050e00b00182631bdf6fmr63576613plb.66.1668064735101; Wed, 09 Nov 2022 23:18:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668064735; cv=none; d=google.com; s=arc-20160816; b=Wf6eBOzFPktCkT6eZ9fWYyy/1SGLGABAkT8MB0EpuHejwGNs9AKvMC2JZz4WGUpSAj 5jihbCj47KNzRA/ZC15MzCNq45B96O/+UMsY/XzZ5lL3dXHLITowo4mB6SfMDAeD8cIR vo3RGILNMZr6SzJUreqwV7VpQyfkQ5kAU7Dg0lwzd5jjbPPu+fQXvf9Q5A89AL3INmTc NX2bYnXKYGsnu7IxUOHBrYznrFrfjfqrVBgWhSHtxbMlepRuVlYZhFD24bBwqtWXfwYY Uq05cIy8uImJykpoqhZe7i0wW8fP3jHQrZSDGINPfvuynoGLqwznrDXidcZfJyK+BX2r RngQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=EWxKRFOmKADNnzF1Aod+jnkWVfK1/B27gMLsjTAJHmQ=; b=JcacNNVR3azt/0UHz8NiztwVBnEtrqUKguni4IUcG0n/AHOySH4ux8UqDgToYe1vKS w3Cc3WW32tK/IjN2+9CSx8t8uFk5z/DtKw+gdDYVmahSNAaTVsCkY4gG8YLCs1gcXoUi UywJakQkWmvkpROBTnqNsMqfUise+Wofttp6uyJAsu9hbVw1OjiCiDW4w07CIBIYphJI sVM0z75AlcQtKtDVKBjSDG1cm2ox3yeZdp5ktvrVsiL5x0FMVVhH/5i1jgVqb0GZHSnT xcfvE5HESSZXXihb0QWvqzRTfL+xxFs9x7f21t+tWneqtE4BEuTiqH3nvkCgZfhd6sIt wdtQ== ARC-Authentication-Results: i=1; mx.google.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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pa9-20020a17090b264900b002136ad22b32si3725916pjb.39.2022.11.09.23.18.42; Wed, 09 Nov 2022 23:18:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232711AbiKJG5J (ORCPT + 93 others); Thu, 10 Nov 2022 01:57:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232704AbiKJG5H (ORCPT ); Thu, 10 Nov 2022 01:57:07 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 718D42F38F; Wed, 9 Nov 2022 22:57:06 -0800 (PST) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4N7CHG4qjLzJnZY; Thu, 10 Nov 2022 14:54:02 +0800 (CST) Received: from kwepemm600003.china.huawei.com (7.193.23.202) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 10 Nov 2022 14:57:04 +0800 Received: from ubuntu1804.huawei.com (10.67.174.175) by kwepemm600003.china.huawei.com (7.193.23.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 10 Nov 2022 14:57:04 +0800 From: Lu Jialin To: Johannes Weiner , Andrew Morton , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song CC: Lu Jialin , , , Subject: [PATCH] mm/memcontrol.c: drains percpu charge caches in memory.reclaim Date: Thu, 10 Nov 2022 14:53:16 +0800 Message-ID: <20221110065316.67204-1-lujialin4@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.174.175] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600003.china.huawei.com (7.193.23.202) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When user use memory.reclaim to reclaim memory, after drain percpu lru caches, drain percpu charge caches for given memcg stock in the hope of introducing more evictable pages. Signed-off-by: Lu Jialin --- mm/memcontrol.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 2d8549ae1b30..768091cc6a9a 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6593,10 +6593,13 @@ static ssize_t memory_reclaim(struct kernfs_open_file *of, char *buf, /* * This is the final attempt, drain percpu lru caches in the * hope of introducing more evictable pages for - * try_to_free_mem_cgroup_pages(). + * try_to_free_mem_cgroup_pages(). Also, drain all percpu + * charge caches for given memcg. */ - if (!nr_retries) + if (!nr_retries) { lru_add_drain_all(); + drain_all_stock(memcg); + } reclaimed = try_to_free_mem_cgroup_pages(memcg, nr_to_reclaim - nr_reclaimed, -- 2.17.1