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 E308FC25B74 for ; Fri, 24 May 2024 19:54:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 57D886B0082; Fri, 24 May 2024 15:54:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 52A2E6B0083; Fri, 24 May 2024 15:54:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F14E6B0085; Fri, 24 May 2024 15:54:43 -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 21A766B0082 for ; Fri, 24 May 2024 15:54:43 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A67C280317 for ; Fri, 24 May 2024 19:54:42 +0000 (UTC) X-FDA: 82154342004.26.90DF107 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by imf11.hostedemail.com (Postfix) with ESMTP id C381840012 for ; Fri, 24 May 2024 19:54:40 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="QHH/0cdC"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf11.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.49 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716580480; 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=ICme2/z6Xr6kFtN3pR1B01HW/Va0+ZeDeW0iiu2ZaK8=; b=MTEWrcbFE7mXHdQxBPnFSAQ6LPFVQyGSJaJ0PJGq6K7X6iXKKkKrnQk8EnTnvQgaElEKqk mt7Gqkrn79UeMwdXDYnxvJgrpHogZR3fat4+plNO7mlqfLsQ8lqci6D+AeWfTNt5v53zWB /XNsLWRUiyWM8H1T7iUHd/IaHo2r7qI= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="QHH/0cdC"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf11.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.49 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716580480; a=rsa-sha256; cv=none; b=quDqOxeOcLB89rz6vnj3CPQ1pJTyFVhFKRMtZqgjx4Utm87lC1usR+4FYEpi7QZfa9Dgas 9h/glxOmRROogNODcZ6FVuZabG/wZ9cfpoT+QjFHnIqXaMQIUVB8NEZF5pa9BOA7H1jzdW GMjrjhLoOHY47TF+waqP1CoHgaHcC+U= Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a6265d3ccbdso119423966b.0 for ; Fri, 24 May 2024 12:54:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1716580479; x=1717185279; darn=kvack.org; 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=ICme2/z6Xr6kFtN3pR1B01HW/Va0+ZeDeW0iiu2ZaK8=; b=QHH/0cdCczxAQ6pCuqTZ8P9ohoT3p8zFNd4lzvU769Unby1/LvsrWJ55m068Dg2ssK n+rFwOvFDRofDvliutLnwon01AueeyetfTsTeOXLuSMg1pigAv58rUQdEXuOtURe9txM Y0sSwaCVinhx2sacAQwBH9swVT5hKuBvRTnyz6oo0B6c+qwmdfoPHdO++B3rAqLZQUXs WFJ7WsohNJP6LyLrXI7uM1jdzPS5utB1TB2AcKBM57m6jVJ90fCP20nqWPr+1qE5Bgec /Q/zxwEEQjBWVH6HI4DWYvf73+sPnNK27F9nMdCHRMCZgYEnSCxWlVHxl8Li6px/y/vG B2cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716580479; x=1717185279; 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=ICme2/z6Xr6kFtN3pR1B01HW/Va0+ZeDeW0iiu2ZaK8=; b=NsFn7kpMVjcR5fXcr9c+kZlyvSV10HpWlZ9D41XZLBdw2dsDip3hmYDrnTmqDgI4Yo mW4ZNA3BeNFxh3cA/WMFNiQBRpli0vtNVR65AdeEoTHvzL9aV1TzGfrzNdiF9Z3ja83s tkuQoy9BY7tkP0STLq1WGgeOH0DC3DAEEd3EBJ5x99+AuAHUp3qS7ABIE9VQMUY3RBN3 pt7I8Nf8fKr7h6rWvxfPHdaIi9cqMyNuhBFwvEXNiXwy1ibDUZwk2AxkjjO0VxtJQx0F e0QAlWwi5rbxNZ6oj/l2h/ASDnXxaNgrPcCmITtB7Tw9V0P/ZXQYnqzEWW0moIpzKJgK NvnQ== X-Forwarded-Encrypted: i=1; AJvYcCUwAipflXP/1C/5BBTKeKBShjkxMvXPbfL5lM1f37g9UPtgfdyhx5D1lJv9GtOB2UoSc1njL+wDNQpaYdv11Sg8478= X-Gm-Message-State: AOJu0YxnBvtfVBIj0Df693jg+YGz6JkJbO97gE5IdoNAlQirZRO2/UYv HtRE9l9t4AJKYjXIbKl4vu7VuDLerYFfliXQKk8VXm94z1QBh+TI120U7qf33YiQ/Aay7jQFVy9 XXFcsldrkAXpUDF7Jj1oI4YHs8ttvFvP/f4C5Ux+fK6XeyQ/JiKF7 X-Google-Smtp-Source: AGHT+IEpm0E34iKpxTfKRJRT8lqX7m0YvtLAkZwX7X8J7kgj94Zr2Xv9VdmfJYxRG0lwyTKu5x/bwZhL/EcoxOEX6yc= X-Received: by 2002:a17:906:c4c6:b0:a59:c28a:7ec2 with SMTP id a640c23a62f3a-a62646ce06amr209526066b.41.1716580478946; Fri, 24 May 2024 12:54:38 -0700 (PDT) MIME-Version: 1.0 References: <20240524033819.1953587-1-yosryahmed@google.com> In-Reply-To: From: Yosry Ahmed Date: Fri, 24 May 2024 12:53:59 -0700 Message-ID: Subject: Re: [PATCH 0/3] mm: zswap: trivial folio conversions To: Matthew Wilcox Cc: Andrew Morton , Johannes Weiner , Nhat Pham , Chengming Zhou , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: C381840012 X-Stat-Signature: 9py5out4ekrpa8e4irkmstpt4fd55xbi X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1716580480-328733 X-HE-Meta: U2FsdGVkX1/xczMZmibUfpf6ifYUzQDPyyBtEY1eSMWvmjt3zsHbMrMgaS+6K86N7jOuZec5Riiq8xSfMivsDyN1GvwHVP78k4tIioQTAWw0gVv1ti95TqkTFToW34vrSRoPH87OJg7NxaG7CDZJKZQm+VeD8r3A6LaGuql0CV1AFR3f7CYxjbHvEzhUyAzY0Bekb99cQtL9ioFt0+M8D6zexwXPz79xirIWarv9eGqqvjWM7Mtai1AphLDu4x2NvJy+agg1+NCrL/n646HXByBEG8LHeqjGQmuTmjoRciDRLMkzfi5WI2nesmBcDyKvlOPw7apGEq5fuD9ph1SfsEvCApRqf2FGITrZfGKqqerUGdbFo/BxZeSQ2fq8wRy5gl0au/TjtYMRNBADzyB8Ets2GbRBfLdrQToQdw6vS55YQFil/qi8uhSzubTOfd9LreP+cgWAM2QmSJ9tkP+cp+sPDNcdZbKpPvCBbx+Vj/kh3KaKKAT+WX76euooRqzOcy8urIyadvVgECr8mY4Aqxm79htDxnMlROfWjWo+UwRuMleyD9bRd0BWry/Ld7rOzjurunMinpp1s7EOHjpHnNrIpHLaPRObNBw/pKDBAaYXgOuMfVrg8ILkFBipX41Jcx41KYqt4rKlTQTe5cHS61tQkEUpj6vi5aaJG9nhXbqnaAVB27OM4pLpFbcQGIg1ULYaboSBYK7Jr9ldDCnWYvWN8sAc0UmMvjWZC2VKap3lEYB4UbibergUcelI5VPNmJ1Pv/gEMLYNEXwWdIUYcDFpKSuSVqp1lNxK/a+BnJpyfaip940yfDEvxNhJmxw3ejOesuf2ygd496E3FmRjTxySXDPWFHwfH+XwnzCfsc71HuKSBqum+8UaIXKbam5/uv+M+rrGCEgsUKswQ6Y6VzpGNk7SDTnXjzwsr9W02zk39snvZvHq+EyWQv1UYAz5hw1H/8gkndTMsDjraYK ar91g+f9 iZoRTsfIonmaOuIHxSbVZPPeknuzRJGx1hoBrjfXxpOOGGZasgzidih7cJI8z3pKRUlPk1MRxGIItexGSrK4+No23SMTfbp9wjcoGTxwMLQHe+nYI1atHxY2EI02pG5tEu52HqAzWgrAtQcWjf39uhC425N70neK/SIgonqsXWg2PUMf16b2JJjwse+3GHNkdBX9zai+wtGG5TwshUIqtKZXSbfvC05QrtB2kI54Hclk0UyUY5h1t+bPgZLIuB0yc6txTwFZx8ofQVle1ovBkJablohFlgov9POdl 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: On Thu, May 23, 2024 at 8:59=E2=80=AFPM Matthew Wilcox wrote: > > On Fri, May 24, 2024 at 03:38:15AM +0000, Yosry Ahmed wrote: > > Some trivial folio conversions in zswap code. > > The three patches themselves look good. > > > The mean reason I included a cover letter is that I wanted to get > > feedback on what other trivial conversions can/should be done in > > mm/zswap.c (keeping in mind that only order-0 folios are supported > > anyway). These are the things I came across while searching for 'page' > > in mm/zswap.c, and chose not to do anything about for now: > > I think there's a deeper question to answer before answering these > questions, which is what we intend to do with large folios and zswap in > the future. Do we intend to split them? Compress them as a large > folio? Compress each page in a large folio separately? I can see an > argument for choices 2 and 3, but I think choice 1 is going to be > increasingly untenable. Yeah I was kinda getting the small things out of the way so that zswap is fully folio-ized, before we think about large folios. I haven't given it a lot of thought, but here's what I have in mind. Right now, I think most configs enable zswap will disable CONFIG_THP_SWAP (otherwise all THPs will go straight to disk), so let's assume that today we are splitting large folios before they go to zswap (i.e. choice 1). What we do next depends on how the core swap intends to deal with large folios. My understanding based on recent developments is that we intend to swapout large folios as a whole, but I saw some discussions about splitting all large folios before swapping them out, or leaving them whole but swapping them out in order-0 chunks. I assume the rationale is that there is little benefit to keeping the folios whole because they will most likely be freed soon anyway, but I understand not wanting to spend time on splitting them, so swapping them out in order-0 chunks makes some sense to me. It also dodges the whole fragmentation issue. If we do either of these things in the core swap code, then I think zswap doesn't need to do anything to support large folios. If not, then we need to make a choice between 2 (compress large folios) & choice 3 (compress each page separately) as you mentioned. Compressing large folios as a whole means that we need to decompress them as a whole to read a single page, which I think could be very inefficient in some cases or force us to swapin large folios. Unless of course we end up in a world where we mostly swapin the same large folios that we swapped out. Although there can be additional compression savings from compressing large folios as a whole. Hence, I think choice 3 is the most reasonable one, at least for the short-term. I also think this is what zram does, but I haven't checked. Even if we all agree on this, there are still questions that we need to answer. For example, do we allocate zswap_entry's for each order-0 chunk right away, or do we allocate a single zswap_entry for the entire folio, and then "split" it during swapin if we only need to read part of the folio? Wondering what others think here.