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 8F46CD3E2C2 for ; Mon, 28 Oct 2024 19:54:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1A1906B009F; Mon, 28 Oct 2024 15:54:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 151A96B00A2; Mon, 28 Oct 2024 15:54:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F347F6B00A1; Mon, 28 Oct 2024 15:54:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D42FF6B0099 for ; Mon, 28 Oct 2024 15:54:36 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 75DE680E12 for ; Mon, 28 Oct 2024 19:54:36 +0000 (UTC) X-FDA: 82724062470.06.C08CD9F Received: from mail-vs1-f52.google.com (mail-vs1-f52.google.com [209.85.217.52]) by imf14.hostedemail.com (Postfix) with ESMTP id 33B2910001C for ; Mon, 28 Oct 2024 19:54:08 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ccFBUKFH; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf14.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.217.52 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730145145; a=rsa-sha256; cv=none; b=xcKJb8Hsb1+o4+Ou7fZFSVP3u4XFMS/ZYNE8dxDP5GYUK1d5sVpMeu+9E99gobWecMF/5d QcEUpR4xYEQ04wqsNexcsgpdb+TsW/ll1fN6mWM+CgzzgDS+KIvZEyWXrd+elhWeDa43zl ijPi5Zhj1JPTdXFqukp026G2jc+HnRA= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ccFBUKFH; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf14.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.217.52 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730145145; 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=xEqSFdphUj/m4lVNP4wwRMew36LE0V9bUPR/s/JiXY0=; b=F1Ldy8rqAgcAakdN7Cjc1KTClSW5C/DHkHYdUZziGzZBITAZePG6bPqUjwVbYRG7cDqr5A 3Hhrpg4TnNJkcrg0ThFR+H6caCZIWItXQj/arHdbwo9VeFjASM1TvS+PNebp9Fb5nCRbd4 MuGfgTUoJtQq805qt8r5HjC57HNrRpM= Received: by mail-vs1-f52.google.com with SMTP id ada2fe7eead31-4a46a25545aso1351507137.0 for ; Mon, 28 Oct 2024 12:54:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730145274; x=1730750074; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=xEqSFdphUj/m4lVNP4wwRMew36LE0V9bUPR/s/JiXY0=; b=ccFBUKFHgcXeQDWHmBgou/tKxRZ/C8RtmDLy6G3atOj8H0yEZrxR+1+VtCMCXJUAAu 8Dz6MNzZtMg1ty4yFTnKS6ofPak6L3ebJKXha/fkzBWorwdT0X0cffKZGzggzVQwoot7 aM7sYbfdawjUG6xL6hkBcgePqjTflq3i2+VxtzOBGVVZIsqCOxtkfs2o0QG1CHDEIG8V ysMU4D5+y7glqPTLehTky41jcLHWWoNo59WL1zKBIuE15WYN0uYEPK6t74qQpL63oQFR 349ETzL6337AYugWVRNwgNWaXbfn6w2oSEmWwHqyAS9pXMQ7wr+kw/9klfhV09peVTd0 AcwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730145274; x=1730750074; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xEqSFdphUj/m4lVNP4wwRMew36LE0V9bUPR/s/JiXY0=; b=fsBaYR5oLBeSLS5ZAjGjS2B/HiauMrAO9bJarEhqoELLBE4ca5ElQx9NPca8hDodVf jLB+nc5tLszz//vMXQ4i2QCgwgl5xoEyGACXQJAKVU+noW1kxogmEbe90wkmmqjuBLWO mTnfk/Le8ft8eRmXZbIUsYeI2AcMFHCLqKfL1pH+zkzq8xyIL9JPmto/KRxNtT5B2ONC O9VbGb2EmKPrkca8B7U3sSsThguXRPG/lXdJByRonk4OZkXztKKdoAQPxlVN6o2mOJ07 jvLUPl7aGsvDiMkWeMillhFFBt6USabmVJze5ovM5duK5s6F/yptiDrF1+9V05wGIsSf 0nAg== X-Forwarded-Encrypted: i=1; AJvYcCU4xD414zyNoRPEbc12SXC62jPJl3tNJ7kFdyr/0TSGCfyLWKoaSOsYgXB13mEXT7/rumkir1+O5A==@kvack.org X-Gm-Message-State: AOJu0YyXWKj+XKiDDj25S4Teg4rZ3XvkvNt77NnHhq130RS7uK8ouvKX 4E8wxt3Uvc7jnqHtKkt034Ag3lxGBJKPD4dJsqCDhiMizrbNcdxAoIYYvhvekpEEG/X9sDcV1wl MINVz1AY9CYp+np1xWm9WQ/Wgmos= X-Google-Smtp-Source: AGHT+IE6nUCB0gz9ZT81xKQAodQPYCEtrgM8tH4oLOMLzbv9hVWzWlWjq9nnbsIhqCd39U4jbUlo2rcB8J5m7nf9CkE= X-Received: by 2002:a05:6102:dcf:b0:4a3:cb2b:9745 with SMTP id ada2fe7eead31-4a8cfd3abfbmr8429227137.22.1730145273747; Mon, 28 Oct 2024 12:54:33 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: <64f12abd-dde3-41a4-b694-cc42784217fb@gmail.com> From: Barry Song <21cnbao@gmail.com> Date: Tue, 29 Oct 2024 03:54:22 +0800 Message-ID: Subject: Re: [PATCH RFC] mm: count zeromap read and set for swapout and swapin To: Usama Arif 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 33B2910001C X-Stat-Signature: 9y613sfhcj6ws9o6unjoomh8mki6f7ss X-Rspam-User: X-HE-Tag: 1730145248-395310 X-HE-Meta: U2FsdGVkX19dpt9jOwB55K86nibIRrKZhHIPeCqzuXYI1Na1MT7oimAdA8MhvJGpmRFkkxkjiY0TDt3qGX5W2vCdltegQYk7dBsC0VXJ9626ucC17vgVdGUPJQ/mJLqHKhWqn/s779VQzWfm+yoSeCoYZ/XA3ckVxIR5TXsXdYy6hGDS+FCg1Tl8VVz20uOEVjA20ySWUeTWSh3UmcGLp0wnbcPHHlArGYbez6Ny6YhRXx4J5kexDEWrxST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+rsQsmq8An0lWFKVl15x6XBQsw006ECU9U5kKdFcFnu2/CvG00VxpkNvVkPEgLjIM/hkB5n+bw6VXcvNUZV9Jw49ruJ36970w9T4ZBxPYSI3/f9N2uwVDGvLKapfaCywIaBrnI= 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 Tue, Oct 29, 2024 at 1:20=E2=80=AFAM Usama Arif = wrote: > > > > On 28/10/2024 17:08, Yosry Ahmed wrote: > > On Mon, Oct 28, 2024 at 10:00=E2=80=AFAM Usama Arif wrote: > >> > >> > >> > >> On 28/10/2024 16:33, Nhat Pham wrote: > >>> On Mon, Oct 28, 2024 at 5:23=E2=80=AFAM Usama Arif wrote: > >>>> > >>>> I wonder if instead of having counters, it might be better to keep t= rack > >>>> of the number of zeropages currently stored in zeromap, similar to h= ow > >>>> zswap_same_filled_pages did it. It will be more complicated then thi= s > >>>> patch, but would give more insight of the current state of the syste= m. > >>>> > >>>> 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 ma= ybe > >> dont consume too much resources but I think we should still think abou= t > >> 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 ofcours= e 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 wast= eful > 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? Thanks Barry