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 X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAD5FC43463 for ; Fri, 18 Sep 2020 09:35:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5311D21582 for ; Fri, 18 Sep 2020 09:35:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5311D21582 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 783D66B0003; Fri, 18 Sep 2020 05:35:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 70B4B6B0055; Fri, 18 Sep 2020 05:35:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D3FA6B005A; Fri, 18 Sep 2020 05:35:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0025.hostedemail.com [216.40.44.25]) by kanga.kvack.org (Postfix) with ESMTP id 451296B0003 for ; Fri, 18 Sep 2020 05:35:10 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 0DA4C824999B for ; Fri, 18 Sep 2020 09:35:10 +0000 (UTC) X-FDA: 77275673580.15.coal28_0d0e09d2712a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id DB03E1814B0C1 for ; Fri, 18 Sep 2020 09:35:09 +0000 (UTC) X-HE-Tag: coal28_0d0e09d2712a X-Filterd-Recvd-Size: 3674 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Fri, 18 Sep 2020 09:35:09 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 37CE8ACB0; Fri, 18 Sep 2020 09:35:42 +0000 (UTC) Date: Fri, 18 Sep 2020 11:35:02 +0200 From: Oscar Salvador To: HORIGUCHI =?utf-8?B?TkFPWUEo5aCA5Y+j44CA55u05LmfKQ==?= Cc: "yaoaili126@163.com" , "linux-mm@kvack.org" , "YANGFENG1@kingsoft.com" , Aili Yao , "willy@infradead.org" Subject: Re: [PATCH] Fix incorrect compound page flags store Message-ID: <20200918093458.GA14286@linux> References: <20200908034441.16359-1-yaoaili126@163.com> <20200908070210.GA14393@hori.linux.bs1.fc.nec.co.jp> <20200908072603.GA11245@linux> <20200908083630.GA15481@hori.linux.bs1.fc.nec.co.jp> <20200908085153.GA12690@linux> <20200908090555.GA17382@hori.linux.bs1.fc.nec.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200908090555.GA17382@hori.linux.bs1.fc.nec.co.jp> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Sep 08, 2020 at 09:05:56AM +0000, HORIGUCHI NAOYA(=E5=A0=80=E5=8F= =A3 =E7=9B=B4=E4=B9=9F) wrote: > > > thp just after passing over the following block: > >=20 > >=20 > >=20 > > >=20 > > > 1408 if (PageTransHuge(hpage)) { > > > 1409 if (try_to_split_thp_page(p, "Memory Failur= e") < 0) { > > > 1410 action_result(pfn, MF_MSG_UNSPLIT_T= HP, MF_IGNORED); > > > 1411 return -EBUSY; > > > 1412 } > > > 1413 VM_BUG_ON_PAGE(!page_count(p), p); > > > 1414 } > > >=20 > > > So I feel that some check might be added after holding page lock to= avoid > > > that case. Or acutally, it might better that moving the above block= into > > > page lock is more better for simpler code. > >=20 > > I will have a look at this. >=20 > Thank you! Hi Naoya, I have been taking a look at this, and unless I am missing something obvi= ous I do not think that a new THP (containing the page) can be collapsed under = us: We do take a refcount on the page by means of get_hwpoison_page. We could only have done that if the page was mapped, so its refcount was = already above 0. Then we split the THP, and the refcount/mapcount go to the page we are tr= ying to poison. At this point the page should add least have refcount > 1 mapcount >=3D 1= . After that, let us assume that a new THP is trying to be collapsed by mea= ns of khugepaged thread or madvise MADV_HUGEPAGE. khugepaged_scan_pmd() scans all ptes from [pte#0..pte#511] to see if they= can be collapsed, and one of the things it does is checking the page's refcou= nt/ mappcount by calling is_refcount_suitable(). expected_refcount =3D total_mapcount(page); return page_count(page) =3D=3D expected_refcount; We do have an extra pin from memory_failure, so this is going to fail bec= ause page: refcount =3D 2 , mapcount =3D 1 Beware that the page must sitll be mapped somehow, otherwise the PageLRU = check from above should have failed with the same result: if (!PageLRU(page)) { result =3D SCAN_PAGE_LRU; goto out_unmap; } So, I do not think the page can be collapsed into a new THP after we have= split it here, but as I said, I might be missing something. Thoughts? --=20 Oscar Salvador SUSE L3