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 33C37C433EF for ; Tue, 12 Apr 2022 09:48:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6C616B007D; Tue, 12 Apr 2022 05:48:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AF47C6B007E; Tue, 12 Apr 2022 05:48:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9BB7E6B0080; Tue, 12 Apr 2022 05:48:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id 87BEE6B007D for ; Tue, 12 Apr 2022 05:48:05 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 50AA021345 for ; Tue, 12 Apr 2022 09:48:05 +0000 (UTC) X-FDA: 79347750930.01.457F79C Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by imf24.hostedemail.com (Postfix) with ESMTP id 14C5D180002 for ; Tue, 12 Apr 2022 09:48:03 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=xuyu@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0V9uMvEX_1649756879; Received: from 30.225.28.172(mailfrom:xuyu@linux.alibaba.com fp:SMTPD_---0V9uMvEX_1649756879) by smtp.aliyun-inc.com(127.0.0.1); Tue, 12 Apr 2022 17:48:00 +0800 Message-ID: Date: Tue, 12 Apr 2022 17:47:59 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH] mm/memory-failure.c: bail out early if huge zero page Content-Language: en-US To: Oscar Salvador , Miaohe Lin Cc: linux-mm@kvack.org, akpm@linux-foundation.org References: <49273e6688d7571756603dac996692a15f245d58.1649603963.git.xuyu@linux.alibaba.com> From: Yu Xu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Stat-Signature: jf57ynwz3pmfhqw3im947u48ub7t4rfz Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of xuyu@linux.alibaba.com designates 115.124.30.45 as permitted sender) smtp.mailfrom=xuyu@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 14C5D180002 X-HE-Tag: 1649756883-208592 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000007, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 4/12/22 5:30 PM, Oscar Salvador wrote: > On Tue, Apr 12, 2022 at 05:25:52PM +0800, Miaohe Lin wrote: >> On 2022/4/12 16:31, Oscar Salvador wrote: >>> On Sun, Apr 10, 2022 at 11:22:34PM +0800, Xu Yu wrote: >>>> Kernel panic when injecting memory_failure for the global huge_zero_page, >>>> when CONFIG_DEBUG_VM is enabled, as follows. >>> ... >>>> In fact, huge_zero_page is unhandlable currently in either soft offline >>>> or memory failure injection. With CONFIG_DEBUG_VM disabled, >>>> huge_zero_page is bailed out when checking HWPoisonHandlable() in >>>> get_any_page(), or checking page mapping in split_huge_page_to_list(). >>>> >>>> This makes huge_zero_page bail out early in madvise_inject_error(), and >>>> panic above won't happen again. >>> >>> I would not special case this in madvise_inject_error() but rather >>> handle it in memory-failure code. >>> We do already have HWPoisonHandlable(), which tells us whether the page >>> is of a type we can really do something about, so why not add another >>> check in HWPoisonHandlable() for huge_zero_page(), and have that checked >>> in memory_failure(). >> >> IIUC, this does not work. Because HWPoisonHandlable is only called in !MF_COUNT_INCREASED case. >> But MF_COUNT_INCREASED is always set when called from madvise_inject_error, so HWPoisonHandlable >> is not even called in this scene. Or am I miss something? > > But nothing stops you from calling it in memory_failure(), right? > > if (MF_COUNT_INCREASED not set) { > .... > ... > } else if(!HWPoisonHandable(p)) { > action_result(pfn, MF_MSG_UNKNOWN, MF_IGNORED); > res = -EBUSY; > goto unlock_mutex; > } > >> BTW: IIRC, LRU isn't set on huge_zero_page. So the origin HWPoisonHandlable can already filter out this page. > > I would rather have it as a explicit check than buried in that kind of > assumption. And this is also why I decided to bail out huge zero page early for both soft offline and memory failure. > > But after all, Naoya's suggestion might just be better and more focused. Agree, thanks! > > -- Thanks, Yu