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 X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A4E8C5DF60 for ; Tue, 5 Nov 2019 20:49:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 17E82214B2 for ; Tue, 5 Nov 2019 20:49:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="RWQz/1XS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 17E82214B2 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B76FD6B0003; Tue, 5 Nov 2019 15:49:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B27116B0005; Tue, 5 Nov 2019 15:49:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A155D6B0006; Tue, 5 Nov 2019 15:49:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0097.hostedemail.com [216.40.44.97]) by kanga.kvack.org (Postfix) with ESMTP id 8C9AB6B0003 for ; Tue, 5 Nov 2019 15:49:35 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 4513F2C88 for ; Tue, 5 Nov 2019 20:49:35 +0000 (UTC) X-FDA: 76123414710.18.power87_8dd0b92e2e42c X-HE-Tag: power87_8dd0b92e2e42c X-Filterd-Recvd-Size: 5953 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Tue, 5 Nov 2019 20:49:34 +0000 (UTC) Received: by mail-pf1-f181.google.com with SMTP id q26so16757241pfn.11 for ; Tue, 05 Nov 2019 12:49:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=KsPPOu5WdPiTsGGCQaclAV8y/iVxTykdi4NOMNIjkwU=; b=RWQz/1XSGcXfcUb9/WwI+Jusy4+H2CsSGfSsSAw0Pv5nuBFvddhZFSGIz6yn1zMRJ3 eK56qHwi4RkssCYdwDH9XTqbA+Bt5etTcQ8brn7xExG585G6OreJhLypS9/uN1M6Smaq fxKeQZuRPDX8rbWNVW7xZaCXV29P7LSr0J6zFTfLXOTG1wmhenc90ZR1+PAgaXFOz+Gb 8mgpUPRg4UCTZRkIpI7+bD2pRbOniAAyKiaZLakRO8DdTi2pQWUEfHY6ZfhsA668FhZu DOI4SIYTcAtB8/XN4pbtLN3iFwzQ5/jRA21hhgD0i+DDhxOtHEGwgd54r1qvobDhTvi8 zxgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=KsPPOu5WdPiTsGGCQaclAV8y/iVxTykdi4NOMNIjkwU=; b=LRwDkwY0dF4ToUO8s54we5TM25tYSf9bSkVDpO38GWn23kRChBrSS2B3WuoJRmmR5D M54qpVWcWc3aPWR0t2tXWJUjMjTz/XqNiS27OBXDb5AjBDsPMuxF5tWRJoWhpvEcWECM eH721A3d0bkBsf4zRoAQ0JOu+YbuqCj4P7AuaX+/gxqOXU3WLB9bV3A7UrZJjJV3d1vx KKhBHFcU48M3WlWG6Mrt3EuLRoc3Xb7Ic3gwEZ4yTTLN4VNBQO/jt//htcEfHvvVo0uv Q2yXyYewGSCQ2ovt3VwSIHAnwMw0GV8yGZHlOugR2VsC8bE8OLluNvXHtHX7CehH3sLV 3khg== X-Gm-Message-State: APjAAAXgl4KcXEJvU7mEjDyyJVRgDZztRw4YIYWHmhSyThfuR9RLXZO6 l+ZjoFUs/d9MelEc6M6DWEi1pg== X-Google-Smtp-Source: APXvYqzyH3ewCTKPBaL+ZyRhVuaTk3SGtsQfAbtBwkqUMCwQMCn00jILvl7jynp3VhBBwZUwMX1lYQ== X-Received: by 2002:a63:734e:: with SMTP id d14mr38279086pgn.357.1572986972450; Tue, 05 Nov 2019 12:49:32 -0800 (PST) Received: from [100.112.92.218] ([104.133.9.106]) by smtp.gmail.com with ESMTPSA id 21sm21800305pgw.87.2019.11.05.12.49.31 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Nov 2019 12:49:31 -0800 (PST) Date: Tue, 5 Nov 2019 12:49:17 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Vlastimil Babka cc: Wei Yang , Matthew Wilcox , linux-mm@kvack.org, "Kirill A. Shutemov" , Hugh Dickins , Roman Gushchin , Minchan Kim , Kirill Tkhai Subject: Re: Why sometimes count vm event with page number, sometimes not? In-Reply-To: Message-ID: References: <20191105022643.GA14722@richard> <20191105033251.GB11823@bombadil.infradead.org> <20191105062809.GA15848@richard> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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: On Tue, 5 Nov 2019, Vlastimil Babka wrote: > On 11/5/19 7:28 AM, Wei Yang wrote: > > On Mon, Nov 04, 2019 at 07:32:51PM -0800, Matthew Wilcox wrote: > >> On Tue, Nov 05, 2019 at 10:26:44AM +0800, Wei Yang wrote: > >>> Hi, All, > >>> > >>> I am curious about the semantic of __count_vm_event[s]. > >>> > >>> For example, we count PGDEACTIVATE event in lru_deactivate_file_fn() and > >>> lru_deactivate_fn(). One of them count with number of page, the other not. > >>> > >>> Just curious about the exact value we want to count. > >> > >> I don't understand the question. We deactivate one page > >> in lru_deactivate_file_fn(). We deactivate several pages in > >> shrink_active_list(). PGDEACTIVATE counts the number of pages which > >> have been deactivated. > >> > >> Does that answer your question? > > > > Not yet. > > > > In function, lru_deactivate_fn(), __count_vm_events's second parameter is > > hpage_nr_pages(page). This is the number in size of "normal" page. Per my > > understanding, the page deactivated in lru_deactivate_file_fn() could be a > > hpage too. But it just count the deactivation once instead of > > hpage_nr_pages(). > > > > Or you want to say the page deactivated in lru_deactivate_file_fn() must be an > > order 0 page? > > I suspect that was true before THP on shmem, but now perhaps it's not > true anymore? CCing Kirill and Hugh. I think that you and Wei are right, that lru_deactivate_file_fn() ought nowadays to __count_vm_events(PGDEACTIVATE, hpage_nr_pages(page)) like lru_deactivate_fn() does. (Though I think the only way shmem gets there is through drop_caches - note the noop_backing_dev_info check in generic_fadvise(). invalidate_mapping_pages() on shmem is rarely more than a waste of time, since all but mapped readonly holes are undiscardably PageDirty. Internally we added a shmem_mapping() check to stop tests wasting time on expensive repeated drop_caches of shmem. And it's debatable whether drop_caches updating those vm_event stats is useful or the reverse.) Except that a couple of lines above I see __count_vm_event(PGROTATED): shouldn't that also use hpage_nr_pages? Then looking further through mm/swap.c, isn't there inconsistency throughout, whether a vm_event on a THP should be counted as 1 or hpage_nr_pages? I think originally the idea was that manipulating a THP should count as a single event, but now we have... a muddle. And what determines whether a memcg event is counted too? mm/vmscan.c chooses to count PGDEACTIVATE and other memcg events, mm/swap.c chooses not to count memcg events - unless it's PGLAZYFREE. I don't have answers. Hugh