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=-15.3 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 5911CC2B9F4 for ; Thu, 17 Jun 2021 12:21:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D874C60C3D for ; Thu, 17 Jun 2021 12:21:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D874C60C3D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 727736B0072; Thu, 17 Jun 2021 08:21:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6FFB46B0073; Thu, 17 Jun 2021 08:21:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 550006B0074; Thu, 17 Jun 2021 08:21:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0252.hostedemail.com [216.40.44.252]) by kanga.kvack.org (Postfix) with ESMTP id 228126B0072 for ; Thu, 17 Jun 2021 08:21:34 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A0470180AD806 for ; Thu, 17 Jun 2021 12:21:33 +0000 (UTC) X-FDA: 78263126466.27.802F52B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 2C181200109C for ; Thu, 17 Jun 2021 12:21:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623932492; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b+ZA+9M/AmhePxqH5FjdT2vnXD7QZ2wr0TxXhZ8hko8=; b=AlIedg+omGjJ9asRhZoRRT92Q1RrmwDFzcCws1gsXAFuqfVgwUGnzMt5m7QjFi6N66aa2z kLRX4VWWrYhZq/hIp5LilaOWKh2z7d+hzbyh2H7X7f8kBmXopyKobD75B4BfpCBb11WZbs qmOlXwV1Jgi5srnBzpnEap7TvgU+38s= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-201-opZJuihuOJ-R8lDax0X6Eg-1; Thu, 17 Jun 2021 08:21:31 -0400 X-MC-Unique: opZJuihuOJ-R8lDax0X6Eg-1 Received: by mail-wm1-f70.google.com with SMTP id y129-20020a1c32870000b029016920cc7087so528248wmy.4 for ; Thu, 17 Jun 2021 05:21:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:organization:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=b+ZA+9M/AmhePxqH5FjdT2vnXD7QZ2wr0TxXhZ8hko8=; b=oBlCIUOmaFFxZcZ3iHQYMhS2yVqnySkZVVR8Gp2g4jyQr+eYLhPeN1vMSg6vvAk+B8 LWVEzLLuzBrrjkQz6r/59te3iqtJxljRMlMr6VXPjevtC1IfKBzWlJ3gf4zCq2DZPt/p UHaOSdW//JMa+yz++pb174y7db85GYX+i5fmXM/AruwOlpDDMAvXGbproJad+NG958+W 6o2dRhIUDUT6D8sejA2tly/dHx1g021HD9RZRGgRRJtUuooOGNO98+NRc8b37MZd2ZKb olDs8vUKqzA5+DQmrTFu2VfaFP0orWen1IyAAKDd7OdA3NluvyCTGwiUX6Ho+pWrzK43 6a6Q== X-Gm-Message-State: AOAM5303Z+yF6SXI2NZ80naefAzhyRSwpwjPMFhNgS5/NlFlO93agl0Z uDg+u1f/Lh8IHXMtjPilWKzvyW2JFnJvE+97LFUXcYlyAJ4gnH912rwQrywo+UPv6VmJ7rS0XFC NjIT6HFslMBY= X-Received: by 2002:adf:a15c:: with SMTP id r28mr5365196wrr.224.1623932490280; Thu, 17 Jun 2021 05:21:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqJL0EYpqAbfb4wADtQH3JAlpChlOd/ZwGNouIltZHrNRyNdsXvH15xqHi5x3gbAiCG6Gwhw== X-Received: by 2002:adf:a15c:: with SMTP id r28mr5365166wrr.224.1623932490037; Thu, 17 Jun 2021 05:21:30 -0700 (PDT) Received: from [192.168.3.132] (p5b0c6170.dip0.t-ipconnect.de. [91.12.97.112]) by smtp.gmail.com with ESMTPSA id p23sm7828685wmi.26.2021.06.17.05.21.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Jun 2021 05:21:29 -0700 (PDT) To: Naoya Horiguchi , linux-mm@kvack.org Cc: Andrew Morton , Mel Gorman , Mike Kravetz , Oscar Salvador , Michal Hocko , Naoya Horiguchi , linux-kernel@vger.kernel.org References: <20210617092626.291006-1-nao.horiguchi@gmail.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH mmotm v1] mm/hwpoison: disable pcp for page_handle_poison() Message-ID: Date: Thu, 17 Jun 2021 14:21:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210617092626.291006-1-nao.horiguchi@gmail.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 2C181200109C X-Stat-Signature: ysasj89h7mweskmkgyinymonp87a5exn Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AlIedg+o; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf18.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=david@redhat.com X-HE-Tag: 1623932483-142181 Content-Transfer-Encoding: quoted-printable 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 17.06.21 11:26, Naoya Horiguchi wrote: > From: Naoya Horiguchi >=20 > Recent changes by patch "mm/page_alloc: allow high-order pages to be > stored on the per-cpu lists" makes kernels determine whether to use pcp > by pcp_allowed_order(), which breaks soft-offline for hugetlb pages. >=20 > Soft-offline dissolves a migration source page, then removes it from > buddy free list, so it's assumed that any subpage of the soft-offlined > hugepage are recognized as a buddy page just after returning from > dissolve_free_huge_page(). pcp_allowed_order() returns true for > hugetlb, so this assumption is no longer true. >=20 > So disable pcp during dissolve_free_huge_page() and > take_page_off_buddy() to prevent soft-offlined hugepages from linking t= o > pcp lists. Soft-offline should not be common events so the impact on > performance should be minimal. And I think that the optimization of > Mel's patch could benefit to hugetlb so zone_pcp_disable() is called > only in hwpoison context. >=20 > Signed-off-by: Naoya Horiguchi > --- > mm/memory-failure.c | 19 ++++++++++++++++--- > 1 file changed, 16 insertions(+), 3 deletions(-) >=20 > diff --git v5.13-rc6-mmotm-2021-06-15-20-24/mm/memory-failure.c v5.13-r= c6-mmotm-2021-06-15-20-24_patched/mm/memory-failure.c > index 1842822a10da..593079766655 100644 > --- v5.13-rc6-mmotm-2021-06-15-20-24/mm/memory-failure.c > +++ v5.13-rc6-mmotm-2021-06-15-20-24_patched/mm/memory-failure.c > @@ -66,6 +66,19 @@ int sysctl_memory_failure_recovery __read_mostly =3D= 1; > =20 > atomic_long_t num_poisoned_pages __read_mostly =3D ATOMIC_LONG_INIT(0= ); > =20 > +static bool __page_handle_poison(struct page *page) > +{ > + bool ret; > + > + zone_pcp_disable(page_zone(page)); > + ret =3D dissolve_free_huge_page(page); > + if (!ret) > + ret =3D take_page_off_buddy(page); > + zone_pcp_enable(page_zone(page)); > + > + return ret; > +} > + > static bool page_handle_poison(struct page *page, bool hugepage_or_fr= eepage, bool release) > { > if (hugepage_or_freepage) { > @@ -73,7 +86,7 @@ static bool page_handle_poison(struct page *page, boo= l hugepage_or_freepage, boo > * Doing this check for free pages is also fine since dissolve_free= _huge_page > * returns 0 for non-hugetlb pages as well. > */ > - if (dissolve_free_huge_page(page) || !take_page_off_buddy(page)) > + if (!__page_handle_poison(page)) > /* > * We could fail to take off the target page from buddy > * for example due to racy page allocation, but that's > @@ -986,7 +999,7 @@ static int me_huge_page(struct page *p, unsigned lo= ng pfn) > */ > if (PageAnon(hpage)) > put_page(hpage); > - if (!dissolve_free_huge_page(p) && take_page_off_buddy(p)) { > + if (__page_handle_poison(p)) { > page_ref_inc(p); > res =3D MF_RECOVERED; > } > @@ -1441,7 +1454,7 @@ static int memory_failure_hugetlb(unsigned long p= fn, int flags) > res =3D get_hwpoison_page(p, flags); > if (!res) { > res =3D MF_FAILED; > - if (!dissolve_free_huge_page(p) && take_page_off_buddy(p)) { > + if (__page_handle_poison(p)) { > page_ref_inc(p); > res =3D MF_RECOVERED; > } >=20 Just to make sure: all call paths are fine that we are taking a mutex,=20 right? I can see that get_hwpoison_page() already disables the PCP. LGTM --=20 Thanks, David / dhildenb