From patchwork Mon May 7 21:01:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 10384781 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 352AD60353 for ; Mon, 7 May 2018 21:00:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 107CC28AAE for ; Mon, 7 May 2018 21:00:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0423B28B27; Mon, 7 May 2018 21:00:01 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID 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 89A1828AAE for ; Mon, 7 May 2018 21:00:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D5646B026A; Mon, 7 May 2018 16:59:59 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 286426B026B; Mon, 7 May 2018 16:59:59 -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 19C7A6B026C; Mon, 7 May 2018 16:59:59 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr0-f197.google.com (mail-wr0-f197.google.com [209.85.128.197]) by kanga.kvack.org (Postfix) with ESMTP id B3C5F6B026A for ; Mon, 7 May 2018 16:59:58 -0400 (EDT) Received: by mail-wr0-f197.google.com with SMTP id z7-v6so19963207wrg.11 for ; Mon, 07 May 2018 13:59:58 -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=PUltZEzDEG5OoCb+tqodLp9Z8/Tnpk6sVV12mVb/eA4=; b=Dh/t0n0kR5+VhhyaWQLYWD30nyq68GwVrRgG09cLtgYw13EO4kl3RoennAp3ybRgPz pjFDGrPV5ghTrPngsKnsCW1TWSIOUCiOtir8JDjL9tiemLbqJvzkW/Cfkx7sSMfwwWim EB1slBHco6wVqNpni2ICz+pNIF4VLkL5H6yhrLL9JgM3E2kaIdP2qn+Fu9ECpXVGk5AC jcxggHLz+scSdMdnS2IV+mnw2UUjGhTKCQ355hUPDnRSAanSpxc4jqlpx126QrCOrZ2i vNKz4jY6W7uJ/ZIEJXms6YlQJrEHd6z351xv7nBLRM1YM6jD2WWTDCE/uVoLGiB9Vfd8 XcMw== X-Gm-Message-State: ALQs6tBq2Q9mNCzrO/9Sf6fApZ8qMa8AT99Rg++udK1UMh4xnxjIbzAY l4m5ud9Mfi6nTiUHfxAD2Wl+tzikJ9yGUnGDF0bGUW7bgTuEq26F5rDNrooR+BznfX8X0yAlkpw r1g7mlu+ild0f5Q+wrj3nTpIFmbMr1s41pPw2AB+Ibi56VAXDy6iRSIeJL7RfK59SIw== X-Received: by 2002:aa7:c657:: with SMTP id z23-v6mr53590112edr.9.1525726798271; Mon, 07 May 2018 13:59:58 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrxwukRQ5MzHXEZkGN2vAcIN1M+nQ2LVB68OFe0/RuyEJOzLQEJR/yUR35bnfuf7Ed1Zron X-Received: by 2002:aa7:c657:: with SMTP id z23-v6mr53590080edr.9.1525726797658; Mon, 07 May 2018 13:59:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525726797; cv=none; d=google.com; s=arc-20160816; b=SUTnSeAAQMd7X35PdnSfiPtOielt6VrMwjtFVM7JhLlZJM+X+URpx/l/ciP64Sc8ES qPANm1Ff0UjlCvew1+g1wPns7QGlvFRQ6tHQ7EsZzHUZ7t+GTsJ2uJ1ge8mcdTblp28Q /0vdHspyCw8VQSvZT0Vch+3vkMu6pfJ+9jihJCqWLlby4hHMtPwgATCwThJo0oj6Gk5X gvHdD+urghnJHFMaJ0HCNBHy4lB/5xkA4WqdwIvoTrk8qbl0z1y915/ew1Pd/YJV0yuF hKH5O4inPDuP+9N+INVFpwSMiEXRdc/7VwdXQN3BWf0FrrlW1ehAe87OLMwAaDkMHw99 +3CA== 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:arc-authentication-results; bh=PUltZEzDEG5OoCb+tqodLp9Z8/Tnpk6sVV12mVb/eA4=; b=r3U3oPU/ZcX+JqOJ14oN12BZRaY1v0m4V6tpLqRxAzXBEeyg6q1rIuFYe9VV2zRfzD 0e5VlIEGWcRvXSYMufBy44ERGQ4Vm4VWmbqbyPlCi3lEpK8ck2sQ0lybiwxty8KXgqRd 01dC9CexJ2MoFR1SbK5Oo2WN+/wetVgvRQ+suvbKFmdU0hIEEuE28xcslYZiJnikF0PS Q2If9H7Y77d1kImjElM6u5ATemBGhTawbxEvQNu9l5YtoqbfC+XiC9PzLUhQPhX/HLEz w0snQwNo9UBCAnjquhdfifoNtgcERsxcR3I4k2SH4G3i9/iYi66I/LCzM/R+RMCmkgdN rfPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg.org header.s=x header.b=OmaVwI8p; spf=pass (google.com: domain of hannes@cmpxchg.org designates 85.214.110.215 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: from gum.cmpxchg.org (gum.cmpxchg.org. [85.214.110.215]) by mx.google.com with ESMTPS id i2-v6si1577280edb.100.2018.05.07.13.59.57 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 May 2018 13:59:57 -0700 (PDT) Received-SPF: pass (google.com: domain of hannes@cmpxchg.org designates 85.214.110.215 as permitted sender) client-ip=85.214.110.215; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg.org header.s=x header.b=OmaVwI8p; spf=pass (google.com: domain of hannes@cmpxchg.org designates 85.214.110.215 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=cmpxchg.org ; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender: Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=PUltZEzDEG5OoCb+tqodLp9Z8/Tnpk6sVV12mVb/eA4=; b=OmaVwI8pE1UO2/VIRQ9jhgQqzZ cQYOQPeroWsyFgzG+sismg1l/i71Nqas83UlWjadkAauuymtfcD/w3ifYgbHJTDuF+7Oek7w4qof9 gS2t9OH+bAFy5pcBH7AjWq1hwNBcVECpGZ5P8EdIFfOuc/go7bKQq9ZfFdAnro536aaQ=; From: Johannes Weiner To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-block@vger.kernel.org, cgroups@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra , Andrew Morton , Tejun Heo , Balbir Singh , Mike Galbraith , Oliver Yang , Shakeel Butt , xxx xxx , Taras Kondratiuk , Daniel Walker , Vinayak Menon , Ruslan Ruslichenko , kernel-team@fb.com Subject: [PATCH 1/7] mm: workingset: don't drop refault information prematurely Date: Mon, 7 May 2018 17:01:29 -0400 Message-Id: <20180507210135.1823-2-hannes@cmpxchg.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180507210135.1823-1-hannes@cmpxchg.org> References: <20180507210135.1823-1-hannes@cmpxchg.org> 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 From: Johannes Weiner If we just keep enough refault information to match the CURRENT page cache during reclaim time, we could lose a lot of events when there is only a temporary spike in non-cache memory consumption that pushes out all the cache. Once cache comes back, we won't see those refaults. They might not be actionable for LRU aging, but we want to know about them for measuring memory pressure. Signed-off-by: Johannes Weiner --- mm/workingset.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mm/workingset.c b/mm/workingset.c index 40ee02c83978..53759a3cf99a 100644 --- a/mm/workingset.c +++ b/mm/workingset.c @@ -364,7 +364,7 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker, { unsigned long max_nodes; unsigned long nodes; - unsigned long cache; + unsigned long pages; /* list_lru lock nests inside the IRQ-safe i_pages lock */ local_irq_disable(); @@ -393,14 +393,14 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker, * * PAGE_SIZE / radix_tree_nodes / node_entries * 8 / PAGE_SIZE */ - if (sc->memcg) { - cache = mem_cgroup_node_nr_lru_pages(sc->memcg, sc->nid, - LRU_ALL_FILE); - } else { - cache = node_page_state(NODE_DATA(sc->nid), NR_ACTIVE_FILE) + - node_page_state(NODE_DATA(sc->nid), NR_INACTIVE_FILE); - } - max_nodes = cache >> (RADIX_TREE_MAP_SHIFT - 3); +#ifdef CONFIG_MEMCG + if (sc->memcg) + pages = page_counter_read(&sc->memcg->memory); + else +#endif + pages = node_present_pages(sc->nid); + + max_nodes = pages >> (RADIX_TREE_MAP_SHIFT - 3); if (nodes <= max_nodes) return 0;