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 ACB58C433F5 for ; Fri, 6 May 2022 17:26:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B8886B0072; Fri, 6 May 2022 13:26:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 166866B0073; Fri, 6 May 2022 13:26:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0557B6B0074; Fri, 6 May 2022 13:26:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id EB4946B0072 for ; Fri, 6 May 2022 13:26:53 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CA9CD1F46 for ; Fri, 6 May 2022 17:26:53 +0000 (UTC) X-FDA: 79435998306.10.29E6633 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf14.hostedemail.com (Postfix) with ESMTP id B4738100009 for ; Fri, 6 May 2022 17:26:51 +0000 (UTC) Received: by mail-pf1-f172.google.com with SMTP id g8so6787138pfh.5 for ; Fri, 06 May 2022 10:26:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=aXO2Fu3NYY2Zx0XhZoe0TjIS7+Cfdg9kovY5KSy5hGU=; b=Jsct77AV4aNMoEDTouuAejvb9DC0Lqc08vF3PXEFDLEn4G9G5QAcSND3nV7kYj0y8V kQqIzgkx/FSkrP9QLpAaRWVB6s9Bx8kB90MVcflmshxzCHve5T2vnT8d1e6BCRZq1Nnj nIQ3yvri5sDtSsAWhi225ccpdFGQOrR0xP6Jom52iZvlj5lopElIN+lv+8GapeEL0aU1 O90+Qipqa6OhRuDkspplkHvKHapgBiq9iuXcfDcDnaKfa2r8QPeblY+lt5i0+CjkJB+J LVvlr5SscphQYTF8WT7rKA0419llgllijB9wlKniR0/MOSJlDq4g63a3XIyMxgbobRtB ARKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aXO2Fu3NYY2Zx0XhZoe0TjIS7+Cfdg9kovY5KSy5hGU=; b=D7eCG2frq7JS2aOvK1vQsJjps3DHtLUn2QWCEixrfQVgVndlDKPf/Ays1vp0R341AM TN8WPRLuhp+2+R+qDG5/wZ+9KT+9yr70vpxffUntiw8PPkDaRooi4FaFImN8pDmsAiXF WiL9SzqI/IgAl4/xjmHUaH3LB/80K5PqNPHqTtvy3c6fPh9DjxhOlH3Q7fCz2Lsa8Pzd SnNqVhXPxyyiR3tyRDUzWWzlUg9AGlWCME9f8dvhDNLTM1CMYNfpgo4QXrpqdKqgGSec Bd42EdmNTfRHdpwpuKedceC0nJbgF79C1eJ4uCVJu7AHjEJoHnXxWw2yNuT50zQ2FWrc OjmA== X-Gm-Message-State: AOAM531eb8NA+SNeQGtd0KwPb1sPABLCs/FsdUi5FugTRLYsXB0N8esy cuiT+ULNsLYxM3oRZlj3Jn5OpWKZXK70K0B2mr0= X-Google-Smtp-Source: ABdhPJy9T+Jn+LwgZNf+UDCwbZTt5TwfLjXzxscGrs2j0Bm3boTDvKJCc0suHjazVzfLaPemEVPpAgHzERJDFjhY7sI= X-Received: by 2002:a65:6951:0:b0:381:f10:ccaa with SMTP id w17-20020a656951000000b003810f10ccaamr3465946pgq.587.1651858012366; Fri, 06 May 2022 10:26:52 -0700 (PDT) MIME-Version: 1.0 References: <165146746627.24404.2324091720943354711@noble.neil.brown.name> <165146932944.24404.17790836056748683378@noble.neil.brown.name> In-Reply-To: From: Yang Shi Date: Fri, 6 May 2022 10:26:40 -0700 Message-ID: Subject: Re: [PATCH] MM: handle THP in swap_*page_fs() - count_vm_events() To: Matthew Wilcox , Huang Ying Cc: NeilBrown , Miaohe Lin , Andrew Morton , Geert Uytterhoeven , Christoph Hellwig , linux-nfs@vger.kernel.org, Linux MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Jsct77AV; spf=pass (imf14.hostedemail.com: domain of shy828301@gmail.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: B4738100009 X-Stat-Signature: xwm8jsq58bf656zgtm4mjngsbc8wetmr X-HE-Tag: 1651858011-380222 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 Sun, May 1, 2022 at 10:32 PM Matthew Wilcox wrote: > > On Mon, May 02, 2022 at 03:28:49PM +1000, NeilBrown wrote: > > On Mon, 02 May 2022, Matthew Wilcox wrote: > > > On Mon, May 02, 2022 at 02:57:46PM +1000, NeilBrown wrote: > > > > @@ -390,9 +392,9 @@ static void sio_read_complete(struct kiocb *iocb, long ret) > > > > struct page *page = sio->bvec[p].bv_page; > > > > > > > > SetPageUptodate(page); > > > > + count_swpout_vm_event(page); > > > > unlock_page(page); > > > > } > > > > - count_vm_events(PSWPIN, sio->pages); > > > > > > Surely that should be count_swpIN_vm_event? > > > > > I'm not having a good day.... > > > > Certainly shouldn't be swpout. There isn't a count_swpin_vm_event(). > > > > swap_readpage() only counts once for each page no matter how big it is. > > While swap_writepage() counts one for each PAGE_SIZE written. > > > > And we have THP_SWPOUT but not THP_SWPIN > > _If_ I understand the swap-in patch correctly (at least as invoked by > shmem), it won't attempt to swap in an entire THP. Even if it swapped > out an order-9 page, it will bring in order-0 pages from swap, and then > rely on khugepaged to reassemble them. Totally correct. The try_to_unmap() called by vmscan would split PMD to PTEs then install swap entries for each PTE but keep the huge page unsplit. BTW, there were patches adding THP swapin support, but they were never merged. > > Someone who actually understands the swap code should check that my > explanation here is correct. >