Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp4032624ybd; Tue, 25 Jun 2019 12:49:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9u8RROVfltetFn5MH34i7BL4APc5Hs1eZPUz3Ckl4bgpiEI3cFcW+VdoAfSI4BfsjdJA8 X-Received: by 2002:a17:902:820c:: with SMTP id x12mr469857pln.216.1561492146400; Tue, 25 Jun 2019 12:49:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561492146; cv=none; d=google.com; s=arc-20160816; b=hbxLFk70Z8sdZJWXY6dHrXUPKQN9kfena7ZE9G6nHDqcbzRKyK+sKLnBasHAzfqFDM QsGxlWx9RB0x+k/z1mEjrddwzfZEKkR8qg7zPAdT3AWQe3PAr5/OowYqXRqNz/bkdTHO ipnTCBdGG2tqL+oEwf41Gh7vTXxVMae0EAN3aI68w5bmxPSHhDCLVkYz5QY6RlIuBNOb 0qea5F0/5e91hrFQ5MSPn7mSndgJ/VRPoy/V72hIe8+ZyOYh/WLKxDfrTrnD4bnTQ8A8 ERFA2M5EF5cGmi4j4xPhZW2m1Vi8Ag9/9iz/MXRD5g40qfq6FRlLt0mJkcJrO++I9Ddo fO+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=kaLNaUo6tcJf7rplltT6xf4Vw8rz3i4+nICfl8MQX1E=; b=qTYUIaQtmqTcFCqxA4qBwL5fj+2PbJ1e2H+mfU6LG8oPDZPNuPzGO+XMK8SkPqehbg h0tVJTppjYKlRImC27/FjlNOZUVUrSfyCY3iUJIDkrSi3Q4WUPznDZUPl2h6z9zKuPKI vdMwPjRzTepHx8a2cB+OuWrFZ3N24XHoeXeU6eFjRZzjYiorg35m3RiyTFgrI4S1RoGW vaEVoZLJ1T9/Ofp+dNIdTXx1mDwXAsx98JRqu/pfc9k9FZOlCoL19wHtk2KDyZn6s5TX 6olUPvvK18eBjW9JgxGyaGBYC5ca7kWlxpB//WHkUvc/6jmRrawhCoaiCj4xD8cHfkIn yzqw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s12si14777225pfm.113.2019.06.25.12.48.50; Tue, 25 Jun 2019 12:49:06 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728942AbfFYRvr (ORCPT + 99 others); Tue, 25 Jun 2019 13:51:47 -0400 Received: from mga07.intel.com ([134.134.136.100]:7964 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726562AbfFYRvr (ORCPT ); Tue, 25 Jun 2019 13:51:47 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jun 2019 10:51:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,416,1557212400"; d="scan'208";a="313156218" Received: from iweiny-desk2.sc.intel.com ([10.3.52.157]) by orsmga004.jf.intel.com with ESMTP; 25 Jun 2019 10:51:44 -0700 Date: Tue, 25 Jun 2019 10:51:45 -0700 From: Ira Weiny To: Pingfan Liu 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 , Linux-kernel@vger.kernel.org Subject: Re: [PATCHv3] mm/gup: speed up check_and_migrate_cma_pages() on huge page Message-ID: <20190625175144.GA13219@iweiny-DESK2.sc.intel.com> References: <1561471999-6688-1-git-send-email-kernelfans@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1561471999-6688-1-git-send-email-kernelfans@gmail.com> User-Agent: Mutt/1.11.1 (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 25, 2019 at 10:13:19PM +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 > --- > v2 -> v3: fix page order to size convertion > > mm/gup.c | 19 ++++++++++++------- > 1 file changed, 12 insertions(+), 7 deletions(-) > > diff --git a/mm/gup.c b/mm/gup.c > index ddde097..03cc1f4 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 = 1 << compound_order(head) - (pages[i] - head); Check your precedence here. step = (1 << compound_order(head)) - (pages[i] - head); Ira > /* > * If we get a page from the CMA zone, since we are going to > * be pinning these entries, we might as well move them out > * of the CMA zone if possible. > */ > - if (is_migrate_cma_page(pages[i])) { > - > - struct page *head = compound_head(pages[i]); > - > - if (PageHuge(head)) { > + if (is_migrate_cma_page(head)) { > + if (PageHuge(head)) > isolate_huge_page(head, &cma_page_list); > - } else { > + else { > if (!PageLRU(head) && drain_allow) { > lru_add_drain_all(); > drain_allow = false; > @@ -1369,6 +1372,8 @@ static long check_and_migrate_cma_pages(struct task_struct *tsk, > } > } > } > + > + i += step; > } > > if (!list_empty(&cma_page_list)) { > -- > 2.7.5 >