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 C84F2C531DC for ; Fri, 23 Aug 2024 07:40:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08B2F6B0160; Fri, 23 Aug 2024 03:40:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0131A6B016C; Fri, 23 Aug 2024 03:40:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF6106B0160; Fri, 23 Aug 2024 03:40:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C29816B015E for ; Fri, 23 Aug 2024 03:40:39 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 6CEBAA16E2 for ; Fri, 23 Aug 2024 07:40:39 +0000 (UTC) X-FDA: 82482712998.17.BAB713A Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf17.hostedemail.com (Postfix) with ESMTP id 53F7740003 for ; Fri, 23 Aug 2024 07:40:34 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf17.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724398820; a=rsa-sha256; cv=none; b=xgbKub7XGGdoz70Qk1XC2AeG/EKsosPLrJrZTZFsGtTMuxStG/CU7E8fLHhLlP8U5AgHN7 1H6YIBmZN4EERq/J5J4/whgmBSTVu0PZ4mSaRdWxyQ6cJ2052+cEurXFC19J2XtP/FRmRA JUNJx/B5uL/VjtPWeyYjrjpxzu9aaOE= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf17.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724398820; h=from:from:sender: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=QW3RPI+jIyqvgoW++8yqdXZK7aKbDNBN5eG5MBSshi0=; b=GjFLpCq+iKlM40buLArFvAdVCp4BpqOhTFmT6q8ZoiYIC36t4DYsJ0kux8mgNZohwWUqN5 m+zQQ8QE7VRGYEgVKOSH+wPFkuMgTHNbDMP1ludxBqiCFiQXLE4FuG4HmAKVnWcb1mk6o8 5nNgS+0PcAgkkgEWaisPpUvIEk4rDno= Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4WqsQ91B6kzpSwG; Fri, 23 Aug 2024 15:38:57 +0800 (CST) Received: from kwepemd200019.china.huawei.com (unknown [7.221.188.193]) by mail.maildlp.com (Postfix) with ESMTPS id 5D7801800D2; Fri, 23 Aug 2024 15:40:31 +0800 (CST) Received: from [10.173.127.72] (10.173.127.72) by kwepemd200019.china.huawei.com (7.221.188.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 23 Aug 2024 15:40:30 +0800 Subject: Re: [PATCH] codetag: debug: mark codetags for pages which transitioned from being poison to unpoison as empty To: Hao Ge , Suren Baghdasaryan CC: , , , Hao Ge , , , , , References: <20240822025800.13380-1-hao.ge@linux.dev> From: Miaohe Lin Message-ID: <292d1141-4edf-ee60-a145-4ca06600076a@huawei.com> Date: Fri, 23 Aug 2024 15:40:29 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.173.127.72] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemd200019.china.huawei.com (7.221.188.193) X-Rspam-User: X-Rspamd-Queue-Id: 53F7740003 X-Rspamd-Server: rspam01 X-Stat-Signature: 5wizbf7uiu7gjqb4m6us1hux13u9yow1 X-HE-Tag: 1724398834-873949 X-HE-Meta: U2FsdGVkX18Tks++pDc/i9vrfZ15e3cgwiAAh1zHI6p8PvaQQ7R2Gg2ISBtzAauW3GeNrLRgY7s3IimsDrAPV+khcBK01piA6iHjgGSjisWPGF5+tdGN4mNF8ujzuzyd18AFHw0g1jo4kBlvZlgDFQxAcndgUldrAbm86kF5klqVEViBLemv3Pl8qoDiRz+eLmS547O1DogoRV3t+E0LzsQn/EbNrl8IT4Pq6SBMPFUgAu0lXHUEeTomLQs8fJDAz1vlLi+r0RHYuhbMhGg63FQyDfnm+cjqg3eb5B9q9n3JSb7gv2cYVHLvpBV9avavHVAqVJ1OOLt/EmaMkiey3tOvOu2usX8D98Tj7mbhTgv+j2HdBRFDiMhLflHoJm4hqLzuGz4W/OOXiVaflnRrGrGUfzALgg4HzYFfze6jIdPPOvRJuOU4HB6+rttd8wUYACYSYsQzjqgX8DBMZYrygsR6Hirgug94Mru3IZ5UXhpj8fpk4LkmXE82f+NDauJtymeG8eP/OsvCtYKyk8Zrnqo0ZAyV4mfwTQVMWGFCJ+YaCVlcETy4R1sh6HbVICN54cKbgAOArrmHFlk2YFgjA7ovAcD6S0pRy6MtXccQ4fkOirOHq7YQp+V25u14LC1lqGq4l0bldJhF1iR5M6Fk5aE3nbVwYAitE7W10MVVMOWHtsSGhU0bOXDXnIAQvrjK4zugtVWcGsLPL6q9mETtJK6sJOL4xEzsbWHk8qodk19BF1sWzNAxw8aaw1Br78lQbN1/PA2ro/gW/6e0iuQ1Hkqve3rtHmGbztNc97d1xIXAOTLfeeQ6UF+nhsS1A8wSq5+Q3ObcDQyj+TBsVgaNzQcXL5FWNxf355vevWACWjRLRUDfvRVit+x0Ef4ULtvotadU+Eg8kUiJ6cw+c0r7nNhz9ZRi6Wphc2a7g3U39dOH+CYW+5kZ0kT6PaWNg6qv2WzAic3vt4udCWrWKec /ulVOk0a zpnD14aMpcS6Rvay3zXMKGn4UCfousGV0zn2MMfx0ivkRiUe3W9/wHGJemlqv1u82jZZmrNyweJ/SnKmhTAWxc3WqKAZ9XqYeRs0k8Gpw91pTBxAiiQVXWUv9upTDlvVORbuSGO9N7Uxpl2zwzQ4uc/u+wiQHwc7n7cmgYbr6YNum/rpBeIkNIQ6jOlgH9R5LwsBz2qIW8lDPbCQB/NHbXlFA8saPIO/vAjckTqj8da0au0uFjFK7tCm74Xv/v857XMX+h1dLpvLm3STe+4LwPkG2rut6g7IJ1mAC 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: List-Subscribe: List-Unsubscribe: On 2024/8/23 11:37, Hao Ge wrote: > Hi Suren and Miaohe > > > On 8/23/24 09:47, Hao Ge wrote: >> Hi Suren and Miaohe >> >> >> Thank you all for taking the time to discuss this issue. >> >> >> On 8/23/24 06:50, Suren Baghdasaryan wrote: >>> On Thu, Aug 22, 2024 at 2:46 AM Hao Ge wrote: >>>> Hi Miaohe >>>> >>>> >>>> Thank you for taking the time to review this patch. >>>> >>>> >>>> On 8/22/24 16:04, Miaohe Lin wrote: >>>>> On 2024/8/22 10:58, Hao Ge wrote: >>>>>> From: Hao Ge >>>>>> >>>>> Thanks for your patch. >>>>> >>>>>> The PG_hwpoison page will be caught and isolated on the entrance to >>>>>> the free buddy page pool. so,when we clear this flag and return it >>>>>> to the buddy system,mark codetags for pages as empty. >>>>>> >>>>> Is below scene cause the problem? >>>>> >>>>> 1. Pages are allocated. pgalloc_tag_add() will be called when prep_new_page(). >>>>> >>>>> 2. Pages are hwpoisoned. memory_failure() will set PG_hwpoison flag and pgalloc_tag_sub() >>>>> will be called when pages are caught and isolated on the entrance to buddy. >>> Hi Folks, >>> Thanks for reporting this! Could you please describe in more details >>> how memory_failure() ends up calling pgalloc_tag_sub()? It's not >>> obvious to me which path leads to pgalloc_tag_sub(), so I must be >>> missing something. >> >> >> OK,Let me describe the scenario I encountered. >> >> In the Link [1] I mentioned,here is the logic behind it: >> >> It performed the following operations: >> >> madvise(ptrs[num_alloc], pagesize, MADV_SOFT_OFFLINE) >> >> and then the kernel's call stack looks like this: >> >> do_madvise >> >> soft_offline_page >> >> page_handle_poison >> >> __folio_put >> >> free_unref_page >> > > I just reviewed it and I think I missed a stack. > > Actually, it's like this > > do_madvise > > soft_offline_page > > soft_offline_in_use_page > > page_handle_poison > > __folio_put > > free_unref_page > > > And I've come up with a minimal solution. If everyone agrees, I'll send the patch.look this > > https://elixir.bootlin.com/linux/v6.11-rc4/source/mm/page_alloc.c#L1056 > > Let's directly call clear_page_tag_ref after pgalloc_tag_sub. I tend to agree with you. It should be a good practice to call clear_page_tag_ref() whenever page_tag finished its work. Do you think below code is also needed? diff --git a/mm/page_alloc.c b/mm/page_alloc.c index de54c3567539..707710f03cf5 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1104,6 +1104,7 @@ __always_inline bool free_pages_prepare(struct page *page, reset_page_owner(page, order); page_table_check_free(page, order); pgalloc_tag_sub(page, 1 << order); + clear_page_tag_ref(page); if (!PageHighMem(page)) { debug_check_no_locks_freed(page_address(page), Thanks. .