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, 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 A69C9C433DB for ; Tue, 23 Mar 2021 11:28:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 407AC61879 for ; Tue, 23 Mar 2021 11:28:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 407AC61879 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C99AD6B0164; Tue, 23 Mar 2021 07:28:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C706C6B0166; Tue, 23 Mar 2021 07:28:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B37BF6B0167; Tue, 23 Mar 2021 07:28:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0106.hostedemail.com [216.40.44.106]) by kanga.kvack.org (Postfix) with ESMTP id 98C0D6B0164 for ; Tue, 23 Mar 2021 07:28:39 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 5CFF38249980 for ; Tue, 23 Mar 2021 11:28:39 +0000 (UTC) X-FDA: 77950916358.14.5D140C8 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf22.hostedemail.com (Postfix) with ESMTP id 8FCD2C0007D5 for ; Tue, 23 Mar 2021 11:28:37 +0000 (UTC) Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4F4TbK3Nspz19HGk; Tue, 23 Mar 2021 19:26:37 +0800 (CST) Received: from [10.174.178.163] (10.174.178.163) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.498.0; Tue, 23 Mar 2021 19:28:32 +0800 Subject: Re: [PATCH 3/5] mm/migrate.c: fix potential indeterminate pte entry in migrate_vma_insert_page() To: Alistair Popple CC: David Hildenbrand , , , , , linux-kernel References: <20210320093701.12829-1-linmiaohe@huawei.com> <20210320093701.12829-4-linmiaohe@huawei.com> <0bee2243-5771-4969-7b92-aaca67abc90c@redhat.com> <5999334.9xz1uWCbsP@nvdebian> From: Miaohe Lin Message-ID: Date: Tue, 23 Mar 2021 19:28:32 +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: <5999334.9xz1uWCbsP@nvdebian> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.163] X-CFilter-Loop: Reflected X-Stat-Signature: tzexcfyh7nyuwom5fm591ip1zji9rjho X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 8FCD2C0007D5 Received-SPF: none (huawei.com>: No applicable sender policy available) receiver=imf22; identity=mailfrom; envelope-from=""; helo=szxga04-in.huawei.com; client-ip=45.249.212.190 X-HE-DKIM-Result: none/none X-HE-Tag: 1616498917-836637 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 2021/3/23 19:07, Alistair Popple wrote: > On Tuesday, 23 March 2021 9:26:43 PM AEDT David Hildenbrand wrote: >> On 20.03.21 10:36, Miaohe Lin wrote: >>> If the zone device page does not belong to un-addressable device memory, >>> the variable entry will be uninitialized and lead to indeterminate pte >>> entry ultimately. Fix this unexpectant case and warn about it. >> >> s/unexpectant/unexpected/ >> >>> >>> Fixes: df6ad69838fc ("mm/device-public-memory: device memory cache > coherent with CPU") >>> Signed-off-by: Miaohe Lin >>> --- >>> mm/migrate.c | 7 +++++++ >>> 1 file changed, 7 insertions(+) >>> >>> diff --git a/mm/migrate.c b/mm/migrate.c >>> index 20a3bf75270a..271081b014cb 100644 >>> --- a/mm/migrate.c >>> +++ b/mm/migrate.c >>> @@ -2972,6 +2972,13 @@ static void migrate_vma_insert_page(struct > migrate_vma *migrate, >>> >>> swp_entry = make_device_private_entry(page, vma->vm_flags & > VM_WRITE); >>> entry = swp_entry_to_pte(swp_entry); >>> + } else { >>> + /* >>> + * For now we only support migrating to un-addressable >>> + * device memory. >>> + */ >>> + WARN_ON(1); >>> + goto abort; >> >> Fix it by crashing the kernel with panic_on_warn? :) >> >> If this case can actual happen, than no WARN_ON() - rather a >> pr_warn_once(). If this case cannot happen, why do we even care (it's >> not a fix then)? > > There is also already a check for this case in migrate_vma_pages(). The > problem is it happens after the call to migrate_vma_insert_page(). I wonder if > instead it would be better just to move the existing check to before that > call? > Yes, sounds good! Many thanks for your advice! :) > > > . >