Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp903091pxk; Thu, 3 Sep 2020 16:06:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQIRwQhJ4L7I1IoAGu31WmQLCW8FWG8yguCJEKBvkUGX06oJztdmvbgcCEyfUvModNUxCS X-Received: by 2002:a17:907:214e:: with SMTP id rk14mr4778092ejb.171.1599174393006; Thu, 03 Sep 2020 16:06:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599174393; cv=none; d=google.com; s=arc-20160816; b=Y2WAgXl7xXAmQpxxXMAk1yFV1MOK3ATYIWqnJ/ulHGws+S/KQbwRbZq9P/GnNpB2Nl vQeo4xCflLCrkwO6kcn7AxxxOF/CqqfyuCmiFZnGn3yTzpqu6NJ2gyCAXGmUIyIbK8QD l8zRZI8U1FWeDMD2d1WajMaAKuZTKSdEGmfWZOFoFUlKgBd6PXIQQgge1CVZW3aQzoRm 6+Nu0UKb+bawb+UAziLwBc3mhQ+ExakqXApSsqBbHsTxO/nOiugW0dR2Yh8dG+B03r11 wV1y1/pihZOEvJrEUh7HsVGUK8nVLmn3/mPm2vkH+LHhno+nfe2cOPVTp+qkeVK8eU/L N/jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:smtp-origin-cluster:cc:to :smtp-origin-hostname:from:smtp-origin-hostprefix:dkim-signature; bh=YWYptwdcblR9vA8Ah1Yv2S9FNwktLFxutd6Oqa5gWDo=; b=IbLK0lTH+eZH95UC+BnPrqgStVkOnZgZZkQMxirIgWI9WnbHaSrvRVZtfoZMpXClE7 2uDG8PrU+OtthtEPylpAu1HtmsmI+XE+LyxsAAO1CPZxOGkpScy3hjLC3pa9TgU4/P4k JYKV8cIJm6wLh4eMye7vS4isrSxpHh2XmUkEDzRdgymhQGYVIHCL4Lc8rBEU8rP5wx3b 2UEFLrci15yevYRTyiSxuz65n27rdtvq3EG9qshCGz09ePrsXiq5xyntyMX786QI96bG SYYPsT4NN/IiJfQ4Zr4RpFTYl2eIo57U8DyY+f01sphfFX3iMRo5nlqdCBcE0p8fW609 OQiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=oYvygHxk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nr22si2806906ejb.535.2020.09.03.16.06.08; Thu, 03 Sep 2020 16:06:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=oYvygHxk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729323AbgICXBR (ORCPT + 99 others); Thu, 3 Sep 2020 19:01:17 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:32698 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728288AbgICXBP (ORCPT ); Thu, 3 Sep 2020 19:01:15 -0400 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 083MtjQ5008580 for ; Thu, 3 Sep 2020 16:01:13 -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-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 03 Sep 2020 16:01:13 -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 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain 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=733 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009030204 X-FB-Internal: deliver Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 shrin= ker *shrinker, for (pages =3D 0, i =3D 0; i < NR_LRU_LISTS; i++) pages +=3D lruvec_page_state_local(lruvec, NR_LRU_BASE + i); - pages +=3D lruvec_page_state_local( - lruvec, NR_SLAB_RECLAIMABLE_B) >> PAGE_SHIFT; - pages +=3D lruvec_page_state_local( - lruvec, NR_SLAB_UNRECLAIMABLE_B) >> PAGE_SHIFT; } else #endif pages =3D node_present_pages(sc->nid); --=20 2.26.2