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 49157D3E2C2 for ; Mon, 28 Oct 2024 20:00:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C2E156B0088; Mon, 28 Oct 2024 16:00:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BB7526B00A2; Mon, 28 Oct 2024 16:00:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A0A2C6B00A3; Mon, 28 Oct 2024 16:00:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 79BB96B0088 for ; Mon, 28 Oct 2024 16:00:06 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2A165C0E2D for ; Mon, 28 Oct 2024 20:00:06 +0000 (UTC) X-FDA: 82724076708.16.EE728B8 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by imf14.hostedemail.com (Postfix) with ESMTP id 9847F10002B for ; Mon, 28 Oct 2024 19:59:37 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Xlop4qQ8; spf=pass (imf14.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.221.48 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730145524; a=rsa-sha256; cv=none; b=kB474X97KfSLEI+Fq9aegdoep6mU1iBjehFSb9wftV0P9EZrZjxRCDUV/kVz/ClNVGKeCy dLpro38OXChf5VLiRN/9jx3btntg5b49d9/zvv1EtK8Jff71xevXyApqYrrRNeS0p/QVWQ GeeXibde66MQnq2HF/QFVlSWtiqQf5k= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Xlop4qQ8; spf=pass (imf14.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.221.48 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730145524; 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=cIUekGsdjBLrzdn8D80ojdZOPBDaJKu1O61Vf5DnR7E=; b=cfGJbU+KOh9cvTTXeHpkDAtFJBSPTv5j2wujZDLupESYbqVbbZHLGtTjxWPUdtaj8ZgYxv pL51q5w6tJCJoOFsbzICJ2ut4Cb+SL6ZLT2xBpeVEFATxOxBNQKy1wJdLYvyKD6a9Kb8rz Wq+rvpwPFFtsEfh9nmXQuc2XhP90344= Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-37d5aedd177so3161444f8f.1 for ; Mon, 28 Oct 2024 13:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730145602; x=1730750402; 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=cIUekGsdjBLrzdn8D80ojdZOPBDaJKu1O61Vf5DnR7E=; b=Xlop4qQ8lvChsyPa7ijeEN17tr00/vKw0jzD/2lmK+zNdZtqxcVVdCs8vQb6kfgezy n+EoCmwE/5W0n0Ps5OhocA3NmKY7jnQ03wEQ/QUPF35pjkzONg2T5FSERR41pgWnvYwV VIr68eXTWqu9uXxSXRY/op+xmGDx5d3MhN4k3ErqmBaBGBPilMXuTSGjgMKQzQOFz/Ja uLBihSnnOLbWzM6kY4Xu1ZCFf++0yXx3dJuoJmA9VlsGAp9JHxTUVLO7X92PsTq6g+sy dJNaubDy3ND/OGnwlZPQQr4ESMzVyfTX5uyLB2O02dpkEFoAU/l5+p8x5DNO0ar4Yj2L Nlkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730145602; x=1730750402; 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=cIUekGsdjBLrzdn8D80ojdZOPBDaJKu1O61Vf5DnR7E=; b=FqnZESQ7hEh2hymBt6PYU55+znmw2gLF3fztmYN/Ynpchj5BmL4HPRT+AIuJTznV9x hr6a3fTKJuLQxi49Y+INzx6cUNtZ7yOnJ5mJlduBtjRtHJmTK2+WMtWNxZkjFC7IL/XK 0xfyT9GWbXSpNUZWHoU7RQFn4/4ngcH9SsWYGD1Tv6SUz1nq2Isbavdplmd/wwsDdG/T v6W8BbgGC6d/WozOP9d4DA51oMdODpH1fENQimzxMCFsmvv9BAz1YsZ4aiH9o32NTuBV UuuLWJW2+gEL1Wj69Rou9XgbBVeF33Thi+Pb3p+KFSB/PBAdv+AG7+UWbmqkyfsbAxqF YzwQ== X-Forwarded-Encrypted: i=1; AJvYcCU/5kqn81rYjnyPA1xpl7Ri697DcydT91q8BtEmznQBvcNZQ+CXmQdMvbEC6pUC7DA5JLnFD9/RQw==@kvack.org X-Gm-Message-State: AOJu0YwDqYPuMCguuUL+LrYwg9fb3t8tt7cF/ZgbwkaiPIQbTB2T4KfJ mS7zOB12ZeE0/YFRy5CePPZONuuriiBffsdsTMyLUfBs2hldgadK X-Google-Smtp-Source: AGHT+IFs1NYcYyNMuGx4j41Mb1jhXv4Eu8GGF3FfsmGpiMZziiqnsiQMQcEQaS7oTxkh6mQERjCFiA== X-Received: by 2002:a5d:50cf:0:b0:37d:94d6:5e20 with SMTP id ffacd0b85a97d-380610f4e77mr7568641f8f.4.1730145602179; Mon, 28 Oct 2024 13:00:02 -0700 (PDT) Received: from ?IPV6:2a02:6b67:d751:7400:c2b:f323:d172:e42a? ([2a02:6b67:d751:7400:c2b:f323:d172:e42a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38058b4a3cesm10331501f8f.63.2024.10.28.13.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Oct 2024 13:00:01 -0700 (PDT) Message-ID: <882008b6-13e0-41d8-91fa-f26c585120d8@gmail.com> Date: Mon, 28 Oct 2024 20:00:01 +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> Cc: Yosry Ahmed , Nhat Pham , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Barry Song , Chengming Zhou , 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> <678a1e30-4962-48de-b5cb-03a1b4b9db1b@gmail.com> <6303e3c9-85d5-40f5-b265-70ecdb02d5ba@gmail.com> <64f12abd-dde3-41a4-b694-cc42784217fb@gmail.com> Content-Language: en-US From: Usama Arif In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Stat-Signature: xhsypyqgcj19ome7j3gasyxfjxu39roi X-Rspamd-Queue-Id: 9847F10002B X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1730145577-680647 X-HE-Meta: U2FsdGVkX18+dOMNM9Qmi655v/KafItkX8H5030rpv4X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cCLG/bojhp8JeFTLnFDwvFLJv8Suf8THjoChI+OHO3tQQPnw7qVUwAK2pUEC5rn/c1nQ14GkUgVNNncmpgHbOpw+F9U6mIVuUpjUsvkxgiXA3dOI5OE5Sld26xjK4HIAw06poy8Hr3Q+vFkj2O+bF0JkALYHACWfmkehUerQ8E5hWvWPiYFoY1R6O9WDzQmsHokurVCcKcb6SkE3PhOFYkQXkQu1Nqdz//tsysSyooHy9etYLL724iFLqFqCVsvqiAUeLymIEjkOW8dVLqs0rAor9yFM3XJyuDkev0Vwc8h79QUTf4aMxWPxY7pYohkTirq356jWn4jWCDefeYPGwlUiTA+e2q2GMDVtPqE119DWtomVIqmCoO732X03/c3DhkLzmQ+nV+Nc3Z2D+kutV719sDZX7X3IwzaGp1EIpmQfjsMjwGmhGI7DgZGHlkNbJoSaxg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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 19:54, Barry Song wrote: > On Tue, Oct 29, 2024 at 1:20 AM Usama Arif wrote: >> >> >> >> On 28/10/2024 17:08, Yosry Ahmed wrote: >>> On Mon, Oct 28, 2024 at 10:00 AM Usama Arif wrote: >>>> >>>> >>>> >>>> On 28/10/2024 16:33, Nhat Pham wrote: >>>>> On Mon, Oct 28, 2024 at 5:23 AM Usama Arif wrote: >>>>>> >>>>>> 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. >>>>> >>>>> I don't think one can substitute for the other. >>>> >>>> Yes agreed, they have separate uses and provide different information, but >>>> maybe wasteful to have both types of counters? They are counters so maybe >>>> dont consume too much resources but I think we should still think about >>>> it.. >>> >>> Not for or against here, but I would say that statement is debatable >>> at best for memcg stats :) >>> >>> Each new counter consumes 2 longs per-memcg per-CPU (see >>> memcg_vmstats_percpu), about 16 bytes, which is not a lot but it can >>> quickly add up with a large number of CPUs/memcgs/stats. >>> >>> Also, when flushing the stats we iterate all of them to propagate >>> updates from per-CPU counters. This is already a slowpath so adding >>> one stat is not a big deal, but again because we iterate all stats on >>> multiple CPUs (and sometimes on each node as well), the overall flush >>> latency becomes a concern sometimes. >>> >>> All of that is not to say we shouldn't add more memcg stats, but we >>> have to be mindful of the resources. >> >> Yes agreed! Plus the cost of incrementing similar counters (which ofcourse is >> also not much). >> >> Not trying to block this patch in anyway. Just think its a good point >> to discuss here if we are ok with both types of counters. If its too wasteful >> then which one we should have. > > Hi Usama, > my point is that with all the below three counters: > 1. PSWPIN/PSWPOUT > 2. ZSWPIN/ZSWPOUT > 3. SWAPIN_SKIP/SWAPOUT_SKIP or (ZEROSWPIN, ZEROSWPOUT what ever) > > Shouldn't we have been able to determine the portion of zeromap > swap indirectly? > Hmm, I might be wrong, but I would have thought no? What if you swapout a zero folio, but then discard it? zeromap_swpout would be incremented, but zeromap_swapin would not. > Thanks > Barry