Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp283028pxy; Wed, 21 Apr 2021 02:56:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWK0GlzzRk0lOoT0fqAYeTqv6dSljL5J3SI5j3hCqn3d4aDDMjJYm4SMI4/pHaji8LUd2D X-Received: by 2002:a17:906:1c98:: with SMTP id g24mr32438401ejh.457.1618998999787; Wed, 21 Apr 2021 02:56:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618998999; cv=none; d=google.com; s=arc-20160816; b=gqxmg/HKLa4Chn4q65HEu7m0jwoGVvS1gof1ofkji80rY2+v7+pdTIpNBeK+fnJESZ Vh/IdV6wCcJN6xgUrEckF0gRN4yTemEiENGAtoSj5KLBy0FWt/vx1oYPAoqF1TWFtZrB G5M6XjL3DVCG1fWB4tuS/iYHIrNVDoapnSI7K+/gWVGJ+GPTanicTWJ6Iv8kOVXsknCs reZxWiGJI58BekM5DcWyoFt0o/fu60y5BFKn+hGliqtdfMHftMiWXc7N8aSENLDXBfUM oBvXOlEZ9vdUGhcFQeqWHOU1hc1hrIb7S0HzLGnosv35363LTAocRH2pkHGPlXZrBKms wT2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=qAY2u0bfgwBYTeYATicJYS9xU5kKHhi6ta4A2XC6dFw=; b=cIIFGSaPb3V86GrDKjgDPOa32v9KKyXq6GEALYwRilKkqFakIegz+Vu5xuacxRbRQM 7mdyISVHn2qvdWRNE/4LsFEwL/7gzANWPFBoklovcZT3r+WxADFxoN7Yl/43qGOJaaQq LviOp8rGyBXl6se4OcsBARbXuTm6FFFAyjLMK8Uy8pcDBaunteeQ/s6G+byILNsTHDEk ZU1jBgK0O09FO1nB38aGQiFf4Gn8YD9CtUhiTMj5ste/o19jvLOa+HxeLaZlZjv0OW1r 7YkmCJN7uAzWgi/7LqN5EMnCaSE0UWos1+sy9SNOMSQwosdAW5y0xpPDst+dvKCm2Wxt WP3A== 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 d26si1337495ejt.459.2021.04.21.02.56.16; Wed, 21 Apr 2021 02:56:39 -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; 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 S234641AbhDUIVm (ORCPT + 99 others); Wed, 21 Apr 2021 04:21:42 -0400 Received: from mx2.suse.de ([195.135.220.15]:40784 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234573AbhDUIVl (ORCPT ); Wed, 21 Apr 2021 04:21:41 -0400 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 11AAAB176; Wed, 21 Apr 2021 08:21:07 +0000 (UTC) Date: Wed, 21 Apr 2021 10:21:03 +0200 From: Oscar Salvador To: Muchun Song Cc: Michal Hocko , Mike Kravetz , Andrew Morton , Linux Memory Management List , LKML , Naoya Horiguchi Subject: Re: [External] Re: [PATCH] mm: hugetlb: fix a race between memory-failure/soft_offline and gather_surplus_pages Message-ID: <20210421082103.GE22456@linux> References: <20210421060259.67554-1-songmuchun@bytedance.com> 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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 21, 2021 at 04:15:00PM +0800, Muchun Song wrote: > > The hwpoison side of this looks really suspicious to me. It shouldn't > > really touch the reference count of hugetlb pages without being very > > careful (and having hugetlb_lock held). What would happen if the > > reference count was increased after the page has been enqueed into the > > pool? This can just blow up later. > > If the page has been enqueued into the pool, then the page can be > allocated to other users. The page reference count will be reset to > 1 in the dequeue_huge_page_node_exact(). Then memory-failure > will free the page because of put_page(). This is wrong. Because > there is another user. Note that dequeue_huge_page_node_exact() will not hand over any pages which are poisoned, so in this case it will not be allocated. But it is true that we might need hugetlb lock, this needs some more thought. I will have a look. -- Oscar Salvador SUSE L3