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=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 1818DC433DB for ; Thu, 11 Mar 2021 08:46:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 73ABD64FA9 for ; Thu, 11 Mar 2021 08:46:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73ABD64FA9 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D7D908D0293; Thu, 11 Mar 2021 03:46:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D2D118D028E; Thu, 11 Mar 2021 03:46:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA6E78D0293; Thu, 11 Mar 2021 03:46:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0146.hostedemail.com [216.40.44.146]) by kanga.kvack.org (Postfix) with ESMTP id 9E6EA8D028E for ; Thu, 11 Mar 2021 03:46:13 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 5CAFE4DCF for ; Thu, 11 Mar 2021 08:46:13 +0000 (UTC) X-FDA: 77906961426.09.52BC6E2 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf08.hostedemail.com (Postfix) with ESMTP id 82C8A8019141 for ; Thu, 11 Mar 2021 08:46:05 +0000 (UTC) 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=1615452371; 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=WufQ3n/kwHjfZtEAjPC6dKTzReIW3D11ZqXq64CI764=; b=NPZL6lossPXcyKWueKyjDu+enqVqiYJGJSYU6wRfI5nseEMa6INY3gr/s9kR5xnKCsZI/Y LxFsfDER3lI9iNKUuKGiJvtfBZDAvmidD5WBhiTFhmTuJ+IP+cE1P6iimwGLV7XK4WhEQe t9iu5Xy2dt09xbzS70zlQquMtYsSzwk= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2BB0CAB8C; Thu, 11 Mar 2021 08:46:11 +0000 (UTC) Date: Thu, 11 Mar 2021 09:46:10 +0100 From: Michal Hocko To: Muchun Song Cc: Jonathan Corbet , Mike Kravetz , Thomas Gleixner , Ingo Molnar , bp@alien8.de, x86@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, Peter Zijlstra , Alexander Viro , Andrew Morton , paulmck@kernel.org, mchehab+huawei@kernel.org, pawan.kumar.gupta@linux.intel.com, Randy Dunlap , oneukum@suse.com, anshuman.khandual@arm.com, jroedel@suse.de, Mina Almasry , David Rientjes , Matthew Wilcox , Oscar Salvador , "Song Bao Hua (Barry Song)" , David Hildenbrand , HORIGUCHI =?utf-8?B?TkFPWUEo5aCA5Y+jIOebtOS5nyk=?= , Joao Martins , Xiongchun duan , linux-doc@vger.kernel.org, LKML , Linux Memory Management List , linux-fsdevel , Chen Huang , Bodeddula Balasubramaniam Subject: Re: [External] Re: [PATCH v18 4/9] mm: hugetlb: alloc the vmemmap pages associated with each HugeTLB page Message-ID: References: <20210308102807.59745-1-songmuchun@bytedance.com> <20210308102807.59745-5-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: wh81wkgtontdn3mgwtugc79btzud5iim X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 82C8A8019141 Received-SPF: none (suse.com>: No applicable sender policy available) receiver=imf08; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615452365-757202 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 Thu 11-03-21 12:26:32, Muchun Song wrote: > On Wed, Mar 10, 2021 at 11:19 PM Michal Hocko wrote: > > > > On Mon 08-03-21 18:28:02, Muchun Song wrote: [...] > > > @@ -1771,8 +1813,12 @@ int dissolve_free_huge_page(struct page *page) > > > h->free_huge_pages--; > > > h->free_huge_pages_node[nid]--; > > > h->max_huge_pages--; > > > - update_and_free_page(h, head); > > > - rc = 0; > > > + rc = update_and_free_page(h, head); > > > + if (rc) { > > > + h->surplus_huge_pages--; > > > + h->surplus_huge_pages_node[nid]--; > > > + h->max_huge_pages++; > > > > This is quite ugly and confusing. update_and_free_page is careful to do > > the proper counters accounting and now you just override it partially. > > Why cannot we rely on update_and_free_page do the right thing? > > Dissolving path is special here. Since update_and_free_page failed, > the number of surplus pages was incremented. Surplus pages are > the number of pages greater than max_huge_pages. Since we are > incrementing max_huge_pages, we should decrement (undo) the > addition to surplus_huge_pages and surplus_huge_pages_node[nid]. Can we make dissolve_free_huge_page less special or tell update_and_free_page to not account against dissolve_free_huge_page? -- Michal Hocko SUSE Labs