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 52F2DC531DC for ; Fri, 23 Aug 2024 17:56:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 91E6F800BC; Fri, 23 Aug 2024 13:56:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8CDCF800B4; Fri, 23 Aug 2024 13:56:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7951C800BC; Fri, 23 Aug 2024 13:56:55 -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 5983B800B4 for ; Fri, 23 Aug 2024 13:56:55 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id DEE724170F for ; Fri, 23 Aug 2024 17:56:54 +0000 (UTC) X-FDA: 82484265948.22.1C5F046 Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) by imf08.hostedemail.com (Postfix) with ESMTP id EC373160009 for ; Fri, 23 Aug 2024 17:56:52 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=RzIKVp2l; spf=pass (imf08.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.184 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724435795; 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=un5k90vrbN5RPrqbHK8kokOeMqPyoW5VK7qLx4GdDLA=; b=XdDw1jc0AntcD5hC5S+JVwiKdwwTQDLTniJxyxf1vEEH0pcWfW7YuPycPooQKH8M8jUHkh xS6aDtUQtuZuM85wsjKVfWdnBBKQmYHk3oueZyglsZrDnevB/HNMH4LSpyMTG6ZdShTS1c gRd+oxhkXXSDJlxBd5TI0j+/U82iOGM= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=RzIKVp2l; spf=pass (imf08.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.184 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724435795; a=rsa-sha256; cv=none; b=jkF3OHA9Y7naiwnpCrzcyFrfjh6aHDrY5s7QUb9NRYP0bMe+G6vmYeksuk7W2mysv2Vp0N zkBO5aLGlXGXw/HQ98cDqAXWPLUB76Nw6KaxoUh1hbyvMGuJnWlZkAdSiMWP1QDt8Z8mhh dqKMiipTAYvA5kOxRptnrr2ZmEHzcXs= Date: Fri, 23 Aug 2024 10:56:42 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1724435810; h=from:from: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; bh=un5k90vrbN5RPrqbHK8kokOeMqPyoW5VK7qLx4GdDLA=; b=RzIKVp2lSda6MKYMug//blydJHWrCxPVCiU1LWPBGEJ92gxsN6wp82o9lw4SBRfN3JlW8P Zxnl/ADb0DfX+2Gfr5m9BICh4TKpC2WchF0QEtrTZ9y3gbFON2/dNiUpUnou3B7cw0lrav 8icY6fHth+MNPBkAEm3R4DlYAVO7gEU= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Barry Song <21cnbao@gmail.com> Cc: hanchuanhua@oppo.com, akpm@linux-foundation.org, linux-mm@kvack.org, baolin.wang@linux.alibaba.com, chrisl@kernel.org, david@redhat.com, hannes@cmpxchg.org, hughd@google.com, kaleshsingh@google.com, kasong@tencent.com, linux-kernel@vger.kernel.org, mhocko@suse.com, minchan@kernel.org, nphamcs@gmail.com, ryan.roberts@arm.com, senozhatsky@chromium.org, shy828301@gmail.com, surenb@google.com, v-songbaohua@oppo.com, willy@infradead.org, xiang@kernel.org, ying.huang@intel.com, yosryahmed@google.com, hch@infradead.org, ryncsn@gmail.com Subject: Re: [PATCH v7 2/2] mm: support large folios swap-in for sync io devices Message-ID: References: <20240821074541.516249-1-hanchuanhua@oppo.com> <20240821074541.516249-3-hanchuanhua@oppo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Stat-Signature: uhnqumepjf4foim3qajmwm1owijnhhfr X-Rspamd-Queue-Id: EC373160009 X-Rspamd-Server: rspam11 X-HE-Tag: 1724435812-597579 X-HE-Meta: U2FsdGVkX1/h0JyNCyIlzIDWIxFR7UwCkIhgOTkFfa/l6XzFgxk3skk78k04h+kGwu+rtUmTmY88Ad7x/myMXRgP4HfjsQi58Tt8T6JdANlE4rXyAkBBFdN/2b1Hkmlcp0YsmIw9CCSO2am4YplW7s66YCXthK8ifDZJSfRYncE6J1AvvLvXWsbGfGfbZMBj7CWXXb+AvXjbPJ75vfzRytBMR5rc+Io+TIxtANbjMk92yUOOae1/aRc4t9Z0TRa06k4Z4qa1U/xTT1oMQh87ZG2AIE4JJMUMBCRLsG/KAfgnejKy616Wytx2pdUyVxY0a0BN1jkeykJfaj+w6i9dVYFtmgXZl66gVVmfY0fE+OMKUS6ZW8ovGIRXOrOKA9stHqeqaaQykHNRk1e6+bhPSBcYaGXoC6mJd9Vut2D/NjJzW8H0djNIywlLlOizgK1H1IJmQ9+ewRPhrruhoYJg6Z3FyAxpIGmMrzLiB745hUPr4e+k/JEooqkkR9tU6wfFh86DCvZ81K96Z6CP1HfMRQCjlIs8kSkDSOio3siUTuj5WRhbXeENVLq8hUpWos9YiUoHdEXOZDmfDriAyr600uH8QKCsqH4jTW9OZFnBom7o+Nq2X2fDcFvwEZDMlEAeoNqJXh1gE9vw9yhnjWJ1JI7xEdaQXcGJ4yBPVe/k0p2b11kx06Ql8G8g0jOhgtLjrgn3Feg+2HXQ17eyQCzuyMQYGJuJO4zTmrNdYaIzsgzIkqPZhA4X5qjxJv2nAPVsbcEnqiNy4eTFEKDSd/SamkAmWjBiAzauJkccjzH2b3ZNI/f7jV3JhnFkkP6isqVPMva0d/4tAnl1GvB8OiJ1OVJBVIH5p+YBCp8tx8d6qDH1h6+Y5CWgTrV/nMLT0QtHKA9g1/oVM3+SrXnGl99kwxH/acrXJWWL68aJKRRVgwzCC3LRqaqe6gQubNq52MTNIWYFy84zwtbBYbPfDrR 3RzRbijE ogY/idFlarAw0qHO2ulwJALBe5IZjndS9yDJgvtqHCU/Em0a1dcPjTuOSvo6kAn18XvjlUjvc2PcZ3wD041oZa8aTfORqKhS3zl3gHr+y2+WL/2tim28ZS7A3Ls8zkvzfGG4WmH53igEKEcEgTk+Gyt4DSAw5ZVFPia6k3HZMM2vgcAI1gvUUg2vV4EUq4XBPGou1vO9fF4Y/azT4naXlydWkROwo1sZKj5K+0Jjp0/wO+eSnXejDNMrKL0Hx+/nUdFzithjK7c+j+/QrHptBdJOhUt9rd4oHOP3B 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: Hi Barry, On Thu, Aug 22, 2024 at 05:13:06AM GMT, Barry Song wrote: > On Thu, Aug 22, 2024 at 1:31 AM Shakeel Butt wrote: > > > > On Wed, Aug 21, 2024 at 03:45:40PM GMT, hanchuanhua@oppo.com wrote: > > > From: Chuanhua Han > > > > > > > > > 3. With both mTHP swap-out and swap-in supported, we offer the option to enable > > > zsmalloc compression/decompression with larger granularity[2]. The upcoming > > > optimization in zsmalloc will significantly increase swap speed and improve > > > compression efficiency. Tested by running 100 iterations of swapping 100MiB > > > of anon memory, the swap speed improved dramatically: > > > time consumption of swapin(ms) time consumption of swapout(ms) > > > lz4 4k 45274 90540 > > > lz4 64k 22942 55667 > > > zstdn 4k 85035 186585 > > > zstdn 64k 46558 118533 > > > > Are the above number with the patch series at [2] or without? Also can > > you explain your experiment setup or how can someone reproduce these? > > Hi Shakeel, > > The data was recorded after applying both this patch (swap-in mTHP) and > patch [2] (compressing/decompressing mTHP instead of page). However, > without the swap-in series, patch [2] becomes useless because: > > If we have a large object, such as 16 pages in zsmalloc: > do_swap_page will happen 16 times: > 1. decompress the whole large object and copy one page; > 2. decompress the whole large object and copy one page; > 3. decompress the whole large object and copy one page; > .... > 16. decompress the whole large object and copy one page; > > So, patchset [2] will actually degrade performance rather than > enhance it if we don't have this swap-in series. This swap-in > series is a prerequisite for the zsmalloc/zram series. Thanks for the explanation. > > We reproduced the data through the following simple steps: > 1. Collected anonymous pages from a running phone and saved them to a file. > 2. Used a small program to open and read the file into a mapped anonymous > memory. > 3. Do the belows in the small program: > swapout_start_time > madv_pageout() > swapout_end_time > > swapin_start_time > read_data() > swapin_end_time > > We calculate the throughput of swapout and swapin using the difference between > end_time and start_time. Additionally, we record the memory usage of zram after > the swapout is complete. > Please correct me if I am wrong but you are saying in your experiment, 100 MiB took 90540 ms to compress/swapout and 45274 ms to decompress/swapin if backed by 4k pages but took 55667 ms and 22942 ms if backed by 64k pages. Basically the table shows total time to compress or decomress 100 MiB of memory, right? > > > > > [2] https://lore.kernel.org/all/20240327214816.31191-1-21cnbao@gmail.com/ > > > > Thanks > Barry