Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3597654pxj; Mon, 7 Jun 2021 15:08:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKdyvmL3ylVYp1fxhKfLHa77WqPA45SFAnHq+Gw7CVIq8Su4ERsc4JBbqJ7O331BcvX6WQ X-Received: by 2002:a05:6402:3585:: with SMTP id y5mr22194609edc.121.1623103705910; Mon, 07 Jun 2021 15:08:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623103705; cv=none; d=google.com; s=arc-20160816; b=ebBb4yQbj+4VqCwBMaQVvSqta4VHrE8uEPYO4ohfatnrZNURPbcrxqxedYw/6jBlHY ad2f7XPMrpzA2vfIN9pYTUiFR7ncmK3hlKlzz0vOER5TQel7A2FZvTrrMGGtBF6e+hpx XOd+eHjDjJ6klzjTSm4L4FtWQt7bW6aXcVLX9dcD1X0xizfco5gd3dVQe9yzBU5wPEP0 6jNAg+Ifckr93SLIMr7hz9mmnpDqbG/zoo1oIOXGnEQ2517fNwTGu1112eqg/S+2eZTN Lu8gpcXfRh89IMXztECLg9vj/6cZtlftFgtcXxVtcY6JxVEp4bpV95uNbJpuMW1YqJ3r 6sDg== 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=zOe4rQFtxBwGRN1K+AKPaoefxAAn3spLFX1ByOSM/mo=; b=CAVmfz4DjW09L4obDtkarWe4iA+mC263KIumN7L0K1Ho7hN91CM44ph/5tD+ig4/ib xiKp3G4IG160+l3RU2PhmXOX39aVI15zGJc+cYxfsF4YnJR5zYrns8StXzcmgAjVJK9t Jd+T76Pm1XS+9IN0eHO4chUdUtZkC7yUQjzEy5W5ro2tSC6yIKHzWMI8tvZKTJnLLmVh Wc4BUUYKG43qI5JY0QlZOtR8S1NBXvoigFmyTRx4HoHWskp/CbRYoclF+t+e4giNlJyG YgrRaL9jaoTp7pr6gYYPIB4lDdMZseGDYSYqk89t/LdVjZ7ewsKEu+/aYHW11RInBUV3 mgXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=itxlC5cs; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j13si9272994edr.332.2021.06.07.15.08.02; Mon, 07 Jun 2021 15:08:25 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=itxlC5cs; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231184AbhFGWF5 (ORCPT + 99 others); Mon, 7 Jun 2021 18:05:57 -0400 Received: from mail-ed1-f49.google.com ([209.85.208.49]:45801 "EHLO mail-ed1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230359AbhFGWFz (ORCPT ); Mon, 7 Jun 2021 18:05:55 -0400 Received: by mail-ed1-f49.google.com with SMTP id r7so7794185edv.12 for ; Mon, 07 Jun 2021 15:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zOe4rQFtxBwGRN1K+AKPaoefxAAn3spLFX1ByOSM/mo=; b=itxlC5css5jLtTv9vn/LKgdTnt3i7NlF7vkViO9R2VSHBPx/qO5ad3w5XDOvR7Yhcq c7tzrMxpd0a9Xv6z0XTJonyS9y6OLDoocibZ8SZin3Q+x3CRqJKd/aOG+aRxXzKEKWdm TzP1Ly/35YzQrgXu5p/VfVetTEsYA++PSeF4K4e4fQG1vIzXGZseUgUT9BhAvJtgAAin /0yRw1WVQgtOI2Sqfu2pOgkTjLPmLvpjd5/32CpOW9s4kyPNUyPqd/BaG7A8qJ6jTSvL cN6PZk9rmCg/OjVoQhNQJi46gOiSIA+HUeotHA6mr0JT2/euSqavkM3G1Wh1d1EVyIEg atAA== 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=zOe4rQFtxBwGRN1K+AKPaoefxAAn3spLFX1ByOSM/mo=; b=sIY2wlxhnXJKUIKreNKCaIGpGlh85bgKZlB5uORoBRjZ1zBD5Gr2l60Atqpyqc6RGP pGGqyL05fZp/awe0oAK6HeVMXd1UPXoeXcOWuIBhrkK0tqErFUqofEISHUtNTrGCvVRr jbyXqkwBaJVS9PUjdbkufXRZhD9MuS6ScwBLX1zuGJ0TetdKMANNsEBjfkama3mwTNVy SHsQ2jnArO2W2rreRYklKN+8MHa8qKo0a9aIcUWUxRGyl/B2YN6yjFtptEIF4LlIuZmB Udsv9L9hpAfg3WEAXmhf4hG2z0mhtCs1N1NgDVofkAxtYDbDP8DEc3cd0108+iCGH6rL 19vA== X-Gm-Message-State: AOAM531kqUA4eNjdKSjsNLSUPSiU5IOmg87aUKaV3oWu3EZn1WcCmLCJ D/3wJ0NUlXp35UqlI2h0QwCjIXLZXqzJQ6wyig+cR5BMmatssQ== X-Received: by 2002:aa7:cf0f:: with SMTP id a15mr19806266edy.313.1623103371320; Mon, 07 Jun 2021 15:02:51 -0700 (PDT) MIME-Version: 1.0 References: <20210604203513.240709-1-shy828301@gmail.com> In-Reply-To: From: Yang Shi Date: Mon, 7 Jun 2021 15:02:39 -0700 Message-ID: Subject: Re: [PATCH] mm: mempolicy: don't have to split pmd for huge zero page To: Michal Hocko Cc: Zi Yan , nao.horiguchi@gmail.com, "Kirill A. Shutemov" , Hugh Dickins , Andrew Morton , Linux MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 7, 2021 at 11:55 AM Michal Hocko wrote: > > On Mon 07-06-21 10:00:01, Yang Shi wrote: > > On Sun, Jun 6, 2021 at 11:21 PM Michal Hocko wrote: > > > > > > On Fri 04-06-21 13:35:13, Yang Shi wrote: > > > > When trying to migrate pages to obey mempolicy, the huge zero page is > > > > split then the page table walk at PTE level just skips zero page. So it > > > > seems pointless to split huge zero page, it could be just skipped like > > > > base zero page. > > > > > > My THP knowledge is not the best but this is incorrect AIACS. Huge zero > > > page is not split. We do split the pmd which is mapping the said page. I > > > suspect you refer to vm_normal_page when talking about a zero page but > > > please be aware that huge zero page is not a normal zero page. It is > > > allocated dynamically (see get_huge_zero_page). > > > > For a normal huge page, yes, split_huge_pmd() just splits pmd. But > > actually the base zero pfn will be inserted to PTEs when splitting > > huge zero pmd. Please check __split_huge_zero_page_pmd() out. > > My bad. I didn't have a look all the way down there. The naming > suggested that this is purely page table operations and I have suspected > that ptes just point to the offset of the THP. > > But I am obviously wrong here. Sorry about that. > > > I should make this point clearer in the commit log. Sorry for the confusion. > > > > > > > > So in the end you patch disables mbind of zero pages to a target node > > > and that is a regression. > > > > Do we really migrate zero page? IIUC zero page is just skipped by > > vm_normal_page() check in queue_pages_pte_range(), isn't it? > > Yeah, normal zero pages are skipped indeed. I haven't studied why this > is the case yet. It surely sounds a bit suspicious because this is an > explicit request to migrate memory and if the zero page is misplaced it > should be moved. On the hand this would increase RSS so maybe this is > the point. The zero page is a global shared page, I don't think "misplace" applies to it. It doesn't make too much sense to migrate a shared page. Actually there is page mapcount check in migrate_page_add() to skip shared normal pages as well. > > > > Have you tested the patch? > > > > No, just build test. I thought this change was straightforward. > > > > > > > > > Set ACTION_CONTINUE to prevent the walk_page_range() split the pmd for > > > > this case. > > > > > > Btw. this changelog is missing a problem statement. I suspect there is > > > no actual problem that it should fix and it is likely driven by reading > > > the code. Right? > > > > The actual problem is it is pointless to split a huge zero pmd. Yes, > > it is driven by visual inspection. > > Is there any actual workload that cares? This is quite a subtle area so > I would be careful to do changes just because... I'm not sure whether there is measurable improvement for actual workloads, but I believe this change does eliminate some unnecessary work. I think the test shown in the previous email gives us some confidence that the change doesn't have regression. > -- > Michal Hocko > SUSE Labs