Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1357696ybd; Wed, 26 Jun 2019 16:17:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyqITIUjdKkvsZ5UnbO4Xl1XWO6kx/s7wIf1LYtFV9zrsq1JeOFbXfXqtyc0LxpxoMEae9 X-Received: by 2002:a17:902:a414:: with SMTP id p20mr667800plq.187.1561591033190; Wed, 26 Jun 2019 16:17:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561591033; cv=none; d=google.com; s=arc-20160816; b=wJceXyORxbVZrhgbhGqfVtuvg1F5HGTnm67+HjpRfbe/3syT/qyqc7GUqhS347gatr GrAoEi/lcJQzW1NPwg0GOlgBq4lSESMzUJHZHbfnhONeFkFrqoZa4EOnskYf+eDWehTy mC7oMbHJ6/uZ1BUa9Yl1X+tZECuvnFWCbnjH7Z5XMh8/3JJERW24/2sHn+wlppZdBKRB dQB+ibsO3MFHigcRfhJgVmepzabGhd55EERYk6xvt4YNPgq721dtqz6KHx+XgPfyzpdp oBcpEmHN/BXaDwvk+jznl1Zln9UdA7bN39LCyTy5Skl+//e5z5FOQKuO624JHOXeU+Wb gEsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=GKskHS9ZrMmpTl7HXRgGF9dvlX1SkdCEtudhd+dfdKc=; b=tuKkC4uPsBhjTbvbYyPuVjxf2PgjzOLQbs89ZdSQKCv9NxWgYz7QvRKkqysKWd9amF Xl24XRv6vYBkU2ts6Hk0TuG8/Xb24zhM9R3CQZJlQ/hCwweg7jhTC9dHNXwfjHaJVhSY FVyz2uTFhGFTATyOh5l/GylyARyEpenEyQW/4tlboWfwqgLbFgPGRCy/ToCk24w4nL4X TmOFHnoi4Ug9iL2NIxGLrBuq5KazwkIr25Mu8I88lXwxwhwTGw3QOeZ4aMC6cuHAbdlx IQkd2EIi79d31pzwxt5fjHZfTV6tRX+sUGR/pYWfGoF81Bw3MVwk+GEo/ZKNMJ7FSe8G osEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uTJS3ibn; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t31si2532773pjb.25.2019.06.26.16.16.57; Wed, 26 Jun 2019 16:17:13 -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=@kernel.org header.s=default header.b=uTJS3ibn; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726518AbfFZXPj (ORCPT + 99 others); Wed, 26 Jun 2019 19:15:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:41198 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726480AbfFZXPj (ORCPT ); Wed, 26 Jun 2019 19:15:39 -0400 Received: from localhost.localdomain (c-73-223-200-170.hsd1.ca.comcast.net [73.223.200.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 54CF421738; Wed, 26 Jun 2019 23:15:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561590938; bh=0Jq+Gi01hm8xr98U/7QJrcZzZaNW00Tq+R6w9xmYElM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=uTJS3ibnxftVoPyYA/8YeyMEeGDcIszJf5JIXpLQcw3XJInC4JVGwHZV/uQlqMf+q kVzlgurXyK9w99/0YaZ4Z2EpTw90T7hdzuVlfHQS0VhWvnNeoAe5hv+YeENsvtfKlF gqqDW8oXyejimuteeE6l7sSE4DgKyE+XRRi0l/Oc= Date: Wed, 26 Jun 2019 16:15:37 -0700 From: Andrew Morton To: Pingfan Liu Cc: Linux-mm@kvack.org, Ira Weiny , 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: [PATCHv4] mm/gup: speed up check_and_migrate_cma_pages() on huge page Message-Id: <20190626161537.ae9fcca4f727c12b2a44b471@linux-foundation.org> In-Reply-To: <1561554600-5274-1-git-send-email-kernelfans@gmail.com> References: <1561554600-5274-1-git-send-email-kernelfans@gmail.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 26 Jun 2019 21:10:00 +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. > > ... > > --- 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)) I suspect this would work correctly if the PageCompound test was simply removed. Not that I'm really suggesting that it be removed - dunno. > + step = (1 << compound_order(head)) - (pages[i] - head); I don't understand this statement. Why does the position of this page in the pages[] array affect anything? There's an assumption about the contents of the skipped pages, I assume. Could we please get a comment in here whcih fully explains the logic and any assumptions?