From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8933C433E6 for ; Fri, 19 Feb 2021 11:17:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6AAEC64EC0 for ; Fri, 19 Feb 2021 11:17:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6AAEC64EC0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9F7CA8D001D; Fri, 19 Feb 2021 06:17:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A81E8D000A; Fri, 19 Feb 2021 06:17:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8BDE18D001D; Fri, 19 Feb 2021 06:17:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0246.hostedemail.com [216.40.44.246]) by kanga.kvack.org (Postfix) with ESMTP id 708948D000A for ; Fri, 19 Feb 2021 06:17:15 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 324211814ACBB for ; Fri, 19 Feb 2021 11:17:15 +0000 (UTC) X-FDA: 77834766030.22.BC2A524 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf30.hostedemail.com (Postfix) with ESMTP id B7BF3E0001B2 for ; Fri, 19 Feb 2021 11:17:14 +0000 (UTC) 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 7CDC7AC6E; Fri, 19 Feb 2021 11:17:13 +0000 (UTC) Date: Fri, 19 Feb 2021 12:17:11 +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: <20210219111703.GA20286@linux> References: <20210217100816.28860-2-osalvador@suse.de> <20210218100917.GA4842@localhost.localdomain> <20210218133250.GA7983@localhost.localdomain> <20210219090548.GA17266@linux> <20210219103943.GA19945@linux> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Stat-Signature: xakjiyasa7zyzgeeeok9a5ddxun6unio X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: B7BF3E0001B2 Received-SPF: none (suse.de>: No applicable sender policy available) receiver=imf30; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: none/none X-HE-Tag: 1613733434-216922 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Feb 19, 2021 at 11:55:00AM +0100, Michal Hocko wrote: > It is not the lock that I care about but more about counters. The > intention was that there is a single place to handle both enqueing and > dequeing. As not all places require counters to be updated. E.g. the > migration which just replaces one page by another. I see. alloc_fresh_huge_page->prep_new_huge_page increments h->nr_huge_pages{_node} counters. Which means: > new_page = alloc_fresh_huge_page(); > if (!new_page) > goto fail; > spin_lock(hugetlb_lock); > if (!PageHuge(old_page)) { > /* freed from under us, nothing to do */ > __update_and_free_page(new_page); Here we need update_and_free_page, otherwise we would be leaving a stale value in h->nr_huge_pages{_node}. > goto unlock; > } > list_del(&old_page->lru); > __update_and_free_page(old_page); Same here. > __enqueue_huge_page(new_page); This is ok since h->free_huge_pages{_node} do not need to be updated. -- Oscar Salvador SUSE L3