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 EA7C9CD1297 for ; Wed, 10 Apr 2024 04:01:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 66BD86B0083; Wed, 10 Apr 2024 00:01:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F4686B0085; Wed, 10 Apr 2024 00:01:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 497976B0087; Wed, 10 Apr 2024 00:01:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 2F19D6B0083 for ; Wed, 10 Apr 2024 00:01:51 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B3B621C0908 for ; Wed, 10 Apr 2024 04:01:50 +0000 (UTC) X-FDA: 81992273580.13.0D9F128 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf24.hostedemail.com (Postfix) with ESMTP id 1991C180019 for ; Wed, 10 Apr 2024 04:01:47 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712721709; 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=ejzLv1Zic6ugFn2OKV8BaEsVbbyY6xR/2TUku7FnGz0=; b=SETy6PcRWdhhffKQC/4UjM1cAIh1gC1+R9xjJYKPGJLzkPCMWc/tFnR5/+V7AIw2MwSmF5 KNhtw946h8QF1rHPz4NDOnhaavqi2eiqjy6K7JuFEb696UAwRiJGqCbwnQoSAUsjG1Hy5E +dUVjuMNwRQwIMgQoSbGtA3yyiZJ6ms= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712721709; a=rsa-sha256; cv=none; b=psgZqazkluJFmndjgarF5WwxckZkwSWz8JSe67aVJwhKIx54GpZKvhk1C8/XkzGrsq+rTa d/Lp623GskDGYBAdxqwUnU8ZmOlEVQk1qVtiz8jMWQesbU8Vv1Ae9LpWHHdhjzIMaTYuwV WfQPSwU15c2pEN70aWCdLbh2el1q6tw= Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4VDpwV6Jz8z1RC6V; Wed, 10 Apr 2024 11:58:50 +0800 (CST) Received: from canpemm500002.china.huawei.com (unknown [7.192.104.244]) by mail.maildlp.com (Postfix) with ESMTPS id D9840140154; Wed, 10 Apr 2024 12:01:42 +0800 (CST) Received: from [10.173.135.154] (10.173.135.154) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 10 Apr 2024 12:01:42 +0800 Subject: Re: [PATCH 4/8] mm/memory-failure: Convert shake_page() to shake_folio() To: Jane Chu , Matthew Wilcox CC: , Naoya Horiguchi , Andrew Morton References: <20240229212036.2160900-1-willy@infradead.org> <20240229212036.2160900-5-willy@infradead.org> From: Miaohe Lin Message-ID: Date: Wed, 10 Apr 2024 12:01:41 +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.173.135.154] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 1991C180019 X-Stat-Signature: 4p5uqqwr58umdfigim7xfiyc69tj77mx X-HE-Tag: 1712721707-578847 X-HE-Meta: U2FsdGVkX1+xKmAEvvWcAg/lSUGB3xSpTe9LZwRxHbLe0s4chx66e9OS5Jm+JhfzN4qDqOi1EIbsmpvkDNNJOG1YiaZIL9SLZ5H5PFCTU6tFTE+oFwJSVMxZ5iHWEyfDGqwopp12T70xUlACZ1O5lb8RQOO6mcSRb24D1PPc8xvaKDBTQTr0j4c/UuFwHsZGMYl3eRVAMO0fn2s9+XVT+N2Zxe6kSXSGWob+zOBsrh2O950bpfdGoXEJkvhiC3fdSR/Es08hWHKFSOK+3txkRHC5D0yC+byB+ITEO4WsqQqpxrAhCaFqTgQiSsf/O3IKCcLJhHI/xh1IMWVmBxtRUH5y0yV4z3u5b28W0rDd+ar64pd4AouNZSEXl+sYiKSgFVl2zVtnbEjdX7PIVk0zDpFxyPdIkr+xmPNey49CshGLpa9/vm2g5QEnIt5l3uBQ73SRw1ELfpWlCgos9Nft/Pup2Y0GE88xsZFepWCCgAADyztnHV9AH7uoP4JrxiPN0ytJiz5l0Rpfh+S19318SfNTi+/kRFl15lPtHfk5phu4PuQFqKxfH0qitwUAkadmNp5iEsyTlZKoesKk8mb1dlKMINu4uCVnPh2haciIbUqQrHVl55m+Ti4QousZMt7G5Sd+5bh9sM2Z1DpIpeJDdyYujx77u+kOlOLjXsCFn0TC1wCK4tIQyTp4VzZEzrpYpG/2xI+IVjXIR5eYARtal7cR4NYc5GVS445MtbdFd36gLhKhJo2SolY2qt6kE+D3+Vei7nPnb8giBhEw8Gp0hN8ofLWrvpBGdXH2RjSKASCldfExWkVQmqZuy3+EyxKoXznlKHwzlKOl+6rn+eYkYXwiQ6FZwOtEBTSag18E/FrjuHZZmOI/xvXpUagAcFAzOfE1gH3t4/DTh+QuiBQQVetFmB9JiMWFM3ei7zmGBLWKI8NlvgyCT6+oQ6KcFRSMbs78/KeVFyq/XA/+jFv ZiCE4qtM Rbo3HY8LmjrbOe7rPjva0yopKsMkFBa+z+sHnHp3cEadzC+XsTI4BZrh++AFxwfj38lTCZcySruE7VSx7mzZWXdjAs8pOokhww3Q135xRR/rGt1XRVPloURTVqXcveC21jGWbviBurkYkUoXeLGiKxaQ8DSb4o8EUGtoaC2eJDo5VtKk= 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: List-Subscribe: List-Unsubscribe: On 2024/4/9 2:31, Jane Chu wrote: > On 4/8/2024 8:36 AM, Matthew Wilcox wrote: > >> On Wed, Mar 06, 2024 at 05:31:19PM +0800, Miaohe Lin wrote: >>>> -void shake_page(struct page *p) >>>> +void shake_folio(struct folio *folio) >>> It might not be a good idea to convert shake_page() into shake_folio(). shake_page() can >>> be called without holding page refcnt. So the below race could happen: >>> >>>   hwpoison_inject >>>    folio = page_folio(p); --> assume p is 4k page [1] >>>    shake_folio(folio) >>>     folio_test_slab(folio) >>>      test_bit(PG_slab, folio_flags(folio, FOLIO_PF_NO_TAIL) [2] >>>       VM_BUG_ON_PGFLAGS(PageTail(page), page) in folio_flags >>> >>> Between [1] and [2], page can become PageTail of a THP. So the VM_BUG_ON_PGFLAGS will trigger. >>> Or am I miss something? >> No, you're not missing anything.  This race can happen.  However, I've >> removed the VM_BUG_ON for folio_test_slab() with "mm: free up PG_slab". >> Now it goes through: >> >> static inline bool PageSlab(const struct page *page) >> { >>          return folio_test_slab(page_folio(page)); >> } >> >> static __always_inline bool folio_test_##fname(const struct folio *folio)\ >> {                                                                       \ >>          return folio_test_type(folio, PG_##lname);                      \ >> }                                                                       \ >> >> #define folio_test_type(folio, flag)                                    \ >>          ((folio->page.page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE) >> >> which has no assertion that the folio is not a tail page.  Maybe it >> should, but until then we'll silently get the wrong result ;-) >> > In this case (4k page -> THP), the act of drain will be triggered with perhaps nothing to do, so looks like a harmless 'wrong result' to me. > > thanks, I tend to agree that with "free up PG_slab", this race should be harmless. Thanks both. . > > -jane > > .