Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp521641rdb; Thu, 1 Feb 2024 16:11:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IFj2aeB1LiZoXvdm1RM1FKss/T0wAhX4ld2GuvAMJQGXLuINLL/fl63huIXNi5p2UG3t4zz X-Received: by 2002:a05:6808:1597:b0:3be:a57f:9f0d with SMTP id t23-20020a056808159700b003bea57f9f0dmr935206oiw.11.1706832716922; Thu, 01 Feb 2024 16:11:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706832716; cv=pass; d=google.com; s=arc-20160816; b=XW3ahVykgHVRigcogMc6qBCK5XCfFcLomzW224D0+lvjT3zrEKxXgqwjzosvVgXzmq 5jkX/yfzmDMWvRwcjCoqBtJ8xE9TaM+Bh/kSB5oKPBkO0IkcpN1OGbjIQDlrXEzAxaMX ETvi+EtZZ7T9wuZIcwMq4sV0s0nYyG7bA1+LnqlA3aff9ZJRuU0U7UI4+R5lV4Hm1x6H D9tkgZXGmPFvi2iKh9wYVgKYtfIZ0AYjf0oTh/jCaqOkHsyMwoRI3uE7I8scf90Of3J5 uTnUlRZ7po8GI/YbcYF62FjGw4lRwd0A7WhopCvHToQ3n9i7RMdKFr+XnLaBxBV+BaLV AuGQ== 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=mDT/qE/+WVGmDsJ6kPb18GmoSMaYniB/v/SigU85+bM=; fh=fGbvSi7f9FF8AknkfCwpVyxwX7UpQsPVA2ZWIu6+SBc=; b=TAwUc5dDM50iFbQrnr4iXTP7UVR6exRrEVTOhrvBgWKM1etXleFszzCNn3bOu/eiAO ac5ve7MXaPBvxkYirQMq7dcohpgop7vwuY35NZkYjKuwxkzv7MRUPw13RWgl5cy8Flrr hj0EfMOQ6ymWetmS/XCWPHzfpHsYgfst4+WZnZJkH8rqNZVJbVtvNEp+M3wIXN93oT9x edHZzk75TCZVIPpPeDXoPGr4iK385WbmvuHBxgTD25ZkaStPiciLqPcLmK1ENQp8d1tT VY5zNsUP38INTKpHh9EH2JO9eQCpNISYxyXvdmGNANx3AhxRhzOCYOsrCg2NFE4q0rJA 85mQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=s+SHRizR; 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-49024-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49024-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; AJvYcCVlxu7tPiDsfPgk5gQl3oAsfwphyok2qNJ3Q7yhWtcnvSVBNHNlMunx+592530/8XXrQKLMIMhzH4pTalAg259BJoTUQUU4ZFslZuzFCg== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u22-20020ac858d6000000b0042a9d83bc75si695202qta.571.2024.02.01.16.11.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 16:11:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49024-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=s+SHRizR; 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-49024-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49024-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A71881C23EA0 for ; Fri, 2 Feb 2024 00:11:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B29F8137B; Fri, 2 Feb 2024 00:11:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="s+SHRizR" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (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 6F4927E5 for ; Fri, 2 Feb 2024 00:11:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706832710; cv=none; b=ilOCuF0jMFtA2+0ZvRB58YLkelngkWFlUx3M092NaxAfaZtMwLVI3Gjm1pgD1aOSHhl2DjjpIHpTG+08g+/a6vP24xXkrQkPLLnm+lwcCMnAznXdYooEv82r6+LaFPc3z9myWMMFrcW56uiRNcq418kT2183XbjeyxLCO3A0Grg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706832710; c=relaxed/simple; bh=lhjdbRHbvdHY7Z3TOsOTDkD9TWvKmPMv1mfS60RvpeY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=hU5AWDv6xDFk22Aaz+JpT2KGMjssINbdbHLIAo1XG+ATVOhlHs1vmjZRBXqAI1wAacBXF2QCjecVyiaRaU5ac3RABK05hr8iCKNh0wp/bYVIq2gu3eeq/tx7ObsSUuLusOk+51m8Jw0QHvnj8l6U8WMK0tAPhTMzR71ovkFlg2I= 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=s+SHRizR; arc=none smtp.client-ip=209.85.128.202 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-f202.google.com with SMTP id 00721157ae682-60404484c23so29134947b3.1 for ; Thu, 01 Feb 2024 16:11:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706832708; x=1707437508; 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=mDT/qE/+WVGmDsJ6kPb18GmoSMaYniB/v/SigU85+bM=; b=s+SHRizRcLTCZtAmRFwN5GccUZJl+l86pIRVqnXZyX+YMNzP4xUrBytDf5taSSBrO5 MU/P7/iPfptT9+GQLb/LHF+R/eg8JMVm8FMTm6zlFp/r9fR8r6JSBmi5NYUReVFobc+D n3qkpdz5ulp4KGdCvZZUF2NuztUq7Zx3yjTlyMRP7ENnkWqzO2/l5fYPDqdU0sGwitiN S8bNwydvxWVVv/HsavhxhI/LefXPor7NB1oL2IfoP8wHHkCbPtFezobZZe+TmkiWiIxo G7Ca3R4A8KzGQPzQy0hxCOhAdNQfkoTdGJi2yAdNC4s4cZ9krTWeGlNOjB6VFknyLJCj HVkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706832708; x=1707437508; 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=mDT/qE/+WVGmDsJ6kPb18GmoSMaYniB/v/SigU85+bM=; b=F3W4+ldQUhTf8oiIWOikgPaqH7sPovFVaF8eUwBII5mNA9FaDsEkWx1LwEIkjNf538 x7f++FVdtgqnQzv9ou25D7QevC3v8ozt+ZPJdPVlZYTSHt7H7d9477kx0JdUVrCK/sKZ tRhETlJeAwCJDUN0y+OkBC0iF2U4D4l0bysXNg4HC8sAOtkxCYDMDee1/zm9ZyAONd82 WAVL+PIHlU/c1iJBlvKqx180oMG0hiqUwGa1mfWaZRSaTjhyGownNQFd868I4GEE8zgQ Y7qMkkDRP62biIiMviaoiEUubmI7aLcAs4uKICmDwQLILuQM37f70eEAtB6Fx9/UvT4D 3FSA== X-Gm-Message-State: AOJu0YxRJPvR9wqHShD2enzjMtkFPkLWx2kjbLUauWdfTFlimagfubyI jauRXcKW7yWUKFXgLXq+PLJkKpBMN24FtW5nSgsu8y+5RTrXAc7HbtYaliP7pAkZ85ZerS9S/cQ 96VQx/dReJ9hv3zctyg== X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:29b4]) (user=yosryahmed job=sendgmr) by 2002:a05:690c:39d:b0:604:228:7e with SMTP id bh29-20020a05690c039d00b006040228007emr1405545ywb.8.1706832708419; Thu, 01 Feb 2024 16:11:48 -0800 (PST) Date: Fri, 2 Feb 2024 00:11:46 +0000 In-Reply-To: <20240201-b4-zswap-invalidate-entry-v1-2-56ed496b6e55@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-v1-0-56ed496b6e55@bytedance.com> <20240201-b4-zswap-invalidate-entry-v1-2-56ed496b6e55@bytedance.com> Message-ID: Subject: Re: [PATCH 2/6] mm/zswap: invalidate zswap entry when swap entry free From: Yosry Ahmed To: Chengming Zhou Cc: Nhat Pham , Johannes Weiner , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="us-ascii" On Thu, Feb 01, 2024 at 03:49:02PM +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. This makes me slightly nervous. Should we add a comment somewhere just in case this is missed if someone adds large folio support? Otherwise the patch itself LGTM.