Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp437525rdb; Thu, 1 Feb 2024 12:57:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IEF95dvvW0hlO1IhPbI4Lvxp+txinbx4FHXDthm90ybO6pnRhbJ/tVybx2MOWEy+iBv919y X-Received: by 2002:a05:6a20:6c91:b0:19c:6a9c:2c76 with SMTP id em17-20020a056a206c9100b0019c6a9c2c76mr5972201pzb.10.1706821021072; Thu, 01 Feb 2024 12:57:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706821021; cv=pass; d=google.com; s=arc-20160816; b=KnB4Ml2LQA6/TgTWOLKO5trriSmXLelFYqap/MRDaHXbHywGL1/zov9gKIbfGb3Ma6 HY1Tql4niYFDfUsOZoML3j3TzwPt/cEoZfyCFU9mh014OiQzXBy3tSVxG9PAhUWxc/gP dydTW91Hwo0fFWWC2U4U7U0OPCJ5641OQmY174yEJDPK6kouYOqR/upSMv2k4tWj13SD NkSeERFgfTdpnN7j2XIBFXFVfIL1m8nuSIoFHg8oQSQ/zacPWTxsQ4uUWKW1qMj8ldqy 4QYgpvGwAmxHCi5rylp79i8JQL0zOf/STQNJw18+WzvolSMSuN4oGj5Cp/BoN/wfdn3G emDw== 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=Y/nlONtiYcjv2EyDK5zfAVRy4ImGtBKSD5gjZQq28ZQ=; fh=pD314jV1L6ClTDo9dOx64uzSxoh/BRmqD8gpm5BIE6Y=; b=dgczEAvWlKSawi7byArx6IQhlarF+8bPjJevPk5AeAe3aldQCpLcw1Iuu8PESw+c3o 83GHRKhZgcFiJG6PJ8kerSUJhinLCDNYCE4FQ/sEHOvbVuwhgVfst4CUOCBR2KBtJXzV Om1s12xWZWlA9f2fL69HowOFxolze9xsQ9iQa6LX9YkmgM7wF27b0llrEmbJgwIERmX6 +myKJWGKaPrdjU/MHpfv1q5YJeJnkJS3hWmx1VYyNPqEqejNgt0zefG94iiExXtujcFu aZrObUpzeTeGL/VE4bDwQPJlV/+SKmZr1iNAXGfnjs5/E8mPalIprwQ7vagd6VujrGJf jT7g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=X8Ofmlh+; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-48834-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48834-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCX0WNadwc55dvqSxHA0bJ+10dS8Hoj9ykd2bC2Q2upOG/HX/kDg2FyvQmJi+vphqZoPtKvkIH9nMbJBL7hERcs8OWXd80MgBQnOiSErwg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id v9-20020a63f209000000b005dab535faabsi311381pgh.231.2024.02.01.12.57.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 12:57:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48834-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=@gmail.com header.s=20230601 header.b=X8Ofmlh+; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-48834-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48834-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B836628CBDE for ; Thu, 1 Feb 2024 20:57:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BC2773CF6D; Thu, 1 Feb 2024 20:56:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X8Ofmlh+" Received: from mail-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) (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 830633C48D for ; Thu, 1 Feb 2024 20:56:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706820993; cv=none; b=LTZky2aSeEp20GyHXaivroKeZD+12SSVMzBnkuh+vJOAydSvtuwbwrVu9kIe/WkiHWBfyH0261XKODY/0GQTh41hCXRAsO6hA8k7k/bX0EHKqWNDNKSSlyKMrvp9dePfR+lhY8UE3TM54tICcYoz1lg38FQjkO2gX3fmXVf1OFg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706820993; c=relaxed/simple; bh=Y/nlONtiYcjv2EyDK5zfAVRy4ImGtBKSD5gjZQq28ZQ=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=LpyZ7yQFvgnuFdT0W6AUl62xFyAglVsiIPlgXZL0Il/OdIknP2Juo1j2ur03Ms9COrbrSG0vyj0bNRYv2JCxKrVQqGnxVcWVKflvhLMhLbga3UIr02XpzcHgD9mmX9wsQFF6drKrTrFOSj+Xdtk69v2iuQ54MEhfawkBQMZ3QL4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=X8Ofmlh+; arc=none smtp.client-ip=209.85.166.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-io1-f45.google.com with SMTP id ca18e2360f4ac-7bc32b04dc9so51914539f.2 for ; Thu, 01 Feb 2024 12:56:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706820991; x=1707425791; 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=Y/nlONtiYcjv2EyDK5zfAVRy4ImGtBKSD5gjZQq28ZQ=; b=X8Ofmlh+Tx1DtvcII31UGUR5PQRXyiTGsgv2mL+DE2SPuus1YA9qO4kJ3nAfGAAbod CzsOPkjWjWN/no98gCHk7+Mr0uk1GW6ihcggtTvp/Zlm/lwnLYcwPrRFh6dmTImsI+br vQf/gvQtZtB/ECcLWdB6c/67kQVfbV1wx8fHvbfelIusIzrcpw7RWDQonuBMei3cT7Qo Thh90ZG6r05RVGhBLXzuUyV7wzXm0+iVyO7lYOz06t82XqzRWOhc/hGBl3bTCfeA8lSJ Fwz520BDSEuaPZ7DK90q8qRLPOkGmtWJ3Puc60sDqmqW8/XNtZ/eBn3dcoDyyCNuGWmV oNiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706820991; x=1707425791; 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=Y/nlONtiYcjv2EyDK5zfAVRy4ImGtBKSD5gjZQq28ZQ=; b=Tyd4PJh8jOdopgKdc3p0KWhE4EUcHjB+ApHBJkrnUwghl6DTph306H3H70o/8KjcWY bMMMsCOzij5lMoAUEmanSXh2p1vJTthS/uG5BfH4LwZchqWrsG1sW4lW5MeQE/m5p9xK d5rMKKfX8jDm9dYaarrwldz4ucwHVH3eOXYRwk2FZ7ovqcChCEGhGgBrs3azIdF+pAVN mktskyACQnrCpDI2d2wTpWroLMRWHQJbmZ+WxOSZkPWOGETIBNqNCbROFuxOiS44j1g4 kMMfLP74dvK2UM9WxwhoYDQI2SXyXA6PgXAs/VP42EZ+F7cS8H1xMv5o7fWmvM2T3vYs +yXA== X-Gm-Message-State: AOJu0YwKZtkVcLwNsZwQYj39fcIWpLr3SYi/fI5Cfbrk85gIx2WWut2u ttZo6jKDLCZhNxj9JpBSHWMxJQk0y/peFEIkgM93FfwvUWL5uPB2ebZtYOc8DNMPQP8UiTnM1eh Tj1NkTBxB99ghrGbq2HC/5yG4sB/hHZl6Qeo= X-Received: by 2002:a5d:8acf:0:b0:7bf:fd6a:dba4 with SMTP id e15-20020a5d8acf000000b007bffd6adba4mr7019607iot.5.1706820991520; Thu, 01 Feb 2024 12:56:31 -0800 (PST) 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-v1-0-56ed496b6e55@bytedance.com> <20240201-b4-zswap-invalidate-entry-v1-2-56ed496b6e55@bytedance.com> In-Reply-To: <20240201-b4-zswap-invalidate-entry-v1-2-56ed496b6e55@bytedance.com> From: Nhat Pham Date: Thu, 1 Feb 2024 12:56:20 -0800 Message-ID: Subject: Re: [PATCH 2/6] mm/zswap: invalidate zswap entry when swap entry free To: Chengming Zhou Cc: Johannes Weiner , Andrew Morton , Yosry Ahmed , linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Feb 1, 2024 at 7:50=E2=80=AFAM 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]=3Dcount()}' > @[-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]=3Dcount()}' > @[0]: 259744 Nice! Reviewed-by: Nhat Pham