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 E482ED3E2C1 for ; Mon, 28 Oct 2024 19:59:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 639DA6B00A0; Mon, 28 Oct 2024 15:59:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E9776B00A1; Mon, 28 Oct 2024 15:59:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B0CE6B00A2; Mon, 28 Oct 2024 15:59:28 -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 2E3276B00A0 for ; Mon, 28 Oct 2024 15:59:28 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D3F49140DDB for ; Mon, 28 Oct 2024 19:59:27 +0000 (UTC) X-FDA: 82724075322.02.7A22980 Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) by imf11.hostedemail.com (Postfix) with ESMTP id 12FCE4001A for ; Mon, 28 Oct 2024 19:58:56 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=UwtrLW3f; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf11.hostedemail.com: domain of yosryahmed@google.com designates 209.85.219.49 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730145391; 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=bzK8bSJWPNgz0T4X+RKgoWG+FMl2NSfatdicRFAzrw0=; b=NQFPvAB2VHYiCFobR8Kcntj4OZwFsOs9UvtGtc4/RsZDkA3tNgs3v3e3TD6Cs+Q+Jt0s/Q wYRQAqawiGb2psbfZtpuqD3jPy0lamNHxqDPPrz3Fn8uszss3BzHk7ckhmYPr2Ivo9LtOX tlZUpABgTTd2VTgBz7FIQ/JMnHKS84I= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730145391; a=rsa-sha256; cv=none; b=Kk93NxvFozvG8qozzbhnABqecJ8w2rJIS9Rmnqn/7+c3mEBlcbDxPoCVQFg7y3zkUWB/nX tvmzSa9Fd1baDwy+wsqTc36FKqe5spYPv39rdrBosw8BU12yz0aU8fPa9dXmqW2n4zs52M EYW4SCHyv1ZmG2ip8s7DgpQ6gzfLwxA= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=UwtrLW3f; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf11.hostedemail.com: domain of yosryahmed@google.com designates 209.85.219.49 as permitted sender) smtp.mailfrom=yosryahmed@google.com Received: by mail-qv1-f49.google.com with SMTP id 6a1803df08f44-6cbd092f7f0so35095526d6.0 for ; Mon, 28 Oct 2024 12:59:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1730145565; x=1730750365; 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=bzK8bSJWPNgz0T4X+RKgoWG+FMl2NSfatdicRFAzrw0=; b=UwtrLW3f5TRdAMp0OXahK+h8MwGR98k+leaF0DkpjYPG2Vqlj/JxVOIto3rPALyU/q hHV/GlkvHnqZ7S7i/RDnwolzePfWawHcKl/Nwfufk9mlQWkl41vIRIqU+LP0uWMpspcC WPxE4zXiGHYEELQxS6GimFusLwehipIdITTKLxrK2cz+QAnJm5SeckRgUuA51x4R3F7y M7XBmKaJZnWmNHZZebyXpy4gdnP/0uah0pePvSyH3beHqO0Uhl6Oojh+g//2OjwwC823 hlFfgVTiWqTAnvA/LieqHakUUgKcpWPNhd+z/vZb76aJVu4af41a0OqJE/MUymU0Mdbx J3Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730145565; x=1730750365; 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=bzK8bSJWPNgz0T4X+RKgoWG+FMl2NSfatdicRFAzrw0=; b=pT9Tmzx1MBaj78PTG5orkE18jfPAEdq5oOEUYnQC1A2QFFtlWCPohxHfk1b9UP8q5R PKBsH90VabrB2mUVW4bXM2ybNdXXV7SJKScVlu9JLtePpbN7TYEqpQOdE/YdRmq7+ywZ zkMgvx5W4p37xHxNshDOMOVvvbEX29BfcB3Oz9hVYp0guV8SyEN2/FFFi7ZNiydW4qCv Ldeho+T43SuajzN/P+0fUn0wnHJHuUW61tqhsfXK6z4IPOJ4zxp4GARdIt50ZfSJM9/o ae5HJzktBQJlfzL6YEI0FAFI67HBfLs8G6Rlu29EJ6uKpCt985GhFRBz9HGSAEQwYGYO F21g== X-Forwarded-Encrypted: i=1; AJvYcCV5B23uvMO6QrdSwyVxyTadwPOH27JZfCMyv+9k59QmZbNu7noN/Q+UeyDPJAmaDU5PObmKXYaMVg==@kvack.org X-Gm-Message-State: AOJu0YyhPeXKAPzMQk9ytc/9Itkw7tY29pYdw3dCubQQq0pLtmGRFlH8 3GGsl71LqDT1PB4zF7fmgUHO1U+DBhWa7A1R6QM8bWv5Wa4IFc5fwJproEvI2r4EOwqEC511MpT jyZxQHka1M0IcvMKoNJC+HI97aNjFlM9UpAI3 X-Google-Smtp-Source: AGHT+IG88AsOvVV2ML4+CNKXrKvi7+ZeC2LKq1piSFh+j2GY6sy2X5YWIr3GwjtASAX89CsNlSbS5yb0Q3NcFrIMXT8= X-Received: by 2002:a05:6214:5705:b0:6cb:c994:160b with SMTP id 6a1803df08f44-6d18580d0edmr169199966d6.18.1730145564954; Mon, 28 Oct 2024 12:59:24 -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: From: Yosry Ahmed Date: Mon, 28 Oct 2024 12:58:47 -0700 Message-ID: Subject: Re: [PATCH RFC] mm: count zeromap read and set for swapout and swapin To: Barry Song <21cnbao@gmail.com> Cc: Usama Arif , 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: rspam07 X-Rspamd-Queue-Id: 12FCE4001A X-Stat-Signature: 1cqxodqrd85cyhqpgdpmmtg1e3cm5515 X-Rspam-User: X-HE-Tag: 1730145536-797850 X-HE-Meta: U2FsdGVkX1+VRF7w9+EkPURshRokPs3qdMPyY3CxMKQogGR62bUYUx+0Q0qvmN4qw5yhLx2IHEfZR/RCNvUcrczW5OOKbz8VuOw84+z+xOUWU5OLIU3itRSCGUG9f31OdhNkKY0qr+lx2e9brM5551UF5y0pEKaJ1fGOf5whFVi8AVUUnV51kw7fcKROO1ZfkSRHnu/Uf9HxVlibVcpInAGmp4Dc71s1QC6RKoxgrGvMeOS2aw8I6E/10eAFldlBZSMvqr/9NHYXsu3hKirtxipXy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, 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 Mon, Oct 28, 2024 at 12:54=E2=80=AFPM Barry Song <21cnbao@gmail.com> wro= te: > > 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= 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 t= his > > >>>> patch, but would give more insight of the current state of the sys= tem. > > >>>> > > >>>> 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 informatio= n, 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 ab= out > > >> 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 ofcou= rse 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 wa= steful > > 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? What about swap entries that get freed without being swapped in (e.g. swapped out anon memory freed, MADV_FREE, shmem truncate, etc)? > > Thanks > Barry