From patchwork Wed Sep 16 02:53:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunxin Zang X-Patchwork-Id: 11778747 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 162E114F6 for ; Wed, 16 Sep 2020 02:55:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C45E4206DB for ; Wed, 16 Sep 2020 02:55:21 +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="wIor56g4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C45E4206DB 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 B8C876B005A; Tue, 15 Sep 2020 22:55:20 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B3DC26B005C; Tue, 15 Sep 2020 22:55:20 -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 A7C866B005D; Tue, 15 Sep 2020 22:55:20 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0167.hostedemail.com [216.40.44.167]) by kanga.kvack.org (Postfix) with ESMTP id 936736B005A for ; Tue, 15 Sep 2020 22:55:20 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 5484A181AC212 for ; Wed, 16 Sep 2020 02:55:20 +0000 (UTC) X-FDA: 77267408400.12.bean01_350b42827116 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 264BD1800E90E for ; Wed, 16 Sep 2020 02:55:20 +0000 (UTC) X-Spam-Summary: 1,0,0,e04538a6b84f66f2,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:4605:5007:6261:6653:7576:7903:7904:8784:10004:11026:11658:11914:12043:12294:12296:12297:12438: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.215.193:@bytedance.com:.lbl8.mailshell.net-66.100.201.201 62.2.0.100;04yrkkt8mfw6sccrctp9p5sukaxcuopyu5t3izupdek7c1epupukyf5khfkkese.ozesy6hh18be8nzserga4ihfspf3j88dtm1hppgunnrdt7ygzs5usidu3kmp16o.r-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:25,LUA_SUMMARY:none X-HE-Tag: bean01_350b42827116 X-Filterd-Recvd-Size: 4553 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Wed, 16 Sep 2020 02:55:19 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id g29so3084822pgl.2 for ; Tue, 15 Sep 2020 19:55:19 -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=vTi1bz/tNmHVuu7oLrOOBbXmUuoclSjfaqrPNU15+RI=; b=wIor56g4jSJd8m3CWJVND6M3Jxtu1f4k0CylDYEO7tbYOb9GqZnNF+bXJ8+zdsldDo rvaL+iLtIZjaEBlbmiFP/WBY9tOF2NUVjPvzQq4J8Uq89daUZmb3s9wwEylEN/QhcrsI Bsj17QbobPuzBm0j9E9h7f2oOETf0r3Koxrw7hXRdLhFHf0YGqgHPHabUQhGOJzU8jh2 balUXpa59ZeEzyFettlQe6jNa9yi9erPOggSg6CnbuOLIsZyjgAGYhQtqEODquZ7ld/1 Xd0rqpl8PQPpNK3Nf2LHl70N5+f2D/nAdWJ4W+b37NZVHYIk+f6LXGymhYc6YH/wO+ku boDA== 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=vTi1bz/tNmHVuu7oLrOOBbXmUuoclSjfaqrPNU15+RI=; b=IyM/vP4QkVdv1fZAgtreUCPVlD5U3HgrufuiO8It2ZOfqKrerInAgQ8BcRoE7BR0d4 1av5Ok4ZbSvZSqP2QXPVCKHHAQOXpjehLHxVCfGAp1Q+yGepkGx04oDkL9W9b4VzIvMT IGKW0Tn1ictwn8fSCtsdqOiHUbW4upbkdj08EVQqHDWNy7SVZvUNTlhT+ctP2C0fzbcZ aHQOIUK9RMrUt3D9ut1+exccs+GVTYHqZjkKMe/KiZg0u2JGf90RbYJV4ux/Dk0Bk3AF hvlS2tNApSaDpg6Ys/d/7lCeu/1odYFitnI5y7Ur8y6E3WFtjQw7JG3GFH+NjT/bhPmB HUug== X-Gm-Message-State: AOAM532qK8KgftTLgaamSUZ09lMhPlZg4FcOGkV3kSF9YXepkwXqV8XP mQ+90lVWFiAXDioHJQkko6QShA== X-Google-Smtp-Source: ABdhPJywHpl7whwPi3zY9xJFRe/KEASmy6QCZtHGlysB6R9q7ULw51gMymiAv8mc0m+dJZkwcsoV3w== X-Received: by 2002:a65:6658:: with SMTP id z24mr16870061pgv.367.1600224918804; Tue, 15 Sep 2020 19:55:18 -0700 (PDT) Received: from Zs-MacBook-Pro.local.net ([103.136.220.71]) by smtp.gmail.com with ESMTPSA id s129sm14677603pfb.39.2020.09.15.19.55.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2020 19:55:18 -0700 (PDT) From: zangchunxin@bytedance.com To: akpm@linux-foundation.org Cc: chris@chrisdown.name, vbabka@suse.cz, mhocko@suse.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chunxin Zang , Muchun Song Subject: [PATCH v5] mm/vmscan: add a fatal signals check in drop_slab_node Date: Wed, 16 Sep 2020 10:53:59 +0800 Message-Id: <20200916025359.70203-1-zangchunxin@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 X-Rspamd-Queue-Id: 264BD1800E90E X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 v5: 1) v4 patch used wrong branch, very apologies about that. 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..c3ed8b45d264 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 (fatal_signal_pending(current)) + return; + freed = 0; memcg = mem_cgroup_iter(NULL, NULL, NULL); do {