Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp864098pxf; Wed, 7 Apr 2021 13:36:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwe9PxU7u1ZNszStEd28SUjXtpdX2D3z3jOI033DmE9n89TGNph6fu/N01ibNFSIhRIqcu8 X-Received: by 2002:aa7:d2cc:: with SMTP id k12mr6357412edr.374.1617827778473; Wed, 07 Apr 2021 13:36:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617827778; cv=none; d=google.com; s=arc-20160816; b=B/qhKzm1JR+r6EPfAvpENH9LDMxCnGDcinxIP1n/vTa5qxpsQQKyqNbjercA4VNxZB 5FY6+LN5dDYcrkYweyJ2sfbLI1plh05rpd9FANfKmHbqTHO+oHnxVoFzn96kspPhColh rwHlczwjfOLe9ceXKAPvSsli1T5xcB3IxW23P/9mhT1c162vwnRrfl92chRnirWdQa5E TV4y/7oWFhCNHcYPYGA9SIOLOU4DCiMgmkGJU/ypiVZoELobbEhH+D8VWpAVRQFDLK1N 0hZQdoRZK8VnqoXYjrDlE8MnxLH7cERvMoZm3VVS9cntTd/HgFtTk3tTWVk5z1kD0Q1z 9qpw== 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:dkim-signature; bh=m3JZQ76Lk/bU7ik3mcWkmrq+4nBKvW17MCmmVyxB7lw=; b=acry3PTB9VRaY4U33Csy0EKtKqYZwGDtyk1opwbZnVC9Q4e8FHUVd6lPZ/NBRdZDWk nT6Ythg5J339NxTHKeYvLxubjFD65apl7FK5C8qIsJgpISlj04TPgYycQSIEeD6nLgr+ PbPc4OOn5S9fW3Q8sUADOmq/u55LigkVl4Nn0aJ0ijmD46UrwvDXZzhKVK90tXkafpEM xio3mIZfL6U6BGy+VfJtWPCYWg96fzxYxSIzj5dWKeX8EJNSQsGV8qOERIwtaFFcMvC2 UesYsih0Nmi/o++6JEEmcKTgzu6vHZvgHjnSphS3ZkoeRxfmL9zJuc3aTwBww0mC8SeM +qGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=FUYhfplp; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u4si43640edo.136.2021.04.07.13.35.55; Wed, 07 Apr 2021 13:36:18 -0700 (PDT) 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=@suse.com header.s=susede1 header.b=FUYhfplp; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348557AbhDGIWw (ORCPT + 99 others); Wed, 7 Apr 2021 04:22:52 -0400 Received: from mx2.suse.de ([195.135.220.15]:44822 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234059AbhDGIVv (ORCPT ); Wed, 7 Apr 2021 04:21:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1617783700; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=m3JZQ76Lk/bU7ik3mcWkmrq+4nBKvW17MCmmVyxB7lw=; b=FUYhfplpuretZ8z4Ls3TdJEHgyq3WTcTUH14CnOnGd38WZf7oMYTp2fMHEho8RhLwENHvS 1fKX2nNGb83WPGqtSfof+Xyl1vHsyoXpe5drYDEjrvrx6rJ/ZNZ+OXs4mI7/quAyWa0yBG hbzs0OXvyrV2ft2xA2zbXlji3bLfFVE= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 533BDB03B; Wed, 7 Apr 2021 08:21:40 +0000 (UTC) Date: Wed, 7 Apr 2021 10:21:37 +0200 From: Michal Hocko To: Mike Kravetz Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Roman Gushchin , Shakeel Butt , Oscar Salvador , David Hildenbrand , Muchun Song , David Rientjes , Miaohe Lin , Peter Zijlstra , Matthew Wilcox , HORIGUCHI NAOYA , "Aneesh Kumar K . V" , Waiman Long , Peter Xu , Mina Almasry , Hillf Danton , Joonsoo Kim , Barry Song , Will Deacon , Andrew Morton Subject: Re: [PATCH v4 4/8] hugetlb: create remove_hugetlb_page() to separate functionality Message-ID: References: <20210405230043.182734-1-mike.kravetz@oracle.com> <20210405230043.182734-5-mike.kravetz@oracle.com> 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 Tue 06-04-21 09:49:13, Mike Kravetz wrote: > On 4/6/21 2:56 AM, Michal Hocko wrote: > > On Mon 05-04-21 16:00:39, Mike Kravetz wrote: [...] > >> @@ -2298,6 +2312,7 @@ static int alloc_and_dissolve_huge_page(struct hstate *h, struct page *old_page, > >> /* > >> * Freed from under us. Drop new_page too. > >> */ > >> + remove_hugetlb_page(h, new_page, false); > >> update_and_free_page(h, new_page); > >> goto unlock; > >> } else if (page_count(old_page)) { > >> @@ -2305,6 +2320,7 @@ static int alloc_and_dissolve_huge_page(struct hstate *h, struct page *old_page, > >> * Someone has grabbed the page, try to isolate it here. > >> * Fail with -EBUSY if not possible. > >> */ > >> + remove_hugetlb_page(h, new_page, false); > >> update_and_free_page(h, new_page); > >> spin_unlock(&hugetlb_lock); > >> if (!isolate_huge_page(old_page, list)) > > > > the page is not enqued anywhere here so remove_hugetlb_page would blow > > when linked list debugging is enabled. > > I also thought this would be an issue. However, INIT_LIST_HEAD would > have been called for the page so, OK, this is true for a freshly allocated hugetlb page (prep_new_huge_page. It's a very sublte dependency though. In case somebody ever wants to fortify linked lists and decides to check list_del on an empty list then this would wait silently to blow up. > Going forward, I agree it would be better to perhaps add a list_empty > check so that things do not blow up if the debugging code is changed. Yes this is less tricky then a bool flag or making more stages of the tear down. 2 stages are more than enough IMHO. > At one time I also thought of splitting the functionality in > alloc_fresh_huge_page and prep_new_huge_page so that it would only > allocate/prep the page but not increment nr_huge_pages. We already have that distinction. alloc_buddy_huge_page is there to allocate a fresh huge page without any hstate accunting. Considering that giga pages are not supported for the migration anyway, maybe this would make Oscar's work slightly less tricky? -- Michal Hocko SUSE Labs