From patchwork Tue Oct 24 14:27:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhongkun He X-Patchwork-Id: 13434690 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 D78C1C00A8F for ; Tue, 24 Oct 2023 14:27:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 56EC76B02AC; Tue, 24 Oct 2023 10:27:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F6AE6B02AD; Tue, 24 Oct 2023 10:27:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 370356B02AE; Tue, 24 Oct 2023 10:27:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 249786B02AC for ; Tue, 24 Oct 2023 10:27:26 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D36C3C02FF for ; Tue, 24 Oct 2023 14:27:25 +0000 (UTC) X-FDA: 81380582850.12.3D62956 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf02.hostedemail.com (Postfix) with ESMTP id 1990C80008 for ; Tue, 24 Oct 2023 14:27:22 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=f+FrHHz9; spf=pass (imf02.hostedemail.com: domain of hezhongkun.hzk@bytedance.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=hezhongkun.hzk@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698157644; 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:dkim-signature; bh=YcQTC+eJzzLlnaNT0UmsWQUFrQijvQZ05PsjYq0iiBE=; b=JwUiQXg4Q29UwoMUnq4WAhTxvhz36G38MCMJeQNAjEUXTKR0lURnXZ45gd5Cn68zofaFbH t3EZCevc0GZd6uT/ZUM89m3h7FyY/QJzDnoMp858kJsfok/ZkdEBYf81N5cvVK6/3Ra82D P+sesQU+HzbfmmY+vxXAgCL8u8ZQmxA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698157644; a=rsa-sha256; cv=none; b=uz6vlCY5TUwtjuaoLIb55oa+GCl8nWLjQpWGg9lMgo0C0DtgKGl2iWBQnNFccCmP09g4Dm AVDd9AkNT6suXE7UCFmX5X0vjMYGXGL3fSVy8PfGCX8nSHgC13OMp/geRt8s5T+i6cJOqE cI1Y+45u8eEaYz+YGcyQL74ghswAvz4= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=f+FrHHz9; spf=pass (imf02.hostedemail.com: domain of hezhongkun.hzk@bytedance.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=hezhongkun.hzk@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1c9b95943beso37827515ad.1 for ; Tue, 24 Oct 2023 07:27:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1698157641; x=1698762441; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=YcQTC+eJzzLlnaNT0UmsWQUFrQijvQZ05PsjYq0iiBE=; b=f+FrHHz9DiqDWN8skpP0U5h3s7dOlJxnYw9PDLO1KkbrbbHiyJJ6si/cQHhe8dsB3n 4gHg0JVH8cplDveW5lv6W3Jn9XFgSw3P/Uwg6qku1WuW4AoWyenebFJYSGhPPvK1dt1R mBjmUwM9V/+eC1qVLW8fz6LT3uPCWQTai9/zjYtIjIPWgUE5v4DaPUTzyk6SbINA/A31 1saKhySlGLqSlN3W6ze1GWi1Mvi89DXAMwE4g0OfPONUC/nAxoDkqFven5Q+O4hxAMp4 iE3lbZ7DgQQirVUOQDC6a/w9oilqCzDsfX81A9yiqvoBT8RQi86gFL3KbnUFM+1ipIqT M1FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698157641; x=1698762441; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YcQTC+eJzzLlnaNT0UmsWQUFrQijvQZ05PsjYq0iiBE=; b=LeP+Gpcm6e425u2JqA8+3AdtXo/QLl92q7Free7yV/LoIFXFS8Fb5BrsbVtK/8t1rt 2muENGyFrSTwJOlMpinL1Gq1ccsf5jlos6FmDJYKrQ1fHg+2hDGTEXsUVJKSNAZvCryA zIYQV+IvPzg3PzXGiAWucQGHD7QFHv3o8/PBT8T8kKVQDyIXRSvKeDRfrRylrAQEXIwA nfjGfpIkL4tBv1YHHNIEioTZa0vteDVvKYWQgKCwRJQd3KsAWEtzTdYMsQN09EaraPeL FECj2UOlaJ2FoNQm71fx+MO42VAZN+UJEsCjbdhXuBtcnq0HqIcY0gSt8XsV2aMpuDkI bqpg== X-Gm-Message-State: AOJu0YxoBlh0vzORt+2PIfIz1yTui6owBw2rVlGbJq4vHwfvtjS/zf9J LlCpE1agz5+9RoXa9GQLtLTBcw== X-Google-Smtp-Source: AGHT+IHHAHbFJzr12MFDRq5IG9+LtJIaiU1yv0G+Yr3j00NhXl3Xbofdpc7yRWDb+5EBBHPOfNdDTQ== X-Received: by 2002:a17:902:c409:b0:1c5:a49e:7aa with SMTP id k9-20020a170902c40900b001c5a49e07aamr14869540plk.27.1698157641443; Tue, 24 Oct 2023 07:27:21 -0700 (PDT) Received: from Tower.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id 1-20020a170902ee4100b001c9db5e2929sm7488397plo.93.2023.10.24.07.27.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 07:27:20 -0700 (PDT) From: Zhongkun He To: akpm@linux-foundation.org Cc: hannes@cmpxchg.org, yosryahmed@google.com, nphamcs@gmail.com, sjenning@redhat.com, ddstreet@ieee.org, vitaly.wool@konsulko.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zhongkun He Subject: [PATCH] mm: zswap: fix the lack of page lru flag in zswap_writeback_entry Date: Tue, 24 Oct 2023 22:27:06 +0800 Message-Id: <20231024142706.195517-1-hezhongkun.hzk@bytedance.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: 1990C80008 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 1bxingfqxj8nzofbzihgshxifbyysc5x X-HE-Tag: 1698157642-240875 X-HE-Meta: U2FsdGVkX18DdGkai9R8rbYGvxm0cCE5oi2IQXLKDIZeMDYhwgxHAX6noMu9JcBi0oSYq/8F617rgwkAlwNFLNxylJFLa96VMNZvvmXVkThhyD0GHRJBqGa3f9FPdAp9n+35EcBCCnZxTCvDaS9YhMLSWNtj00MMCeZpirSOWxasWD5kYtPQ3bEQDplNpvzmTYfyEkkYECFRe2IFW9NCvemJcePEaHFzBgpv5DRQ7zsR6ms13NaeKks4cH/cr2sq42yxBizQ2jlPJCvMFnySzhfejr/kpyKX0SY9R3RMfov92qKau/Cpqkxs4dQ/3IQ7MB5u7KCPP9oLroHhhJTVvNVcMYTavncZ5ALOcz1Ci0++hBLpQsfxRiuF+bk/x7Olnx3J6rMv74D89wuGGbptEH0/LQCfTlZ6XGeJgoainNDj3f+tmsFJG0IW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evwQ== 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: List-Subscribe: List-Unsubscribe: The zswap_writeback_entry() will add a page to the swap cache, decompress the entry data into the page, and issue a bio write to write the page back to the swap device. Move the page to the tail of lru list through SetPageReclaim(page) and folio_rotate_reclaimable(). Currently, about half of the pages will fail to move to the tail of lru list because there is no LRU flag in page which is not in the LRU list but the cpu_fbatches. So fix it. Signed-off-by: Zhongkun He --- mm/zswap.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/zswap.c b/mm/zswap.c index 083c693602b8..b9b94cbd403c 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1139,6 +1139,11 @@ static int zswap_writeback_entry(struct zswap_entry *entry, /* move it to the tail of the inactive list after end_writeback */ SetPageReclaim(page); + if (!PageLRU(page)) { + /* drain lru cache to help folio_rotate_reclaimable() */ + lru_add_drain(); + } + /* start writeback */ __swap_writepage(page, &wbc); put_page(page);