From patchwork Wed Jul 18 13:36:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 10532489 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0824D601D2 for ; Wed, 18 Jul 2018 13:36:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE0BB29086 for ; Wed, 18 Jul 2018 13:36:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DED642908F; Wed, 18 Jul 2018 13:36:49 +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=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable 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 576B429086 for ; Wed, 18 Jul 2018 13:36:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2FBAA6B0008; Wed, 18 Jul 2018 09:36:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 237D66B0010; Wed, 18 Jul 2018 09:36:33 -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 EC0C06B0269; Wed, 18 Jul 2018 09:36:32 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id 65FF76B0008 for ; Wed, 18 Jul 2018 09:36:32 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id g11-v6so1871956edi.8 for ; Wed, 18 Jul 2018 06:36:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=hSXhFFw360YrbuqzkFfmSJkq2hRkBPG8++qfHcIT1hM=; b=KJ84O4kY3ls/7IiVzbou4ebZg2rIUwIpDcu85Nihqms895iqUcsczgyzuNxFFhI8Tp 9x0i/xQVc6eu7goGXk6fjCGLAqi6NZYpjV8jwp6lPkqYKPAWwz3zt1UYgkkAd/FUdw0g tSBOkwPEfGBDnl9SBPLNVTKT+uYGGqQPDyZig2Zb6zWdGttLYJanZZv9kL2KyRlEBf4c cg5FLCXUP7HOxNsXUyT5ffMESWdcLE1cWXdlw9kF6pv5unJYZ434TvFjfGLqqgquuyhr W7LXWdjIyaaTAGFVcHud+FT5iFQ5eQ5PNb3A4YT2U/Cz5krlV4I7T5W2gUvYEC8lrrq8 WVNg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of vbabka@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Gm-Message-State: AOUpUlF3UnWTSgepVV4zFWOR5BJXrUpyM72O8We3KLyzkkZ8OauhdM3E otoXW1aZ2c4PmJn1sngNi6pxbuNwZSpMRHYnUXF7XfNOFAjhynWGxMU+bRGhLcZCm8S4tvlDM+v 26HFSFLY7T4GTUTqN3IQ9imoBoT0+RJLiK79IfDbTCAoOkXMgZFcdR75lk1dC7sjVrA== X-Received: by 2002:a50:a9e2:: with SMTP id n89-v6mr7006086edc.158.1531920991892; Wed, 18 Jul 2018 06:36:31 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcujCniYG1eFy+u6nNYA77NvzqMeyy1vOVybeTG0vWlNCux9j0H+stEeidpcn9dKELelwDR X-Received: by 2002:a50:a9e2:: with SMTP id n89-v6mr7005981edc.158.1531920990345; Wed, 18 Jul 2018 06:36:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531920990; cv=none; d=google.com; s=arc-20160816; b=qd1dgTCNzABQKNmzIdPuFoZOljn2PY6tu/yf4imc6nFUGY3hxmqZV/zU/BBum4vNYE pdr2s+aXbjHXB61chB2Dm8PXwBXiCol7JKu6pZbwfLSaRO3R8I0Sw/aG+H0xvCE2EEc2 L9lz4frujWnp/4xwdqJsMp48OdMYbtR/4pLEc1ZoKwqevTPgT5LRvLyISV5D+L0ZmHXT LPHA5lEugNHGsKctSijrE7s2yJJrLxShFtSNWRqcC/wWnFrorEIHhN/LLk48LZVZs7rT qI4J6TXH9cM7puNnMvY28j2vk4GC4qYiySpyqG37mC5UIy3NJB5Z7itNO4WwIHY2HELm cw/g== 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 :arc-authentication-results; bh=hSXhFFw360YrbuqzkFfmSJkq2hRkBPG8++qfHcIT1hM=; b=JY0jWs4YjwjExaLA9boY6Gvgy+B+2UuFXvxlEwePKKeBNt7nV/tVq55XAOqD329NmD MNpT0OK5Jnuv1ZYue8O0vMqCxHaO2XzBkwN/06REaPBSYIsxOg3nV072gHus3xGVFSH2 HOUvMDNH8IliFEc61ivIskz6CFApIyJMn28zmMqhrSXH1EKwAIWH4QxcSN9PE2zWcTPH Ksxu3Nlzzm+v7+uG2fZBBhcl3ihicVq3WpzWzc4CJNtJV6DYhprDETV/pLHRiI4JoVU1 STgeXZDyqL/1n3ApPFp3DCVN6YYoiXEMe/2hAbsUuuv6jk+l7NhgpszX/EvosSsK8YZe yoKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of vbabka@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=vbabka@suse.cz Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id i20-v6si576014edj.108.2018.07.18.06.36.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 06:36:30 -0700 (PDT) Received-SPF: pass (google.com: domain of vbabka@suse.cz designates 195.135.220.15 as permitted sender) client-ip=195.135.220.15; Authentication-Results: mx.google.com; spf=pass (google.com: domain of vbabka@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id EE597AE74; Wed, 18 Jul 2018 13:36:28 +0000 (UTC) From: Vlastimil Babka To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Roman Gushchin , Michal Hocko , Johannes Weiner , Christoph Lameter , David Rientjes , Joonsoo Kim , Mel Gorman , Matthew Wilcox , Vlastimil Babka , Vijayanand Jitta , Laura Abbott , Sumit Semwal Subject: [PATCH v3 5/7] mm: rename and change semantics of nr_indirectly_reclaimable_bytes Date: Wed, 18 Jul 2018 15:36:18 +0200 Message-Id: <20180718133620.6205-6-vbabka@suse.cz> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180718133620.6205-1-vbabka@suse.cz> References: <20180718133620.6205-1-vbabka@suse.cz> 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 The vmstat counter NR_INDIRECTLY_RECLAIMABLE_BYTES was introduced by commit eb59254608bc ("mm: introduce NR_INDIRECTLY_RECLAIMABLE_BYTES") with the goal of accounting objects that can be reclaimed, but cannot be allocated via a SLAB_RECLAIM_ACCOUNT cache. This is now possible via kmalloc() with __GFP_RECLAIMABLE flag, and the dcache external names user is converted. The counter is however still useful for accounting direct page allocations (i.e. not slab) with a shrinker, such as the ION page pool. So keep it, and: - change granularity to pages to be more like other counters; sub-page allocations should be able to use kmalloc - rename the counter to NR_KERNEL_MISC_RECLAIMABLE - expose the counter again in vmstat as "nr_kernel_misc_reclaimable"; we can again remove the check for not printing "hidden" counters Signed-off-by: Vlastimil Babka Cc: Vijayanand Jitta Cc: Laura Abbott Cc: Sumit Semwal Acked-by: Christoph Lameter --- drivers/staging/android/ion/ion_page_pool.c | 8 ++++---- include/linux/mmzone.h | 2 +- mm/page_alloc.c | 19 +++++++------------ mm/util.c | 3 +-- mm/vmstat.c | 6 +----- 5 files changed, 14 insertions(+), 24 deletions(-) diff --git a/drivers/staging/android/ion/ion_page_pool.c b/drivers/staging/android/ion/ion_page_pool.c index 9bc56eb48d2a..0d2a95957ee8 100644 --- a/drivers/staging/android/ion/ion_page_pool.c +++ b/drivers/staging/android/ion/ion_page_pool.c @@ -33,8 +33,8 @@ static void ion_page_pool_add(struct ion_page_pool *pool, struct page *page) pool->low_count++; } - mod_node_page_state(page_pgdat(page), NR_INDIRECTLY_RECLAIMABLE_BYTES, - (1 << (PAGE_SHIFT + pool->order))); + mod_node_page_state(page_pgdat(page), NR_KERNEL_MISC_RECLAIMABLE, + 1 << pool->order); mutex_unlock(&pool->mutex); } @@ -53,8 +53,8 @@ static struct page *ion_page_pool_remove(struct ion_page_pool *pool, bool high) } list_del(&page->lru); - mod_node_page_state(page_pgdat(page), NR_INDIRECTLY_RECLAIMABLE_BYTES, - -(1 << (PAGE_SHIFT + pool->order))); + mod_node_page_state(page_pgdat(page), NR_KERNEL_MISC_RECLAIMABLE, + -(1 << pool->order)); return page; } diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 32699b2dc52a..c2f6bc4c9e8a 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -180,7 +180,7 @@ enum node_stat_item { NR_VMSCAN_IMMEDIATE, /* Prioritise for reclaim when writeback ends */ NR_DIRTIED, /* page dirtyings since bootup */ NR_WRITTEN, /* page writings since bootup */ - NR_INDIRECTLY_RECLAIMABLE_BYTES, /* measured in bytes */ + NR_KERNEL_MISC_RECLAIMABLE, /* reclaimable non-slab kernel pages */ NR_VM_NODE_STAT_ITEMS }; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 5d800d61ddb7..91f75bf4404d 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4704,6 +4704,7 @@ long si_mem_available(void) unsigned long pagecache; unsigned long wmark_low = 0; unsigned long pages[NR_LRU_LISTS]; + unsigned long reclaimable; struct zone *zone; int lru; @@ -4729,19 +4730,13 @@ long si_mem_available(void) available += pagecache; /* - * Part of the reclaimable slab consists of items that are in use, - * and cannot be freed. Cap this estimate at the low watermark. + * Part of the reclaimable slab and other kernel memory consists of + * items that are in use, and cannot be freed. Cap this estimate at the + * low watermark. */ - available += global_node_page_state(NR_SLAB_RECLAIMABLE) - - min(global_node_page_state(NR_SLAB_RECLAIMABLE) / 2, - wmark_low); - - /* - * Part of the kernel memory, which can be released under memory - * pressure. - */ - available += global_node_page_state(NR_INDIRECTLY_RECLAIMABLE_BYTES) >> - PAGE_SHIFT; + reclaimable = global_node_page_state(NR_SLAB_RECLAIMABLE) + + global_node_page_state(NR_KERNEL_MISC_RECLAIMABLE); + available += reclaimable - min(reclaimable / 2, wmark_low); if (available < 0) available = 0; diff --git a/mm/util.c b/mm/util.c index 3351659200e6..891f0654e7b5 100644 --- a/mm/util.c +++ b/mm/util.c @@ -675,8 +675,7 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin) * Part of the kernel memory, which can be released * under memory pressure. */ - free += global_node_page_state( - NR_INDIRECTLY_RECLAIMABLE_BYTES) >> PAGE_SHIFT; + free += global_node_page_state(NR_KERNEL_MISC_RECLAIMABLE); /* * Leave reserved pages. The pages are not for anonymous pages. diff --git a/mm/vmstat.c b/mm/vmstat.c index 8ba0870ecddd..c5e52f94ba5f 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1161,7 +1161,7 @@ const char * const vmstat_text[] = { "nr_vmscan_immediate_reclaim", "nr_dirtied", "nr_written", - "", /* nr_indirectly_reclaimable */ + "nr_kernel_misc_reclaimable", /* enum writeback_stat_item counters */ "nr_dirty_threshold", @@ -1704,10 +1704,6 @@ static int vmstat_show(struct seq_file *m, void *arg) unsigned long *l = arg; unsigned long off = l - (unsigned long *)m->private; - /* Skip hidden vmstat items. */ - if (*vmstat_text[off] == '\0') - return 0; - seq_puts(m, vmstat_text[off]); seq_put_decimal_ull(m, " ", *l); seq_putc(m, '\n');