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 AEFCCC38145 for ; Thu, 8 Sep 2022 07:07:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3CE916B0073; Thu, 8 Sep 2022 03:07:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 37D256B0074; Thu, 8 Sep 2022 03:07:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 245E58D0001; Thu, 8 Sep 2022 03:07:47 -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 16EAB6B0073 for ; Thu, 8 Sep 2022 03:07:47 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E78D480163 for ; Thu, 8 Sep 2022 07:07:46 +0000 (UTC) X-FDA: 79888038132.16.18D5C0F Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf31.hostedemail.com (Postfix) with ESMTP id 7C29020096 for ; Thu, 8 Sep 2022 07:07:46 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 23EAC1F8A3; Thu, 8 Sep 2022 07:07:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1662620865; h=from:from:reply-to: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=CzVBfjR1nIXXxdOIZV4ORhJET4DmK+Dtxtfv33hVk/I=; b=TtMBvi1X+B/8tPjgPqUMVzk/1Z11ITUnx6u7WOb1a3tfdt1xoSAHZ0yRaHV8mEQPvtM4Po DGMvgnNN4oDNkfyPPPU8oHcgb87UfUQD8CLk8QgxadkiLt6uqj3u3LLgXQVlZAmGlr9pqc zmfLu0qeoLXUzoH61qhRNv3cOliRmuc= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 01AE113A6D; Thu, 8 Sep 2022 07:07:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id FuotOcCUGWPbCQAAMHmgww (envelope-from ); Thu, 08 Sep 2022 07:07:44 +0000 Date: Thu, 8 Sep 2022 09:07:44 +0200 From: Michal Hocko To: Miaohe Lin Cc: HORIGUCHI =?utf-8?B?TkFPWUEo5aCA5Y+jIOebtOS5nyk=?= , Naoya Horiguchi , David Hildenbrand , "linux-mm@kvack.org" , Andrew Morton , Muchun Song , Matthew Wilcox , Yang Shi Subject: Re: [PATCH] mm/huge_memory: use pfn_to_online_page() in split_huge_pages_all() Message-ID: 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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662620866; a=rsa-sha256; cv=none; b=fiXxt+0zdva7iDXXJL9ijpc7m8vvBOACgAQOQKtoQEmOv9MonzPVPPbbN9yOb5SDJdcq1l PJLlBJG8rO+2NLfrUxmLhsULPXoEK28g4etGcdRbOUiQ6m98ERDhmhoBYVfneyQHXQ39ou 7cwxou3K4jsGzc025MAmz3wFESP1rz4= ARC-Authentication-Results: i=1; imf31.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=TtMBvi1X; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf31.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662620866; 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:dkim-signature; bh=CzVBfjR1nIXXxdOIZV4ORhJET4DmK+Dtxtfv33hVk/I=; b=fDDRsRHxSyoyLWuZ1vUbVJFcWhZZ384AWlf7Vt0hDkkTl0Ovs0yHDE9DyNT0a4ntWnCXSJ mjtO+NPr7gEMGmXp1Y0nFPlHXWVYLIYONmg7odJrz6XcwiiWGpm6YMFU4J7p8fYPl0Jbby gEi5bhcxJpWcITbh5zGV8T670jh6Gus= X-Rspam-User: X-Stat-Signature: shk9ueq13zctyiddu63gkopnb5guik5r X-Rspamd-Queue-Id: 7C29020096 Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=TtMBvi1X; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf31.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com X-Rspamd-Server: rspam05 X-HE-Tag: 1662620866-945654 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 Thu 08-09-22 11:25:54, Miaohe Lin wrote: > 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. ;) Most of those whic are directly triggerable should be taken care of. It would be still good to go through `git grep -w pfn_to_page' and evaluate all callers. Still more than 400 callsites so not a trivial task. -- Michal Hocko SUSE Labs