Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1236555rdb; Fri, 2 Feb 2024 20:34:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IGvlg7J13pDv7ZL/BsRJ+/rjyNvkwTKSBGEgXFNqU4VrslcbLacB41qxNy5Hul5+4xmE9GK X-Received: by 2002:a17:90b:118e:b0:296:2a15:5f27 with SMTP id gk14-20020a17090b118e00b002962a155f27mr838098pjb.2.1706934894214; Fri, 02 Feb 2024 20:34:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706934894; cv=pass; d=google.com; s=arc-20160816; b=g7RKfDXeTx5ZNUpbWXRPabswNvYdZJRbx6kyvlyBQAnHDBaAAILpCLn1eG161qsDDv 7eUhgUi9aWTmCdyPZvTtyTOFZANoOSQUMHsRxKV+R3MlwigrGkMyLqad3KRkgYekmOHG JEqGpJwdSrst6E7/1KRP//xfa1f/jgZpBLBCKCMuxWkhLNIImJSxvHM7DfTbEDTq4XhQ fpzFIs0gNs5o3fYYgw5yVItk7059HoraCiVH3i4sLEw+0eV74DKWlYr6yJMt9utR94wr CMVEe4QIJtzTvUmH8Ouud08ZGFSyHEqg5ZEfpEOVzx3wN+srML5QbEe8vxwgy1pooHh2 tn6A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=1OOpEywyK6PX3KS+rQWL+L2zrjo4/gGzpSvMxyFSqgc=; fh=6PX0ZYkYh9lrO1FpH0BHPS2a8upCRtCtm8YGdrxzvio=; b=TwD9f6f8a4qE2b1DxlM38yV6stiWDeKkM0FzRtoQib/YBeR07pxbZCC+1jm+gLFXb3 u3HZ6knJ7ih/kBs9Cy/RErTEx2P8IqcFEuyvnhmWw35uPonIyVPZ7WMpFDVV4zz5uKEK jMSEtI9M2yonuOdO5Nr52BIbgI8pWt5lgS5UbK3CfbzQTntRVMFIDPfscBlCrwDTVaUq xqfQ74YqMvipHXorVJsv4han5tVxeiBhtC4/US8yJ8z3fuxV0HOv1kHkM1C7oi/Uk3OO 0uA2qVVxQ6/AupE+qS4WuKZf7C6X3bvKu9zfk4J2omko2WRFN84vmlbdIk/pMLbpF3vA gCfA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=PsTZWgsd; 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-50916-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50916-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com X-Forwarded-Encrypted: i=1; AJvYcCWI6KZhuGmwxWFMMiN97RRxpO283aC/A7JGVkqOD3u4pSO4+M2CiEbTOjXzWZKOQPrD5vBX31d87OTOGbavGF4M6yTz27mSBH/OtFgtag== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c62-20020a17090a494400b00295dda7f384si955873pjh.152.2024.02.02.20.34.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 20:34:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50916-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=@bytedance.com header.s=google header.b=PsTZWgsd; 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-50916-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50916-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 1723B2837E9 for ; Sat, 3 Feb 2024 04:34:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 951C1FC09; Sat, 3 Feb 2024 04:29:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="PsTZWgsd" Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (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 792A12CA5 for ; Sat, 3 Feb 2024 04:29:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706934566; cv=none; b=oRJDyyRUaupkYzgYcMiuc2XOa4eeNP4oi7SUIN+FnCXcFr/y0+ejErADoRKWiGdXdIB8E+BEBNyU2jgh4kQFvlqz4KgCkZVql6/cKs0ALqbg26FNp6+aD9pBTSfgGbg5FMs5+FKzKzli7yVKyKxMiRoVUCXCF01EB2ftxlJbpxU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706934566; c=relaxed/simple; bh=4qqSaaEUaBxS/Ftpx5ut5gMjSpAATXUG2v3pxLtTKv0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Sfbze19L3l07eXEtkma4lADuxbf9WZtig91HDAr1pJvB3RPJID38ZEHl817fxLXAg+2d7hztSP9oLtutCrXBk3DwcDDZVqClTVBJ2U5rBsvLcoOU4KktBkos/2JXvRS3jqdqJmnGbS68bGpdfaqMVznOUAMbiRmidoQNItCAmhk= 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=PsTZWgsd; arc=none smtp.client-ip=209.85.215.181 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-pg1-f181.google.com with SMTP id 41be03b00d2f7-5d7005ea1d0so1061977a12.1 for ; Fri, 02 Feb 2024 20:29:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1706934564; x=1707539364; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=1OOpEywyK6PX3KS+rQWL+L2zrjo4/gGzpSvMxyFSqgc=; b=PsTZWgsdvj8z4doAvoejMFffuidiYXRo19Hv4RUjevLEbsn64+MrDYWTgCbGTvI9w0 zLU/OsOTMf/Qyt/CsRkLiOpM8Bhl0FiWnuzOZYbaCTXwg5uTZzPGfw7YMluj4eUlOckc vznsBnsrEgSg/xE2RsRu3C6yiXP3WC4LK9LiMNWTi9Ht7YXsnLbE3VBXkcErH9O36T38 mLRj5Yrw17FFcycrsG2joUwjwpB7VpjNJM33wYmjp92XMCBR+h6i57qZVRokl4vvOif/ ZRYNaYPlsKf495Kf2YHM4Z7ZCqX0ONXoDPc5Rm3GEu7piGP25GZBMM9YUvbxS0nYQlMb /fcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706934564; x=1707539364; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1OOpEywyK6PX3KS+rQWL+L2zrjo4/gGzpSvMxyFSqgc=; b=TgJC3KBWzvUNBu7LLDPhWwVKDvvSl+55mJS2mTZupXP78RKgR+gf3G8OnQRtxa+2LN NV2/auvnMGrii2r9gTjP8EKetUUdMkchuV939v6K8SizFj37UcLTbIvOIaLMgBZqz0zC mF6MGz8Ck/Zyele7SVeRXsmWXW4n9wcQqsULdiyE54BLT97GR1umCOzRXwgXaoHW7PRO CJLDFno4P+rI583btAxspnB6h1popqvpDZ4FGi+PwcLLcSpfSY9DA5Z5vx6/uRzdc0sm WSYAQJgic2tkk2yTXBOK4EVC8j/jw4Fxk+7m5r/1tAQZ2LQUOBuRuIK8re+FkzXoZ4F9 7urw== X-Gm-Message-State: AOJu0YzhE2R/PFdfbxglFwpnK7zNmW7brLz4jTgY6yiNAzn8sl42D4Fa EcqHc/u6TyygaqubQv2PVG8JxQdWJpYUUmy8FL1ef8KQpfHdEL0yk4gReysESQ+p9B5Y6DuNnxP e X-Received: by 2002:a05:6a21:328e:b0:19e:3839:4fc2 with SMTP id yt14-20020a056a21328e00b0019e38394fc2mr903713pzb.26.1706934563683; Fri, 02 Feb 2024 20:29:23 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWsy5iHsgi0/7lWONXylSavwzjl3LXlbzwKWLoT4phVm66hn6dRJIu0Zsk73Zn+KR5t3KlfTlJJT9dwl8sNedyLikih3mUjodRzQQYkUzgJnGHEjfAzt5Ne5WfzEtQKW09m6YORcudd2qMHpjyd42WTZ2JkdhIWOrA48gSWhqmCAEFR/zu0Lu06oVMuGLHGAtPtaw== Received: from [10.4.12.121] ([139.177.225.224]) by smtp.gmail.com with ESMTPSA id u27-20020a63471b000000b005c259cef481sm2601789pga.59.2024.02.02.20.29.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 02 Feb 2024 20:29:23 -0800 (PST) Message-ID: <80460fe5-baec-4e56-9e10-a233e5a3c8d3@bytedance.com> Date: Sat, 3 Feb 2024 12:29:16 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 4/6] mm/zswap: remove duplicate_entry debug value Content-Language: en-US To: Nhat Pham Cc: Johannes Weiner , Andrew Morton , Yosry Ahmed , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20240201-b4-zswap-invalidate-entry-v1-0-56ed496b6e55@bytedance.com> <20240201-b4-zswap-invalidate-entry-v1-4-56ed496b6e55@bytedance.com> From: Chengming Zhou In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 2024/2/3 06:28, Nhat Pham wrote: > On Thu, Feb 1, 2024 at 7:50 AM Chengming Zhou > wrote: >> >> cat /sys/kernel/debug/zswap/duplicate_entry >> 2086447 >> >> When testing, the duplicate_entry value is very high, but no warning >> message in the kernel log. From the comment of duplicate_entry >> "Duplicate store was encountered (rare)", it seems something goes wrong. >> >> Actually it's incremented in the beginning of zswap_store(), which found >> its zswap entry has already on the tree. And this is a normal case, >> since the folio could leave zswap entry on the tree after swapin, >> later it's dirtied and swapout/zswap_store again, found its original >> zswap entry. (Maybe we can reuse it instead of invalidating it?) > > Interesting. So if we make invalidate load the only mode, this oddity > is gone as well? Good point! This oddity is why we need to invalidate it first at the beginning. But there is another oddity that a stored folio maybe dirtied again, so that folio needs to be writeback/stored for the second time, in which case, we still need to invalidate it first to avoid WARN_ON later. Thanks. >> >> So duplicate_entry should be only incremented in the real bug case, >> which already have "WARN_ON(1)", it looks redundant to count bug case, >> so this patch just remove it. > > But yeah, I have literally never checked this value (maybe I should > ha). I'm fine with removing it, unless someone has a strong case for > this counter? > > For now: > Reviewed-by: Nhat Pham > >> >> Signed-off-by: Chengming Zhou >> --- >> mm/zswap.c | 9 +-------- >> 1 file changed, 1 insertion(+), 8 deletions(-) >> >> diff --git a/mm/zswap.c b/mm/zswap.c >> index 4381b7a2d4d6..3fbb7e2c8b8d 100644 >> --- a/mm/zswap.c >> +++ b/mm/zswap.c >> @@ -71,8 +71,6 @@ static u64 zswap_reject_compress_poor; >> static u64 zswap_reject_alloc_fail; >> /* Store failed because the entry metadata could not be allocated (rare) */ >> static u64 zswap_reject_kmemcache_fail; >> -/* Duplicate store was encountered (rare) */ >> -static u64 zswap_duplicate_entry; >> >> /* Shrinker work queue */ >> static struct workqueue_struct *shrink_wq; >> @@ -1571,10 +1569,8 @@ bool zswap_store(struct folio *folio) >> */ >> spin_lock(&tree->lock); >> entry = zswap_rb_search(&tree->rbroot, offset); >> - if (entry) { >> + if (entry) >> zswap_invalidate_entry(tree, entry); >> - zswap_duplicate_entry++; >> - } >> spin_unlock(&tree->lock); >> objcg = get_obj_cgroup_from_folio(folio); >> if (objcg && !obj_cgroup_may_zswap(objcg)) { >> @@ -1661,7 +1657,6 @@ bool zswap_store(struct folio *folio) >> */ >> while (zswap_rb_insert(&tree->rbroot, entry, &dupentry) == -EEXIST) { >> WARN_ON(1); >> - zswap_duplicate_entry++; >> zswap_invalidate_entry(tree, dupentry); >> } >> if (entry->length) { >> @@ -1822,8 +1817,6 @@ static int zswap_debugfs_init(void) >> zswap_debugfs_root, &zswap_reject_compress_poor); >> debugfs_create_u64("written_back_pages", 0444, >> zswap_debugfs_root, &zswap_written_back_pages); >> - debugfs_create_u64("duplicate_entry", 0444, >> - zswap_debugfs_root, &zswap_duplicate_entry); >> debugfs_create_u64("pool_total_size", 0444, >> zswap_debugfs_root, &zswap_pool_total_size); >> debugfs_create_atomic_t("stored_pages", 0444, >> >> -- >> b4 0.10.1