Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp8548450pxu; Sun, 27 Dec 2020 10:19:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJyriljKxJT3EiiMefg14UuZZppUE15PFyM+QCuy3vRpzWsF17deQ3yOoOp2fqhqBPz2Tyu1 X-Received: by 2002:a17:906:b2da:: with SMTP id cf26mr39840478ejb.176.1609093147500; Sun, 27 Dec 2020 10:19:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609093147; cv=none; d=google.com; s=arc-20160816; b=GAAplCsCIs6BMuWBQ4x7Uy56Cf5mz5NgxieoIcQSzH+i2nGKusZBktzHww1diOMo+8 qX0TWPliG/R3tebiD4vnpvJuLKVO9nk4c73obbyw29idrpa7UtlFI4ZXmjFEn3y6kRMW 0CW1i8FWm/50GHVsf57Pbr1TfauM9WnqAhpZ5rYGUkxtvZjDfFLphtY5Tjqazql9TUQU PSb4YE2Wi/mduWfEMDHBm73EYwWBYCOQiGJD9FJvtDv6NG3eJ5zVmohn5G1JxTQr0OIv R8uaegh5kNMVc+piYduTJFi3Zwenht/ZYSmPUtpZYkOvQ9OJBTIhZC+76ot9ur6P9H7P 0eTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=bnArJigGBdabFnIq+hfnR+zQf4osesgW3QYyMon5IsY=; b=L6wRR5WrLzoHuurrTu5gx0BjIexX/9L3VnKHdslkZ7Tsq7fGvP9Wiqa0SFi0dL4bu3 klEh6zNWNtXq5MAZ7MrZyybSwuFd9y8p8lH724o/Q6A59gjhpOjHuyTSLIIAhxm3QKrc TjwFKOXeGAj8CTMb1l+0TralyDWXvHfPHI2Cl7iuuua4ZsccvXz7T0KUxq2Jh+cKZund YD7Qd2jl1XYt/VD7v/0VWe/0cQWcyIJN/X3dgr1+59Y0diqzLfrhz5zfL/KOx5dV0hsE p+cqzjK5VowUA5vt0CLEW2Whiy3B+MTQVkB1l54hlpusBfOGK/ktGE44NE8D7Zfii47e kdgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=v2G03nV+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t21si23949496edi.2.2020.12.27.10.18.45; Sun, 27 Dec 2020 10:19:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=v2G03nV+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726350AbgL0SR3 (ORCPT + 99 others); Sun, 27 Dec 2020 13:17:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726329AbgL0SR2 (ORCPT ); Sun, 27 Dec 2020 13:17:28 -0500 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E311C061796 for ; Sun, 27 Dec 2020 10:16:47 -0800 (PST) Received: by mail-lf1-x12f.google.com with SMTP id a12so19487763lfl.6 for ; Sun, 27 Dec 2020 10:16:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bnArJigGBdabFnIq+hfnR+zQf4osesgW3QYyMon5IsY=; b=v2G03nV+9gGBzxb5Ei6xCyhk+ThA79SlBStyTRawZsx+G7RliHUy1xcyejpJptiZBU yGDD7PKM2T9YXLbQW7nrtC5GOpsfUZ4d1pzWzGW8oKU421LZZ6drxDOdj/jdkVCfc/JM OzFy/key+ZtK/8CJ0MTeV4nuzBMcYxPB69traZy8+yV5mntyLFs+iiln39ZhOtLCzkhK RBhRCdIODMRuedFES95/c1byzajReyejDRWbmdEfw1V66l+gwg/k2DOrr36yv01RHECl 08PqLzrZekSImPDElEQ/2xvnUcr/CymVw48DApfx7C+urzHwkO4GRvYg5oT7mAkhjnOs h5zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bnArJigGBdabFnIq+hfnR+zQf4osesgW3QYyMon5IsY=; b=FYi+QNkzcWVVUPll3vaNnAepoLGQAcdt8U2svHsRhxZs1sauz/C1NvoMuQCfQMkNCC 4pXne7PdZMBnOQo9xdmWm/DqHp8xTDH8AzDR46ouALBP/z2rlSnpzUTnb88HnYp6ddkv u+2AxjkbMIZFP+G5LxsqllAHp77RS/5DEK9EL6UYP3Qdg89BQzVoxi/q7n3xXGPyQ4r9 2brn//WSD1bU7pK/kiwMqwtTSkaOhFkL8DdMrCBg1bxsB5cLFFps5JylzZ2DW7Hr8a31 //U+To6ygbEYpw+TLjaU1jT86aaUz6fqj5LM1ocErbsoLxDOoI1W2QnimwHNoW3ZugcW xwyA== X-Gm-Message-State: AOAM533xb8DtDNHi2eYdQMrm64oXJ2dZwPQNWtVW7077Pggigjxfvaau jZC8pKUqN0hbRuwWg2u0x32eKGScew7ywkoo1mEdXA== X-Received: by 2002:ac2:47e7:: with SMTP id b7mr16818656lfp.117.1609093005766; Sun, 27 Dec 2020 10:16:45 -0800 (PST) MIME-Version: 1.0 References: <20201227181310.3235210-1-shakeelb@google.com> <20201227181310.3235210-2-shakeelb@google.com> In-Reply-To: <20201227181310.3235210-2-shakeelb@google.com> From: Shakeel Butt Date: Sun, 27 Dec 2020 10:16:34 -0800 Message-ID: Subject: Re: [PATCH 2/2] mm: fix numa stats for thp migration To: Muchun Song , Naoya Horiguchi , Andrew Morton Cc: "Kirill A . Shutemov" , Johannes Weiner , Roman Gushchin , Cgroups , Linux MM , LKML , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Dec 27, 2020 at 10:14 AM Shakeel Butt wrote: > > Currently the kernel is not correctly updating the numa stats for > NR_FILE_PAGES and NR_SHMEM on THP migration. Fix that. For NR_FILE_DIRTY > and NR_ZONE_WRITE_PENDING, although at the moment there is no need to > handle THP migration as kernel still does not have write support for > file THP but to be more future proof, this patch adds the THP support > for those stats as well. > > Fixes: e71769ae52609 ("mm: enable thp migration for shmem thp") > Signed-off-by: Shakeel Butt > Cc: > --- > mm/migrate.c | 23 ++++++++++++----------- > 1 file changed, 12 insertions(+), 11 deletions(-) > > diff --git a/mm/migrate.c b/mm/migrate.c > index 613794f6a433..ade163c6ecdf 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -402,6 +402,7 @@ int migrate_page_move_mapping(struct address_space *mapping, > struct zone *oldzone, *newzone; > int dirty; > int expected_count = expected_page_refs(mapping, page) + extra_count; > + int nr = thp_nr_pages(page); > > if (!mapping) { > /* Anonymous page without mapping */ > @@ -437,7 +438,7 @@ int migrate_page_move_mapping(struct address_space *mapping, > */ > newpage->index = page->index; > newpage->mapping = page->mapping; > - page_ref_add(newpage, thp_nr_pages(page)); /* add cache reference */ > + page_ref_add(newpage, nr); /* add cache reference */ > if (PageSwapBacked(page)) { > __SetPageSwapBacked(newpage); > if (PageSwapCache(page)) { > @@ -459,7 +460,7 @@ int migrate_page_move_mapping(struct address_space *mapping, > if (PageTransHuge(page)) { > int i; > > - for (i = 1; i < HPAGE_PMD_NR; i++) { > + for (i = 1; i < nr; i++) { > xas_next(&xas); > xas_store(&xas, newpage); > } > @@ -470,7 +471,7 @@ int migrate_page_move_mapping(struct address_space *mapping, > * to one less reference. > * We know this isn't the last reference. > */ > - page_ref_unfreeze(page, expected_count - thp_nr_pages(page)); > + page_ref_unfreeze(page, expected_count - nr); > > xas_unlock(&xas); > /* Leave irq disabled to prevent preemption while updating stats */ > @@ -493,17 +494,17 @@ int migrate_page_move_mapping(struct address_space *mapping, > old_lruvec = mem_cgroup_lruvec(memcg, oldzone->zone_pgdat); > new_lruvec = mem_cgroup_lruvec(memcg, newzone->zone_pgdat); > > - __dec_lruvec_state(old_lruvec, NR_FILE_PAGES); > - __inc_lruvec_state(new_lruvec, NR_FILE_PAGES); > + __mod_lruvec_state(old_lruvec, NR_FILE_PAGES, -nr); > + __mod_lruvec_state(new_lruvec, NR_FILE_PAGES, nr); > if (PageSwapBacked(page) && !PageSwapCache(page)) { > - __dec_lruvec_state(old_lruvec, NR_SHMEM); > - __inc_lruvec_state(new_lruvec, NR_SHMEM); > + __mod_lruvec_state(old_lruvec, NR_SHMEM, -nr); > + __mod_lruvec_state(new_lruvec, NR_SHMEM, nr); > } > if (dirty && mapping_can_writeback(mapping)) { > - __dec_lruvec_state(old_lruvec, NR_FILE_DIRTY); > - __dec_zone_state(oldzone, NR_ZONE_WRITE_PENDING); > - __inc_lruvec_state(new_lruvec, NR_FILE_DIRTY); > - __inc_zone_state(newzone, NR_ZONE_WRITE_PENDING); > + __mod_lruvec_state(old_lruvec, NR_FILE_DIRTY, -nr); > + __mod_zone_page_tate(oldzone, NR_ZONE_WRITE_PENDING, -nr); This should be __mod_zone_page_state(). I fixed locally but sent the older patch by mistake. > + __mod_lruvec_state(new_lruvec, NR_FILE_DIRTY, nr); > + __mod_zone_page_state(newzone, NR_ZONE_WRITE_PENDING, nr); > } > } > local_irq_enable(); > -- > 2.29.2.729.g45daf8777d-goog >