Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7173433pxb; Thu, 18 Feb 2021 03:31:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+5GkzqRVDl3T6h699QTDXzCklUNHBqmPakja3RA9+nNGBDgdtbN5CVgTEzgVdO1Jomt3f X-Received: by 2002:a17:906:8472:: with SMTP id hx18mr3417563ejc.329.1613647875248; Thu, 18 Feb 2021 03:31:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613647875; cv=none; d=google.com; s=arc-20160816; b=HPi7W1hs12XA6oQAbQTgifQeScODXeandXD+njwD0tx6P7K/ZYR7UVB7BLk0R9djx/ gCbdHYkAoFaV55yZlS9eRaqOsgTTVpPyCfwZM2HVL4iWk7JndSFDaBbU8luryJZxCI0C fOeE+OnMEe90wEujxzLw6m78ezWDaGXVK5c0sn0gIQnU8AJay3M2XNubRAdBKjDavUSN ubHGgwclMgtGiQPgzcdua9ZuNQGVzyTyDMVKPyNPpp+qXIDLbljbufBGZUDBoAaoU+pU wJVuXrSA8FG9bXfszkHHZCKRbaBRE30TydK7jVebghfBKQ3kpP+ihl4mGZRsP5WsreF6 fznA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=uXhXhxmTctGjKN2W8jRWjK1q47DZ+OBtP7Xy08nJUqs=; b=pMjMwVs0CpS0MaZAJC1P/hd2H3keN5OYeIISDGByk+S3erca3lTR2SA5Ey5zsgjjgW Y9g9X0zKUA2cyiTUx4TmJ3EKKvhhSXmM2wOVK1SdALBF6n0pVu4ADzolWb9s6XTk/M8E KY/SzEuuBHNdfshk+hNIKsLqb5oBmPcEZTV/j3Ko+0MKPezUASRi/5Mp4AkzRRUmTTT0 5qX5Ql6OWj7wM43krOgat0lruP1j1RCGy8P7QGhxe97XIrTnZiyvQTa56vW/zDnyh1kR qG0E1w7eD3XSfsSoqWNh5BefOmCjKQCLSfU0hhalOM9o3Gm+uFAIv9l+7MbR/WCudkZT 1leg== ARC-Authentication-Results: i=1; mx.google.com; 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 y12si3447030edp.485.2021.02.18.03.30.50; Thu, 18 Feb 2021 03:31:15 -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; 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 S231248AbhBRLYy (ORCPT + 99 others); Thu, 18 Feb 2021 06:24:54 -0500 Received: from mx2.suse.de ([195.135.220.15]:43712 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232566AbhBRKKK (ORCPT ); Thu, 18 Feb 2021 05:10:10 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id A42DEADE5; Thu, 18 Feb 2021 10:09:20 +0000 (UTC) Date: Thu, 18 Feb 2021 11:09:17 +0100 From: Oscar Salvador To: Michal Hocko Cc: Andrew Morton , Mike Kravetz , David Hildenbrand , Muchun Song , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] mm: Make alloc_contig_range handle free hugetlb pages Message-ID: <20210218100917.GA4842@localhost.localdomain> References: <20210217100816.28860-1-osalvador@suse.de> <20210217100816.28860-2-osalvador@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 17, 2021 at 04:00:11PM +0100, Michal Hocko wrote: > Is this really necessary? dissolve_free_huge_page will take care of this > and the race windown you are covering is really tiny. Probably not, I was trying to shrink to race window as much as possible but the call to dissolve_free_huge_page might be enough. > > + nid = page_to_nid(page); > > + spin_unlock(&hugetlb_lock); > > + > > + /* > > + * Before dissolving the page, we need to allocate a new one, > > + * so the pool remains stable. > > + */ > > + new_page = alloc_fresh_huge_page(h, gfp_mask, nid, nmask, NULL); > > wrt. fallback to other zones, I haven't realized that the primary > usecase is a form of memory offlining (from virt-mem). I am not yet sure > what the proper behavior is in that case but if breaking hugetlb pools, > similar to the normal hotplug operation, is viable then this needs a > special mode. We do not want a random alloc_contig_range user to do the > same. So for starter I would go with __GFP_THISNODE here. Ok, makes sense. __GFP_THISNODE will not allow fallback to other node's zones. Since we only allow the nid the page belongs to, nodemask should be NULL, right? > > + if (!h) > > + /* > > + * The page might have been dissolved from under our feet. > > + * If that is the case, return success as if we dissolved it > > + * ourselves. > > + */ > > + return true; > > nit I would put the comment above the conditin for both cases. It reads > more easily that way. At least without { }. Yes, makes sense. > Other than that I haven't noticed any surprises. I did. The 'put_page' call should be placed above, right after getting the page. Otherwise, refcount == 1 and we will fail to dissolve the new page if we need to (in case old page fails to be dissolved). I already fixed that locally. -- Oscar Salvador SUSE L3