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 A0CABC54EE9 for ; Tue, 13 Sep 2022 06:51:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 26E078D0001; Tue, 13 Sep 2022 02:51:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 21E346B0073; Tue, 13 Sep 2022 02:51:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 10D438D0001; Tue, 13 Sep 2022 02:51:58 -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 F1DFF6B0072 for ; Tue, 13 Sep 2022 02:51:57 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CB8F5160454 for ; Tue, 13 Sep 2022 06:51:57 +0000 (UTC) X-FDA: 79906142274.17.452CBDB Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf17.hostedemail.com (Postfix) with ESMTP id CCBFE40095 for ; Tue, 13 Sep 2022 06:51:55 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MRYxC58yBzHntY; Tue, 13 Sep 2022 14:49:51 +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.31; Tue, 13 Sep 2022 14:51:52 +0800 Subject: Re: [PATCH 08/16] mm/page_alloc: add missing is_migrate_isolate() check in set_page_guard() To: David Hildenbrand CC: , , , Andrew Morton References: <20220909092451.24883-1-linmiaohe@huawei.com> <20220909092451.24883-9-linmiaohe@huawei.com> From: Miaohe Lin Message-ID: <9b7f63cf-dfc1-a1d8-695d-94f6b1af4512@huawei.com> Date: Tue, 13 Sep 2022 14:51:51 +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: 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663051917; a=rsa-sha256; cv=none; b=NTULYlBQ6SiJvGgYz0ZQsvWNgrQhKfZEWptTTOf6PRFwKmEYfKSV/wObAX3pv66LZ0Q4xJ kJPaDmaRzhe6m7uvTExW07v1w0u+/PwBfjpvF8tRdRAY6SWv0xdOyfu/krJvmC/JvZqlCl 8P/LBuNPHndZVEhShJQcjj26XbBx9rc= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663051917; 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=FsMgp8H3yem1TD8Vam9cOxGmTC8t5rk7aKXHI/9g2Ws=; b=Hz75Q75qvhiGONMgZpH7aTX6WyThpctdEUxNmLahq6ufvb6OYXJcowIyNhweWFPW8Q+S1Q F4TItL0gm7ck4TH5XYhc5bhRmLOSE62RNx3apT98B157Z24PFSsTzsjnb1C7IF8VZuftHZ Y5xqmj0Ffrj3hDJScbrxGhVyxv8prjY= X-Stat-Signature: 9ijbwhrrpsriccm4cxz5a6bpgnkrg56t X-Rspamd-Queue-Id: CCBFE40095 Authentication-Results: imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1663051915-219709 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/9 19:31, David Hildenbrand wrote: > On 09.09.22 11:24, Miaohe Lin wrote: >> In MIGRATE_ISOLATE case, zone freepage state shouldn't be modified as >> caller will take care of it. Add missing is_migrate_isolate() here to >> avoid possible unbalanced freepage state. >> >> Signed-off-by: Miaohe Lin >> --- >>   mm/page_alloc.c | 3 ++- >>   1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/mm/page_alloc.c b/mm/page_alloc.c >> index a35ef385d906..94baf33da865 100644 >> --- a/mm/page_alloc.c >> +++ b/mm/page_alloc.c >> @@ -873,7 +873,8 @@ static inline bool set_page_guard(struct zone *zone, struct page *page, >>       INIT_LIST_HEAD(&page->buddy_list); >>       set_page_private(page, order); >>       /* Guard pages are not available for any usage */ >> -    __mod_zone_freepage_state(zone, -(1 << order), migratetype); >> +    if (!is_migrate_isolate(migratetype)) >> +        __mod_zone_freepage_state(zone, -(1 << order), migratetype); >>         return true; >>   } > > Do we have a fixes: tag for this one? > > Can it even happen that the pageblock is isolated when we end up in this function? IIUC, we'd have an allocation in an isolated pageblock, which would be wrong already? For "normal" page allocation case, migratetype can't be MIGRATE_ISOLATE. So it's fine. But when called from take_page_off_buddy(), the issue could be triggered as it breaks the assumption in the set_page_guard (that migratetype can't be MIGRATE_ISOLATE). So the fixes tag might be: Fixes: 06be6ff3d2ec ("mm,hwpoison: rework soft offline for free pages") Or am I miss something? Many thanks for your review and comment in this series, David. :) Thanks, Miaohe Lin