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 9984FD1359F for ; Mon, 28 Oct 2024 12:23:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 311D86B0089; Mon, 28 Oct 2024 08:23:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 29B146B008A; Mon, 28 Oct 2024 08:23:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 114F16B008C; Mon, 28 Oct 2024 08:23:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E7A326B0089 for ; Mon, 28 Oct 2024 08:23:17 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 574DD409D2 for ; Mon, 28 Oct 2024 12:23:05 +0000 (UTC) X-FDA: 82722924858.07.FCBA930 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by imf29.hostedemail.com (Postfix) with ESMTP id 224CD12001F for ; Mon, 28 Oct 2024 12:22:43 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=DmfqgQUr; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.208.49 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730118141; a=rsa-sha256; cv=none; b=bvWMZSXmXbR4GFcdSqKzuBp2VsyJJy89vEcl5d8+l4HsRi+5aFdG4Z17JtNmko+2Zf7U0z o5NLic4aSbXukCPc8OcJ045WNXIhELrCi+TAcuBkXJCqc8+bPvhH0iLo0I5eTRfukuGYY8 ASgrbaOvGxySgABrWvSRWlm5C9WBBk0= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=DmfqgQUr; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.208.49 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=1730118141; 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=Ga+QC/cz6mBGu37O80ejWdpJXnenUBU6ztw+p/e2ORg=; b=k9u13LpBIdYj4h08uVg9ynCeAkmKXtQD08qwm6sfCHCSd3SruMTr3/zAHjOy840cuZA5UU eDsX6UrkuvLf8CJPLaPpNM07faddTyjPLha0P6Z9J0KvlreKJZqTX9GGBjxCwBUzss1Cvz h+/ah69wrIp76X5oKYRKsamd5c0eOTE= Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-5c97c7852e8so6035698a12.1 for ; Mon, 28 Oct 2024 05:23:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730118194; x=1730722994; 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=Ga+QC/cz6mBGu37O80ejWdpJXnenUBU6ztw+p/e2ORg=; b=DmfqgQUrnz7DylrEpohYIwOOv2bLvci06TRXus6RRaWKaKogptevOzPoW/GpOIJkNm DuRtj8yAx4uXUdnF915uj6c7OgC4hx4BAWxVFVIDcGHuPS5asvRrb6fZtgcyqQKeXrCJ a2JJMW5jk6N4uSXQW17ow6aXHYbWNxLIgP3bNIBvMassbhYmZSbnKnl8y374kqa9pEAr V6H9O7c4XeZc8tNc01358u8IZFDKqgQ6qT6yek7tkNo5I9On7NPV3QF4onDev4u3prGo Fu+nl4zA4y42Wfulr7Zh5yVS7d+ckScuXz34agY02kdxCbzP3AFR6m3gAMZRsD4ZFPhh fpZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730118194; x=1730722994; 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=Ga+QC/cz6mBGu37O80ejWdpJXnenUBU6ztw+p/e2ORg=; b=R7vwPZRwd0UP4lEjxuAJy3F0CHIj3bhE85ho7/VTCs9UR+bqhsKuUW/fNZYePifpfm rhGQN+wEB1L258UlG/WurTEajbUmiGbUFcsf7WjbbrOHBj2GVovc6yCdchmzMJfR5A+m 63zO7v3GPcMUcm7fq7yqwlaRZvWr2bD7hB6891fUGxU71nHcOXnCFz2VOoBYj42g74tH d0fOPp9cA0M2jbjpMmsamAmDelpgpLS4DSinqjSoVE8VYb/LEa2m1qriEqmaLwBPEhPj 8t9y+iJ6lKZnwj2iVm/WRQhYh1sPm625bfozet7Kn6C/BkeQSmfDjiiNqu0BxOFkrKw4 dc/g== X-Forwarded-Encrypted: i=1; AJvYcCXtPAocJN8BUr3rWJWIZIJl53pC0zZyD2SrzIB3h1SnPPyok+ImE99ynRrbp/7c4L8ORHIQNb9LVA==@kvack.org X-Gm-Message-State: AOJu0Yy4jKpJR+ospyi2lzQbP0IBbmAduIpRCx5bp1GfMZ/sJv1Nuf5A IQsNYIspSDQmMjrDz1J1iDWafHdTfnDMzHeop8pL7vM3iCWQY3O/ X-Google-Smtp-Source: AGHT+IFYjdhxWYM6GXoFR/9NZTPQUJjmCFU0rAVx4YAoHkudOwBd74AhcCJFnvrsWt5R9NYIdRIemg== X-Received: by 2002:a17:907:9487:b0:a99:c0be:a8ac with SMTP id a640c23a62f3a-a9de5ee477dmr784336266b.37.1730118193712; Mon, 28 Oct 2024 05:23:13 -0700 (PDT) Received: from ?IPV6:2a03:83e0:1126:4:eb:d0d0:c7fd:c82c? ([2620:10d:c092:500::5:1494]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b3a086f6dsm371115666b.214.2024.10.28.05.23.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Oct 2024 05:23:13 -0700 (PDT) Message-ID: <678a1e30-4962-48de-b5cb-03a1b4b9db1b@gmail.com> Date: Mon, 28 Oct 2024 12:23:12 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFC] mm: count zeromap read and set for swapout and swapin To: Barry Song <21cnbao@gmail.com>, Nhat Pham Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Barry Song , Chengming Zhou , Yosry Ahmed , Johannes Weiner , David Hildenbrand , Hugh Dickins , Matthew Wilcox , Shakeel Butt , Andi Kleen , Baolin Wang , Chris Li , "Huang, Ying" , Kairui Song , Ryan Roberts , joshua.hahnjy@gmail.com References: <20241027011959.9226-1-21cnbao@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: 224CD12001F X-Rspamd-Server: rspam01 X-Stat-Signature: 8i74u8dnck5smm7475k1fotk91heh1w9 X-HE-Tag: 1730118163-859006 X-HE-Meta: U2FsdGVkX18WAp0Yr1AA+MJaShsV9e7wWiuMhufDqPLxTWcXe7l0+bBoCByDz7V37U9Au4DmfyFGEiWPSUSDsu9nRG9v83sJRs1sj/xXwJXrbnpPkSkw+xEpi3mHLbJuq7q6nas0tQ35xxdGWXeASVzCNU3tbgfyYhDwluYqW/UTyg4ZVUgXKpInr9Xp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1xx3eq4SZuN0t44kWiN3tczpZLXLCd0cyRdpSue3h0PUZKQl1fjYE3AirqGoKEg26x5jABCUfx3kLlT4aoUnO8bMgW94hxI7llEHqgvQnfkXsC1BBKywSb3JzQojnDg3Xt/L5b6FbjwAaZYZ+yhV4v2ICRq4N+sqpPbC4exrZHWithANhGHD4hMlX+2odrJmr3EGwc14KcNOZzlmyL3BNANKkS6sIl3qX2s7ZLbd19Wu+EyUfbPLM24qbUsH/EQLDOsbgSPD/0WmGLWh9r3UR+IYWRS6sE0UWwNOHGTjkYI9Sa8E4p74aGayy3SWjVM= 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 28/10/2024 02:32, Barry Song wrote: > On Sun, Oct 27, 2024 at 3:45 PM Nhat Pham wrote: >> >> On Sat, Oct 26, 2024 at 6:20 PM Barry Song <21cnbao@gmail.com> wrote: >>> >>> From: Barry Song >>> >>> When the proportion of folios from the zero map is small, missing their >>> accounting may not significantly impact profiling. However, it’s easy >>> to construct a scenario where this becomes an issue—for example, >>> allocating 1 GB of memory, writing zeros from userspace, followed by >>> MADV_PAGEOUT, and then swapping it back in. In this case, the swap-out >>> and swap-in counts seem to vanish into a black hole, potentially >>> causing semantic ambiguity. >> >> I agree. It also makes developing around this area more challenging. >> I'm working on the swap abstraction, and sometimes I can't tell if I >> screwed up somewhere, or if a proportion of these allocated entries go >> towards this optimization... >> >> Thanks for taking a stab at fixing this, Barry! >> >>> >>> We have two ways to address this: >>> >>> 1. Add a separate counter specifically for the zero map. >>> 2. Continue using the current accounting, treating the zero map like >>> a normal backend. (This aligns with the current behavior of zRAM >>> when supporting same-page fills at the device level.) >> >> Hmm, my understanding of the pswpout/pswpin counters is that they only >> apply to IO done directly to the backend device, no? That's why we >> have a separate set of counters for zswap, and do not count them >> towards pswp(in|out). >> >> For users who have swap files on physical disks, the performance >> difference between reading directly from the swapfile and going >> through these optimizations could be really large. I think it makes >> sense to have a separate set of counters for zero-mapped pages >> (ideally, both at the host level and at the cgroup level?) > > agree it is better to have a separate counter for zeromap. > then it raises a question: what is the proper name for it :-) > > zeromap_swpin, zeromap_swpout seems too long? and zswpin > and zswpout have been used by zswap > > Thanks > barry I wonder if instead of having counters, it might be better to keep track of the number of zeropages currently stored in zeromap, similar to how zswap_same_filled_pages did it. It will be more complicated then this patch, but would give more insight of the current state of the system. Joshua (in CC) was going to have a look at that. Thanks, Usama