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=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,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 D30E5C433E0 for ; Fri, 10 Jul 2020 09:35:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A1B6D206E2 for ; Fri, 10 Jul 2020 09:35:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A1B6D206E2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 253A88D0003; Fri, 10 Jul 2020 05:35:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 204698D0002; Fri, 10 Jul 2020 05:35:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 118AE8D0003; Fri, 10 Jul 2020 05:35:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0063.hostedemail.com [216.40.44.63]) by kanga.kvack.org (Postfix) with ESMTP id EC10C8D0002 for ; Fri, 10 Jul 2020 05:35:37 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 6F6E4181AEF07 for ; Fri, 10 Jul 2020 09:35:37 +0000 (UTC) X-FDA: 77021658714.14.top12_2f165e726ecd Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id 029C8182299A7 for ; Fri, 10 Jul 2020 09:35:36 +0000 (UTC) X-HE-Tag: top12_2f165e726ecd X-Filterd-Recvd-Size: 4024 Received: from out30-56.freemail.mail.aliyun.com (out30-56.freemail.mail.aliyun.com [115.124.30.56]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Fri, 10 Jul 2020 09:35:34 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07484;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0U2H8hSR_1594373729; Received: from IT-FVFX43SYHV2H.local(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0U2H8hSR_1594373729) by smtp.aliyun-inc.com(127.0.0.1); Fri, 10 Jul 2020 17:35:30 +0800 Subject: Re: a question of split_huge_page To: =?UTF-8?Q?Mika_Penttil=c3=a4?= , "Kirill A. Shutemov" , Matthew Wilcox Cc: Johannes Weiner , Linux-MM , "linux-kernel@vger.kernel.org" , Hugh Dickins , Joerg Roedel , iommu@lists.linux-foundation.org References: <20200709155002.GF12769@casper.infradead.org> <20200709160750.utl46xvavceuvnom@box> <441ebbeb-0408-e22e-20f4-1be571c4a18e@nextfour.com> From: Alex Shi Message-ID: <50113530-fae5-bb36-56c2-5b5c4f90426d@linux.alibaba.com> Date: Fri, 10 Jul 2020 17:34:52 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <441ebbeb-0408-e22e-20f4-1be571c4a18e@nextfour.com> Content-Type: text/plain; charset=utf-8 X-Rspamd-Queue-Id: 029C8182299A7 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 Content-Transfer-Encoding: quoted-printable 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: =E5=9C=A8 2020/7/10 =E4=B8=8B=E5=8D=881:28, Mika Penttil=C3=A4 =E5=86=99=E9= =81=93: >=20 >=20 > On 10.7.2020 7.51, Alex Shi wrote: >> >> =E5=9C=A8 2020/7/10 =E4=B8=8A=E5=8D=8812:07, Kirill A. Shutemov =E5=86= =99=E9=81=93: >>> On Thu, Jul 09, 2020 at 04:50:02PM +0100, Matthew Wilcox wrote: >>>> On Thu, Jul 09, 2020 at 11:11:11PM +0800, Alex Shi wrote: >>>>> Hi Kirill & Matthew, >>>>> >>>>> In the func call chain, from split_huge_page() to lru_add_page_tail= (), >>>>> Seems tail pages are added to lru list at line 963, but in this sce= nario >>>>> the head page has no lru bit and isn't set the bit later. Why we do= this? >>>>> or do I miss sth? >>>> I don't understand how we get to split_huge_page() with a page that'= s >>>> not on an LRU list. Both anonymous and page cache pages should be o= n >>>> an LRU list. What am I missing?>=20 >> >> Thanks a lot for quick reply! >> What I am confusing is the call chain: __iommu_dma_alloc_pages() >> to split_huge_page(), in the func, splited page, >> page =3D alloc_pages_node(nid, alloc_flags, order); >> And if the pages were added into lru, they maybe reclaimed and lost, >> that would be a panic bug. But in fact, this never happened for long t= ime. >> Also I put a BUG() at the line, it's nevre triggered in ltp, and run_v= mtests >=20 >=20 > In=C2=A0 __iommu_dma_alloc_pages, after split_huge_page(),=C2=A0 who is= taking a > reference on tail pages? Seems tail pages are freed and the function > errornously returns them in pages[] array for use? >=20 CC Joerg and iommu list, That's a good question. seems the split_huge_page was never triggered her= e, since the func would check the PageLock first. and have page->mapping and= PageAnon check, any of them couldn't be matched for the alloced page. Hi Joerg, would you like look into this? do we still need the split_huge_page() her= e? Thanks Alex int split_huge_page_to_list(struct page *page, struct list_head *list) { struct page *head =3D compound_head(page); struct deferred_split *ds_queue =3D get_deferred_split_queue(head= ); struct anon_vma *anon_vma =3D NULL; struct address_space *mapping =3D NULL; int count, mapcount, extra_pins, ret; pgoff_t end; VM_BUG_ON_PAGE(is_huge_zero_page(head), head); VM_BUG_ON_PAGE(!PageLocked(head), head); <=3D=3D >=20