Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2674750rdb; Mon, 5 Feb 2024 14:06:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGjhYkyBT1HzQV4SZuSodYvEMXb39y8PA5XjclO+xmJtrUJUlf7JgrYUC/q/jkSKTR7n98o X-Received: by 2002:a05:6402:7c5:b0:560:5417:5d81 with SMTP id u5-20020a05640207c500b0056054175d81mr413913edy.21.1707170766292; Mon, 05 Feb 2024 14:06:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707170766; cv=pass; d=google.com; s=arc-20160816; b=snk9Ri02uZFuXofpK2VMBXPSwWZ3Tob3TvZkSQ8cesEC7Pee1FSaKAozOFJSI4X5JL rgtGgWVs7MbmF8s6fToJCn1sKUsXhp9BoXGhh5OyfiLwnygC4Yh1qybyT6VmcLp1lB0H 7cyI1zJOFN3ko7pU2StP/zk2C9jZX4NhHMglB3/OgZju1laxYyUrOxinTexi71TvC98k H0QjdUWUiDuPiO2ocMM65RTpR2epMLkYEWQ0+yx8kSakmKoLyAqi6y8Mv8DLEEnpDZ0H SyGkXZskF5YyoTgOuU379G9ZVUtZ+QU0de/tCiFP/Vy5SD+JBvUVfpcdGC2d1Ctw6xrP rlhA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=jNIvfpTU2Fpa4ge5KnuIotPD5KC6q3mmjxvezR8AkOo=; fh=VfrMtXHPCTrpBTaduSUoYbOMSU+bUq/PnoK+48ffNpc=; b=U/SWQNdzP9Qp/GnrEaEpUmCgCwWCwInE/DbmdT9dHNKrLVQinfa1UR7P2kH3cZbDJi iPbnVjfxneTv6xGp1zlNhBEnb81Ngfm8Lv7RWdyECmE/gvfBTJi7w9Il5DjzR2f4+6je KGBcP/mYeIhqgLUFobYSNHWTUSwzfMy56a5PocRCddpKWwRU6zjS1tRS1Km17EGZWuHV 6Ct9ZKgvJ3UOYV7DCr194nB+zTCQxsGgjercYTnWbdPR3vOT9C0KJsBqX/wymXHXr2QO yNRHfVLcAIUfY4TMa9hWzuMczbjZXZhhKxzVyA8fSEjY4GkSM+5M6wJ0eSe6LqWLhQOH a1ZQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=KsDHlM0s; arc=pass (i=1 spf=pass spfdomain=flex--yosryahmed.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-53967-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53967-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCX8KotBf+QIBfDK6GBbr2lCtKBtEOnRNmKHBAdu/CRCBAeM6cpfbrQZElOoWsqWpsV2zXn6m1Suie0GIqpVHOHn5MuCCqLZ68ehPCCFzQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id d5-20020aa7c1c5000000b0056064d1163fsi310696edp.494.2024.02.05.14.06.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 14:06:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53967-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=KsDHlM0s; arc=pass (i=1 spf=pass spfdomain=flex--yosryahmed.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-53967-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53967-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0C1CB1F2CC74 for ; Mon, 5 Feb 2024 22:06:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 421144F602; Mon, 5 Feb 2024 21:20:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="KsDHlM0s" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 DF3E945953 for ; Mon, 5 Feb 2024 21:20:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707168051; cv=none; b=H0wuiMQ1ZG9089ikgcPYWdz7esdC9Qi9yoWhbgoYvrPvLWC7EyYA0fUraVkO1A5e7buzQedWiPYK2/CGMTbWGiaa0UOJdjO4WwapIHXHLbAUVwOSVNQXRo1hb6njO9ZInZMky2/OLTVW0gfjE2y5qvvQOEWfwvQSWc9zvHnAQcw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707168051; c=relaxed/simple; bh=M9O3+Ozab6saJ9Z898RaMAf45Ltfzqt72TIxEA7NSds=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=E1ncCwmDct8FKbwmSo9hSdNs4J6J3XXpvTf1VKJcOYk29ObKNwp3+6Gi9Ds/KkwKgvJ30s4yTeL9VU/nPuE0d9FkxTQ9Gxfo9riSmiKWNjKU4XnJyPkuwwBiIvfTjEsdNMgjj3bHkhNuo7d3Tm+LE4/KygqsgfW86V1fbNgyHp8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--yosryahmed.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=KsDHlM0s; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--yosryahmed.bounces.google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6040a34c24bso3478547b3.0 for ; Mon, 05 Feb 2024 13:20:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707168049; x=1707772849; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=jNIvfpTU2Fpa4ge5KnuIotPD5KC6q3mmjxvezR8AkOo=; b=KsDHlM0soT9qHy72nMp+pmFlQfvY+J2Vy6/RKbSpR0G6RLHY0KWQz/MptMS5UNUdqT eeghsPO7jhE/hNOLf4SLxxfd079JsXVufE5g6B+2GopueuqLnwh2PdF2SUxiAKVw2IuN 1DqgUgR1tnOOWsPvqGLdj9yqwGG4xNqThJvH1gac2lln71XFqFYoBz7KVgL8qzyLORyC NflTDKiKwRzUFkFKZIWIYOSPzMwbsyWUfY+jnIYQo2qroOGgK/CBY1uOUml4Qoag3DTU KMZqTdQQayw84vfKhpNNpodPlICJfhcqdb+OeeiJ6U159hZnV4yEdioIS18bsd01GCZ/ 9iPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707168049; x=1707772849; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jNIvfpTU2Fpa4ge5KnuIotPD5KC6q3mmjxvezR8AkOo=; b=wYN8X/PZIgC+NkPuVL+uD6F2FIspipO2G7HBIJdhpYoGdXTGRNXuCtbRMvABE1u71g afLzfl0o81VFFfu64QR4QzVlYntkfQpxSV68+FKGfS+73RBXrJZsKp0DV0ajKjs2zgOK Shfva4U24T1XAIdQPWMO5nWlFNbmYjfo3bew4eygrMN7BnuWcMUb3Zr35w6IxX5kRsRn 7Y9hYupsXAymN94SHwXhGC73XsX9z15MeWOoZHB5ebPo+yLbCnLpQdshpuD+Cqh9kUMt m8EXF/A6hYczWSlpi+Te/+66Jl+hB5nM6cXJmdOHXytS3PSlE13uviMOHZUh/N3cxyim AO/w== X-Gm-Message-State: AOJu0Yx4xajkefyjHJhfhdny0qh0xRVTi9jDoyYGKeLbNguM1UeFYpgT IDT7tenETcKDBaWBMHmz1YGoRah9KNsjMmj/GEVtmEM2mYdsetv/WEYZtwieom+B5OcqbDhDp0Z 8ewBPlNk5NadsnrW/jg== X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:29b4]) (user=yosryahmed job=sendgmr) by 2002:a81:4cc7:0:b0:602:d83f:bf36 with SMTP id z190-20020a814cc7000000b00602d83fbf36mr150466ywa.0.1707168048867; Mon, 05 Feb 2024 13:20:48 -0800 (PST) Date: Mon, 5 Feb 2024 21:20:46 +0000 In-Reply-To: <20240201-b4-zswap-invalidate-entry-v2-2-99d4084260a0@bytedance.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240201-b4-zswap-invalidate-entry-v2-0-99d4084260a0@bytedance.com> <20240201-b4-zswap-invalidate-entry-v2-2-99d4084260a0@bytedance.com> Message-ID: Subject: Re: [PATCH v2 2/6] mm/zswap: invalidate zswap entry when swap entry free From: Yosry Ahmed To: Chengming Zhou Cc: Nhat Pham , Andrew Morton , Johannes Weiner , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Sun, Feb 04, 2024 at 03:06:00AM +0000, Chengming Zhou wrote: > During testing I found there are some times the zswap_writeback_entry() > return -ENOMEM, which is not we expected: > > bpftrace -e 'kr:zswap_writeback_entry {@[(int32)retval]=count()}' > @[-12]: 1563 > @[0]: 277221 > > The reason is that __read_swap_cache_async() return NULL because > swapcache_prepare() failed. The reason is that we won't invalidate > zswap entry when swap entry freed to the per-cpu pool, these zswap > entries are still on the zswap tree and lru list. > > This patch moves the invalidation ahead to when swap entry freed > to the per-cpu pool, since there is no any benefit to leave trashy > zswap entry on the tree and lru list. > > With this patch: > bpftrace -e 'kr:zswap_writeback_entry {@[(int32)retval]=count()}' > @[0]: 259744 > > Note: large folio can't have zswap entry for now, so don't bother > to add zswap entry invalidation in the large folio swap free path. > > Reviewed-by: Nhat Pham > Acked-by: Johannes Weiner > Signed-off-by: Chengming Zhou Acked-by: Yosry Ahmed