From patchwork Thu Sep 3 23:00:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 11755515 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EFEF1746 for ; Thu, 3 Sep 2020 23:01:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B2C6D20639 for ; Thu, 3 Sep 2020 23:01:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="oYvygHxk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B2C6D20639 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=fb.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D5BAF6B006E; Thu, 3 Sep 2020 19:01:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CE5D96B0070; Thu, 3 Sep 2020 19:01: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 BAC7D6B0071; Thu, 3 Sep 2020 19:01:12 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0238.hostedemail.com [216.40.44.238]) by kanga.kvack.org (Postfix) with ESMTP id A0C0F6B006E for ; Thu, 3 Sep 2020 19:01:12 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 4CC57362E for ; Thu, 3 Sep 2020 23:01:12 +0000 (UTC) X-FDA: 77223272784.18.cats88_040cff5270ad Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 140B4100ED3CD for ; Thu, 3 Sep 2020 23:01:12 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,prvs=65156da82a=guro@fb.com,,RULES_HIT:30001:30005:30034:30054:30064,0,RBL:67.231.153.30:@fb.com:.lbl8.mailshell.net-62.18.0.100 64.10.201.10;04yg8bp3pb59ahpj8x8sokst77eekypdmjaekcf4heokngdcj1w88a5o4ucuyhk.4ak6a6oqnd5uc3qj8g95uph7974kpw7i4mr7oyfo3gpu13r8n4etqgcsqi7j3tg.o-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: cats88_040cff5270ad X-Filterd-Recvd-Size: 4566 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Thu, 3 Sep 2020 23:01:11 +0000 (UTC) Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 083MtjQ0008580 for ; Thu, 3 Sep 2020 16:01:11 -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-transfer-encoding : content-type; s=facebook; bh=YWYptwdcblR9vA8Ah1Yv2S9FNwktLFxutd6Oqa5gWDo=; b=oYvygHxk1usYgCuxr0lqc29kSgBGPkEh4uIFXs8uqdq26t9svmxmeTts+25EZnwNzi1m nx1fheoukbQTWz5G0EOxL4DOlyuVvCAVmjqY3ISQapcqc4SGiibdvhGDNRiiYyBVwerV 2dX0znpWIRaGC5+SC7pGGshjohlBDhsrr7s= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com with ESMTP id 33ae5urnv2-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 03 Sep 2020 16:01:10 -0700 Received: from intmgw002.41.prn1.facebook.com (2620:10d:c085:208::11) by mail.thefacebook.com (2620:10d:c085:11d::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 3 Sep 2020 16:01:09 -0700 Received: by devvm1096.prn0.facebook.com (Postfix, from userid 111017) id 2291C3B54F24; Thu, 3 Sep 2020 16:01:09 -0700 (PDT) Smtp-Origin-Hostprefix: devvm From: Roman Gushchin Smtp-Origin-Hostname: devvm1096.prn0.facebook.com To: Andrew Morton , CC: =Shakeel Butt , Johannes Weiner , Michal Hocko , , , Roman Gushchin , Michal Hocko Smtp-Origin-Cluster: prn0c01 Subject: [PATCH] mm: workingset: ignore slab memory size when calculating shadows pressure Date: Thu, 3 Sep 2020 16:00:55 -0700 Message-ID: <20200903230055.1245058-1-guro@fb.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-09-03_14:2020-09-03,2020-09-03 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 mlxscore=0 bulkscore=0 spamscore=0 phishscore=0 malwarescore=0 adultscore=0 priorityscore=1501 suspectscore=0 impostorscore=0 mlxlogscore=725 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009030204 X-FB-Internal: deliver X-Rspamd-Queue-Id: 140B4100ED3CD X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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: In the memcg case count_shadow_nodes() sums the number of pages in lru lists and the amount of slab memory (reclaimable and non-reclaimable) as a baseline for the allowed number of shadow entries. It seems to be a good analogy for the !memcg case, where node_present_pages() is used. However, it's not quite true, as there two problems: 1) Due to slab reparenting introduced by commit fb2f2b0adb98 ("mm: memcg/slab: reparent memcg kmem_caches on cgroup removal") local per-lruvec slab counters might be inaccurate on non-leaf levels. It's the only place where local slab counters are used. 2) Shadow nodes by themselves are backed by slabs. So there is a loop dependency: the more shadow entries are there, the less pressure the kernel applies to reclaim them. Fortunately, there is a simple way to solve both problems: slab counters shouldn't be taken into the account by count_shadow_nodes(). Signed-off-by: Roman Gushchin Cc: Johannes Weiner Cc: Michal Hocko Cc: Shakeel Butt --- mm/workingset.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mm/workingset.c b/mm/workingset.c index 92e66113a577..50d53f3699e4 100644 --- a/mm/workingset.c +++ b/mm/workingset.c @@ -495,10 +495,6 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker, for (pages = 0, i = 0; i < NR_LRU_LISTS; i++) pages += lruvec_page_state_local(lruvec, NR_LRU_BASE + i); - pages += lruvec_page_state_local( - lruvec, NR_SLAB_RECLAIMABLE_B) >> PAGE_SHIFT; - pages += lruvec_page_state_local( - lruvec, NR_SLAB_UNRECLAIMABLE_B) >> PAGE_SHIFT; } else #endif pages = node_present_pages(sc->nid);