Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1536199imm; Thu, 19 Jul 2018 03:34:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpepyf8Ib0RaabzEVjObSAjsgGZ+OVwphdBj3+sQurO2IYpI2MYt3wszsNN/rVcqSuox/1Xq X-Received: by 2002:a63:5c10:: with SMTP id q16-v6mr9444364pgb.452.1531996477121; Thu, 19 Jul 2018 03:34:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531996477; cv=none; d=google.com; s=arc-20160816; b=jO36GRm6lSWUVA+IfU7kAfoAJNuXpn44mOFoffXvKEkgnmU2/taTFxaxsb+cq74k0m FFUHgHDxMRqmxI3x3qqxEOAUKz2wdgMlm0Bs0ohd5cYxex/7tHNwqKfYkA0/2ln+Em6y tVdFEhKnrjjO/ZMK+h83Mc/mGUC0elL6Kpf5NbW3D3XQlDgAbihaQUWMrbC/1XZqcVRl uy6rVleKIIFoP2/f2VUP6OM+H87n3JyWwuazFkE94aiZsGlabgij/GntCZuanu5EBy4v k4Zu4GhecNbIxYLqJeP8KgxhRtyFTmm82BOVL9+HnUNfXmHZ5Ix7cWJQuyr02L6xOD61 kZKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=oky8eBD6+sFhsL5dkx3cXj+kGlHA01YIv+DdE43fSwg=; b=gv6Z/oT2GYRNwRfWbEfQQlvxOihpa3mrQnVxmdTaJldZhCT3/lhMI45shMcjLUMm4T 2FO0DL8U24+CYrvv4M9mvWkRsYct49hNzrN1J7uyn0UboWECAUJ+88g4MUqViuhU1JXr 319+1HdSq5BgxLFqjry/p0TV0ppxw37mOb0rSypK7VyAX+JFHwC0gSHzgp6uM47S6Jy3 egFrguAm9whKwRe0GNJ+Ris9EAgxIEceKniDraFW86vBs3JRdSx7MSW2MidtxxDO9gJP Z2lNaiLnm8E+j+R95PP68mhFdwydpsUqkz5tlvxHPwi6zZs50kG2+V9jv0OV3dJfEBe3 nfrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x18-v6si5075584pfh.84.2018.07.19.03.33.59; Thu, 19 Jul 2018 03:34:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727512AbeGSLPC (ORCPT + 99 others); Thu, 19 Jul 2018 07:15:02 -0400 Received: from mx2.suse.de ([195.135.220.15]:50164 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727000AbeGSLPC (ORCPT ); Thu, 19 Jul 2018 07:15:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6B001AECE; Thu, 19 Jul 2018 10:32:31 +0000 (UTC) Date: Thu, 19 Jul 2018 12:32:29 +0200 From: Michal Hocko To: Naoya Horiguchi Cc: "linux-mm@kvack.org" , Andrew Morton , "xishi.qiuxishi@alibaba-inc.com" , "zy.zhengyi@alibaba-inc.com" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2 1/2] mm: fix race on soft-offlining free huge pages Message-ID: <20180719103229.GT7193@dhcp22.suse.cz> References: <1531805552-19547-1-git-send-email-n-horiguchi@ah.jp.nec.com> <1531805552-19547-2-git-send-email-n-horiguchi@ah.jp.nec.com> <20180717142743.GJ7193@dhcp22.suse.cz> <20180718005528.GA12184@hori1.linux.bs1.fc.nec.co.jp> <20180718085032.GS7193@dhcp22.suse.cz> <20180719061945.GB22154@hori1.linux.bs1.fc.nec.co.jp> <20180719071516.GK7193@dhcp22.suse.cz> <20180719080804.GA32756@hori1.linux.bs1.fc.nec.co.jp> <20180719082743.GN7193@dhcp22.suse.cz> <20180719092247.GB32756@hori1.linux.bs1.fc.nec.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180719092247.GB32756@hori1.linux.bs1.fc.nec.co.jp> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 19-07-18 09:22:47, Naoya Horiguchi wrote: > On Thu, Jul 19, 2018 at 10:27:43AM +0200, Michal Hocko wrote: > > On Thu 19-07-18 08:08:05, Naoya Horiguchi wrote: > > > On Thu, Jul 19, 2018 at 09:15:16AM +0200, Michal Hocko wrote: > > > > On Thu 19-07-18 06:19:45, Naoya Horiguchi wrote: > > > > > On Wed, Jul 18, 2018 at 10:50:32AM +0200, Michal Hocko wrote: > > [...] > > > > > > Why do we even need HWPoison flag here? Everything can be completely > > > > > > transparent to the application. It shouldn't fail from what I > > > > > > understood. > > > > > > > > > > PageHWPoison flag is used to the 'remove from the allocator' part > > > > > which is like below: > > > > > > > > > > static inline > > > > > struct page *rmqueue( > > > > > ... > > > > > do { > > > > > page = NULL; > > > > > if (alloc_flags & ALLOC_HARDER) { > > > > > page = __rmqueue_smallest(zone, order, MIGRATE_HIGHATOMIC); > > > > > if (page) > > > > > trace_mm_page_alloc_zone_locked(page, order, migratetype); > > > > > } > > > > > if (!page) > > > > > page = __rmqueue(zone, order, migratetype); > > > > > } while (page && check_new_pages(page, order)); > > > > > > > > > > check_new_pages() returns true if the page taken from free list has > > > > > a hwpoison page so that the allocator iterates another round to get > > > > > another page. > > > > > > > > > > There's no function that can be called from outside allocator to remove > > > > > a page in allocator. So actual page removal is done at allocation time, > > > > > not at error handling time. That's the reason why we need PageHWPoison. > > > > > > > > hwpoison is an internal mm functionality so why cannot we simply add a > > > > function that would do that? > > > > > > That's one possible solution. > > > > I would prefer that much more than add an overhead (albeit small) into > > the page allocator directly. HWPoison should be a really rare event so > > why should everybody pay the price? I would much rather see that the > > poison path pays the additional price. > > Yes, that's more maintainable. > > > > > > I know about another downside in current implementation. > > > If a hwpoison page is found during high order page allocation, > > > all 2^order pages (not only hwpoison page) are removed from > > > buddy because of the above quoted code. And these leaked pages > > > are never returned to freelist even with unpoison_memory(). > > > If we have a page removal function which properly splits high order > > > free pages into lower order pages, this problem is avoided. > > > > Even more reason to move to a new scheme. > > > > > OTOH PageHWPoison still has a role to report error to userspace. > > > Without it unpoison_memory() doesn't work. > > > > Sure but we do not really need a special page flag for that. We know the > > page is not reachable other than via pfn walkers. If you make the page > > reserved and note the fact it has been poisoned in the past then you can > > emulate the missing functionality. > > > > Btw. do we really need unpoisoning functionality? Who is really using > > it, other than some tests? > > None, as long as I know. Then why do we keep it? > > How does the memory become OK again? > > For hard-offlined in-use pages which are assumed to be pinned, > we clear the PageHWPoison flag and unpin the page to return it to buddy. > For other cases, we simply clear the PageHWPoison flag. > Unless the page is checked by check_new_pages() before unpoison, > the page is reusable. No I mean how does the memory becomes OK again. Is there any in place repair technique? > Sometimes error handling fails and the error page might turn into > unexpected state (like additional refcount/mapcount). > Unpoison just fails on such pages. > > > Don't we > > really need to go through physical hotremove & hotadd to clean the > > poison status? > > hotremove/hotadd can be a user of unpoison, but I think simply > reinitializing struct pages is easiler. Sure, that is what I meant actually. I do not really see any way to make the memory OK again other than to replace the faulty dimm and put it back online. The state is not really preserved for that so having a sticky struct page state doesn't make much sense. So from what I understood, we only need to track the poison state just allow to hotremove that memory and do not stumble over an unexpected page or try to do something with it. All other actions can be done synchronously (migrate vs. kill users). -- Michal Hocko SUSE Labs