Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp989462imu; Thu, 20 Dec 2018 08:22:28 -0800 (PST) X-Google-Smtp-Source: AFSGD/XxVoWjnSOihe/YtXbYf53VbDoB4L0dS+pSTouQAw2/03GN/Oak8a/qp3TSrUDs0jXdvewB X-Received: by 2002:a65:520a:: with SMTP id o10mr7403284pgp.276.1545322948194; Thu, 20 Dec 2018 08:22:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545322948; cv=none; d=google.com; s=arc-20160816; b=WzCXYmNaCPVb0obpUC7ojgmtvdMvgucsN760vmmG+gU9hZQkVKeb124b79XXaFCOSG QulKnXMn7iN61FIrJ+9EFzkPa2XjrJptmObmDOEagN9GElDn7ktnvVHoZxY/JirJ2Bwy WtORhWLivN6QdTrb+q2kxF2PXiT3y8xqmpJk76Wex97RDPKHwxUkchZD06pitpnOdh2j wgzghMlRNKJDRIBhLfl8sYVXTer5vrIU6qMU4pa86rD1d33Z4BgM90POzW3mjpH40pKc xPwpdSEckNbCzmeF2R3PyPxeh7Lc+isqkRCjWorZrAaoDPoiO6aEM7lfodYfh6q++9ZZ ndYg== 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=rzUpdN3OBLvtdCD5iTNiuiJGzbmHpJT6YUMdYvTBUZI=; b=X1UCFVPGU/kK84JFNK7HOL1hAxMBexDaFXwtYoTmoeTnZyuxkWyM+vbMhtVROsD4aO yrDyS3bP6WpH/MmoWVturkzx1F47Dinu34apsyyTgI1QBdLGq/wVCeUwtd1zAQRJTRBs Qs+KQZkGXRSifkHdwySTyQ/aUywF5qsBPmK21GqClfwXoKEEwszwg42wyo7ywoX3bZeo gqhWCwH6ihaej5zIqyqHVJOQ73q+JUI5SeZ3tv0LJL3/VR8wuBzR+12Jhf0RYdnSUn9f vdqPOapG2Fv9ivP/H0SaxBw0MgEjsxRCsW0DWv7OE6TnDg8+OqcPg8oTj5DKiR0QIFKy G6vQ== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k2si15689245pgh.63.2018.12.20.08.22.12; Thu, 20 Dec 2018 08:22:28 -0800 (PST) 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387676AbeLTOjn (ORCPT + 99 others); Thu, 20 Dec 2018 09:39:43 -0500 Received: from mx2.suse.de ([195.135.220.15]:49270 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731493AbeLTOjm (ORCPT ); Thu, 20 Dec 2018 09:39:42 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B5760AF0D; Thu, 20 Dec 2018 14:39:40 +0000 (UTC) Date: Thu, 20 Dec 2018 15:39:39 +0100 From: Michal Hocko To: Oscar Salvador Cc: Wei Yang , akpm@linux-foundation.org, vbabka@suse.cz, pavel.tatashin@microsoft.com, rppt@linux.vnet.ibm.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm, page_alloc: Fix has_unmovable_pages for HugePages Message-ID: <20181220143939.GA6210@dhcp22.suse.cz> References: <20181217225113.17864-1-osalvador@suse.de> <20181219142528.yx6ravdyzcqp5wtd@master> <20181219233914.2fxe26pih26ifvmt@d104.suse.de> <20181220091228.GB14234@dhcp22.suse.cz> <20181220124925.itwuuacgztpgsk7s@d104.suse.de> <20181220130606.GG9104@dhcp22.suse.cz> <20181220134132.6ynretwlndmyupml@d104.suse.de> <20181220142124.r34fnuv6b33luj5a@d104.suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181220142124.r34fnuv6b33luj5a@d104.suse.de> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 20-12-18 15:21:27, Oscar Salvador wrote: > On Thu, Dec 20, 2018 at 02:41:32PM +0100, Oscar Salvador wrote: > > On Thu, Dec 20, 2018 at 02:06:06PM +0100, Michal Hocko wrote: > > > You did want iter += skip_pages - 1 here right? > > > > Bleh, yeah. > > I am taking vacation today so my brain has left me hours ago, sorry. > > Should be: > > > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index 4812287e56a0..0634fbdef078 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -8094,7 +8094,7 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, > > goto unmovable; > > > > skip_pages = (1 << compound_order(head)) - (page - head); > > - iter = round_up(iter + 1, skip_pages) - 1; > > + iter += skip_pages - 1; > > continue; > > } > > On a second thought, I think it should not really matter. > > AFAICS, we can have these scenarios: > > 1) the head page is the first page in the pabeblock > 2) first page in the pageblock is not a head but part of a hugepage > 3) the head is somewhere within the pageblock > > For cases 1) and 3), iter will just get the right value and we will > break the loop afterwards. > > In case 2), iter will be set to a value to skip over the remaining pages. > > I am assuming that hugepages are allocated and packed together. > > Note that I am not against the change, but I just wanted to see if there is > something I am missing. Yes, you are missing that this code should be as sane as possible ;) You are right that we are only processing one pageorder worth of pfns and that the page order is bound to HUGETLB_PAGE_ORDER _right_now_. But there is absolutely zero reason to hardcode that assumption into a simple loop, right? -- Michal Hocko SUSE Labs