Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2026162ybd; Sun, 23 Jun 2019 22:45:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqyuiK96MSPWNWeCiJyZOC7pd5Z2zhpnMrccqJIOmdfka47HpZXcfwQxhH4W6p68UWfGAblu X-Received: by 2002:a17:90a:8d86:: with SMTP id d6mr21674183pjo.127.1561355103056; Sun, 23 Jun 2019 22:45:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355103; cv=none; d=google.com; s=arc-20160816; b=wxhf/7Pzg0l8RpOH6Hc3d3Uv8afoM4zKsFXe/Z6gMI2EMLjpwcKQnvtCzUgg3dn7CS NCmgqgnHe6MpBB3XqcdPhMROOPgMQQ862aeckS64AJA0wP3oxpvhaCYF5z0wB1U12si/ EOGoVRJoyDAi5a1CoBfnOoEQEEaHde1btAU8+F6IG1mm8Qa4R8LOtaYVf1O2d7bHxBiH sd4gdLSABXIulZpyEGKa3P5K1eBmOkhZDkRDE0SYOCyiSPsfnBSwRl/lmBNa/58rX1Uj gqxtsQqp7u71snDpTcAWRgo9oViDbBKDb02nenMl9pa5vDrwBYwxE3lWwcLXg8yEd4+S qDhQ== 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=O2cgsn++49XRi6aE7UftxVDux3g2be02ob/0XO5leII=; b=psUYDUHV8lnMf/3kW4dG4lcdMNuq5T2X/UDvpK5TTYXBX8nakrja+AlMhdPcI3DMUX lj6az0FY2dL87ma9ri9WxJHjyTL2vgbxYEu2hi8C7JD9hhmhtKIN3+zeB/Yyvc97kZwx QnWMvJFSheHlwgXWTiPbdD+VAET1MO/rWIPoyRVJPnWbco2gaaYGgi2L+o5+YdAeWC0Q XdFohRWUxdKmFg7FPO4OQOSxsAoFcmVyp2jngf3LiMkzGM5EGz8CL/Rop/x2ICDb9RDV QN1frTa0vUCWZGHNPTFjRgP9pITDqrg8FVXx5xZjCYBo9dm5I2AJYEuItReCjB1/u5ZO DBCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZUFFpEiZ; 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 x8si9715521pfa.186.2019.06.23.22.44.47; Sun, 23 Jun 2019 22:45:03 -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=ZUFFpEiZ; 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 S1726781AbfFXFeO (ORCPT + 99 others); Mon, 24 Jun 2019 01:34:14 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:38740 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726304AbfFXFeN (ORCPT ); Mon, 24 Jun 2019 01:34:13 -0400 Received: by mail-io1-f65.google.com with SMTP id j6so621058ioa.5 for ; Sun, 23 Jun 2019 22:34:13 -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=O2cgsn++49XRi6aE7UftxVDux3g2be02ob/0XO5leII=; b=ZUFFpEiZaiVkP2DAtpPpJdLBcrNKA9cH3iGexIP4qVSiH3s6Ph/+nWoAXjtSgV9qiW S/MqeWZ9lJiuxTnnse2zwppjjSxvd3MZ5gaEkBq0Tx7sdpZTHNvhXGyGkbivSn5EM3sV PmjzgK+pPR5F9iFCIgp57SC3UeZnajMu3j+oSl9qBRl/CRWKRfBHD1/X7yZzlo+xRHiS NQfxE8K9kmG+aXIWTyCV5fT596GsAP1qtw0aA8yQxmRpz62O3/dGBaIaPU2UkltRgLps 9zHkuW3F1UTYS/SwcLCPFPZ0RyJSsAscHyqm7+EpI5MgrgH1QWjEaNtValTV8+BsywOp EO/Q== 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=O2cgsn++49XRi6aE7UftxVDux3g2be02ob/0XO5leII=; b=XxjPyvu9NAKMq4F59DmWBihi1goR4jtWDLOmtBFgkXDJXUb1PKw76rdzsaH7IRAhOG 5rjIH1CDqjN9DatU6r7wH65KGJJ4bQ8U0bjd1OJ1bGzP+2WpPqmFDLvr3rQiWzk9LeoA JVh1VBEKkk5iBkYkgaqr8Y02gMJ2iPHUXxpz2JB/J6wiA564MdSk7fp4IyK39K/ILrcp hemBGs3xVwbbjy8GBFZkjgwdX57ydJZoGsXTe+jqrcWzPYSeVMtguwdfoUoBUQ1EiCha B3Cfjh57a5NRODg2BIPTGuXntqhmz50L2kwsT/Ekw2APPKMRZDMri250D7WuvOboRQ3X Y3pw== X-Gm-Message-State: APjAAAWjJOYPMcE1/tWWgeG0nmCSWkYy+jXETd4By93Pb6a6ekwIJ89e 92f3MycwigMxxAe8GmCtTjWeV2573XVzhm8D/A== X-Received: by 2002:a02:a384:: with SMTP id y4mr124692536jak.77.1561354452881; Sun, 23 Jun 2019 22:34:12 -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: From: Pingfan Liu Date: Mon, 24 Jun 2019 13:34:01 +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 1:32 PM Pingfan Liu wrote: > > 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? > Oh, got it. It should be 1< Thanks, > Pingfan > [...]