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 B2BE2CD11C2 for ; Wed, 20 Mar 2024 21:07:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35F7A6B0083; Wed, 20 Mar 2024 17:07:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E83C6B0085; Wed, 20 Mar 2024 17:07:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 162266B0087; Wed, 20 Mar 2024 17:07:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id F20746B0083 for ; Wed, 20 Mar 2024 17:07:24 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C5FFF1C1375 for ; Wed, 20 Mar 2024 21:07:24 +0000 (UTC) X-FDA: 81918653208.20.9A21290 Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) by imf15.hostedemail.com (Postfix) with ESMTP id 82934A002E for ; Wed, 20 Mar 2024 21:07:22 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=AKEdJPA0; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf15.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.182 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710968843; 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=DvZNgV1UJ3rZdpEWn2rh61ztKfIJaaGzKCo/9kKoW2Q=; b=hNgZuBBee4KAwuAMpC4zztVcRR3LLxeokfiNjHbI829CidHCVHHxpz60bULs19sC2oI5zJ hqfas18RQivBAze+ee72sRzaKy5QFw0NcTewIruMcIh2pjfepTPpqveI6K9Rl8ybtNWTmv +3FYsRNxRD6telJfCPNOOMyZzUDe67g= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=AKEdJPA0; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf15.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.182 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710968843; a=rsa-sha256; cv=none; b=8lSLPJBT3ApYnggm+U/QHsSkouHrHqUdqQCPCygijJvrxTrGbK+6KKbHhs5h3kImO+og1D IZDyQ/S98UDeOAe47bXaggeByckKHoB9G6JRlsO73cPRlXxb8QhXsD3n47zKzIRacLApHg zqmQ7XmTt8FnT4AjxUFjclAwd8aUfGM= Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-789e5021703so21965185a.0 for ; Wed, 20 Mar 2024 14:07:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1710968841; x=1711573641; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=DvZNgV1UJ3rZdpEWn2rh61ztKfIJaaGzKCo/9kKoW2Q=; b=AKEdJPA0nr8voUP5nauikVgC2PE8wgQj3gwK8eCQAUFa27Gq0LQM01uDyXYUyIQ+aR Dnelpu9oAu0KoFAzwb6yys0/qSEnf991UP6ZwtS9m73oZaTO8Bw9yFuOj6Hdo9+OG8RY sswHSqJ5hqrMMVY2jLnFdAIBw24WUQD6lmgeaCsbUcacVS4gU0pPSOogfqgE93Wp68L6 MtYHmxVHuVUTq4jKfUEIlox6DM7WxobVw1Rcb3NzNayMpCB9eM5O3dt85Quxrz1Hx0rr 2LtssNsA583uNe/PnPqpkKut3YKSBm32At1sUt6b7ScFPQqfI+qS+j0efVuAXH/q1o1g CRlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710968841; x=1711573641; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=DvZNgV1UJ3rZdpEWn2rh61ztKfIJaaGzKCo/9kKoW2Q=; b=IcDYAIUuzUtkBXCj/ymT0lqEc9VCrhPJ6t/q7jnV51YaZ/iBWraLGbpSXYyeD96lLg l9oDVBVL5I8+iSkIp7ymJq7NxJjebI8yiH54U6TarQS+THhaHYhEXkwyDhCXuJUdOt+U BsEC88bCobCcXdbwggQOy0K6ef266gnFZyeppJ/qLxh6RnBoFWNIEjmjzAovE7No42eX p40a5/x+LMyLrE+XU92cHMdBAa6Jpn93spda/jgvnwg7jyMs38kkMRQtPmV8dOJZd439 VBOQAqJ6kL+SmXM6ScMKFIHssqOkUklKu0YvqReNRx1sMshwQzf7V4di9LN3+BniI8wr XuKg== X-Forwarded-Encrypted: i=1; AJvYcCUkVlzWsnYFpaETkTb8Bw4re6okPlcrn6Yvc7ZuG3XsFjmcZrSVZ+encDgiqx+gGoA3oTdVCLdjhviPdqrIgQbwT18= X-Gm-Message-State: AOJu0Yw/2EbfZ8mdtjtzsy1DWQkWOrm3XmwhNfPdhQXadEasHvEm4240 x1g/jvwKvE/XXdmfAMuxrz0eGi0WSwShH6tB8wx2hQea5Iykevgnhqwt8LaImwJM/kgd8MoZ41Y w X-Google-Smtp-Source: AGHT+IF2CT4+jW/F9XGjEwotNFLhfvlPliK30kSyzQxiyk3Yw6CKoVX0YJLVqR777nO4H3y9v+alMA== X-Received: by 2002:a05:620a:110a:b0:789:e8f9:3d45 with SMTP id o10-20020a05620a110a00b00789e8f93d45mr7204845qkk.29.1710968841178; Wed, 20 Mar 2024 14:07:21 -0700 (PDT) Received: from localhost (2603-7000-0c01-2716-da5e-d3ff-fee7-26e7.res6.spectrum.com. [2603:7000:c01:2716:da5e:d3ff:fee7:26e7]) by smtp.gmail.com with ESMTPSA id s3-20020a05620a16a300b00789ee7c9d2fsm4503940qkj.109.2024.03.20.14.07.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 14:07:20 -0700 (PDT) Date: Wed, 20 Mar 2024 17:07:16 -0400 From: Johannes Weiner To: Yosry Ahmed Cc: Nhat Pham , Chengming Zhou , Chris Li , Linux-MM Subject: Re: [RFC] Storing same-filled pages without a zswap_entry Message-ID: <20240320210716.GH294822@cmpxchg.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 82934A002E X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: bct8niohzj68aw6c77z5sepnzm8unpd9 X-HE-Tag: 1710968842-328628 X-HE-Meta: U2FsdGVkX1/vRKKDTPxyN5P/tmaAAPsKPFXQULUObJcHj5ck2CfaFOuxX//jq1qTnvbMobkk8xgMMYVjyNH4JxYdoc3YjAanJj5GEfQSTeOugtnTp54J+RahXBmn6D4AYoIejeBcUL5neOCqBF3ku8NaaAVJ1jQyYVKXmxQN/GvdWgjjOJVRzNJb3qqCrDLBReFkcrcvrJkJCKYRt+2ZC6Ejak4HQPvWHaf3XqE+AVrhNPomR14qNLYUo6TqZOY15PzbKw1FZIkAr91FOzru1Dcv4x/4cJ4V9cMqGwoWim6+JLGC0NNA9pqdDRA1Kjp1FuZ1hlvKAjj5pY4/iN6izeDBpaFjMmPkMcz+UZx1FysP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ity: Ham, tests=bogofilter, spamicity=0.007093, 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 Wed, Mar 20, 2024 at 01:49:17PM -0700, Yosry Ahmed wrote: > Hey folks, > > I was looking at cleaning up the same-filled handling code in zswap, > when it hit me that after the xarray conversion, the only member of > struct zwap_entry that is relevant to same-filled pages is now the > objcg pointer. > > The xarray allows a pointer to be tagged by up to two tags (1 and 3), > so we can completely avoid allocating a zswap_entry for same-filled > pages by storing a tagged objcg pointer directly in the xarray > instead. > > Basically the xarray would then either have a pointer to struct > zswap_entry or struct obj_cgroup, where the latter is tagged as > SAME_FILLED_ONE or SAME_FILLED_ZERO. > > There are two benefits of this: > - Saving some memory (precisely 64 bytes per same-filled entry). > - Further separating handling of same-filled pages from compressed > pages, which results in some nice cleanups (especially in > zswap_store()). It also makes further improvements easier (e.g. > skipping limit checking for same-filled entries). This sounds interesting. Where would you store the byte value it's filled with? Or would you limit it to zero-filled only? > The disadvantage is obviously the complexity needed to handle two > different types of pointers in the xarray, although I think with the > correct abstractions this is not a big deal. > > I have some untested patches that implement this that I plan on > testing and sending out at some point, the reason I am sending this > RFC now is to gauge interest. I am not sure how common same-filled > pages are. Unfortunately, this data is not easy to collect from our > fleet (still working on it), so if someone has data from actual > workloads that would be helpful. > > Running the kernel build test only shows a small amount of same-filled > pages landing in zswap, but I am thinking maybe actual workloads have > more zerod pages lying around. In our fleet, same-filled pages seem to average pretty consistently at 10% of total stored entries. I'd assume they're mostly zero-filled instead of other patterns, but I don't have any data on that. The savings from the entry would be a few megabytes per host, probably not an argument by itself. But the code simplifications and shaving a few cycles of the fast paths do sound promising.