Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp289753rdb; Wed, 17 Jan 2024 01:53:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IFvf9/Ev+LbrbbuQtQDI5FcJHSApVv4CoQ2mOL05yMgh/K0ddiXFdgVfeN+vHWjy29PG/eE X-Received: by 2002:a05:6a00:1c8f:b0:6db:8b48:ddce with SMTP id y15-20020a056a001c8f00b006db8b48ddcemr2921488pfw.17.1705485193710; Wed, 17 Jan 2024 01:53:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705485193; cv=pass; d=google.com; s=arc-20160816; b=wCmFRGYUn9giwiqey3HWKqDil9HhMwWnwcO2atzBMsx1OZT7vpn0G8LnJJTVPb3fFC OmwU2xBIg3GasouF11gc0gNEzRXE2zCNpoQmx66oExeb1+5lciOlOiXRXZ9FOictZPGE 70AXe0fQj3FmoFIBitxKNHIMDAH1oIOataLdK/lGfus1QSwx5HgHTo7M7PncYCYCx4y/ TjjQkfqVeYQlcjQg8vre4/sZtk3FvkRSKjiEiXkUD8vpRHKbXB2u+SwFaUp3prs+OlQ/ PupKOWh3ZwsxxcBMycnzoZ3Q9zpXSXcIhhlZJgpWK26eQSNY8zxm8dKqaNJyyBbLsYvm jH+A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=/N7eo+PKWQbtdhFE2Ma1k5gF85XRa6NcuJZbycWLyxQ=; fh=PdxaOaROxVZUE+tyaHOYRHN6VtUP4w5KvPKQeJgZV/8=; b=L0deTYJ+YkIN7KRZKCMT0upowOtGj4eF5pAlHnswqTnfq6mVdzKDQrprBZOemnheG5 PsQkL271WDoohqAWf0X35S1fPxGtOTvm4vV8qN6FMFQ0dGJno04C/r0ytXFPurA76Sha ZKdjhKqnpz3YPDEjdHIgXEcrzImQbhfIVnyOIQ1VGnEInUqln3C8Y1rvyCdScxVSaX5O Wvm1vroO4DYkjNkQ49879U732ywFjbbbOpzk0f2BN0uJ48UuVivBL+EScIu0NqQQihCd iFq2EqVS+ATz/l6MCRRUxUhhqMfWIRReT0bj3nfC32ET/sfL6+BB3oOrnSz2S+jfCDlk vxyA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=HR0gGpc2; arc=pass (i=1 spf=pass spfdomain=bytedance.com dkim=pass dkdomain=bytedance.com dmarc=pass fromdomain=bytedance.com); spf=pass (google.com: domain of linux-kernel+bounces-28769-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28769-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id s15-20020a056a00178f00b006db9bcb8f7dsi1174488pfg.362.2024.01.17.01.53.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 01:53:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-28769-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=HR0gGpc2; arc=pass (i=1 spf=pass spfdomain=bytedance.com dkim=pass dkdomain=bytedance.com dmarc=pass fromdomain=bytedance.com); spf=pass (google.com: domain of linux-kernel+bounces-28769-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28769-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id B4BDFB21531 for ; Wed, 17 Jan 2024 09:53:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C740B14277; Wed, 17 Jan 2024 09:53:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="HR0gGpc2" Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D8CD1426B for ; Wed, 17 Jan 2024 09:53:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705485183; cv=none; b=iH9ocuACDv896NGMHVIENcbhvT/WEnh1DME+7U1h4BSifUB7gBJ6OPN7DuEugTMr4l6A1rdxSAgmNWefbq/FcgpYmvHVFJtr/RE3t/3URmN/EdbG6s4+N7QfE52xwq/0rBv/p7tymxDbfNP+mywwMAKocJNdYOjL7LUaJRbFZzo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705485183; c=relaxed/simple; bh=p6bd6mq8KFsjzFJ6wNa5CZdWzu0wPSbOf1Nsjitat3Q=; h=Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Google-Smtp-Source:X-Received:MIME-Version: References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc: Content-Type:Content-Transfer-Encoding; b=X+DInG3D2YsszTc/dyhnLAsu5/667JV1BLMfodot98kvyYRb4esBJN9BPqL+7kywCOkErV0gFCSkODdEOxI9VEroNlbQAtdNZWj8GT4iRS9sluiRgMJKmbnRHGKCI+hnQ64LRZXN0GUv+GZLd+NwbAkM649NKQZvILYU4cz4tHk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=HR0gGpc2; arc=none smtp.client-ip=209.85.167.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-50eabfac2b7so12809945e87.0 for ; Wed, 17 Jan 2024 01:53:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1705485179; x=1706089979; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=/N7eo+PKWQbtdhFE2Ma1k5gF85XRa6NcuJZbycWLyxQ=; b=HR0gGpc2pNpx6TPlvs0c+yQQuClzdsMtFQwJJmsxBBjvnYRYrSLPA85sA1hKtHxrqn xaXjzX7jkyaaI69gpxQVa7p3E3K2YrdRBJhhqpIvXGr7lYQ/qdDYQCzywxd2Lb5/ctXW OJSnkKp55Zmb4HNxwXpG1ocls1B2KVLTtD1aSqAcbtwgfXuA6bwaPt8BAOI+VedONtHg BZi4kcGHkWIHWIzPxS6dJkGB7sdXkiO+RRHS0dVOcBd1ewwcG2OjLgE6q23udvGjDvn9 CU+nL8ADgebWbKzscx+V7m3H0+xwdcl3u6RIHMV2MAQECV9HFJaSJblc9ibRnb1ZTZQq bIEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705485179; x=1706089979; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/N7eo+PKWQbtdhFE2Ma1k5gF85XRa6NcuJZbycWLyxQ=; b=d5r4gfY6yeumX5vLOkukAresmhPB9IAAowpBQ7wzAY7Ndg5QcQxjsx3IwqQHKMMh+U wn11ARc1TrzF233SZe+eqikU18lgse7YYID5aJW9r9wMT/Wb0Ow7EbrW2RKTQiyXuYkh 7+akMs4tWoqd4hfslI0pJNVWQAVhf3lZIRNBv7Y1oc2oYnnk43GuSgFeQ/sahMpK8cz2 Q8XNoWIUBs7eebNXA9zxrtRJrUNB8+L+OS+2iBdY9vgCy9J6WTPrCzGLHYU+jdxztCBG z5tscVRPCK2HT2ochvB+/sxs80OzSEX3Kos9WQ6Smm+I0HFYBhWhuLk45HfmiylbK7LV xLEg== X-Gm-Message-State: AOJu0YwZLGIseSU6BFIrWhV3+2NA1FxFUuuHZ+iCe3/u36814ZE24xsY iIdIhOk3sS5XykBMrCBgPz/bNM5x7FZKiXzcPBfpJeOTz9nu3A== X-Received: by 2002:a05:6512:2007:b0:50e:dc99:b9d4 with SMTP id a7-20020a056512200700b0050edc99b9d4mr3538603lfb.44.1705485178988; Wed, 17 Jan 2024 01:52:58 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231024142706.195517-1-hezhongkun.hzk@bytedance.com> In-Reply-To: From: Zhongkun He Date: Wed, 17 Jan 2024 17:52:47 +0800 Message-ID: Subject: Re: [External] Re: [PATCH] mm: zswap: fix the lack of page lru flag in zswap_writeback_entry To: Yosry Ahmed Cc: Nhat Pham , akpm@linux-foundation.org, hannes@cmpxchg.org, sjenning@redhat.com, ddstreet@ieee.org, vitaly.wool@konsulko.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chris Li , Michal Hocko Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > > > > Please forgive me for adding additional information about this patch. > > > > I have finished the opt for introducing a folio_add_lru_tail(), but > > there are many > > questions: > > 1) A new page can be move to LRU only by lru_add_fn, so > > folio_add_lru_tail could not add pages to LRU for the following cod= e > > in folio_batch_move_lru(),which is added by Alex Shi for > > serializing memcg changes in pagevec_lru_move_fn[1]. > > > > /* block memcg migration while the folio moves between lru */ > > if (move_fn !=3D lru_add_fn && !folio_test_clear_lru(folio)) > > continue; > > To achieve the goal, we need to add a new function like lru_add_fn > > which does not have the lru flag and folio_add_lru_tail() > > + if (move_fn !=3D lru_add_fn && move_fn !=3D lru_move_ta= il_fn_new && > > + !folio_test_clear_lru(folio)) > > > > 2) __read_swap_cache_async has six parameters, so there is no space to > > add a new one, add_to_lru_head. > > > > So it seems a bit hacky just for a special case for the reasons above. > > It's a lot of plumbing for sure. Adding a flag to current task_struct > is a less-noisy yet-still-hacky solution. I am not saying we should do > it, but it's an option. I am not sure how much task flags we have to > spare. Got it. > > > > > Back to the beginning, lru_add_drain() is the simplest option=EF=BC=8C= which is common > > below the __read_swap_cache_async(). Please see the function > > swap_cluster_readahead() > > and swap_vma_readahead(), of course it has been batched. > > > > Or we should leave this problem alone=EF=BC=8Cbefore we can write back= zswap > > in batches. > > Calling lru_add_drain() for every written back page is an overkill > imo. If we have writeback batching at some point, it may make more > sense then. Agree. > > Adding Michal Hocko was recently complaining [1] about lru_add_drain() > being called unnecessarily elsewhere. Got it, thanks. > > [1]https://lore.kernel.org/linux-mm/ZaD9BNtXZfY2UtVI@tiehlicka/