From patchwork Thu May 9 08:07:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 10936837 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CC6F0112C for ; Thu, 9 May 2019 08:08:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF30428647 for ; Thu, 9 May 2019 08:08:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B353128928; Thu, 9 May 2019 08:08:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50F1328647 for ; Thu, 9 May 2019 08:08:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 05F346B0006; Thu, 9 May 2019 04:08:06 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 00FFC6B0007; Thu, 9 May 2019 04:08:05 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E40B66B0008; Thu, 9 May 2019 04:08:05 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id AB5A36B0006 for ; Thu, 9 May 2019 04:08:05 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id z7so1164959pgc.1 for ; Thu, 09 May 2019 01:08:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id; bh=H6pwDfurTwvymXFL+GjiNLQ/ZlmPmWdTfSv7esEAkNY=; b=V87nYxV322u8mEMtpGNrL5+t+OOcAeI0B4HAQzXELmc7K4+6SliMdx41949QbdCUpF Ht9BoXqRov0JFQ3GFkxUek/F6c5R9JGs21476GRxpYEEZdyiPGGjWblINccb33V+Wd+u h/etYkYmaUEd1T5egwp5QiUcD+k6+ZXbtQGPrJToQWkG8vPDrPh92cWvFJPEdXftdgKh mgGAMv9Em62bL5VYnpnXUuOagJDQHZ84oi0h2fH31i0FviwBqMHxLdmJ17y1FbuRkAH7 igu14BdOnMLYSKqCa1lOunXQeNuGH38s6EAssVxTe5i1mrAjluKQFB9TWVW+nELb5xKw WyqA== X-Gm-Message-State: APjAAAXSkibDOnrdUk5M+Hn5ZgnZ5hzC3gk/+eQJpH7rDE/69B0mp8Ai KlwgXtV3QbVaFRM09cUiK3B2eu5276HjpEqxi0PbYieuWSqV6R0ksy0yUazk7hq88teZqHcYa+3 3Mggqel7bdGjukm4L3HPHJNCGpmf/p7gF1TO34EcPVt3BRISkBtJraVb2JoPR/l4oEg== X-Received: by 2002:a17:902:302:: with SMTP id 2mr3288440pld.232.1557389285303; Thu, 09 May 2019 01:08:05 -0700 (PDT) X-Received: by 2002:a17:902:302:: with SMTP id 2mr3288357pld.232.1557389284307; Thu, 09 May 2019 01:08:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557389284; cv=none; d=google.com; s=arc-20160816; b=CK5jKQ7ucQsMl2t72nOYU0XuhDoXmeiQs/bWTttWXj8brEelEf0eyWJFsu71QWRN12 tb0M89iHsbhtm8mbySaKakwE2XNrEEZIlZ5lwSJrPh/pwhkf67qX7B/USl6TtSIlSaNv +NISgVqYUcsTFQlSEVAQ4JD9JrciU/pvbZMTiFG58FrgGol03sgvBUAgK7dEGqrQwbqH lnFnQezzBcWffZ0VE8Qg99BG92a7cYYBB2hqsueqQAW/L1kUby8ePsBa5aNL8KFR2Jkg 69DndtV1bP189qm6zwtl3iN1OjCRilYuEwuV0baq0gG4qZpJ4cXy8timaB9Y9ao3NWU1 i83A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=H6pwDfurTwvymXFL+GjiNLQ/ZlmPmWdTfSv7esEAkNY=; b=fKTdDYoXT0gdiZ4V5tvZsGmmDHAljsHyexBW9jCT5BKgCAsuOFBSV2/4A3yAcYdVlh tdpSqnpieIYrj30guIG0UpUxr43x63Y9/fB9ABEdJV5i5gWUlLl+N1qHlam8CWGjpoUr XJC++3e3s5xdwvud0aym++mfvk6EKQWBZ08kAM5cK6UCzgxQ9D/dWY2wpXFu6j9vtxko yzI50Ky51kpDOlhzrJrZyGRObSDdaRhx0l58Hf1l2p2xeq37sujhD5qgKCWG58CD4jTI 3pb4cdfdQoWydT7gc7KUWqwPiKTz1Q6V8/gZvQ7O1CBMKPsPMveTWPX7BX3B5tZyCsBt U62A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bA0qFJhQ; spf=pass (google.com: domain of laoar.shao@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id c13sor1790921pfm.33.2019.05.09.01.08.04 for (Google Transport Security); Thu, 09 May 2019 01:08:04 -0700 (PDT) Received-SPF: pass (google.com: domain of laoar.shao@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bA0qFJhQ; spf=pass (google.com: domain of laoar.shao@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=H6pwDfurTwvymXFL+GjiNLQ/ZlmPmWdTfSv7esEAkNY=; b=bA0qFJhQKRl5jKpJ2Zy/A310jSNANtgHJumZzv3BjUmmIzMJFsCjAgVFvq2W9JIQbe hzLCEcg2NUZoeE0JXqNclJeubBxQE0/nNWXLld7fCK9xfueGVILIcagCNZ2b023VvPTy RzUo4EGBGtaqSP8Cc5nBi0RanWSR4oOR2BjxBz50CfHCCdkqIr8VKRReGwWUGcB74F5/ 4rkB4v1upv702fGDLgI42cOojs07DGZkZ1Hzy7O10UYhVpvaOxlvbhXytrWL6kEpTjSk 25c9+yQE9PjcFMU9Cac1b51yIRaC8nWJt2MfOAluvIUse9yNXltuF87YmEDnoUkSFsRH qfRA== X-Google-Smtp-Source: APXvYqyOem3fIt47qokFydBDWrDUILZ9SZDb6yMRFMeU5NG3cpeU6HXB1BRzecjf9ThTNjYaoq8hjg== X-Received: by 2002:a62:56d9:: with SMTP id h86mr3198371pfj.195.1557389284019; Thu, 09 May 2019 01:08:04 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id d186sm1620900pgc.58.2019.05.09.01.08.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 May 2019 01:08:02 -0700 (PDT) From: Yafang Shao To: mhocko@suse.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, shaoyafang@didiglobal.com, Yafang Shao Subject: [PATCH 1/2] mm/vmstat: expose min_slab_pages in /proc/zoneinfo Date: Thu, 9 May 2019 16:07:48 +0800 Message-Id: <1557389269-31315-1-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 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: X-Virus-Scanned: ClamAV using ClamSMTP On one of our servers, we find the dentry is continuously growing without shrinking. We're not sure whether that is because reclaimable slab is still less than min_slab_pages. So if we expose min_slab_pages, it would be easy to compare. As we can set min_slab_ratio with sysctl, we should expose the effective min_slab_pages to user as well. That is same with min_unmapped_pages. Signed-off-by: Yafang Shao --- mm/vmstat.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mm/vmstat.c b/mm/vmstat.c index a7d4933..bb76cfe 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1549,7 +1549,15 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat, NR_VM_NUMA_STAT_ITEMS], node_page_state(pgdat, i)); } + +#ifdef CONFIG_NUMA + seq_printf(m, "\n %-12s %lu", "min_slab", + pgdat->min_slab_pages); + seq_printf(m, "\n %-12s %lu", "min_unmapped", + pgdat->min_unmapped_pages); +#endif } + seq_printf(m, "\n pages free %lu" "\n min %lu" From patchwork Thu May 9 08:07:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 10936839 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2493F14B6 for ; Thu, 9 May 2019 08:08:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16F9B28623 for ; Thu, 9 May 2019 08:08:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B5BB2880C; Thu, 9 May 2019 08:08:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A191428623 for ; Thu, 9 May 2019 08:08:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C20406B0007; Thu, 9 May 2019 04:08:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BCF286B0008; Thu, 9 May 2019 04:08:12 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ABEE76B000A; Thu, 9 May 2019 04:08:12 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 7754A6B0007 for ; Thu, 9 May 2019 04:08:12 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id c12so1087458pfb.2 for ; Thu, 09 May 2019 01:08:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=zE1IYQhkRVrv69+xXa1Vu4sJkBuCxayvya+FzxecnN4=; b=V0O2ZsHSqKvNqVBkEsuNjFaNPZkBJJU0B8/XUM4mhKb7e3n+zeJ0GE8fVCCf1PErFE IpzTnA3CAhDbRTZBG2TsPgaBcRCEDsipu7FsUgcy9+ArjdLHvql4Hfgt3oGhqRAOipz/ md3fwv0uKh6SlpkPIZNwKm6o56Omi6DczRYEKgBFTbFwXwiVS8DFQ2TarlEfDsfHmXZ8 uTA1zlGQKJcw1DDJxjAZHotwpEHTk9OxPjZHeqz+TFpWMrvolt6ca7fJS3XrIodfyAfH BTTvgXMEGJxhOSL+/6REmkoQyUaeQrCk5VT4QhRMksIzI5SPM17kGlbRU1KdiSs4AJ1M re0g== X-Gm-Message-State: APjAAAU2vnzw1fkBoBEyhkke8SpXUkVCjn9WE5v8ihk8m+0zWZSOD+Y9 BU0xnDYD8dNJPUZxEkTo/Pc8+yqc8tCHKpW34YDedYCBukE5lB3sL+XOws9IUD4CbWZXkhGRQXF E3wK9O7fuEwbzMALh9FXVUos1dzrdMhBz1GgEn7zJplFHCrhOmclPRU2SAMnP/3yEEQ== X-Received: by 2002:a63:4c26:: with SMTP id z38mr3676959pga.425.1557389292149; Thu, 09 May 2019 01:08:12 -0700 (PDT) X-Received: by 2002:a63:4c26:: with SMTP id z38mr3676880pga.425.1557389291058; Thu, 09 May 2019 01:08:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557389291; cv=none; d=google.com; s=arc-20160816; b=hiruvKa7mmoxUOgYJRHKUu8+PtNR+aFya58J9lN+pSRH9HQ2xxNsrIOlYl2K9aEBO0 eRGmrz724IQrJ1GPsfOLAtf7PXenFcQCFCj/HjdWXwrZiMCfxlyYaFyBahChwb0oHcmT q13T1zwC5618R2+wvFlI/JKYEcnLOLqIWEIn1H+d6V3jahqfXSuiPyfpPOaWezvwZul8 o8e4FHPHr8Te1+XvhPpjKMFDn2gEz+Wy33zNAk3TWpPS67++wcbcHwUAiJYKiFqaVHPp 9XptejZfw4xvYibyLUlrDzRY7c0mbrMfzuI+RqON+ly1/rt9lvAiT1cdetA2J7PYFDEe iKQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zE1IYQhkRVrv69+xXa1Vu4sJkBuCxayvya+FzxecnN4=; b=mvh8+DYb+bAYH4ByNzkJaaPGW2JvuAeEJ6mAIoLxyROyqc5umWTHHB6YCq7sYQsT4h NQt3ChfvH3j4/fZA9Da8lJjRQjmGI+DfyeV/WsIP1Lfu7rHbTwsSGj1cbfOoy8iuz3Gz m2benIgDUVwB5pSQj9RD+100dDpmpflo2wpwwasuGOOgCuYGWZsFHCuL3q7muT7HXquI IoPnhTNJd/dqX/hzKYS0oSLY7fNx020mQTy/rrO4jZtEI7WnbhI9e2RI7WAnbp21yaaE 5H8iekoZzFsTkD/LyHbwHpPbCD8465SpaFotc1K2pEy5l0krjm9e/XfuA8muS5wiRma+ +I7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=H4jVh1+n; spf=pass (google.com: domain of laoar.shao@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 30sor1316262pgo.39.2019.05.09.01.08.10 for (Google Transport Security); Thu, 09 May 2019 01:08:11 -0700 (PDT) Received-SPF: pass (google.com: domain of laoar.shao@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=H4jVh1+n; spf=pass (google.com: domain of laoar.shao@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zE1IYQhkRVrv69+xXa1Vu4sJkBuCxayvya+FzxecnN4=; b=H4jVh1+nvpWWdebin0Y0sDnVshQi50d0495HR7MrLtTby4cCV4Mwvvu4pI8sVMX9dI XI7EX+LDqJItIr94JxsO6jms+MqmWhC+pRDIK06gscx6etwYn4Jz6v7t7KeySigE0jmc WCVJp1TS/JtRWfraauWahbQ5A63fHW9JlXnrVQhoeNASWxOVJH8UY3w8rreTFfbYTL8s f9ZOvwrdraDgR7iaJI9iCRXGwfjxuGtk5TXAYY5Mv4LwkhPcMBShjc3zMe6H4SBvJqNB lpycR7k7rY8+l4hZRPEmj6qnVttLZZ3DrzwHaelCqTQjV3odZuNsWoI+5yAL03z6I3gk fZxw== X-Google-Smtp-Source: APXvYqwXkhhugnBjs1CmjQRx6KIxv3pohcZmSaIBWj27neW7/8K1IcXRbGSyZ6BDywTlm+2cjginpA== X-Received: by 2002:a65:6497:: with SMTP id e23mr3742728pgv.18.1557389290835; Thu, 09 May 2019 01:08:10 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id d186sm1620900pgc.58.2019.05.09.01.08.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 May 2019 01:08:09 -0700 (PDT) From: Yafang Shao To: mhocko@suse.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, shaoyafang@didiglobal.com, Yafang Shao Subject: [PATCH 2/2] mm/vmscan: shrink slab in node reclaim Date: Thu, 9 May 2019 16:07:49 +0800 Message-Id: <1557389269-31315-2-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1557389269-31315-1-git-send-email-laoar.shao@gmail.com> References: <1557389269-31315-1-git-send-email-laoar.shao@gmail.com> 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: X-Virus-Scanned: ClamAV using ClamSMTP In the node reclaim, may_shrinkslab is 0 by default, hence shrink_slab will never be performed in it. While shrik_slab should be performed if the relcaimable slab is over min slab limit. This issue is very easy to produce, first you continuously cat a random non-exist file to produce more and more dentry, then you read big file to produce page cache. And finally you will find that the denty will never be shrunk. Signed-off-by: Yafang Shao --- mm/vmscan.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index d9c3e87..2c73223 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4141,6 +4141,8 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in .may_unmap = !!(node_reclaim_mode & RECLAIM_UNMAP), .may_swap = 1, .reclaim_idx = gfp_zone(gfp_mask), + .may_shrinkslab = node_page_state(pgdat, NR_SLAB_RECLAIMABLE) > + pgdat->min_slab_pages, }; trace_mm_vmscan_node_reclaim_begin(pgdat->node_id, order, @@ -4158,15 +4160,13 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in reclaim_state.reclaimed_slab = 0; p->reclaim_state = &reclaim_state; - if (node_pagecache_reclaimable(pgdat) > pgdat->min_unmapped_pages) { /* * Free memory by calling shrink node with increasing * priorities until we have enough memory freed. */ - do { - shrink_node(pgdat, &sc); - } while (sc.nr_reclaimed < nr_pages && --sc.priority >= 0); - } + do { + shrink_node(pgdat, &sc); + } while (sc.nr_reclaimed < nr_pages && --sc.priority >= 0); p->reclaim_state = NULL; current->flags &= ~PF_SWAPWRITE;