Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp284531pxy; Wed, 21 Apr 2021 02:59:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTSp6nS6QzLRH/baEuYVX9mjwBV4sN1or4YbxH9YFRHgKytqMnYcVEQ6QN0I+I5ErBQrto X-Received: by 2002:a05:6402:4245:: with SMTP id g5mr37721349edb.306.1618999172333; Wed, 21 Apr 2021 02:59:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618999172; cv=none; d=google.com; s=arc-20160816; b=u0b9mvQLkV9N4Y2mWTxDXkmPq1MfDXZysux/8uIXEXvypqv3w6acclL2GoQUUWGedk g+oWelcxakJZQ181sTU/YAlvQ8UklJ2NMqI41MPJ84KVDTg3KOTzH9xcxCoAtU0BUHu1 tb/azEvsq+dRLjN3eW7fyD0h+DTU+Ru+mH1uVuiw0/5Cnp7gIFEJdZCjaXlfUmDuvpDh ZZEKqYQqh/qKaQ8DVa/Qcpqizqk7LgAkg8dXYB8bYKQGg0gVz3c+1OtTdhu+le2iEoUN BoYVX516daIs14Mkec7w7RzVdp+gp6baOfNCKD0Ejr6ZAUYojCmmBiMKI9xD81SyEqLn L3pw== 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=qx4dGYz57xIKRcyBm8cNLa//VH6OP4QY62G9bSPSqbY=; b=llCo7bwy2QReQityTJ1fxF5uJQ1vBkw1WlwpkSydBnREJimq1vQIiMutTBimC06/JT MylQhm1nlLDOuAw+62F9k57roB/N+c4FEQfadOxddaLt5H97rfi3+BSYsRe0c4xrrB0N IdFqSYo01+o01RN2qMWB3biEfjlJR4GAMKwWj2pyU7o2kjqAVE63Vvv+zj3T8f28fFOL 70J8rjMCqCNnsa+XubkJRdM7v4Tr4QRWynQ3PlfO35gbgJZvlQt0f7Y+2d2pKO+Ei+qO vTvT5HRmRefY98inPxMchEFEWpN/gNtXcoOjNjBi1p2OXkE9plKj9ttNW9lmB4wm+lQN u9Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=vR1jIb+I; 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 dn3si1482351ejc.198.2021.04.21.02.59.09; Wed, 21 Apr 2021 02:59:32 -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=vR1jIb+I; 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 S236859AbhDUIoC (ORCPT + 99 others); Wed, 21 Apr 2021 04:44:02 -0400 Received: from mx2.suse.de ([195.135.220.15]:37094 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232194AbhDUIoB (ORCPT ); Wed, 21 Apr 2021 04:44:01 -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=1618994608; 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=qx4dGYz57xIKRcyBm8cNLa//VH6OP4QY62G9bSPSqbY=; b=vR1jIb+IgHGDVvD+K8RweleyuDGzDT/mMygFYy7nkeudoMFWAJVfU/v1E09OascrON5j3j Q3Wb53w8sKl5yVpWbnaVJZaCpEEyA6h00hpKvfXVnYxV5a++I10QGew/VTkFK7AVpqm+L0 357YNt97omyJtOgPqG4H7hMYOLn/zNk= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id DE8C8B151; Wed, 21 Apr 2021 08:43:27 +0000 (UTC) Date: Wed, 21 Apr 2021 10:43:26 +0200 From: Michal Hocko To: Oscar Salvador Cc: Muchun Song , 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: References: <20210421060259.67554-1-songmuchun@bytedance.com> <20210421082103.GE22456@linux> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210421082103.GE22456@linux> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 21-04-21 10:21:03, Oscar Salvador wrote: > 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. I have to say I have missed the HWPoison check so the this particular scenario is not possible indeed. > But it is true that we might need hugetlb lock, this needs some more > thought. yes, nobody should be touching to the reference count of hugetlb pool pages out of the hugetlb proper. > I will have a look. Thanks! -- Michal Hocko SUSE Labs