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 1FAD1C74A5B for ; Thu, 23 Mar 2023 19:55:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AFB5E6B0071; Thu, 23 Mar 2023 15:55:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AAB546B0072; Thu, 23 Mar 2023 15:55:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 974C26B0074; Thu, 23 Mar 2023 15:55:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 840DC6B0071 for ; Thu, 23 Mar 2023 15:55:22 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 61DB61C5E7C for ; Thu, 23 Mar 2023 19:55:22 +0000 (UTC) X-FDA: 80601217284.22.2980AD1 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by imf02.hostedemail.com (Postfix) with ESMTP id 9C9B38001E for ; Thu, 23 Mar 2023 19:55:20 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=MxnbHRb6; spf=pass (imf02.hostedemail.com: domain of yosryahmed@google.com designates 209.85.208.49 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679601320; 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=PgE3XfWVFFmxWS8Bd5DjGGKxj/WkwiVn7oelMK2t77k=; b=Q1IliIyx9T+H9NLyc2stk9cj/ySpSKa5/NnNjf+gUeGmYN18dNm4TX8+oAjzjWt6/tCAft 8Y5rwZ9oVogW+8b6CEilDFl1T5DhUYGdWISz4b2ASXmTyu9fCS0SgRq1sfrDNS9RPOOiTE I/GGtqzrhKxBgsYG97ACzqphx8p+B74= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=MxnbHRb6; spf=pass (imf02.hostedemail.com: domain of yosryahmed@google.com designates 209.85.208.49 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679601320; a=rsa-sha256; cv=none; b=MG2cnRZtFv9ZRPxBkyi0EzgJQ/aABurv39wims3I8oCfn0+7OMwzaDKPU2JBPyoLfblycO HDpS9IycZk88K1KMkiR24nfvVux9Znlj3eRG9+NvAILHRC6aLfmVWKr+7fKFJovCyqqqHi 6P8PT2mC3HOgLYvH7/VEAerY2y0UreQ= Received: by mail-ed1-f49.google.com with SMTP id b20so58557366edd.1 for ; Thu, 23 Mar 2023 12:55:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1679601319; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=PgE3XfWVFFmxWS8Bd5DjGGKxj/WkwiVn7oelMK2t77k=; b=MxnbHRb6Hn+xIPAymq39l5UU9bZeWmKSHo2ZQgjjAthx7CCKb9u3YuCTcVy2m1YSoN ONdrDeQeGnGsX9nBBMBKr3QfYtPMDQs7Mfk69VjaPGPYniNY8Yh4/QdH7Ef59rq0Cno/ BKj/9JtilBA1+HjxuaO4P+rPZzpwqV73nLeh2QzkW/drNtTPei7luRvhk5YWxkT4CmH8 h/9JqRIuyvi0iOD/oGyJRgnNHlPQR53Uz9KmWnWrlJ/OYqrDcIF4UVfQ73FoUeoKQ8Dn WQ6MITZzj9rSfwFWzbZLk3IUPmOzrxNqo3zPlwvUGuZHw/Qln38QveWKHfAAnI5jICyF HbUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679601319; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PgE3XfWVFFmxWS8Bd5DjGGKxj/WkwiVn7oelMK2t77k=; b=fMTwmGN/eYzM9vcFTY44I9x+0XAipq6c/9b6z5uLp04LyAzWQMxgZwqu4g0Ckb0UXz d/6dmz+jAU/e7BpunQ0Ujbvf35NdYPLsl9rE7yGgYULW6JHagXt86WDI6owGd34fwQhX 2fGwUYu5OJJNVyukgaIRF3W0VnzD1l4DpF4RI7SjMl/UytgjvEkauJPlBKHr7wyP4o3s CSSeNm2UY/VsiOEgWw9cFzP3K0yzNbgZ+v6fMIBXJ2jyiIxAgHW9IKBtOrUGTSz5i65f U4f6ZGPMfXaL+hvvSTrB7TWBQomu14bDocE0vph/YAUUsEmAlADDy3bHJFZiAyBLZsLL agAg== X-Gm-Message-State: AAQBX9e9ypLNiCScMzP2AYrZAF2fVdDrMfjGWIujyIsydR3rpxOYQYV1 5Z8zuxHtAkV7lhhGR1ZiPMmZRri4CRRz5QPdQR7nTA== X-Google-Smtp-Source: AKy350apnSrEJJtyOHTAQfOsQUpn9B0sfXJcsr3MaMIY/MGRWG3BjtIX4aj9tGu0bU78tzgBvy0WWrlO/yQ9COoWDv8= X-Received: by 2002:a17:907:788e:b0:927:912:6baf with SMTP id ku14-20020a170907788e00b0092709126bafmr92953ejc.15.1679601318846; Thu, 23 Mar 2023 12:55:18 -0700 (PDT) MIME-Version: 1.0 References: <87bkkt5e4o.fsf@yhuang6-desk2.ccr.corp.intel.com> <87y1ns3zeg.fsf@yhuang6-desk2.ccr.corp.intel.com> <878rfothdg.fsf@yhuang6-desk2.ccr.corp.intel.com> <871qlgrm5j.fsf@yhuang6-desk2.ccr.corp.intel.com> In-Reply-To: From: Yosry Ahmed Date: Thu, 23 Mar 2023 12:54:42 -0700 Message-ID: Subject: Re: [LSF/MM/BPF TOPIC] Swap Abstraction / Native Zswap To: Chris Li Cc: "Huang, Ying" , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 9C9B38001E X-Stat-Signature: 5atp9b9nswpcs1appek9ydsgytr3udir X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1679601320-417988 X-HE-Meta: U2FsdGVkX1/l42bWrZr/bYjOu4GJBaUSQJl41EqE3CKPTYNEk/dNYC7Fd/5vWa14tFWJ4XbW4HaeC2kMTvvZl0coXA4GjmR/KdxUvsqwwUYTL+Bi8qdULFtXjt2RXdnpnA8cYXbQmUlge2mMwgHAEsWohz0XQy/1kuL/iRCbARFbRQP5sWEtCf13sj/HRfn2vW9ZXFMPxt9vpvyH3D3JuKa7txCeeVqUYtSUfUnav/97PzKqpb/fcDPzqYpuyvBYQmCnS4GASlQrSLpjZKYMSXG8HQZsU8QEtvxNjJ97RSttpBnms/dWdkQPTG7WqSJAZzvpqer1KsVmoODDPlY5wHv//OyjvsSJ0C1kqRtINvN7Ly1JoXfYUJFsVbU3rzwUTYCFOlIQxoruvOREx28FA1kspdvI2y283yODWUNl+vdPEfdZ/McPvocMKbzIire40JfrwD6oArwK79DPo/e5PM+imelzu/kSv0SUEhf++IRLi7hiBofinsf7tmmU9cuwowNhbgBuDXRDHLJMlz4XoqSfm5lzmCZ1JtNQwKlhVMqQqVzhIV9AiXV7kye7oYWKd81TodFOZubh4gRT2BX//dNhS7NGP3v4X/RwGq7v5po7qzYzrJ9hY7EPAfg3oYvwPu+3T2GhAOBjGoYTK+luBZBOjFni07velO6NqhzSVNMRwQu1CSYxpyjfZVdhbfLv6LAwycCe2aNp7+EJH2P9M0wcVnIIxSJ2KVqVP/6Zb2kRiePPQ5S2uverKKgXUKuvLpQbL3lTQDCK+YH8N6Uq/s9+HzB4p+nGKJPiiN0OTv45n94ONCjOvcawms9gjWIDgVAwdTnzaugMDm/uOQ6khNTgdxmOFwF0jHCSGb5ut8zNNe1ygfjlnBn0elola16GeQOJeF7qP14LNVNb1Cf4J6YPjdBL9n+mHHt5WbtiGTt2+vptQDx3+J0rd9F4457HJy5PBVanOuH9Xslg9rN 1XpqXZOi q26rmjGvoip1dPpMQXK8tI/TRvpLzxjysYlmCxJBT0z29aNcrwcJZybcxNKthhstKJkwjprVLLwX/ECcPBlETCvAlDRsLmIS8t8pizJGoao26Nw9XDuc/XXfGMHQdiLM9kDkYU2j8EvuzHsjgp8gShSGGgR04QH/3a7ErjkkFtTun/uRy6WIKoBQBs5C5g/ODaxeT9IaIpKzzbUckVI4lbbXxRlww1HybRuQq/Kk4DCqEqUvR7iiLKh537GyaK3ca1MWjFO3VULzdpEotSgUHUlRg8qe58whxsgYH33iZiFtgoyglW2eGOaLnAA== 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 12:50=E2=80=AFPM Chris Li wrote= : > > On Thu, Mar 23, 2023 at 11:40:35AM -0700, Yosry Ahmed wrote: > > > Thanks for the clarification. If we have swap_desc index in the PTE, > > > let's call it S1. I assume S1 will contain A1 and B1 as part of the > > > swap_desc struct. > > > > > > Now we are getting to some very interesting details. > > > > > > What is the life cycle of the S1? Does S1 share the same index as A1? > > > > The idea that we are currently discussing does not involve a swap_desc > > struct. There is only a swap ID that indexes into an xarray that > > points to a swap_entry. This swap ID and the xarray formulate the > > indirection layer. > > I see. The swap_entry is the same size as the swp_entry_t, which is > unsigned long. > > > I am guessing in this design the swap ID is allocated when unmapping a > > page to be swapped out, and freed when the underlying swap_entry's > > swap count falls to 0. > > If none of the swap pages on A need to move to B (yet). Does it still > need to allocate an entry in the swap ID xarray, only pointing to A1? > > At the time of swap out page into A, we will not know if it will > move to B in a later time. I guess the swap ID xarray look up always > needs to be there? If the indirection is enabled, yes. > > > Moving a page from a swap backend A to another swap backend B should > > not be a problem in terms of the swap cache, as we will add it to the > > swap cache of B, modify the swap ID mapping to point to B, then remove > > it from the swap cache of A. > > That means when B swap in a page, it will always look up the swap ID > xarray first, then resolve to the actual swap_entry B1. Yes. There is an extra lookup. > > > There are some concerns with this design that I outlined in one of my > > previous emails, such as having separate swap counting implementation > > in different swap backends, which is a maintenance burden and > > error-prone. > > I agree that allocating the swap ID and maintaining the free swap ID > would be some extra complexity if we are not reusing the existing swap > count code path. > > My other concern would be the swap ID xarray indirection is always there > regardless if you need to use the indirection or not. I think the idea is that this design is more minimal than the proposed swap_desc, so we can have it behind a config option and remove the indirection layer if it is not configured. However, I am not yet sure if this would be straightforward. I need to give this more thought. > > Chris