Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp7379725rwn; Tue, 13 Sep 2022 19:57:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR5BApGjdEE9iVk83q/ybo7WyE48peLUpuOBRer20l/r7k/lk9xpU5wAZnY5wusYbaO3q+cu X-Received: by 2002:a05:6402:5189:b0:451:791e:f328 with SMTP id q9-20020a056402518900b00451791ef328mr12973569edd.282.1663124249455; Tue, 13 Sep 2022 19:57:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663124249; cv=none; d=google.com; s=arc-20160816; b=E9HtWTiXjR+AzFgYnq7+TpMKVV17182rtXijp/lxh3FvDQkUm5PwTWkpN9WJt/J62M pwow1qY/Drm7YBo6mkLoGcs0f/q+CxQSfzGqLPxbzm4TG8Keb1lL5M2UWneVirKm4w6g KI1IA1yMBtPbCsKRPhlSrzOMJCR8ugg1zNJlAl73CtWWk0skX9VwZH0akbYiXYzsVT/Y XegUVUnP6HQ07nitTQ11UFPZ0VD+d8AbMVHvUJ93p3SYY9zQdXYS4iGZxB2QHgkveXXT zkEQcG/yHgVoFL/OMPN1pbA9Nqkw4xCErDPzXfGFkE2SIVB52R/toz7XXxOCufkHo7Nb Q0/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=KjcfMJthEKDhemlxiuQTxbAeixNaPIaBqEbzNbnu2tc=; b=JAO6AuRXVch8fVH86pGDKPI6l0MEDbGay/BDpLUdkN1sYjl8QFH/VXCVSw/Jkm5hC8 auEuky5JFhA0aCxvPIiZaheJbxUDFzhN9ZLHTzf8oIAHGZfXRCHhuGeqjxINDDy+QIn2 zHa9r7/MQicju+0bi18XXptrZ10p9W7+LtnwbnbJlXteyQjKBHJiJYpVg7rnn2qDAwwb GY6GFwYgmQQHig/4pxdRxL1J/4kzQWYDeD0n+mIfu+bzISf2eEX9mRRXY04xhXpPnG20 IBSeIcg7Rj90bdp2PrPuoWl/0WDR2iqkV/Y/tU+kSFwJaC3UcsoPUrt0yznc+sFg9CLf 5aiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dr13-20020a170907720d00b00778aa522d8fsi11146015ejc.350.2022.09.13.19.57.04; Tue, 13 Sep 2022 19:57:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229479AbiINCdp (ORCPT + 99 others); Tue, 13 Sep 2022 22:33:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230019AbiINCdi (ORCPT ); Tue, 13 Sep 2022 22:33:38 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0F9426555C for ; Tue, 13 Sep 2022 19:33:35 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit 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/ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.34.1