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 5AD9EC433DF for ; Fri, 10 Jul 2020 12:56:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2360F207DF for ; Fri, 10 Jul 2020 12:56:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2360F207DF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=8bytes.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A46AB8D0002; Fri, 10 Jul 2020 08:56:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9F63B8D0001; Fri, 10 Jul 2020 08:56:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 90CC48D0002; Fri, 10 Jul 2020 08:56:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0220.hostedemail.com [216.40.44.220]) by kanga.kvack.org (Postfix) with ESMTP id 7C39E8D0001 for ; Fri, 10 Jul 2020 08:56:27 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 089636121 for ; Fri, 10 Jul 2020 12:56:27 +0000 (UTC) X-FDA: 77022164814.08.day63_070cc4b26ece Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id D12651819E766 for ; Fri, 10 Jul 2020 12:56:26 +0000 (UTC) X-HE-Tag: day63_070cc4b26ece X-Filterd-Recvd-Size: 3933 Received: from theia.8bytes.org (8bytes.org [81.169.241.247]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Fri, 10 Jul 2020 12:56:26 +0000 (UTC) Received: by theia.8bytes.org (Postfix, from userid 1000) id 9CA1B20C; Fri, 10 Jul 2020 14:56:24 +0200 (CEST) Date: Fri, 10 Jul 2020 14:56:23 +0200 From: Joerg Roedel To: Alex Shi , Robin Murphy Cc: Mika =?iso-8859-1?Q?Penttil=E4?= , "Kirill A. Shutemov" , Matthew Wilcox , Johannes Weiner , Linux-MM , "linux-kernel@vger.kernel.org" , Hugh Dickins , iommu@lists.linux-foundation.org Subject: Re: a question of split_huge_page Message-ID: <20200710125623.GH27672@8bytes.org> References: <20200709155002.GF12769@casper.infradead.org> <20200709160750.utl46xvavceuvnom@box> <441ebbeb-0408-e22e-20f4-1be571c4a18e@nextfour.com> <50113530-fae5-bb36-56c2-5b5c4f90426d@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <50113530-fae5-bb36-56c2-5b5c4f90426d@linux.alibaba.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Queue-Id: D12651819E766 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: Adding Robin. On Fri, Jul 10, 2020 at 05:34:52PM +0800, Alex Shi wrote: > =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_ta= il(), > >>>>> Seems tail pages are added to lru list at line 963, but in this s= cenario > >>>>> 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 tha= t's > >>>> not on an LRU list. Both anonymous and page cache pages should be= on > >>>> 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= time. > >> Also I put a BUG() at the line, it's nevre triggered in ltp, and run= _vmtests > >=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 >=20 > CC Joerg and iommu list, >=20 > That's a good question. seems the split_huge_page was never triggered h= ere, > since the func would check the PageLock first. and have page->mapping a= nd PageAnon > check, any of them couldn't be matched for the alloced page. >=20 > Hi Joerg, > would you like look into this? do we still need the split_huge_page() h= ere? >=20 > Thanks > Alex >=20 > 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(he= ad); > struct anon_vma *anon_vma =3D NULL; > struct address_space *mapping =3D NULL; > int count, mapcount, extra_pins, ret; > pgoff_t end; >=20 > VM_BUG_ON_PAGE(is_huge_zero_page(head), head); > VM_BUG_ON_PAGE(!PageLocked(head), head); <=3D=3D > >=20