Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2026126ybd; Sun, 23 Jun 2019 22:44:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPXMuOfREpSvdlZ8NQX6QXBmsyPJDL+YbSRf095u2wLxtck/L4gS/Sz1MTdlu9hIjPeDRN X-Received: by 2002:a17:90a:9503:: with SMTP id t3mr22556652pjo.47.1561355099432; Sun, 23 Jun 2019 22:44:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355099; cv=none; d=google.com; s=arc-20160816; b=TNnyPknRViw3msdyCWd/JPhZ4qB4lxVUUaziyVNrbv1I2+qHV8OeyueSC/IhdoeeVq 1D1B83iWVbf5MwJC8Ixg5xz0d08MtVjgUZ5eap8GiakYeeH545GpU6/kwRei4dJV+9ng WBBmYwCsJVS9x/0k2Je3DdBWtnEO4ibsTNEfxbZxIXJ1T48zhNv0557m0Refpac7N+Sw M1nVkUaI9aqHd2ucwXOedww7WXG1n3me2OmOHG9Nd4IzdR2xus9ycTupqJeoxHO3kGqz lzUQJB7nCec+W0MOHUz8ehpMKlVZrl26NBm1azru2Tr4TBq4KBvCWg6q/c/5kkZgorhm v67w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=/l5qUlzkkXSn8Rj4gRqkwVlRMYz6YfXqXzcoaQu0DB4=; b=qmLbeI9Ct1KlCCbTgzUW+7wcaCqK7uQmhaOAy3Jbogqx8DzVG+XAWWuIEqSXYOXSWj dPOisPPrA7CCc1KaD33sMyYI/vUUIXzW34dyo0Di9MQ8lySpuWofAoZ8GA6FQ89ja5ay eq3EuyUGyZiHjU4/nK1S0F/tk3hgyGYD6f3f/3978NpUZ629RdIQYvA7tMDqmxtrFn6s MnNYHSpu3CZ7lGYmlD5IKZGHPMFun2zwVgfb7PvkresuYo2Gz1m/7o2mZV/5GBvYiuiZ kgqGDO4KeIkILd8xol41qP6I39DrFfD+VoONlOiDgT/GAquMPt8IlsqPOPx+B3oOty9d 8UaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Dkbiwb35; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id 24si9214896pgo.350.2019.06.23.22.44.44; Sun, 23 Jun 2019 22:44:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Dkbiwb35; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726663AbfFXFcq (ORCPT + 99 others); Mon, 24 Jun 2019 01:32:46 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:42873 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726469AbfFXFcq (ORCPT ); Mon, 24 Jun 2019 01:32:46 -0400 Received: by mail-io1-f65.google.com with SMTP id u19so273698ior.9 for ; Sun, 23 Jun 2019 22:32:46 -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=/l5qUlzkkXSn8Rj4gRqkwVlRMYz6YfXqXzcoaQu0DB4=; b=Dkbiwb35Z4XCd7jAlpAZCQu5U6vQ2IJMnfRSCFrBUb+0AD++dGclfZL2qAFUVugf9q cUnF8CJHMh2e1Y2kwP/3P+4vHjICpw5lRXFrR75FNpAOxz4UyV/NWmUBlx5OX663D6b3 FpjNyvXxm2+UK741ClSkR+a6xyMg/8mHcFOpRl4CDHUJnY0Pxz5Ywn7fT3+Hf6Nx991+ WCTtn8lQkJbVEqqQKZXc5VljE/9+bsxN4bJtL5w6NXn54UH/1XSi7bsSKrP9f3QBwPys SWb6/JhlZvRJd9GHNzdgugfJ782MbwIJulfvwNr471wDzJpW/sBRYyeAm07BCOosFi9P roJw== 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=/l5qUlzkkXSn8Rj4gRqkwVlRMYz6YfXqXzcoaQu0DB4=; b=OsTS4Zy8mIAbe99OGRrfZfJMgxao9NObbadVMg2xAUevr/TXTIXXUWgPDkDyRKgnlq iy+1XGDuPLqhvrQNdQuCdnmrQsDFjxjp8sLKc+XpOcaJ4f6OFUSV9SeCrWMgIomcTdjo YMLv9CEeCHOIeK/wH+fux2CbuT4fSW247/VTeHgb3gsVQ5DZWFAD/TED3Lt7lakqbFm3 bFJ3vjv2P4GqbgvZqMuycuaqNoZmgxXqq/3V0f+E/p0OMQqY1B8/itJjukssoND+P2nq aCGgsAL5v/eXhomABARgA11WRz2A7MF2bynXvoLjFKPQfahk4RWJut+ZEREA8J9mB8b/ 2ymw== X-Gm-Message-State: APjAAAVt54113m2FxGh7uJcaJF74YTZmFXHaKUE/sDHPMwVge6JJWNwh zzU2rn2sc3RI6scq8fpIHeyEumo/+iHiyLaVjg== X-Received: by 2002:a6b:6f06:: with SMTP id k6mr52432551ioc.32.1561354365683; Sun, 23 Jun 2019 22:32:45 -0700 (PDT) MIME-Version: 1.0 References: <1561349561-8302-1-git-send-email-kernelfans@gmail.com> <20190624044305.GA30102@iweiny-DESK2.sc.intel.com> In-Reply-To: <20190624044305.GA30102@iweiny-DESK2.sc.intel.com> From: Pingfan Liu Date: Mon, 24 Jun 2019 13:32:34 +0800 Message-ID: Subject: Re: [PATCHv2] mm/gup: speed up check_and_migrate_cma_pages() on huge page To: Ira Weiny Cc: Linux-mm@kvack.org, Andrew Morton , Mike Rapoport , "Kirill A. Shutemov" , Thomas Gleixner , John Hubbard , "Aneesh Kumar K.V" , Christoph Hellwig , Keith Busch , Mike Kravetz , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 24, 2019 at 12:43 PM Ira Weiny wrote: > > On Mon, Jun 24, 2019 at 12:12:41PM +0800, Pingfan Liu wrote: > > Both hugetlb and thp locate on the same migration type of pageblock, since > > they are allocated from a free_list[]. Based on this fact, it is enough to > > check on a single subpage to decide the migration type of the whole huge > > page. By this way, it saves (2M/4K - 1) times loop for pmd_huge on x86, > > similar on other archs. > > > > Furthermore, when executing isolate_huge_page(), it avoid taking global > > hugetlb_lock many times, and meanless remove/add to the local link list > > cma_page_list. > > > > Signed-off-by: Pingfan Liu > > Cc: Andrew Morton > > Cc: Ira Weiny > > Cc: Mike Rapoport > > Cc: "Kirill A. Shutemov" > > Cc: Thomas Gleixner > > Cc: John Hubbard > > Cc: "Aneesh Kumar K.V" > > Cc: Christoph Hellwig > > Cc: Keith Busch > > Cc: Mike Kravetz > > Cc: Linux-kernel@vger.kernel.org > > --- > > mm/gup.c | 19 ++++++++++++------- > > 1 file changed, 12 insertions(+), 7 deletions(-) > > > > diff --git a/mm/gup.c b/mm/gup.c > > index ddde097..544f5de 100644 > > --- a/mm/gup.c > > +++ b/mm/gup.c > > @@ -1342,19 +1342,22 @@ static long check_and_migrate_cma_pages(struct task_struct *tsk, > > LIST_HEAD(cma_page_list); > > > > check_again: > > - for (i = 0; i < nr_pages; i++) { > > + for (i = 0; i < nr_pages;) { > > + > > + struct page *head = compound_head(pages[i]); > > + long step = 1; > > + > > + if (PageCompound(head)) > > + step = compound_order(head) - (pages[i] - head); > > Sorry if I missed this last time. compound_order() is not correct here. For thp, prep_transhuge_page()->prep_compound_page()->set_compound_order(). For smaller hugetlb, prep_new_huge_page()->prep_compound_page()->set_compound_order(). For gigantic page, prep_compound_gigantic_page()->set_compound_order(). Do I miss anything? Thanks, Pingfan [...]