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, URIBL_BLOCKED,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 A36ABC433E3 for ; Fri, 10 Jul 2020 12:56:30 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7C3E320720 for ; Fri, 10 Jul 2020 12:56:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C3E320720 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=8bytes.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 686F5896FF; Fri, 10 Jul 2020 12:56:30 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kCr4zeYJKEQ4; Fri, 10 Jul 2020 12:56:29 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id D560C89741; Fri, 10 Jul 2020 12:56:29 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BCF3CC077B; Fri, 10 Jul 2020 12:56:29 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 33FCDC016F for ; Fri, 10 Jul 2020 12:56:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 2FD7C89741 for ; Fri, 10 Jul 2020 12:56:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3HBzHmifkgAM for ; Fri, 10 Jul 2020 12:56:26 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from theia.8bytes.org (8bytes.org [81.169.241.247]) by whitealder.osuosl.org (Postfix) with ESMTPS id A7794896FF 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 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-Disposition: inline In-Reply-To: <50113530-fae5-bb36-56c2-5b5c4f90426d@linux.alibaba.com> User-Agent: Mutt/1.10.1 (2018-07-13) Cc: Hugh Dickins , "linux-kernel@vger.kernel.org" , Matthew Wilcox , Linux-MM , iommu@lists.linux-foundation.org, Mika =?iso-8859-1?Q?Penttil=E4?= , Johannes Weiner , "Kirill A. Shutemov" X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" QWRkaW5nIFJvYmluLgoKT24gRnJpLCBKdWwgMTAsIDIwMjAgYXQgMDU6MzQ6NTJQTSArMDgwMCwg QWxleCBTaGkgd3JvdGU6Cj4g5ZyoIDIwMjAvNy8xMCDkuIvljYgxOjI4LCBNaWthIFBlbnR0aWzD pCDlhpnpgZM6Cj4gPiAKPiA+IAo+ID4gT24gMTAuNy4yMDIwIDcuNTEsIEFsZXggU2hpIHdyb3Rl Ogo+ID4+Cj4gPj4g5ZyoIDIwMjAvNy8xMCDkuIrljYgxMjowNywgS2lyaWxsIEEuIFNodXRlbW92 IOWGmemBkzoKPiA+Pj4gT24gVGh1LCBKdWwgMDksIDIwMjAgYXQgMDQ6NTA6MDJQTSArMDEwMCwg TWF0dGhldyBXaWxjb3ggd3JvdGU6Cj4gPj4+PiBPbiBUaHUsIEp1bCAwOSwgMjAyMCBhdCAxMTox MToxMVBNICswODAwLCBBbGV4IFNoaSB3cm90ZToKPiA+Pj4+PiBIaSBLaXJpbGwgJiBNYXR0aGV3 LAo+ID4+Pj4+Cj4gPj4+Pj4gSW4gdGhlIGZ1bmMgY2FsbCBjaGFpbiwgZnJvbSBzcGxpdF9odWdl X3BhZ2UoKSB0byBscnVfYWRkX3BhZ2VfdGFpbCgpLAo+ID4+Pj4+IFNlZW1zIHRhaWwgcGFnZXMg YXJlIGFkZGVkIHRvIGxydSBsaXN0IGF0IGxpbmUgOTYzLCBidXQgaW4gdGhpcyBzY2VuYXJpbwo+ ID4+Pj4+IHRoZSBoZWFkIHBhZ2UgaGFzIG5vIGxydSBiaXQgYW5kIGlzbid0IHNldCB0aGUgYml0 IGxhdGVyLiBXaHkgd2UgZG8gdGhpcz8KPiA+Pj4+PiBvciBkbyBJIG1pc3Mgc3RoPwo+ID4+Pj4g SSBkb24ndCB1bmRlcnN0YW5k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wgZXh0cmFfcGlucywgcmV0Owo+ICAgICAgICAgcGdv ZmZfdCBlbmQ7Cj4gCj4gICAgICAgICBWTV9CVUdfT05fUEFHRShpc19odWdlX3plcm9fcGFnZSho ZWFkKSwgaGVhZCk7Cj4gICAgICAgICBWTV9CVUdfT05fUEFHRSghUGFnZUxvY2tlZChoZWFkKSwg aGVhZCk7CTw9PQo+ID4gCl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fCmlvbW11IG1haWxpbmcgbGlzdAppb21tdUBsaXN0cy5saW51eC1mb3VuZGF0aW9uLm9y ZwpodHRwczovL2xpc3RzLmxpbnV4Zm91bmRhdGlvbi5vcmcvbWFpbG1hbi9saXN0aW5mby9pb21t dQ== 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