Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2657620pxb; Tue, 23 Feb 2021 12:10:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJxUA29Bk1AgkDCvhV99zMos24iTQQwfMQm/puWFS7+IKAi+JZOSDZhGTc1mBtb6OrU6TNNq X-Received: by 2002:a05:6402:229a:: with SMTP id cw26mr29472549edb.224.1614111029918; Tue, 23 Feb 2021 12:10:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614111029; cv=none; d=google.com; s=arc-20160816; b=obXAF51XTza6orIz2vQqr2gfpzA+Mt1bOPqFl1j0xAorkFU/A22CuoxMvn3XaXvBde CK0OSq37/rhNrhQ5N1Ra5WBAwPbLTBqHe5Yrika50qCf+eWtLm6oHOEssBSEob4pFdvT 0XrFBBkLRiK/wPJcW6i021LTFN9rXK3Fq+SNmcGGVFVUcK+nlt8ihuMLryi5SzLFPw2S 8bTSptsXvd1T2maaGemFSaMvWNASXyZ7Qv2pJ/WtfP23DcVIamwxD7vdYMolCeJ8Kw+c iYuehZneVSBtO/EkpY+R6nlU/fBYT3eyeI5tlhDPspBlk0Qabvk7w+sv6I3dSo/dgNzi wL+g== 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=2On6KxFug9L0PvNDBGHV1XEKttEH+Ni2ko2XFdiTXKk=; b=w8OyG28hvyF9hNlSDOKM0vSCYW8H3kFdnhfxDi7BgJBbXX0bvL3YGmaLxi5Bf7lubK 0oZOfkPq+ySyZmPREJ/1DdGpBuKlNF+IIcyyTLGjbrR256+kUoqFcmwTIpMoAiUcTVS6 UIA5MNEZzuLtz+nzfo5n3n3j9+hRUQjntehzbAk1LiqTyP1qrzDNlQSTONNkJZLKLlQO X8TV9DzvQSYUbLrE9JG5z9MDfiu8DdhSc3UZxXSfTP258Wh6qNqL5UAKC9c/ogyzvUQ3 ShEmt7yJMdIS7e7rUHllMQGpsrIccVDHwvicB6FokrFrH8NlkrjdTd592sM+jPb/t7SI g7yA== 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 i12si14108345ejr.344.2021.02.23.12.10.02; Tue, 23 Feb 2021 12:10:29 -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 S233268AbhBWPmS (ORCPT + 99 others); Tue, 23 Feb 2021 10:42:18 -0500 Received: from mx2.suse.de ([195.135.220.15]:35408 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233101AbhBWPmQ (ORCPT ); Tue, 23 Feb 2021 10:42:16 -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 A7C06AF5A; Tue, 23 Feb 2021 15:41:32 +0000 (UTC) Date: Tue, 23 Feb 2021 16:41:28 +0100 From: Oscar Salvador To: Muchun Song Cc: Mike Kravetz , Jonathan Corbet , Thomas Gleixner , mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, Peter Zijlstra , viro@zeniv.linux.org.uk, 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 , Michal Hocko , "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 Subject: Re: [External] Re: [PATCH v16 4/9] mm: hugetlb: alloc the vmemmap pages associated with each HugeTLB page Message-ID: <20210223154128.GA21082@localhost.localdomain> References: <20210219104954.67390-1-songmuchun@bytedance.com> <20210219104954.67390-5-songmuchun@bytedance.com> <13a5363c-6af4-1e1f-9a18-972ca18278b5@oracle.com> <20210223092740.GA1998@linux> <20210223104957.GA3844@linux> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210223104957.GA3844@linux> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 23, 2021 at 11:50:05AM +0100, Oscar Salvador wrote: > > CPU0: CPU1: > > set_compound_page_dtor(HUGETLB_PAGE_DTOR); > > memory_failure_hugetlb > > get_hwpoison_page > > __get_hwpoison_page > > get_page_unless_zero > > put_page_testzero() > > > > Maybe this can happen. But it is a very corner case. If we want to > > deal with this. We can put_page_testzero() first and then > > set_compound_page_dtor(HUGETLB_PAGE_DTOR). > > I have to check further, but it looks like this could actually happen. > Handling this with VM_BUG_ON is wrong, because memory_failure/soft_offline are > entitled to increase the refcount of the page. > > AFAICS, > > CPU0: CPU1: > set_compound_page_dtor(HUGETLB_PAGE_DTOR); > memory_failure_hugetlb > get_hwpoison_page > __get_hwpoison_page > get_page_unless_zero > put_page_testzero() > identify_page_state > me_huge_page > > I think we can reach me_huge_page with either refcount = 1 or refcount =2, > depending whether put_page_testzero has been issued. > > For now, I would not re-enqueue the page if put_page_testzero == false. > I have to see how this can be handled gracefully. I took a brief look. It is not really your patch fault. Hugetlb <-> memory-failure synchronization is a bit odd, it definitely needs improvment. The thing is, we can have different scenarios here. E.g: by the time we return from put_page_testzero, we might have refcount == 0 and PageHWPoison, or refcount == 1 PageHWPoison. The former will let a user get a page from the pool and get a sigbus when it faults in the page, and the latter will be even more odd as we will have a self-refcounted page in the free pool (and hwpoisoned). As I said, it is not this patchset fault. I just made me realize this problem. I have to think some more about this. -- Oscar Salvador SUSE L3