From patchwork Tue Sep 15 13:27:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunxin Zang X-Patchwork-Id: 11776643 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 C96A6746 for ; Tue, 15 Sep 2020 13:27:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5C03422273 for ; Tue, 15 Sep 2020 13:27:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bytedance-com.20150623.gappssmtp.com header.i=@bytedance-com.20150623.gappssmtp.com header.b="dTQmO6eK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5C03422273 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 333C190005F; Tue, 15 Sep 2020 09:27:52 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2E34A90004C; Tue, 15 Sep 2020 09:27:52 -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 1D39F90005F; Tue, 15 Sep 2020 09:27:52 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0057.hostedemail.com [216.40.44.57]) by kanga.kvack.org (Postfix) with ESMTP id 0650390004C for ; Tue, 15 Sep 2020 09:27:52 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B60692470 for ; Tue, 15 Sep 2020 13:27:51 +0000 (UTC) X-FDA: 77265373542.06.cord15_4907eaf27111 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id 8A33910069814 for ; Tue, 15 Sep 2020 13:27:51 +0000 (UTC) X-Spam-Summary: 1,0,0,b976861655575cf8,d41d8cd98f00b204,zangchunxin@bytedance.com,,RULES_HIT:41:355:379:541:800:960:966:973:982:988:989:1260:1311:1314:1345:1437:1515:1534:1541:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:3872:3874:4321:4385:5007:6261:6653:7576:7903:7904:8784:10004:11026:11658:11914:12294:12296:12297:12517:12519:12555:12679:12895:12986:13053:13069:13161:13229:13311:13357:13869:13894:14096:14181:14384:14394:14721:21080:21444:21451:21627:21990:30005:30054:30070:30075,0,RBL:209.85.214.196:@bytedance.com:.lbl8.mailshell.net-62.2.0.100 66.100.201.201;04yrw9idj1oou4kaa49jxaedtemq3yckgo14mnthmek7c1epuposte3rudxuk3b.mjkj6sa86z9z8me6d3c8frrgpqyx4ie5thespmhqrjg59rt5oxz55ba1uqyhoew.k-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:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: cord15_4907eaf27111 X-Filterd-Recvd-Size: 4404 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Tue, 15 Sep 2020 13:27:50 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id f1so1341131plo.13 for ; Tue, 15 Sep 2020 06:27:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7vhjnhaOBNypT0J1caJeAb0BF+ROLuuFdlB5WaLOXWw=; b=dTQmO6eKwduT7IaIh4/3GtHGWGXulgiVyvo2tcuLJKe4T8M1CUzMgkss5IffOi6IqT GbVXsPhP6n6MZSyyXBzDuTlaczde+R2addAWfJ4X6ol6rjBTo0FZPAtgdCIn+qI8jmSc Cc3MqrYmn7lvDnH2KviU1J01FNR46KrC8zJKV8JMCpYLThIEiUgKtoscqDPlNfUAspSY frbzNx+MmCx9EWDBhGa+fFpHUlbeFDaJMbhQP2JCHA7fqNOmC3gD4keSwLJ9NG8woET0 gVUS2Afhrp8ZCp3U2vR3fOfQ+PH8IIC9XOItqeGg8wv9KEix8ZHHOgZaYjQBhsC8gWdP JGzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7vhjnhaOBNypT0J1caJeAb0BF+ROLuuFdlB5WaLOXWw=; b=pSRQdhI8DDqa1YS9Sj/iDwppL+xjlJDuU1A/Bu6FRasG2duzlPw4bSROot537MiCWr V2iJfcXuiQonjK1Wco3jSnp8bxWpDnFePHOKRHg6VYZZbryBi2XrMnGwasiFhFaBIPP/ ed+DSxScA1mNnnovEUgsqMMy6OdD9E/h9sUOPBlGke6RnPw+dQr04q9vAUArhQBOaa2J 4YyZhmIz8QfkqG4ncl4jMAZMZB0af9i5KzHMQDmK9G3i5IOMwOc3dj4rhq+ZNnMmHilf A5K/ZcAWY44Qccv8fORTSOhBW6C7Y8pY/45XsnZHXioNXeTlke3i0CsIx3jCsSXiJ/DD NS4g== X-Gm-Message-State: AOAM530h5tzbgnsKsxXxUvOTg4P4fuAmJn+/avKChPjtPoA+hesGXyGI djkfCtXBXwNEBuSeW/82+0ty12eDKmjlUna6 X-Google-Smtp-Source: ABdhPJw12ixCnD+C0yvcpiXBUPv8NOwFo2xCyijS3BEGCK93LIB7TvFraxv5Y3HdSHelDvkDyLH6AA== X-Received: by 2002:a17:90a:ead8:: with SMTP id ev24mr4174614pjb.89.1600176469553; Tue, 15 Sep 2020 06:27:49 -0700 (PDT) Received: from Zs-MacBook-Pro.local.net ([103.136.220.73]) by smtp.gmail.com with ESMTPSA id a13sm9644029pfl.184.2020.09.15.06.27.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2020 06:27:48 -0700 (PDT) From: zangchunxin@bytedance.com To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chunxin Zang , Muchun Song Subject: [PATCH v4] mm/vmscan: add a fatal signals check in drop_slab_node Date: Tue, 15 Sep 2020 21:27:41 +0800 Message-Id: <20200915132741.84869-1-zangchunxin@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 X-Rspamd-Queue-Id: 8A33910069814 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: From: Chunxin Zang On our server, there are about 10k memcg in one machine. They use memory very frequently. We have observed that drop_caches can take a considerable amount of time, and can't stop it. There are two reasons: 1. There is somebody constantly generating more objects to reclaim on drop_caches, result the 'freed' always bigger than 10. 2. The process has no chance to process signals. We can get the following info through 'ps': root:~# ps -aux | grep drop root 357956 ... R Aug25 21119854:55 echo 3 > /proc/sys/vm/drop_caches root 1771385 ... R Aug16 21146421:17 echo 3 > /proc/sys/vm/drop_caches Add a bail out on the fatal signals in the main loop so that the operation can be terminated by userspace. Signed-off-by: Chunxin Zang Signed-off-by: Muchun Song Acked-by: Michal Hocko Acked-by: Chris Down --- changelogs in v4: changelogs in v3: 1) Fix some descriptive problems pointed out by Michal Hocko. v2 named: mm/vmscan: fix infinite loop in drop_slab_node changelogs in v2: 1) via check fatal signal break loop. mm/vmscan.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/vmscan.c b/mm/vmscan.c index b6d84326bdf2..6b2b5d420510 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -704,6 +704,9 @@ void drop_slab_node(int nid) do { struct mem_cgroup *memcg = NULL; + if (signal_pending(current)) + return; + freed = 0; memcg = mem_cgroup_iter(NULL, NULL, NULL); do {