Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp871715rdb; Fri, 9 Feb 2024 04:01:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGcZdTFwLT7QQKmzY0VL+JRl1UsxyWe4gSiUhr3Lo3Mnl32q+oX5I0uSRN3PgEyVoVnx7v0 X-Received: by 2002:a05:6a00:2d16:b0:6e0:4e4c:572 with SMTP id fa22-20020a056a002d1600b006e04e4c0572mr1373322pfb.28.1707480065824; Fri, 09 Feb 2024 04:01:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707480065; cv=pass; d=google.com; s=arc-20160816; b=kwJGijR13kMAVik+9HyEa0B8i5YDudBj3oIkqoH9f7JOrkmOYbX8T9vDZ9JNRNnDSY IN2mrD8SMP0PJneem/RKrL+EZY0e2EsSfgyKcL/xKgQMzY7ygmVsoMcj1ybab17PxIlG FAiDJj8d/qanJcYPLsVy+lORVc0vlMEpMetg6Kt3QehL/8YgZsEar8zEzp3EDSs9qe14 u1t4VxNc9qankZJiLA78R3LHD7VnTucWp7yYes7VeV9vW0vHGTML0i7UZDQt5eansmqf N4w/4jiNu7imNVPAyAURQl0Bnn3J51+bFX+r/rVcdhpBALVtCtTdkvX/KPYk+S86+1yz LVrA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=H8vjJet6cEqjnm/AF8gtjZ0cWAGZljlA0TlT1cQYzHE=; fh=bE/r4nj6TCDseRs0k5AYT9vd0A8r6oQ+pg66gjJJagQ=; b=cVJBP1ukGzyNwRO0A7ZuT48fTc86qN9tT/7Yq6voVRFNqHklxOVn1GZWHSavuh84c8 yT7baBsS6+DqHfNfFciSl6f0WGK2DwKYKmfjy6X0LqJ2VY+uYR9E7Z082LTqhOy/5ga6 JzMHxb23zjkrk+fSFhUcC0pyN0DasC5aE0ppQv7Vz5/vnynQqyqNSeYLhgZsm31mytWf mXX8NyqxYp7B5GvDeDQdpFQu+3JXd4R2AnonCgwQ7jJfLTeij7nRIC2IPQ9x9BqeVhQs fY1VeXPT3GV8pW9CV00jTb7rkMXJripjnopdIvPne4qQuj6NDa2zxZ14C+ASRxV7CxbJ 97Xg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=wR6BtmIv; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-59305-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59305-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev X-Forwarded-Encrypted: i=2; AJvYcCUY4fTusztOmdypyhtPD9fZAouhLAAa5/8ZxSF7YIM5puYOEPSxllNnFJELzKm7gdmaoXMO2KlWj3Dft1DW9ykYFH8ujWeCqMllZpYGhw== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id o18-20020a056a001b5200b006e08f8d3c81si182074pfv.400.2024.02.09.04.01.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 04:01:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59305-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=wR6BtmIv; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-59305-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59305-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A1DCE28C822 for ; Fri, 9 Feb 2024 12:01:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6DD9F328B6; Fri, 9 Feb 2024 12:00:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="wR6BtmIv" Received: from out-189.mta0.migadu.com (out-189.mta0.migadu.com [91.218.175.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5293F20311 for ; Fri, 9 Feb 2024 12:00:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.189 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707480051; cv=none; b=VC+UzzpePF4FtojxCJilu07tM2sIZxkKMbW6IxxdgootLIE/MyOz7wkX5yPeE4aV+5Bk273sUKQriQPt3/v0qjJCZGk2zbgRYCaNZ4XP1NeV39cx6njlxeJO6VYizrYsTP7/jDmsTz1zn4luGtKeosTI15aeZsf4e4msahap7+A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707480051; c=relaxed/simple; bh=KEBYIrTh33UwK7TabHpZdff+4ImJ7WjKDWafJZ2lFVU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qKgjBCvrKt7ZkU+nheUQHexUr8nckZtqlIkRuEh7KajL54BQkRR+JqgAS/3OcfVYHcdKAh4GG0QHw754wODjpL6QZ5nDF0lsUXuY/4cJfFVp1HOmYMv2zxulqmr9Hx24yrBYoXf36qfJZ7eDzQv6kIUZjthZBxmcpPhoxMS/R0Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=wR6BtmIv; arc=none smtp.client-ip=91.218.175.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1707480043; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H8vjJet6cEqjnm/AF8gtjZ0cWAGZljlA0TlT1cQYzHE=; b=wR6BtmIvXYaNDb25zKYBYPeL0CPBfaQZ6v/7Gr9UKiDDQsSWzzxx4NdEmrRZKajRv9ME6N YsugFwG1wpt+u3qF0D4YGlMz3v4TtSyRVvNUgXu4jBEGgLtudbwWMSYJdnGOcP8klAr4e6 uQsskjmJ2Pdx40q3SmNvSRxSqYIGhG8= From: chengming.zhou@linux.dev To: willy@infradead.org, hannes@cmpxchg.org, yosryahmed@google.com, nphamcs@gmail.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, chengming.zhou@linux.dev, Chengming Zhou Subject: [PATCH RFC 1/1] mm/swap: queue reclaimable folio to local rotate batch when !folio_test_lru() Date: Fri, 9 Feb 2024 11:59:50 +0000 Message-Id: <20240209115950.3885183-2-chengming.zhou@linux.dev> In-Reply-To: <20240209115950.3885183-1-chengming.zhou@linux.dev> References: <20240209115950.3885183-1-chengming.zhou@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: Chengming Zhou All LRU move interfaces have a problem that it has no effect if the folio is isolated from LRU (in cpu batch or isolated by shrinker). Since it can't move/change folio LRU status when it's isolated, mostly just clear the folio flag and do nothing in this case. In our case, a written back and reclaimable folio won't be rotated to the tail of inactive list, since it's still in cpu lru_add batch. It may cause the delayed reclaim of this folio and evict other folios. This patch changes to queue the reclaimable folio to cpu rotate batch even when !folio_test_lru(), hoping it will likely be handled after the lru_add batch which will put folio on the LRU list first, so will be rotated to the tail successfully when handle rotate batch. Signed-off-by: Chengming Zhou --- mm/swap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index cd8f0150ba3a..d304731e47cf 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -236,7 +236,8 @@ static void folio_batch_add_and_move(struct folio_batch *fbatch, static void lru_move_tail_fn(struct lruvec *lruvec, struct folio *folio) { - if (!folio_test_unevictable(folio)) { + if (!folio_test_locked(folio) && !folio_test_dirty(folio) && + !folio_test_unevictable(folio) && !folio_test_active(folio)) { lruvec_del_folio(lruvec, folio); folio_clear_active(folio); lruvec_add_folio_tail(lruvec, folio); @@ -254,7 +255,7 @@ static void lru_move_tail_fn(struct lruvec *lruvec, struct folio *folio) void folio_rotate_reclaimable(struct folio *folio) { if (!folio_test_locked(folio) && !folio_test_dirty(folio) && - !folio_test_unevictable(folio) && folio_test_lru(folio)) { + !folio_test_unevictable(folio) && !folio_test_active(folio)) { struct folio_batch *fbatch; unsigned long flags; -- 2.40.1