Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp343256pxb; Wed, 3 Feb 2021 06:57:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+eJyKpqFrtuiRMGzFxIUo50/iYmC4Y2WGII9NE96mtnAAFLZ2pf+jkA1istE1szy/6SGH X-Received: by 2002:a50:d6c1:: with SMTP id l1mr3356784edj.336.1612364266729; Wed, 03 Feb 2021 06:57:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612364266; cv=none; d=google.com; s=arc-20160816; b=WLp8kOx9WKLnmrrsmiUQ7z/7Xc8UDs/MDZ7iwWC/oQJaOd2yrs4xK87MnKHqTOaATW SZvZ49Sx0mKrTqkPzkVfY6GPCmcCQ5Vavs0AjVkrgS/gO41VR8atDV+Vo/Txvqw5kvp4 RPcVlmwyDZa3I7YeNetmgBTU3DKZUag76EG1JYgrLR86Ly55v5sMO0x8dZlwkBI8/uUe KAm2G7vEVpwoqjsDCPHdvY8/L4bkP51DUDIB+DCcEkZxileGUi1pokaq7MvB/iNV6zNn WZrOOviZbIIBKyr5tFJyBIPgawukUowaTwtwt9qWOlF/PICzfdhwfCHJCUNtQEP/59cX XJQQ== 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=Ba8vo7NYBPo9eSD9iOWqZ0kAa5nRbWhxZY4okQVnGnw=; b=Vzlu3Xr7sq3EZ/wBIBypmgVMLqb35zpsHA7Kz07cZZ0myP2nF1DrbB+i48cUCkUxGC rSrQYMfPLlc/g+6LtWhkB+ctT1g09XUQVYJowRBpHabT8Od82I3v4gfUqfUczT1ZV8xK PB0Pt/nXkN0ppcsEoQSX2Ul/R5f9Zsi08whFFZlV/9nezw3xqWux+qNmYLekABIeAXBI Yag9hGizVACqwzMZC9F+AUG+RPh0rvuuhnGjdi1Ysyw5AMj9NIIxokONmE+tZpFlWpgk gPxQi27ZbdBzw4f9PnQwgvqgAILYniApfWkM11MohUOglO4oT7VqX+kR9Bt4UtGxgB6P p+Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=kabU4DJV; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y9si1259820edw.319.2021.02.03.06.57.21; Wed, 03 Feb 2021 06:57:46 -0800 (PST) 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=@soleen.com header.s=google header.b=kabU4DJV; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233055AbhBCOwy (ORCPT + 99 others); Wed, 3 Feb 2021 09:52:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232684AbhBCOwv (ORCPT ); Wed, 3 Feb 2021 09:52:51 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84673C0613ED for ; Wed, 3 Feb 2021 06:52:09 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id b9so16618550ejy.12 for ; Wed, 03 Feb 2021 06:52:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Ba8vo7NYBPo9eSD9iOWqZ0kAa5nRbWhxZY4okQVnGnw=; b=kabU4DJVcmFBq7Y/Y5iY/7dh3vcJdF72Bi6T33jpaCj1V26uxUKBXh1yOn5EA8wwlm /+xBYhOekNZRvBc1hobzHgb4+0FgkyDE+jt/TEMFdCRxDCAPoG+/L4TCs5MdVBOk1kgI yvHaN0O7w+ZJwAz1QB54rkyZLH2uyg+Qp5Fw0ZxIZc19NV/skkUUHB2fi7a6iEQGtx+h sO+l+EY5zNKxiTg9dV0wXzHynAABbrarCWdlBcYumPEZOgXBsUs8kPLaCROsqPa4dLs4 Tt1tki7Aetn+Rysl2ZK6MvVicNY0q72pvToY74ctM7GWm6X9w5xCVvSlPQ545FqVh69n /opA== 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=Ba8vo7NYBPo9eSD9iOWqZ0kAa5nRbWhxZY4okQVnGnw=; b=gIhl0P6pu7/GE8FJbavZI17CjJGt++mzz3RFqOs3vCPKqAY5E9Oq8930sV15qK4i73 Sxro7rwsJ7klwJ+diHUy0TdccYweMbs/V2NcmKW68ykbHr7AUPFzdFy+mGVLboFVa67O cbLZINVP47Rsjiehat3TvVZ/YpKkhn6k9rqJ5OERnP1ZvYnDo+/AlHYMi/Td3G5sXJdW wdg+HLxHLf54h05y65dxthZQ+4QGx10vuiyYp/4bRi/b3GL02lIapB+sH1nEjUejyjJ9 MwiOAjUR5BceDJ6PW0ynKIbS9CZo2zuuy3Qgb/owRHJr1wIZhC+R6KpOGwcvn7QgQobI gY7Q== X-Gm-Message-State: AOAM5328nUV6Ojy3uMdvfg51BU8L8Gm0KXIaXh0ixIKCATXCZyi0uffQ tGJ7FNfmaekz3FMwa9+ui4w+sK2I96D2WtzFtKZnRg== X-Received: by 2002:a17:906:eddd:: with SMTP id sb29mr3441623ejb.383.1612363928105; Wed, 03 Feb 2021 06:52:08 -0800 (PST) MIME-Version: 1.0 References: <20210125194751.1275316-1-pasha.tatashin@soleen.com> <20210125194751.1275316-3-pasha.tatashin@soleen.com> <05a66361-214c-2afe-22e4-12862ea1e4e2@oracle.com> In-Reply-To: <05a66361-214c-2afe-22e4-12862ea1e4e2@oracle.com> From: Pavel Tatashin Date: Wed, 3 Feb 2021 09:51:32 -0500 Message-ID: Subject: Re: [PATCH v8 02/14] mm/gup: check every subpage of a compound page during isolation To: Joao Martins Cc: Jason Gunthorpe , LKML , linux-mm , Andrew Morton , Vlastimil Babka , Michal Hocko , David Hildenbrand , Oscar Salvador , Dan Williams , Sasha Levin , Tyler Hicks , Joonsoo Kim , Mike Kravetz , Steven Rostedt , Ingo Molnar , Peter Zijlstra , Mel Gorman , Matthew Wilcox , David Rientjes , John Hubbard , Linux Doc Mailing List , Ira Weiny , linux-kselftest@vger.kernel.org, James Morris Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 3, 2021 at 8:23 AM Joao Martins wrote: > > On 1/25/21 7:47 PM, Pavel Tatashin wrote: > > When pages are isolated in check_and_migrate_movable_pages() we skip > > compound number of pages at a time. However, as Jason noted, it is > > not necessary correct that pages[i] corresponds to the pages that > > we skipped. This is because it is possible that the addresses in > > this range had split_huge_pmd()/split_huge_pud(), and these functions > > do not update the compound page metadata. > > > > The problem can be reproduced if something like this occurs: > > > > 1. User faulted huge pages. > > 2. split_huge_pmd() was called for some reason > > 3. User has unmapped some sub-pages in the range > > 4. User tries to longterm pin the addresses. > > > > The resulting pages[i] might end-up having pages which are not compound > > size page aligned. > > > > Fixes: aa712399c1e8 ("mm/gup: speed up check_and_migrate_cma_pages() on huge page") > > Reported-by: Jason Gunthorpe > > Signed-off-by: Pavel Tatashin > > Reviewed-by: Jason Gunthorpe > > --- > > [...] > > > /* > > * 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 > > @@ -1599,8 +1596,6 @@ static long check_and_migrate_cma_pages(struct mm_struct *mm, > > } > > } > > } > > - > > - i += step; > > } > > > Hi Joao, > With this, longterm gup will 'regress' for hugetlbfs e.g. from ~6k -> 32k usecs when > pinning a 16G hugetlb file. Estimate or you actually measured? > > Splitting can only occur on THP right? If so, perhaps we could retain the @step increment Yes, I do not think we can split HugePage, only THP. > for compound pages but when !is_transparent_hugepage(head) or just PageHuge(head) like: > > + if (!is_transparent_hugepage(head) && PageCompound(page)) > + i += (compound_nr(head) - (pages[i] - head)); > > Or making specific to hugetlbfs: > > + if (PageHuge(head)) > + i += (compound_nr(head) - (pages[i] - head)); Yes, this is reasonable optimization. I will submit a follow up patch against linux-next. Thank you, Pasha