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 537C5C433C1 for ; Tue, 23 Mar 2021 11:24:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9D137600CC for ; Tue, 23 Mar 2021 11:24:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D137600CC 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 300946B015D; Tue, 23 Mar 2021 07:24:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 261C66B015E; Tue, 23 Mar 2021 07:24:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1170D6B015F; Tue, 23 Mar 2021 07:24:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0059.hostedemail.com [216.40.44.59]) by kanga.kvack.org (Postfix) with ESMTP id E49666B015D for ; Tue, 23 Mar 2021 07:24:32 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A42A58249980 for ; Tue, 23 Mar 2021 11:24:32 +0000 (UTC) X-FDA: 77950905984.12.421A2AE Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf13.hostedemail.com (Postfix) with ESMTP id 8207EE0011F4 for ; Tue, 23 Mar 2021 11:24:31 +0000 (UTC) Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4F4TVT0drWzwQ9L; Tue, 23 Mar 2021 19:22:25 +0800 (CST) Received: from [10.174.178.163] (10.174.178.163) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.498.0; Tue, 23 Mar 2021 19:24:18 +0800 Subject: Re: [PATCH 3/5] mm/migrate.c: fix potential indeterminate pte entry in migrate_vma_insert_page() To: David Hildenbrand , CC: , , , References: <20210320093701.12829-1-linmiaohe@huawei.com> <20210320093701.12829-4-linmiaohe@huawei.com> <0bee2243-5771-4969-7b92-aaca67abc90c@redhat.com> From: Miaohe Lin Message-ID: <488547af-3fa0-69bc-1c05-f4a077ab67d1@huawei.com> Date: Tue, 23 Mar 2021 19:24:18 +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: <0bee2243-5771-4969-7b92-aaca67abc90c@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US X-Originating-IP: [10.174.178.163] X-CFilter-Loop: Reflected X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 8207EE0011F4 X-Stat-Signature: ddrncmmfos9tzdxo68oej18zmioi33oj Received-SPF: none (huawei.com>: No applicable sender policy available) receiver=imf13; identity=mailfrom; envelope-from=""; helo=szxga05-in.huawei.com; client-ip=45.249.212.191 X-HE-DKIM-Result: none/none X-HE-Tag: 1616498671-385457 Content-Transfer-Encoding: quoted-printable 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: Hi: On 2021/3/23 18:26, David Hildenbrand wrote: > On 20.03.21 10:36, Miaohe Lin wrote: >> If the zone device page does not belong to un-addressable device memor= y, >> the variable entry will be uninitialized and lead to indeterminate pte >> entry ultimately. Fix this unexpectant case and warn about it. >=20 > s/unexpectant/unexpected/ >=20 >> >> Fixes: df6ad69838fc ("mm/device-public-memory: device memory cache coh= erent with CPU") >> Signed-off-by: Miaohe Lin >> --- >> =C2=A0 mm/migrate.c | 7 +++++++ >> =C2=A0 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 migr= ate_vma *migrate, >> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 swp_entry =3D make_device_private_entry(page, vma->vm_fla= gs & VM_WRITE); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 entry =3D swp_entry_to_pte(swp_entry); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } else { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 * For now we only support migrating to un-addressable >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 * device memory. >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 */ >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 WA= RN_ON(1); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 go= to abort; >=20 > Fix it by crashing the kernel with panic_on_warn? :) >=20 Sorry, my bad. :( > If this case can actual happen, than no WARN_ON() - rather a pr_warn_on= ce(). If this case cannot happen, why do we even care (it's not a fix the= n)? Yep, this case can actual happen. Many thanks for providing alternative p= r_warn_once(). >=20 >=20