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 783ACCF9C69 for ; Mon, 23 Sep 2024 10:22:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF1726B007B; Mon, 23 Sep 2024 06:22:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CA1816B0083; Mon, 23 Sep 2024 06:22:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B690B6B0085; Mon, 23 Sep 2024 06:22:37 -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 926256B007B for ; Mon, 23 Sep 2024 06:22:37 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 474041A11C8 for ; Mon, 23 Sep 2024 10:22:37 +0000 (UTC) X-FDA: 82595613954.17.19E206F Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) by imf03.hostedemail.com (Postfix) with ESMTP id 458E52000E for ; Mon, 23 Sep 2024 10:22:35 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=nQVNnlsS; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.208.177 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727086920; a=rsa-sha256; cv=none; b=eCzSZNoDqtJWOMrNbNHc12XTLfK1X3Vx+gyAXxKBL1VnYtrLEHaB8q73WLBeN1Y04crPnZ gJ0GQzbVwCSgtXiV3w1Q0Wl0v4Kfjtdy9O25XN+imNYaYGmzXX0IIITCISp0VwDuG59uHT NPOxYcGDgYQyak9IxXdFnudhLRl74uw= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=nQVNnlsS; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.208.177 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727086920; 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=p0uuKdeGezjZc5UnHOkWvAYXuGVRFJ2H/2YngeFELEQ=; b=UoTBoLfsZrVjwJwIShnrfFAFTft1dF3gBaBAXOjJkxwojIidm4ZiyZ4LfAyNNeJ//rM0G2 OSH2bdq2nSfU67R5q1t+gLOEbTFIsmeOWnKRJEvktuVPv3mr09Jn9Oc4zdsHOypaH9Lm+k oNq2Ylkn8RykT5Ak35sp4wO4bR9ea5I= Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2f761461150so47011191fa.0 for ; Mon, 23 Sep 2024 03:22:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727086953; x=1727691753; darn=kvack.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=p0uuKdeGezjZc5UnHOkWvAYXuGVRFJ2H/2YngeFELEQ=; b=nQVNnlsSNHJnFYGgMGfkU7YZTXziqOqQLXH148IPYelIV7Rlq1xQ16zpvCR8uxOzvk T81k/cTmEjOPsXbQX3I+ZM24KFDbC4P29eBPKWwsWlY8Nl/XoRcpDmWrl+sCIEHZbOuU NiKdHsf+n+Om3JfZv2QJ9e2LbMDSHOS189hKVBS4NEfePxg0EwvnyuwowRW6Moa4885N 31yYIK4mFa6NOy1yq9dJ2L1i3fEB38tipKaFOR6Xr+3eTvG/5XsKUm/adhL8W2UJ67/S 49+Bey+9aHLEBz9Wz5VIhcZrc8sd2p7RtW03HLCFC13oGtKwkBZryAYa7hK2yPnZGS77 fWNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727086953; x=1727691753; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=p0uuKdeGezjZc5UnHOkWvAYXuGVRFJ2H/2YngeFELEQ=; b=Hby4Vak83SYGdWiLFAwOf30Ht36pTAo+5NvEO2c9uqvQE7OzjppYt10NS566NQPIf/ MAF8iiLAH3aImSXxz593owWkGy1RJtkvZV53IonuYmWPAOAdksLyR9a/2XJFwL5CvQk6 AZMOK7foVN8vt7YNrw6M9as1jiRTVEdiJQTOgjrcc/FekaaYzJWu7qvi1+TM7NggBTD+ ye8x1UGdwuJo+Lwtbe/DEC++Bg+InmqojyZUnR9pStkvmLlrp1pvrpnG3b149qJBTazc tm9i0aki8NAOqRziFplESoBa/nF8vVu7s1sab+0QgCbjRyQ5Ynha1Bq4/79MNBD+DK/u 6lDQ== X-Forwarded-Encrypted: i=1; AJvYcCXBsDdvdsNxffAEDgrhjkUaO1eqtP78w7n4ofluhwAGxCsue+J9Wq2uJF02NubdVdaWP3KbxxSHig==@kvack.org X-Gm-Message-State: AOJu0Yx8dABRBQrw03ymnS2uFKGfxJmU/8UQx2YDZAC30j8yO6/RRsV1 TyOXYSPFfYV+KOxAXGg+0IDnRH59OtyVWP5OUPloWqV4HloJ8j5g X-Google-Smtp-Source: AGHT+IGsAWMklqsvh12ib54u9c5KIkHgI6oDOMOya6Vik+HzuQP8fqL/PpJOBar2JIdHosXGpXcp3Q== X-Received: by 2002:a2e:9e04:0:b0:2f6:6198:1cf9 with SMTP id 38308e7fff4ca-2f7cb358243mr53564731fa.31.1727086952924; Mon, 23 Sep 2024 03:22:32 -0700 (PDT) Received: from ?IPV6:2a03:83e0:1126:4:eb:d0d0:c7fd:c82c? ([2620:10d:c092:500::6:274b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90979ceb67sm878196466b.219.2024.09.23.03.22.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Sep 2024 03:22:32 -0700 (PDT) Message-ID: <2c418b81-8f67-4a45-b4d2-d158fa4f05d9@gmail.com> Date: Mon, 23 Sep 2024 11:22:30 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v7 2/2] mm: support large folios swap-in for sync io devices To: Barry Song <21cnbao@gmail.com>, Yosry Ahmed Cc: Andrew Morton , Kairui Song , hanchuanhua@oppo.com, linux-mm@kvack.org, baolin.wang@linux.alibaba.com, chrisl@kernel.org, david@redhat.com, hannes@cmpxchg.org, hughd@google.com, kaleshsingh@google.com, linux-kernel@vger.kernel.org, mhocko@suse.com, minchan@kernel.org, nphamcs@gmail.com, ryan.roberts@arm.com, senozhatsky@chromium.org, shakeel.butt@linux.dev, shy828301@gmail.com, surenb@google.com, v-songbaohua@oppo.com, willy@infradead.org, xiang@kernel.org, ying.huang@intel.com, hch@infradead.org, Hailong Liu References: <20240821074541.516249-1-hanchuanhua@oppo.com> <20240821074541.516249-3-hanchuanhua@oppo.com> <20240903130757.f584c73f356c03617a2c8804@linux-foundation.org> <94eb70cd-b508-42ef-b5d2-acc29e22eb0e@gmail.com> Content-Language: en-US From: Usama Arif In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Queue-Id: 458E52000E X-Rspamd-Server: rspam01 X-Stat-Signature: 9zak4ambecetbxxxpeuubs88qro4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rZeci7Nl6cCo9ND9ofjm+Q++lQgDkfwol8i29JphEqaCFJWLswHIXuN9FWhM1LJ/uaMGGRZoXgqhmRb3Bf7lVN+KpMqC0zr0RUttdKYb1Rzu9pTlb/2Ekyj8dSJd7aQyivmajGmqpafcqXG+VOPM84YOe8qOKOJ6q4OVz29Wu5XJXAxqJpMDyxQeheoLxEQPgISw2awrC13QeCKgdQ7Mav5BCl1FqVfEEGRj29+GzliSJVkJQXWWNdSw6HXKY+1eCwphnvVLYWekEpqjMLpB/uqa5SF9fWx9KOciKXwydTX45C3xzCYZwBsb2uXXC87gI/yEvnv+2iP48f2/R4C8LAwoyo4153F86dilDHaIi9CHsoeogYgPDckDtPBbk3ahknU8SQu2XUCWER7zpix1O1bjDDTGKN91GNo6yTuVWdSAprFMHcvJlSXf9sHhoa5jWK0qkkKgwmObVCyEBHsv/UOIOowJpwvIyz42OQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000113, 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 23/09/2024 00:57, Barry Song wrote: > On Thu, Sep 5, 2024 at 7:36 AM Yosry Ahmed wrote: >> >> [..] >>>> >>>> On the other hand, if you read the code of zRAM, you will find zRAM has >>>> exactly the same mechanism as zeromap but zRAM can even do more >>>> by same_pages filled. since zRAM does the job in swapfile layer, there >>>> is no this kind of consistency issue like zeromap. >>>> >>>> So I feel for zRAM case, we don't need zeromap at all as there are duplicated >>>> efforts while I really appreciate your job which can benefit all swapfiles. >>>> i mean, zRAM has the ability to check "zero"(and also non-zero but same >>>> content). after zeromap checks zeromap, zRAM will check again: >>>> >>> >>> Yes, so there is a reason for having the zeromap patches, which I have outlined >>> in the coverletter. >>> >>> https://lore.kernel.org/all/20240627105730.3110705-1-usamaarif642@gmail.com/ >>> >>> There are usecases where zswap/zram might not be used in production. >>> We can reduce I/O and flash wear in those cases by a large amount. >>> >>> Also running in Meta production, we found that the number of non-zero filled >>> complete pages were less than 1%, so essentially its only the zero-filled pages >>> that matter. >>> >>> I believe after zeromap, it might be a good idea to remove the page_same_filled >>> check from zram code? Its not really a problem if its kept as well as I dont >>> believe any zero-filled pages should reach zram_write_page? >> >> I brought this up before and Sergey pointed out that zram is sometimes >> used as a block device without swap, and that use case would benefit >> from having this handling in zram. That being said, I have no idea how >> many people care about this specific scenario. > > Hi Usama/Yosry, > > We successfully gathered page_same_filled data for zram on Android. > Interestingly, > our findings differ from yours on zswap. > > Hailong discovered that around 85-86% of the page_same_filled data > consists of zeros, > while about 15% are non-zero. We suspect that on Android or similar > systems, some > graphics or media data might be duplicated at times, such as a red > block displayed > on the screen. > > Does this suggest that page_same_filled could still provide some > benefits in zram > cases? Hi Barry, Thanks for the data, its very interesting to know this from mobile side. Eventhough its not 99% that I observed, I do feel 85% is still quite high. The 2 main reasons for the patcheset to store zero pages to be swapped out in a bitmap were for applications that use swap but not zswap/zram (reducing I/O and flash wear), and simplifying zswap code. It also meant fewer zswap_entry structs in memory which would offset the memory usage by bitmap. Yosry mentioned that Sergey pointed out that zram is sometimes used as a block device without swap, and that use case would benefit from having this handling in zram. Will that case also not go through swap_writepage and therefore be takencare of by swap_info_struct->zeromap? Also just curious if there are cases in mobile where only swap is used, but not zswap/zram? I think even with 85% zero-filled pages, we could get rid of page_same_filled especially if the zram without swap case is handled by swap_info_struct->zeromap. But don't have strong preference. Thanks, Usama > > Thanks > Barry