From patchwork Fri Nov 18 07:06:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 13047760 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFC74C433FE for ; Fri, 18 Nov 2022 07:06:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B5FD08E0001; Fri, 18 Nov 2022 02:06:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B10776B0072; Fri, 18 Nov 2022 02:06:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D7428E0001; Fri, 18 Nov 2022 02:06:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 8E8BF6B0071 for ; Fri, 18 Nov 2022 02:06:48 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5728AAB1E4 for ; Fri, 18 Nov 2022 07:06:48 +0000 (UTC) X-FDA: 80145680496.25.CB4E365 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf13.hostedemail.com (Postfix) with ESMTP id 0F51F20008 for ; Fri, 18 Nov 2022 07:06:46 +0000 (UTC) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AI6IfiZ002186; Fri, 18 Nov 2022 07:06:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=N4KdvjMJHC5x6ymTMDf532HEFw4KhYB9MxBma68Whaw=; b=K5qeR2rkczKSqUDb9c6M3vsH+9E2EUIt61DQ32yuEHhRtOf/FNttWepddKFc17VfBdmV K9XtCesE74O3wcO/nb0vAfcDZDRce6d+vaesm0Mfk2hTEw0vjvSYIWUIgbwLgrj0Mpxr +chs28agSzM96IR44JniRCXZnPyfulB50j6dpQWn91VljgL/ganHvslFll6ommP/ZZSH tU4kUexLPZZISQF41cuk7VY4/NDCaPkjvoF5Xgt8/Qf/MsJd3Ac0nQC9d0utUZMYxL7B ADPPZukB0CUSnEk3JxH73vYslTLy+m74uT0YR8Et7Oskc7zpLnjp35t4v0fir8ky4keM xA== Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kx4nxrx0s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 18 Nov 2022 07:06:40 +0000 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2AI74veO021301; Fri, 18 Nov 2022 07:06:38 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma01wdc.us.ibm.com with ESMTP id 3kt349x4gh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 18 Nov 2022 07:06:38 +0000 Received: from smtpav02.dal12v.mail.ibm.com ([9.208.128.128]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2AI76Y2n47317370 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 18 Nov 2022 07:06:34 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 759A35805F; Fri, 18 Nov 2022 07:06:37 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F368F5805E; Fri, 18 Nov 2022 07:06:33 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.43.38.233]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 18 Nov 2022 07:06:33 +0000 (GMT) From: "Aneesh Kumar K.V" To: linux-mm@kvack.org, akpm@linux-foundation.org, Tejun Heo , Zefan Li , Johannes Weiner Cc: cgroups@vger.kernel.org, "Aneesh Kumar K.V" , stable@kernel.org Subject: [PATCH] mm/cgroup/reclaim: Fix dirty pages throttling on cgroup v1 Date: Fri, 18 Nov 2022 12:36:03 +0530 Message-Id: <20221118070603.84081-1-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: eQuWpoFTu9NJ90eS_0oqrMunQX0yUx92 X-Proofpoint-GUID: eQuWpoFTu9NJ90eS_0oqrMunQX0yUx92 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-17_06,2022-11-17_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 mlxscore=0 impostorscore=0 adultscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 clxscore=1011 bulkscore=0 mlxlogscore=906 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211180048 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668755207; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=N4KdvjMJHC5x6ymTMDf532HEFw4KhYB9MxBma68Whaw=; b=DNfEfR1V8iovbB2cLCUcowI8JbiruUQrjVsOicUpd6iFXNf3uFyC4lMIcQ7TcL6SthMJPv ENrFn4AqwyZQUMZoUsIELm3xsOp3iWjYxsBHcl9Or6kTfJZxfsKhXEFAj35v7iDqfEnQr1 r4U3lzqjwPMncnY7anvNgpmW/sNwIu0= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=K5qeR2rk; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf13.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668755207; a=rsa-sha256; cv=none; b=qFJxJWW1J6rw2GHIEmpUxnYHGQ2iNzcm/2GUbbkmjdow17F6qcgj3DTPXJdXZ11MxRUg+F xRHmVQqPwRT39gHiQLrVyES0dRaOBgh6+PoWJstCVCLZYQbyYoep57HXZ7IbnxIIwO4gZR J5rGIKdmR1bJXE0BKMHgdIW728fdbbE= X-Rspam-User: X-Stat-Signature: x5xf3p3zwr7iqaf4hu4i11bnd7cr87wf X-Rspamd-Queue-Id: 0F51F20008 Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=K5qeR2rk; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf13.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com X-Rspamd-Server: rspam07 X-HE-Tag: 1668755206-117726 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: balance_dirty_pages doesn't do the required dirty throttling on cgroupv1. See commit 9badce000e2c ("cgroup, writeback: don't enable cgroup writeback on traditional hierarchies"). Instead, the kernel depends on writeback throttling in shrink_folio_list to achieve the same goal. With large memory systems, the flusher may not be able to writeback quickly enough such that we will start finding pages in the shrink_folio_list already in writeback. Hence for cgroupv1 let's do a reclaim throttle after waking up the flusher. The below test which used to fail on a 256GB system completes till the the file system is full with this change. root@lp2:/sys/fs/cgroup/memory# mkdir test root@lp2:/sys/fs/cgroup/memory# cd test/ root@lp2:/sys/fs/cgroup/memory/test# echo 120M > memory.limit_in_bytes root@lp2:/sys/fs/cgroup/memory/test# echo $$ > tasks root@lp2:/sys/fs/cgroup/memory/test# dd if=/dev/zero of=/home/kvaneesh/test bs=1M Killed Cc: Suggested-by: Johannes Weiner Signed-off-by: Aneesh Kumar K.V Acked-by: Johannes Weiner --- mm/vmscan.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 04d8b88e5216..388022c5ef2b 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2514,8 +2514,20 @@ static unsigned long shrink_inactive_list(unsigned long nr_to_scan, * the flushers simply cannot keep up with the allocation * rate. Nudge the flusher threads in case they are asleep. */ - if (stat.nr_unqueued_dirty == nr_taken) + if (stat.nr_unqueued_dirty == nr_taken) { wakeup_flusher_threads(WB_REASON_VMSCAN); + /* + * For cgroupv1 dirty throttling is achieved by waking up + * the kernel flusher here and later waiting on folios + * which are in writeback to finish (see shrink_folio_list()). + * + * Flusher may not be able to issue writeback quickly + * enough for cgroupv1 writeback throttling to work + * on a large system. + */ + if (!writeback_throttling_sane(sc)) + reclaim_throttle(pgdat, VMSCAN_THROTTLE_WRITEBACK); + } sc->nr.dirty += stat.nr_dirty; sc->nr.congested += stat.nr_congested;