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 D61AEC6FD1C for ; Thu, 23 Mar 2023 06:46:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 52A336B0072; Thu, 23 Mar 2023 02:46:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D97C6B0074; Thu, 23 Mar 2023 02:46:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A25E6B0075; Thu, 23 Mar 2023 02:46:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2B8066B0072 for ; Thu, 23 Mar 2023 02:46:51 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E4758140555 for ; Thu, 23 Mar 2023 06:46:50 +0000 (UTC) X-FDA: 80599230180.27.BDE6678 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf03.hostedemail.com (Postfix) with ESMTP id 2C5BF20003 for ; Thu, 23 Mar 2023 06:46:47 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=SdrQwd7v; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf03.hostedemail.com: domain of chrisl@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=chrisl@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679554008; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=q1YjwJWudmDWh9pgtfH1UgvHbnp2275Fc5mmMnbNNls=; b=jhw5cjr6SG1807uT+B5huJ46b6ojOrx7yjxhXtt+94HlOmF0vptVFMMfEbI1IV4qdvisv+ kpbNY8b+bHpVGmGkts9bvVxCQ8d/IA8CVFBa9qKvVJPK9Ngx8rLbSZ3V18M10JdhhrQey4 Y1gMyo5+pjn6TwBhkQsQS0qIeAWBiDU= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=SdrQwd7v; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf03.hostedemail.com: domain of chrisl@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=chrisl@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679554008; a=rsa-sha256; cv=none; b=Ar3KPNrNVAUkBPpPIoRs7NBCqFzDebh3Py14UTpAfYGx9JmlouiwL1iw4Pqlc8LB/SkFQU n12kc9kpKcvAAPVusLfHLiMFVDUQZkrZUQ+MRDAPKpscE05GUCt8CIwN4hCAOfdDkffsas f/yQbdjA0UG5YglHxOuSP3pgvvv/BMw= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 021C76248C; Thu, 23 Mar 2023 06:46:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE4A1C433EF; Thu, 23 Mar 2023 06:46:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679554006; bh=Al/vs00F5EGwmtF+41M35ZbVTsIJfYMyphmah4SyrvQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SdrQwd7vANmThrAqra/CwyHQ4sbFuRf33Qrd9vutUuWdn6cBnOKTqcMlUl3/Peqoc fzF5ifKSw4OIrzr5XC0pyd3+v0Wy0at81rc5DflWaPUkIIbUXc1qEZFiYbTf9W3okt N0NLD6gG2PCcucEG01IGpA6/RPU99hIZZaP/eC10ol9bgXtNGlrcB3dRS+XqtsUs8p exTUVt1cpexCWWVXuKkTYZXAqUslWDOF9fnSlVmGW8PwghyWH6Gg70XpFz2kFy2c6+ XuwWYYTZgWDRRD3qOVJiCNhgWOyXX4GyLUrx7T5bLo1Peo+V/yGVQ7/n0ILHrCibAH NvkV/7h055jEg== Date: Wed, 22 Mar 2023 23:46:44 -0700 From: Chris Li To: "Huang, Ying" Cc: Yosry Ahmed , lsf-pc@lists.linux-foundation.org, Johannes Weiner , Linux-MM , Michal Hocko , Shakeel Butt , David Rientjes , Hugh Dickins , Seth Jennings , Dan Streetman , Vitaly Wool , Yang Shi , Peter Xu , Minchan Kim , Andrew Morton , Aneesh Kumar K V , Michal Hocko , Wei Xu Subject: Re: [LSF/MM/BPF TOPIC] Swap Abstraction / Native Zswap Message-ID: References: <87y1o571aa.fsf@yhuang6-desk2.ccr.corp.intel.com> <87o7ox762m.fsf@yhuang6-desk2.ccr.corp.intel.com> <87bkkt5e4o.fsf@yhuang6-desk2.ccr.corp.intel.com> <87y1ns3zeg.fsf@yhuang6-desk2.ccr.corp.intel.com> <878rfothdg.fsf@yhuang6-desk2.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <878rfothdg.fsf@yhuang6-desk2.ccr.corp.intel.com> X-Rspamd-Queue-Id: 2C5BF20003 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: g4foyon5owdmboyfar7ekfw4pnyoju7x X-HE-Tag: 1679554007-635195 X-HE-Meta: U2FsdGVkX1+oZMkoWSWOcgRLmakryUCVnqeCtWWIIIIyO0eUXGyV7h8XVckdyg8RN3tg3APB75E2AZN8Dcagtqs5cLN1jc3eyrmd29kgH6f++v0Epxl6mj889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fAGpS39GCud81Un/15Cc4nCiNMe9HDeQeR+8wApICl/xR8iDDQeL4= 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: On Thu, Mar 23, 2023 at 08:56:43AM +0800, Huang, Ying wrote: > > We need to carefully design the swap cache that, when moving between > > swap implementaions, there will be one shared swap cache. The current > > swap cache belongs to swap devices, so two devices will have the same > > page in two swap caches. > > We can remove a page from the swap cache for the swap device A, then > insert the page into the swap cache for the swap device B. The swap > entry will be changed too. It is possible, however very tricky. Let's assume the swap entry in device A has more than one user. e.g. Swap entry A1 on device A is shared by three different process. It is installed in three PTE locations. When A1 page data write to device B, gain a new swap entry B1. We will need to walk the three process page table to hunt down PTE point to the swap entry A1, change that to B1. There will be a short time window some processes have B1 and other processes havee A1. If both of them trigger page fault to swap in the page. You will have the same page in both A and B's swap cache. It needs to be back by the same physical page. That seems to suggest that it needs to merge the swap cache look up somehow. > >> We can allocate a swap entry for each swapped page in zswap. > > > > One thing to consider when moving page from zswap to swap file, is the > > zswap swap entry the same entry as the swap file entry. > > I think that the swap entry will be changed after moving. Swap entry is > kind of local to a swap device. While the swap desc ID isn't changed, > that is why we need the indirection layer. Due to the above mentioned complication. I am also evaluating a design have the zswap just share the same swap entry as the underlying swap device. The price to pay is one extra look up in zswap. That is similar to the current frontswap. Chris