From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS, T_DKIMWL_WL_HIGH,T_DKIMWL_WL_MED,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4C23C433F4 for ; Fri, 31 Aug 2018 20:35:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 570B020837 for ; Fri, 31 Aug 2018 20:35:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="GRYuzrFq"; dkim=pass (1024-bit key) header.d=fb.onmicrosoft.com header.i=@fb.onmicrosoft.com header.b="NaKJtpDe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 570B020837 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=fb.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727664AbeIAAo0 (ORCPT ); Fri, 31 Aug 2018 20:44:26 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:47068 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727245AbeIAAo0 (ORCPT ); Fri, 31 Aug 2018 20:44:26 -0400 Received: from pps.filterd (m0001255.ppops.net [127.0.0.1]) by mx0b-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w7VKLfFX027542; Fri, 31 Aug 2018 13:35:10 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=facebook; bh=0blCr1ii/BVavaAvJV4Yrg734i8h8nbutQIIPDVXq6w=; b=GRYuzrFqt1BNh8+whNRfSwh59yoolTOrkEdCRQKtqhQI1VSRnJ+5V1Aw0LC4yelFGfHq UfgdAZhj7vWk1LlveWED0AZJoEI5oH90RzbUw4TIpq5GkwnDEkO+dc1/zEEQZ6wP0htS vHePei+ctRLvpVBe9s/tj7TujzxFGrU9K7o= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0b-00082601.pphosted.com with ESMTP id 2m7b1w0bjx-2 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 31 Aug 2018 13:35:10 -0700 Received: from NAM03-DM3-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.24) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 31 Aug 2018 13:35:09 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0blCr1ii/BVavaAvJV4Yrg734i8h8nbutQIIPDVXq6w=; b=NaKJtpDe7A8DiOrZCkFH6t+oWhcmjfongFm54ESq4prnwVjLZAyNYRLqqVjqPg5OSe9O+xbpWGgtll6rqW4S7Ur4R9VF67Yt80o/D/zzRzYo2IzBy9QGtvKSuF3JpAJ4HUK+ijuKy2/IGYvXEygftyNgHlgaG5nP4T8IPctGbKI= Received: from tower.thefacebook.com (2620:10d:c090:200::7:2c8b) by SN1PR15MB0176.namprd15.prod.outlook.com (2a01:111:e400:58cf::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.17; Fri, 31 Aug 2018 20:35:06 +0000 From: Roman Gushchin To: CC: , , Roman Gushchin , Josef Bacik , Johannes Weiner , Rik van Riel , Andrew Morton Subject: [PATCH] mm: slowly shrink slabs with a relatively small number of objects Date: Fri, 31 Aug 2018 13:34:50 -0700 Message-ID: <20180831203450.2536-1-guro@fb.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [2620:10d:c090:200::7:2c8b] X-ClientProxiedBy: MWHPR15CA0041.namprd15.prod.outlook.com (2603:10b6:300:ad::27) To SN1PR15MB0176.namprd15.prod.outlook.com (2a01:111:e400:58cf::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e8a89e06-edc5-4582-f4aa-08d60f813d37 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:SN1PR15MB0176; X-Microsoft-Exchange-Diagnostics: 1;SN1PR15MB0176;3:PBQlfuQyELZ6oM/lZqXvwtbcMgSkMxPxaaHx3OgjI9AsJS5V9Dst8XGXsHlgR1LFVZt7L3lgmjzYoJmrmgQxX0nRLNhZpRi1sWRdTxGIkSyab+o9gUgJ73o0PiRw5DNUMh0He7YTYQ+37jMckHwlAGUx/EaVKHYcEXxZfj1y3b7RfKeNcXOzv4VRoaYxVK7YGwqLBpl1Bet3Ds7sW4lPi6WHcYTsoiqv9L61ZDm3VrUEyAAJfp3BTu/fNoK1JNUT;25:9O58YtpVj757YqCKjo2s0LkE48TWznxx3z/brG59y8HIAIkt0yGcg9p6Mq8RFUWk51Gtn+ovo0wyc1PqIXIoY7tVzI4cAkjYekxI+//r3OGbAfylxofHUKHejCC1fzNB9VR9GlVhxxwkG/eSsrMSLPu0t43Zyakw52S8d9XrDHZbRBz1ek4c8f767a7kl0zfNkljwzXc55WFuqdzwex9VMsAExj5vOk/UW/dOZrGWhrcBflRqSg6rMdnAtZBUKcIx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JqrK0cswnLPDr+s2HRGqWuPtWtcChfHfVCdol8vUxI4/8gwJ5/zNFZT9Z10OKtkVAx6FbLVjMOi8umbOiNmVmCxRiwynYJmmYItmcOBpFi6YQOewE0bUky/IqWUN6xFE3WSizL1Y41kmOZK8 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(67672495146484); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(823301075)(93006095)(93001095)(3231311)(11241501184)(944501410)(52105095)(3002001)(10201501046)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201708071742011)(7699016);SRVR:SN1PR15MB0176;BCL:0;PCL:0;RULEID:;SRVR:SN1PR15MB0176; X-Forefront-PRVS: 07817FCC2D X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(366004)(376002)(346002)(39860400002)(136003)(199004)(189003)(476003)(46003)(2616005)(16526019)(5660300001)(6916009)(6666003)(69596002)(316002)(54906003)(1857600001)(6506007)(486006)(47776003)(52396003)(16586007)(14444005)(51416003)(52116002)(386003)(186003)(86362001)(7736002)(2351001)(106356001)(2361001)(53936002)(105586002)(305945005)(6486002)(53416004)(2906002)(8936002)(6512007)(8676002)(68736007)(4326008)(50226002)(1076002)(97736004)(6116002)(478600001)(36756003)(25786009)(50466002)(48376002)(81166006)(81156014)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:SN1PR15MB0176;H:tower.thefacebook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN1PR15MB0176;23:788Dqy/2QgGDi0HCeOpxz4oj1t4JG3XfStwcFIlPJ?= =?us-ascii?Q?ivlj8f/99AADj+PuJR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xvWumZziZNBg7OvviY0+muxXrzMDZh+V89cLlQVGhJMol1Hrj7JR8oINoS0bAx6cWtfYo3HZoZmsWF9ouVnRrHHu+4zQKqCzMfQTqj3Gri4ZLmgIwhnU+mnHImQPDlB5sQFD2RB/0kA50sBQQ0bpBadtvDBlGHMUI+mZ05RyfYmghZ9oRHjvh7yd5o0lOQTSOUHVN1yndD6+7rz6YvylgmsegC8G4a0GYAk1ttAmh3hxC8KN8fnsw==;5:jw2zg+HbnkExiitgnd0CoPZmmZIr199JZM/4IebDc13gB8pxQG8Qz/Z8w6oVGtgOV37FGf4r5FSAXUrld6YPiMIu9POJBSejIyxDlmTNFo8dXYc3aYQaq2hQyoHgCqXI5EKdh8lSvfHNGwoOpLNn3+tsXSWOhf+3eoqkxrvWYfU=;7:1C47Y/VvqwIV6hJjVVndKoxqWJiNciDUfAifmHaHEaZ74X85QteboSXRflpyXvNr886mStGX5OA9AJc7txE1FNXgdU7CXBTOD7rz+BYwjZ7SbNnHhpSiLrXH+t48HebuycYB29CtqlFMJ/ZCeBML3xcDgcebg7dYZSVR2ffl+djMtb7Fl22xzypU7FEgUHhgxIY20Sd8TNXi72ZZ4MONMteXHixtqG7ORd1/JR57XdEjhqUtmm5JBkNvM+TEnR1T SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;SN1PR15MB0176;20:XvV9d6k19ocTXACBoCqdEhQa8bBRoeEj5lJA5xrlWhAw//bwUBYd4jquGeAjjVVgAHtPn5KdstGrNDJxpqDLg3OwsvuyPR90IYevBVlJ0VM+/vJ53j1XAXSdjgasOpCH7LHPc+mbcBfo9TxT054cOF8cgKbKcBz1qpv2orCIlsM= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2018 20:35:06.4152 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e8a89e06-edc5-4582-f4aa-08d60f813d37 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR15MB0176 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-08-31_08:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 9092c71bb724 ("mm: use sc->priority for slab shrink targets") changed the way how target the slab pressure is calculated and made it priority-based: delta = freeable >> priority; delta *= 4; do_div(delta, shrinker->seeks); The problem is that on a default priority (which is 12) no pressure is applied at all, if the number of potentially reclaimable objects is less than 4096. It wouldn't be a big deal, if only these objects were not pinning the corresponding dying memory cgroups. 4096 dentries/inodes/radix tree nodes/... is a reasonable number, but 4096 dying cgroups is not. If there are no big spikes in memory pressure, and new memory cgroups are created and destroyed periodically, this causes the number of dying cgroups grow steadily, causing a slow-ish and hard-to-detect memory "leak". It's not a real leak, as the memory can be eventually reclaimed, but it could not happen in a real life at all. I've seen hosts with a steadily climbing number of dying cgroups, which doesn't show any signs of a decline in months, despite the host is loaded with a production workload. It is an obvious waste of memory, and to prevent it, let's apply a minimal pressure even on small shrinker lists. E.g. if there are freeable objects, let's scan at least min(freeable, scan_batch) objects. This fix significantly improves a chance of a dying cgroup to be reclaimed, and together with some previous patches stops the steady growth of the dying cgroups number on some of our hosts. Signed-off-by: Roman Gushchin Cc: Josef Bacik Cc: Johannes Weiner Cc: Rik van Riel Cc: Andrew Morton --- mm/vmscan.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/vmscan.c b/mm/vmscan.c index fa2c150ab7b9..c910cf6bf606 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -476,6 +476,10 @@ static unsigned long do_shrink_slab(struct shrink_control *shrinkctl, delta = freeable >> priority; delta *= 4; do_div(delta, shrinker->seeks); + + if (delta == 0 && freeable > 0) + delta = min(freeable, batch_size); + total_scan += delta; if (total_scan < 0) { pr_err("shrink_slab: %pF negative objects to delete nr=%ld\n", -- 2.17.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt0-f197.google.com (mail-qt0-f197.google.com [209.85.216.197]) by kanga.kvack.org (Postfix) with ESMTP id CEC236B58D2 for ; Fri, 31 Aug 2018 16:35:13 -0400 (EDT) Received: by mail-qt0-f197.google.com with SMTP id b5-v6so15946410qtk.4 for ; Fri, 31 Aug 2018 13:35:13 -0700 (PDT) Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com. [67.231.153.30]) by mx.google.com with ESMTPS id i33-v6si5352326qtb.238.2018.08.31.13.35.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Aug 2018 13:35:12 -0700 (PDT) From: Roman Gushchin Subject: [PATCH] mm: slowly shrink slabs with a relatively small number of objects Date: Fri, 31 Aug 2018 13:34:50 -0700 Message-ID: <20180831203450.2536-1-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain Sender: owner-linux-mm@kvack.org List-ID: To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, Roman Gushchin , Josef Bacik , Johannes Weiner , Rik van Riel , Andrew Morton Commit 9092c71bb724 ("mm: use sc->priority for slab shrink targets") changed the way how target the slab pressure is calculated and made it priority-based: delta = freeable >> priority; delta *= 4; do_div(delta, shrinker->seeks); The problem is that on a default priority (which is 12) no pressure is applied at all, if the number of potentially reclaimable objects is less than 4096. It wouldn't be a big deal, if only these objects were not pinning the corresponding dying memory cgroups. 4096 dentries/inodes/radix tree nodes/... is a reasonable number, but 4096 dying cgroups is not. If there are no big spikes in memory pressure, and new memory cgroups are created and destroyed periodically, this causes the number of dying cgroups grow steadily, causing a slow-ish and hard-to-detect memory "leak". It's not a real leak, as the memory can be eventually reclaimed, but it could not happen in a real life at all. I've seen hosts with a steadily climbing number of dying cgroups, which doesn't show any signs of a decline in months, despite the host is loaded with a production workload. It is an obvious waste of memory, and to prevent it, let's apply a minimal pressure even on small shrinker lists. E.g. if there are freeable objects, let's scan at least min(freeable, scan_batch) objects. This fix significantly improves a chance of a dying cgroup to be reclaimed, and together with some previous patches stops the steady growth of the dying cgroups number on some of our hosts. Signed-off-by: Roman Gushchin Cc: Josef Bacik Cc: Johannes Weiner Cc: Rik van Riel Cc: Andrew Morton --- mm/vmscan.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/vmscan.c b/mm/vmscan.c index fa2c150ab7b9..c910cf6bf606 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -476,6 +476,10 @@ static unsigned long do_shrink_slab(struct shrink_control *shrinkctl, delta = freeable >> priority; delta *= 4; do_div(delta, shrinker->seeks); + + if (delta == 0 && freeable > 0) + delta = min(freeable, batch_size); + total_scan += delta; if (total_scan < 0) { pr_err("shrink_slab: %pF negative objects to delete nr=%ld\n", -- 2.17.1