Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3131845rdb; Thu, 16 Nov 2023 00:33:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IFznfboSDAWSu1czZ6Tj3n4p6dZqpHspw/wbpyllXB3rYT01+G7iE1UciW+RF9G7GMSzRPy X-Received: by 2002:a05:6808:1583:b0:3b5:81bb:ef23 with SMTP id t3-20020a056808158300b003b581bbef23mr20055811oiw.21.1700123615636; Thu, 16 Nov 2023 00:33:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700123615; cv=none; d=google.com; s=arc-20160816; b=iBZWYwbOh3vLhbWIlbJvNZsSRu+0SqJJk+hX483q6ko26+6iy6CXhu+1VGdAUNmjv0 aYrz5MjmNNRu/6C+Tz3G8wOrwXYSG9OJXraekV4KEz4ZE5lhycQ8oKimWtLSViW1bSZR O2mxZMkrVnNENnMeN5qqYH1AjiIYwcJmWq7Fhu2nj6rbKe4aPwVB6dHVFjWBC5/FjAOl drxCQyThyogkZ9fVNVfa6AXqICtgMy8SE3MLgpF745l0dYzVOmDEHHCZPpeslxZ+mCjR vWHkQRzkEn+EhnC4H2ijlHbUjvk5OFywVVQ+qCa0GYBm/j10IQWBTVTp6srW7cX7zKn9 exCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:message-id:date:references:in-reply-to:subject:cc:to :from:dkim-signature; bh=2pdOAkIF3BrflhUJcHeCmAhhjIUw5doLroEfwG2OVno=; fh=UTwwXFMJ881bwflf8yjeuIBIjHll9KHNXf1DBlRaqOk=; b=ltUIhOhcULHAnpoIfAkApz6SAuSYtAVafaAT6dDPdZh5S7olI2qXSFFf2PE7a2uFY+ JQV+7bQA4PWgocyw/dp66G6n7kZRpt0ca/l9zzgM+HxulkYHyMRwZ0yNp5gUJ0O7M80C pxfgg9rJ5dHs6ELw8w0ydK7DEs2qbEouiMv4cECV1pcIxBq3B04XyaIKEEgwZUgO8iqu EbWgDx7djmBQQk4PaXx7sinCxgchUtPjJbKZU4LQCDBZXnFllEos+5HV5X9fyCzCJICU C7cMNagrxxdCNI2yI5cjYz76fOF473CMTng8q29bl7BbouQ6lNKSZAf0QMJC5llm7KeY EnUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fW9WfrC1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id d67-20020a633646000000b005b928e39429si12339981pga.259.2023.11.16.00.33.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 00:33:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fW9WfrC1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id DA34481167B9; Thu, 16 Nov 2023 00:33:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235126AbjKPIdY (ORCPT + 99 others); Thu, 16 Nov 2023 03:33:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235559AbjKPIdT (ORCPT ); Thu, 16 Nov 2023 03:33:19 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91823D43 for ; Thu, 16 Nov 2023 00:33:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700123594; x=1731659594; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version:content-transfer-encoding; bh=a6pNSoBHnMP71ZOfqHBa2nwHsEXWNsx5L+AMwWNcIXs=; b=fW9WfrC1Jp5PloBDSrCVMaLk7lCKrfVTkAFmHAFpOvnADF5S4RuSrBGw O5zQykt4Ziz3lt/oGZRzDihNaxQe8h0SNUyDhGBPpNjqPwf9uN7N1HBpU tyrZ5zpxdf5my+iaCmC0PgMCGSYKnAu9yCdgPuEx6DenDAnKgDeh3R0p7 haAVR7qStggIkW/Cp1fR3wBrfZ+HjdSNu7L4BhP94zt35FHQfr7z8XqEA TaVSjzo7owdILGabExYzXJW/BpCW+uXCkKBiRjQ/jlyO8gC8bM34sfqL4 vPcSxUfO7WjlrM9aJNjxrTQs40mzXxyF5dv6UlG5qh0wZ0WT5IkOsEwpd A==; X-IronPort-AV: E=McAfee;i="6600,9927,10895"; a="388209419" X-IronPort-AV: E=Sophos;i="6.03,307,1694761200"; d="scan'208";a="388209419" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2023 00:33:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10895"; a="758759956" X-IronPort-AV: E=Sophos;i="6.03,307,1694761200"; d="scan'208";a="758759956" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2023 00:33:10 -0800 From: "Huang, Ying" To: Yosry Ahmed Cc: Zhongkun He , akpm@linux-foundation.org, hannes@cmpxchg.org, nphamcs@gmail.com, sjenning@redhat.com, ddstreet@ieee.org, vitaly.wool@konsulko.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm:zswap: fix zswap entry reclamation failure in two scenarios In-Reply-To: (Yosry Ahmed's message of "Tue, 14 Nov 2023 09:16:00 -0800") References: <20231113130601.3350915-1-hezhongkun.hzk@bytedance.com> Date: Thu, 16 Nov 2023 16:31:09 +0800 Message-ID: <87bkbudrqq.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 16 Nov 2023 00:33:33 -0800 (PST) Yosry Ahmed writes: > +Ying > > On Mon, Nov 13, 2023 at 5:06=E2=80=AFAM Zhongkun He > wrote: >> >> I recently found two scenarios where zswap entry could not be >> released, which will cause shrink_worker and active recycling >> to fail. >> 1)The swap entry has been freed, but cached in swap_slots_cache, >> no swap cache and swapcount=3D0. >> 2)When the option zswap_exclusive_loads_enabled disabled and >> zswap_load completed(page in swap_cache and swapcount =3D 0). > > For case (1), I think a cleaner solution would be to move the > zswap_invalidate() call from swap_range_free() (which is called after > the cached slots are freed) to __swap_entry_free_locked() if the usage > goes to 0. I actually think conceptually this makes not just for > zswap_invalidate(), but also for the arch call, memcg uncharging, etc. > Slots caching is a swapfile optimization that should be internal to > swapfile code. Once a swap entry is freed (i.e. swap count is 0 AND > not in the swap cache), all the hooks should be called (memcg, zswap, > arch, ..) as the swap entry is effectively freed. The fact that > swapfile code internally batches and caches slots should be > transparent to other parts of MM. I am not sure if the calls can just > be moved or if there are underlying assumptions in the implementation > that would be broken, but it feels like the right thing to do. This sounds reasonable for me. Just don't forget to change other swap_range_free() callers too. -- Best Regards, Huang, Ying