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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EDF5C433EF for ; Thu, 21 Apr 2022 14:20:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 32C7A6B0072; Thu, 21 Apr 2022 10:20:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DC046B0073; Thu, 21 Apr 2022 10:20:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A4266B0074; Thu, 21 Apr 2022 10:20:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 098386B0072 for ; Thu, 21 Apr 2022 10:20:20 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B6CA12745C for ; Thu, 21 Apr 2022 14:20:19 +0000 (UTC) X-FDA: 79381096158.30.EED1374 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 46A5C4002C for ; Thu, 21 Apr 2022 14:20:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650550818; 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=cgfeAm2iEB905RN1m/pwZv+PSShsBs0z05aWSrdVjJo=; b=XXGhuPwgEKb0vfRkFcHc9pysB7r8mfDnb4IrSyAt703aP94J4/eVa+RVEmOzDxeozzXwEL L50jMse/4f9+MArm/zD1oOvzoMu5Bris0g0wTH9zZzsqMHu6IgZoUbBqj4Wj4/ayOxzF3X h9Slcmx1KndImdZjuIwAA5r/GzDx4ps= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-570-N-VSa5vfNQyuA4-aIGUzoQ-1; Thu, 21 Apr 2022 10:20:17 -0400 X-MC-Unique: N-VSa5vfNQyuA4-aIGUzoQ-1 Received: by mail-wr1-f69.google.com with SMTP id 61-20020adf80c3000000b00207a6ffdd1eso1186793wrl.14 for ; Thu, 21 Apr 2022 07:20:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:references:from:organization:subject :in-reply-to:content-transfer-encoding; bh=cgfeAm2iEB905RN1m/pwZv+PSShsBs0z05aWSrdVjJo=; b=t0LStAppvAoZ8twx7ikcLB+GXWBOKyDjAS0TQiYep+Hj0K4a4cibCyDOVLLtUs4653 zt2uv5YjRXWdMAuPHlhNSz9Wxp+FUfCsP38WVTrKBtWjfNbpeD9v1WRqhzdBmIjsy5yr RP4X5qNrCUUD/o2JPxIl/fyahHT3Adbnr9aT3vKODa865EudQ9q+BPszYYctDbFny39j h2DqPI6odYdKi3liWMNEpG3+HoH5x0A3MWxUp3CnGGhGYfywtxQ9qAZFgxwuRObVI+sr TmPNEUx57nIB+J1kt1fp3dE4z4brniz0FlROoaqNhk4y7kYuzFzoynnSS6C/lRPv4lvE p58g== X-Gm-Message-State: AOAM530NRHRMy15j0qrOxuI3eGcm/CqgEWr0KysXyCAcUfQE+3UGiVLd B1RMZjliMYERPRutTBcpdra8RsOGjp3JTdena3E+NVKOGp5pipCDsuuX8sMlXFWAz3VS9msdb7A O9dEPhGbyK/s= X-Received: by 2002:a05:6000:1a86:b0:20a:a933:ba16 with SMTP id f6-20020a0560001a8600b0020aa933ba16mr9480789wry.583.1650550816040; Thu, 21 Apr 2022 07:20:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRRbpKnJ9/eE6gsD+4QxEmdPqcDEaUEUINsFTdWmYyAgvU0MGDBkJJuVh1969nuIV7H33eeA== X-Received: by 2002:a05:6000:1a86:b0:20a:a933:ba16 with SMTP id f6-20020a0560001a8600b0020aa933ba16mr9480767wry.583.1650550815692; Thu, 21 Apr 2022 07:20:15 -0700 (PDT) Received: from ?IPV6:2003:cb:c702:de00:711b:76af:b335:9b70? (p200300cbc702de00711b76afb3359b70.dip0.t-ipconnect.de. [2003:cb:c702:de00:711b:76af:b335:9b70]) by smtp.gmail.com with ESMTPSA id d11-20020adfa34b000000b0020ab3201c50sm2395559wrb.17.2022.04.21.07.20.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Apr 2022 07:20:15 -0700 (PDT) Message-ID: <8fae51af-b12f-4232-1330-54f7b0943907@redhat.com> Date: Thu, 21 Apr 2022 16:20:13 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 To: Miaohe Lin , akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador , Mike Kravetz , Naoya Horiguchi References: <20220421135129.19767-1-linmiaohe@huawei.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH] mm/memory_hotplug: avoid consuming corrupted data when offline pages In-Reply-To: <20220421135129.19767-1-linmiaohe@huawei.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 46A5C4002C X-Stat-Signature: 1843obnf83wtf6b9qq5ppgq84mnj866c Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XXGhuPwg; spf=none (imf11.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1650550817-456915 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000060, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 21.04.22 15:51, Miaohe Lin wrote: > When trying to offline pages, HWPoisoned hugepage is migrated without > checking PageHWPoison first. So corrupted data could be consumed. Fix > it by deferring isolate_huge_page until PageHWPoison is handled. > CCing Oscar, Mike and Naoya > Signed-off-by: Miaohe Lin > --- > mm/memory_hotplug.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 4c6065e5d274..093f85ec5c5c 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -1600,11 +1600,9 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) > folio = page_folio(page); > head = &folio->page; > > - if (PageHuge(page)) { > + if (PageHuge(page)) > pfn = page_to_pfn(head) + compound_nr(head) - 1; > - isolate_huge_page(head, &source); > - continue; > - } else if (PageTransHuge(page)) > + else if (PageTransHuge(page)) > pfn = page_to_pfn(head) + thp_nr_pages(page) - 1; > > /* > @@ -1622,6 +1620,11 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) > continue; > } > > + if (PageHuge(page)) { > + isolate_huge_page(head, &source); > + continue; > + } > + > if (!get_page_unless_zero(page)) > continue; > /* The problem statement makes sense to me but I am not sure about the details if we run into the "PageHWPoison" path with a huge page. I have the gut feeling that we have to do more for huge pages in the PageHWPoison() path, because we might be dealing with a free huge page after unmap succeeds. I might be wrong. -- Thanks, David / dhildenb