Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp675549pxb; Thu, 31 Mar 2022 14:41:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxadEh7F64E5NZ9trjwZlj3l2nRiVRTcmXiIR0BBgEightYvSHvtvSj3qPa0rlTGl48rgIl X-Received: by 2002:a17:906:a219:b0:6e4:86a3:44ea with SMTP id r25-20020a170906a21900b006e486a344eamr6864879ejy.385.1648762869040; Thu, 31 Mar 2022 14:41:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648762869; cv=none; d=google.com; s=arc-20160816; b=TZjzo+Xti/TGrpHLGNG0xN55YhSXKaj9oH3UabNZQREzP8UxUxjY5JxUPmi3zoQ13z oX4aX9Jo6c7ZvV/0ZrMbV+VStnWjvQr8zAItEGZYWl6K2f4F581jQyBnLElfOjLEZ/8B VmCAZ/+G5CkI+rMV4pQ2Nfm/VvRyf0DcWtRHo7qWJO7+IUflpiErMp/WVk9DX84nBLlr yRrIwnfIpJ0bjYwRJ+rQ1qNygkD+cRCUpRZwWdpoNh2s+bz00SiuxwOSoo6jUwybXmhG ImfIIv+VgYi+AD+3re8jrp5udeRv9VQ5Mif6qux7nhCrzpQwrBzyzBOanQ+YBx4zk+Xm C6fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:date:message-id:subject:cc:from:to; bh=h3svgtw+I6EOe3Q2LzTmGGnLT9KRqUrAf9XwhmhDS6M=; b=vvJMue41gGTaf37WkN4udzydTv2qzWxW/lbtL6fcFkk8fzCuiULt4z9Mh5YgrBi/Jv IgGvxpotlLJ3PxmdiVXJc+0n+aRxw46m4qGd2m9pQeLSyQIMhh6NoM5SwJnh33pOJxXU KsJt0R2UPKAvYv1IVZmsNGkgTu9soowQ3KBYS7L+P4lqXr76+yhl8DTYSjfpAjCv6nIg oNE/nXqVUAXpjYartN2rdRbYExHIdQfBn4YacG06xSIUPJ+ifUGSbajDksA8nznU8IYw jApCkXskyPHkJeIGkUcyD7koKWkmD35ksxLhdodMghf9QU0t4vFJhh1smMLKVmdDWGTH oouQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e20-20020a170906c01400b006df76385d0fsi475985ejz.431.2022.03.31.14.40.43; Thu, 31 Mar 2022 14:41:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234806AbiCaK6Q (ORCPT + 99 others); Thu, 31 Mar 2022 06:58:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232609AbiCaK6P (ORCPT ); Thu, 31 Mar 2022 06:58:15 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6259E1E5A66 for ; Thu, 31 Mar 2022 03:56:28 -0700 (PDT) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KTgFz2MNRzdZLs; Thu, 31 Mar 2022 18:56:07 +0800 (CST) Received: from dggpemm100009.china.huawei.com (7.185.36.113) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 31 Mar 2022 18:56:26 +0800 Received: from [10.174.179.24] (10.174.179.24) by dggpemm100009.china.huawei.com (7.185.36.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 31 Mar 2022 18:56:26 +0800 To: Naoya Horiguchi , Andrew Morton From: Liu Shixin CC: , Linux Kernel Mailing List Subject: Question about hwpoison handling of 1GB hugepage Message-ID: <0af88a11-4dfe-9a4e-7b94-08f12caafcf3@huawei.com> Date: Thu, 31 Mar 2022 18:56:25 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.24] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100009.china.huawei.com (7.185.36.113) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Recently, I found a problem with hwpoison 1GB hugepage. I created a process and mapped 1GB hugepage. This process will then fork a child process and write/read this 1GB hugepage. Then I inject hwpoison into this 1GB hugepage. The child process triggers the memory failure and is being killed as expected. After this, the parent process will try to fork a new child process and do the same thing. It is killed again and finally it goes into such an infinite loop. I found this was caused by commit 31286a8484a8 ("mm: hwpoison: disable memory error handling on 1GB hugepage") It looks like there is a bug for hwpoison 1GB hugepage so I try to reproduce the bug described. After trying to revert the patch in an earlier version of the kernel, I reproduce the bug described. Then I try to revert the patch in latest version, and find the bug is no longer reproduced. I compare the code paths of 1 GB hugepage and 2 MB hugepage for second madvise(MADV_HWPOISON), and find that the problem is caused because in gup_pud_range(), pud_none() and pud_huge() both return false and then trigger the bug. But in gup_pmd_range(), the pmd_none() is modified to pmd_present() which will make code return directly. The I find that it is commit 15494520b776 ("mm: fix gup_pud_range") which cause latest version not reproduced. I backport commit 15494520b776 in earlier version and find the bug is no longer reproduced either. So I'd like to consult that is it the time to revert commit 31286a8484a8? Or if we modify pud_huge to be similar with pmd_huge, is it sufficient? I also noticed there is a TODO comment in memory_failure_hugetlb(): - conversion of a pud that maps an error hugetlb into hwpoison entry properly works, and - other mm code walking over page table is aware of pud-aligned hwpoison entries. I'm not sure whether the above fix are sufficient, so is there anything else need to analysis that I haven't considered? Thanks,