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 BF742C38145 for ; Thu, 8 Sep 2022 03:25:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F68A8D0001; Wed, 7 Sep 2022 23:25:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A6E26B0073; Wed, 7 Sep 2022 23:25:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 06E248D0001; Wed, 7 Sep 2022 23:25:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id EC07D6B0072 for ; Wed, 7 Sep 2022 23:25:58 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C13D41C6349 for ; Thu, 8 Sep 2022 03:25:58 +0000 (UTC) X-FDA: 79887479196.11.D0B5270 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf11.hostedemail.com (Postfix) with ESMTP id 018924006E for ; Thu, 8 Sep 2022 03:25:57 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MNPY032wMzNm4y; Thu, 8 Sep 2022 11:21:24 +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; Thu, 8 Sep 2022 11:25:54 +0800 Subject: Re: [PATCH] mm/huge_memory: use pfn_to_online_page() in split_huge_pages_all() To: =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= CC: Naoya Horiguchi , David Hildenbrand , "linux-mm@kvack.org" , Andrew Morton , Muchun Song , Matthew Wilcox , Michal Hocko , Yang Shi References: <20220907100855.GA2894785@ik1-406-35019.vs.sakura.ne.jp> <1481ce19-0a64-d1dc-4d89-4db71d6f7eb3@redhat.com> <20220907121157.GA2954283@ik1-406-35019.vs.sakura.ne.jp> <9cb0b01e-c80d-667c-47f1-ad30e329784b@huawei.com> <20220908030652.GA1492282@hori.linux.bs1.fc.nec.co.jp> From: Miaohe Lin Message-ID: Date: Thu, 8 Sep 2022 11:25:54 +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: <20220908030652.GA1492282@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: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662607558; a=rsa-sha256; cv=none; b=oP6uTyyl/l377mRUXyusUWfgAiO1oGNPrwLhGZJfY4+b9vhzpzNr24ud+ggKh/NNTvJWif 1z0w4XIceegBYlk9bypOm+RlIWKoP4pSMhfqwWwpfFJ/qCP2oBqNCw9BG3u4ITs2LrU74l C4YbhJRRCuXbfyntDm34qd/5eE+auMI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662607558; 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=GV+xE1LDfJnUsRkVuSIG7IsNMFLLp2A7A4PRkFmtFbA=; b=BC47ovzuB6pT+ABxaORPa2/uVDNbuAulJzsoP6wMVSTE0H2Jxd8kkIpiXBUUWnIq74Ybv5 hyHWn6/Oxw1LJIJw5tK8MidnRfhIe2BrT0MF+ZsjmkDJln5fOUWSYLW+IvMB1cpvJk8MIh kShSqNqVKRblRuq2+V85wuloOg83NnA= X-Rspamd-Queue-Id: 018924006E X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspamd-Server: rspam04 X-Stat-Signature: osuzhoz81w9j3wjh8x3ng8fquyiqgbqc X-HE-Tag: 1662607557-930477 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/9/8 11:06, HORIGUCHI NAOYA(堀口 直也) wrote: > On Thu, Sep 08, 2022 at 10:19:03AM +0800, Miaohe Lin wrote: >> On 2022/9/7 20:11, Naoya Horiguchi wrote: > ... >>> >From 8a5c284df732943065d23838090d15c94cd10395 Mon Sep 17 00:00:00 2001 >>> From: Naoya Horiguchi >>> Date: Wed, 7 Sep 2022 20:58:44 +0900 >>> Subject: [PATCH] mm/huge_memory: use pfn_to_online_page() in >>> split_huge_pages_all() >>> >>> NULL pointer dereference is triggered when calling thp split via debugfs >>> on the system with offlined memory blocks. With debug option enabled, >>> the following kernel messages are printed out: >>> >>> page:00000000467f4890 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x121c000 >>> flags: 0x17fffc00000000(node=0|zone=2|lastcpupid=0x1ffff) >>> raw: 0017fffc00000000 0000000000000000 dead000000000122 0000000000000000 >>> raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000 >>> page dumped because: unmovable page >>> page:000000007d7ab72e is uninitialized and poisoned >>> page dumped because: VM_BUG_ON_PAGE(PagePoisoned(p)) >>> ------------[ cut here ]------------ >>> kernel BUG at include/linux/mm.h:1248! >>> invalid opcode: 0000 [#1] PREEMPT SMP PTI >>> CPU: 16 PID: 20964 Comm: bash Tainted: G I 6.0.0-rc3-foll-numa+ #41 >>> ... >>> RIP: 0010:split_huge_pages_write+0xcf4/0xe30 >>> >>> This shows that page_to_nid() in page_zone() is unexpectedly called for an >>> offlined memmap. >>> >>> Use pfn_to_online_page() to get struct page in PFN walker. >> >> With changes proposed by David, this patch looks good to me. >> >> Reviewed-by: Miaohe Lin > > Thank you. > >> >> BTW: IMHO, there might be many similar code places need to take care of memory hotremove where >> *pfn is operated directly* while it's not protected against memory hotremove. > > I had the similar concern, but there seems many place doing PFN walk, > so checking them one-by-one that offlined memory can be walked over > requires much effort. Yes, that will be a heavy work. We could fix them one by one if they ever occur. ;) Thanks, Miaohe Lin > > Thanks, > Naoya Horiguchi >