From patchwork Wed Sep 14 02:33:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongchen Zhang X-Patchwork-Id: 12975512 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 E7E8CC54EE9 for ; Wed, 14 Sep 2022 02:33:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 364646B0071; Tue, 13 Sep 2022 22:33:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 313506B0073; Tue, 13 Sep 2022 22:33:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 202D08D0001; Tue, 13 Sep 2022 22:33:35 -0400 (EDT) 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 10AB46B0071 for ; Tue, 13 Sep 2022 22:33:35 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D968D1202E9 for ; Wed, 14 Sep 2022 02:33:34 +0000 (UTC) X-FDA: 79909119948.05.09E6597 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by imf12.hostedemail.com (Postfix) with ESMTP id 57BC2400B7 for ; Wed, 14 Sep 2022 02:33:32 +0000 (UTC) Received: from loongson.. (unknown [111.207.111.194]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cx72txPSFjXrMYAA--.27807S2; Wed, 14 Sep 2022 10:33:28 +0800 (CST) From: Hongchen Zhang To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hongchen Zhang Subject: [PATCH] mm/vmscan: don't scan adjust too much if current is not kswapd Date: Wed, 14 Sep 2022 10:33:18 +0800 Message-Id: <20220914023318.549118-1-zhanghongchen@loongson.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Cx72txPSFjXrMYAA--.27807S2 X-Coremail-Antispam: 1UD129KBjvJXoWrtFy7tr45Ar1kWrWUWFy5twb_yoW8Jr1fpa yfGw1jqFs5GrnIkas8JF409w1fCry5GFy7GrWfW3WxCw47Gr48Jry3urW5XFy2ya1xuF43 Zr98Ka45WF1agaUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkv14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4j 6r4UJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26F 4UJVW0owAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv 7VC0I7IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r 1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY02Avz4vE14v_ Gr1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxV WUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI 7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r 1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI 42IY6I8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x0JUvoGQUUUUU= X-CM-SenderInfo: x2kd0w5krqwupkhqwqxorr0wxvrqhubq/ ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663122814; a=rsa-sha256; cv=none; b=7D9ZMJewCVQQf6irz74FKla5OQXyGtGM2MLjC51EiuBSPCSX0M7ahYqnjXBGDT+9zA0cXD HHPy/9wTwpyCrx7SpFIkmey4gVJT0Qq3ekZ+84F8Lo83GLsOhwd0/zgnV8RYpAbE/d+1kW qA73DSV2YrfGWnaVUCXUwa+y/qCPWoA= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of zhanghongchen@loongson.cn designates 114.242.206.163 as permitted sender) smtp.mailfrom=zhanghongchen@loongson.cn; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663122814; 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; bh=KjcfMJthEKDhemlxiuQTxbAeixNaPIaBqEbzNbnu2tc=; b=TcLQzXxXIyrTdMSPamWQWxEqr88qkRPMsnESc9FTTGTGRO+BKQVvcKksWDtviiC6H75du7 x67t5DtShXYN8VItcs5K0m1I1HGTHL2VnxnzhWxI5cQItmyFLVFFLUqmmpk8S8X0oK1XF4 tzQebLKMrWe/KyUKL/qEp2xaINOM018= X-Rspamd-Queue-Id: 57BC2400B7 Authentication-Results: imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of zhanghongchen@loongson.cn designates 114.242.206.163 as permitted sender) smtp.mailfrom=zhanghongchen@loongson.cn; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam10 X-Stat-Signature: 59iqc3fnpdob8dytsnyze1o5gydku3nw X-HE-Tag: 1663122812-623161 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: when a process falls into page fault and there is not enough free memory,it will do direct reclaim. At the same time,it is holding mmap_lock.So in case of multi-thread,it should exit from page fault ASAP. When reclaim memory,we do scan adjust between anon and file lru which may cost too much time and trigger hung task for other thread.So for a process which is not kswapd,it should just do a little scan adjust. Signed-off-by: Hongchen Zhang --- mm/vmscan.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/vmscan.c b/mm/vmscan.c index b2b1431352dc..07fb58db812b 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -3042,11 +3042,17 @@ static void shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc) nr[lru] = targets[lru] * (100 - percentage) / 100; nr[lru] -= min(nr[lru], nr_scanned); + if (!current_is_kswapd()) + nr[lru] = min(nr[lru], nr_to_reclaim); + lru += LRU_ACTIVE; nr_scanned = targets[lru] - nr[lru]; nr[lru] = targets[lru] * (100 - percentage) / 100; nr[lru] -= min(nr[lru], nr_scanned); + if (!current_is_kswapd()) + nr[lru] = min(nr[lru], nr_to_reclaim); + scan_adjusted = true; } blk_finish_plug(&plug);