From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA650C61D85 for ; Tue, 21 Nov 2023 00:57:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C5D26B0381; Mon, 20 Nov 2023 19:57:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 675156B0387; Mon, 20 Nov 2023 19:57:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 53DB96B0390; Mon, 20 Nov 2023 19:57:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 476A16B0381 for ; Mon, 20 Nov 2023 19:57:08 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 26E7D160443 for ; Tue, 21 Nov 2023 00:57:08 +0000 (UTC) X-FDA: 81480147336.27.72431BD Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by imf04.hostedemail.com (Postfix) with ESMTP id 6FB3A4000C for ; Tue, 21 Nov 2023 00:57:05 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=MCRfGK4f; spf=pass (imf04.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700528226; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Zt1gUVX0IpCnPXwTyG8+humOtp/ZKrAnf7a59Q12nNU=; b=68Z3UQlEfUv05EFbPd5yLl7QuAOQWM/qZvl3vPD9B6ZA1QGMjv/gNZ9q0KbgK11E5Hm25w 3BgdW8GwcpMSuoY1awtIv7yFdCkelIaJ8DPXmBcLV9DI9i98gwKvfAHeqMnyFtroVi/kBF ppF3CSlZDgdmMeLZr5716Lv/mREDbqY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700528226; a=rsa-sha256; cv=none; b=CG7+2AT5ML+OQW8K2Na5G57kkKuFbdViwRAAyaNMR1UKtbJnkqhPAx6QWATVrVpPixSyuh udsgILkEy79NzVqs2vNjqlfydiEv+o38szLgQZTLfgHrWfmZ0TpVJh2rNOPbrbCY6o+Yw6 urAO4h3Abg47LSOgbWX4SkcK5WKkBFk= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=MCRfGK4f; spf=pass (imf04.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700528225; x=1732064225; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version:content-transfer-encoding; bh=nMU2J77ghZ+e8qdA0h9ywIv9K6Jb8YxZyIcZx9Q1D4U=; b=MCRfGK4fQT4y3XRfFcQjwfkVlNsN64f9dSBHCEEuMt2L5EqVO7TTlYQR eRhQ/4wEkPkPWTocBiVXrn6+DR/hdMIjUI9sRVscuCum+LvIzerfeclX3 z/A2TS9AFB+L9CVDZQvbQArfQ+HH9Ry2HMWgSFgcJ9bwys1idglJqdfML 58/w/nqLdDh+KhRc2so5J0GkD6/t0VDOikf6f9jLriqDH+g7qcLbU/dHg BpUDiUAq8zLmccW30GLc7t9qiE3kEOmKd4kCo/1C0uWZ3Cj3U7BNdoDEH NLb4kofSZeXKxY+Snu/FJr/y6oG1ImTQUEfF4J4dQIXkrNYWLHiAmFcGh w==; X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="394580412" X-IronPort-AV: E=Sophos;i="6.04,214,1695711600"; d="scan'208";a="394580412" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 16:56:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="716376843" X-IronPort-AV: E=Sophos;i="6.04,214,1695711600"; d="scan'208";a="716376843" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 16:56:53 -0800 From: "Huang, Ying" To: Yosry Ahmed Cc: Chris Li , Zhongkun He , Andrew Morton , Johannes Weiner , Nhat Pham , Seth Jennings , Dan Streetman , Vitaly Wool , linux-mm , LKML Subject: Re: [PATCH] mm:zswap: fix zswap entry reclamation failure in two scenarios In-Reply-To: (Yosry Ahmed's message of "Mon, 20 Nov 2023 10:52:25 -0800") References: <20231113130601.3350915-1-hezhongkun.hzk@bytedance.com> <8734x1cdtr.fsf@yhuang6-desk2.ccr.corp.intel.com> Date: Tue, 21 Nov 2023 08:54:52 +0800 Message-ID: <87edgkapsz.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-Stat-Signature: 9uacap1b6ujjkn5zg4brh7qwkd1eaf9y X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 6FB3A4000C X-Rspam-User: X-HE-Tag: 1700528225-340483 X-HE-Meta: U2FsdGVkX1/26OEE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APKoN9yfae952LY20QSuclvGtO2sjy6UoYONj8cs/SLEISFuoGCYxthdeQbm5FSNBO40ShMHZU/1lJvKNt816mMP771YVb X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Yosry Ahmed writes: > On Sun, Nov 19, 2023 at 7:20=E2=80=AFPM Huang, Ying wrote: >> >> Chris Li writes: >> >> > On Thu, Nov 16, 2023 at 12:19=E2=80=AFPM Yosry Ahmed wrote: >> >> >> >> Not bypassing the swap slot cache, just make the callbacks to >> >> invalidate the zswap entry, do memg uncharging, etc when the slot is >> >> no longer used and is entering the swap slot cache (i.e. when >> >> free_swap_slot() is called), instead of when draining the swap slot >> >> cache (i.e. when swap_range_free() is called). For all parts of MM >> >> outside of swap, the swap entry is freed when free_swap_slot() is >> >> called. We don't free it immediately because of caching, but this >> >> should be transparent to other parts of MM (e.g. zswap, memcg, etc). >> > >> > That will cancel the batching effect on the swap slot free, making the >> > common case for swapping faults take longer to complete, righ? >> > If I recall correctly, the uncharge is the expensive part of the swap >> > slot free operation. >> > I just want to figure out what we are trading off against. This is not >> > one side wins all situations. >> >> Per my understanding, we don't batch memcg uncharging in >> swap_entry_free() now. Although it's possible and may improve >> performance. > > Yes. It actually causes a long tail in swapin fault latency as Chris > discovered in our prod. I am wondering if doing the memcg uncharging > outside the slots cache will actually amortize the cost instead. > > Regardless of memcg charging, which is more complicated, I think we > should at least move the call to zswap_invalidate() before the slots > cache. I would prefer that we move everything non-swapfile specific > outside the slots cache layer (zswap_invalidate(), > arch_swap_invalidate_page(), clear_shadow_from_swap_cache(), > mem_cgroup_uncharge_swap(), ..). However, if some of those are > controversial, we can move some of them for now. That makes sense for me. > When draining free swap slots from the cache, swap_range_free() is > called with nr_entries =3D=3D 1 anyway, so I can't see how any batching is > going on. If anything it should help amortize the cost. In swapcache_free_entries(), the sis->lock will be held to free multiple swap slots via swap_info_get_cont() if possible. This can reduce sis->lock contention. -- Best Regards, Huang, Ying