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 6C464C433F5 for ; Mon, 25 Apr 2022 01:59:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D94B96B0095; Sun, 24 Apr 2022 21:59:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D6AC96B0096; Sun, 24 Apr 2022 21:59:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C31DE6B0098; Sun, 24 Apr 2022 21:59:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id B52BC6B0095 for ; Sun, 24 Apr 2022 21:59:43 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8216527094 for ; Mon, 25 Apr 2022 01:59:43 +0000 (UTC) X-FDA: 79393745046.29.FFA800A Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf28.hostedemail.com (Postfix) with ESMTP id E1882C003B for ; Mon, 25 Apr 2022 01:59:36 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Kmp6R2ShVzGpFF; Mon, 25 Apr 2022 09:57:03 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 25 Apr 2022 09:59:37 +0800 Subject: Re: [PATCH v3 3/3] mm/madvise: free hwpoison and swapin error entry in madvise_free_pte_range To: =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= CC: "akpm@linux-foundation.org" , "willy@infradead.org" , "vbabka@suse.cz" , "dhowells@redhat.com" , "neilb@suse.de" , "david@redhat.com" , "apopple@nvidia.com" , "surenb@google.com" , "minchan@kernel.org" , "peterx@redhat.com" , "sfr@canb.auug.org.au" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" References: <20220424091105.48374-1-linmiaohe@huawei.com> <20220424091105.48374-4-linmiaohe@huawei.com> <20220424234128.GA3740950@hori.linux.bs1.fc.nec.co.jp> From: Miaohe Lin Message-ID: <66a3d738-9dcb-76d6-6507-abbb13569709@huawei.com> Date: Mon, 25 Apr 2022 09:59:36 +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: <20220424234128.GA3740950@hori.linux.bs1.fc.nec.co.jp> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: E1882C003B X-Stat-Signature: wdeoeqfgespbb1odnpcjjtoxsd1m8yca Authentication-Results: imf28.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf28.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-HE-Tag: 1650851976-758797 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 2022/4/25 7:41, HORIGUCHI NAOYA(堀口 直也) wrote: > On Sun, Apr 24, 2022 at 05:11:05PM +0800, Miaohe Lin wrote: >> Once the MADV_FREE operation has succeeded, callers can expect they might >> get zero-fill pages if accessing the memory again. Therefore it should be >> safe to delete the hwpoison entry and swapin error entry. There is no >> reason to kill the process if it has called MADV_FREE on the range. >> >> Suggested-by: Alistair Popple >> Signed-off-by: Miaohe Lin >> Acked-by: David Hildenbrand > > I confirmed that hwpoison entry is properly removed with madvise(MADV_FREE) > with this patch. This provides applications with the ability to recover from > memory errors in simpler way (applications don't have to munmap then mmap again > the error address). That's a good small improvement. Thank you. > > Reviewed-by: Naoya Horiguchi Many thanks for your testing and review! :) > >> --- >> mm/madvise.c | 13 ++++++++----- >> 1 file changed, 8 insertions(+), 5 deletions(-) >> >> diff --git a/mm/madvise.c b/mm/madvise.c >> index 4d6592488b51..5f4537511532 100644 >> --- a/mm/madvise.c >> +++ b/mm/madvise.c >> @@ -624,11 +624,14 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr, >> swp_entry_t entry; >> >> entry = pte_to_swp_entry(ptent); >> - if (non_swap_entry(entry)) >> - continue; >> - nr_swap--; >> - free_swap_and_cache(entry); >> - pte_clear_not_present_full(mm, addr, pte, tlb->fullmm); >> + if (!non_swap_entry(entry)) { >> + nr_swap--; >> + free_swap_and_cache(entry); >> + pte_clear_not_present_full(mm, addr, pte, tlb->fullmm); >> + } else if (is_hwpoison_entry(entry) || >> + is_swapin_error_entry(entry)) { >> + pte_clear_not_present_full(mm, addr, pte, tlb->fullmm); >> + } >> continue; >> } >> >> -- >> 2.23.0