Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp516340ybt; Fri, 10 Jul 2020 05:57:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhO4dZaNSingFD72kDu+jyYIGP3uZPYUlIj+h/UrQjYk4G8YnozbLnH0h9uwmSIeDOMKjH X-Received: by 2002:a17:906:c415:: with SMTP id u21mr60141280ejz.45.1594385830666; Fri, 10 Jul 2020 05:57:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594385830; cv=none; d=google.com; s=arc-20160816; b=S+yld95zcytNK4Av6u+IvFyVIGFmv4+rOcdYUmXK7O974vm1BDS7oJ2/K1H75J7/dc /BHDIqVGKNbVdBRSrf+gjoST1HP83x1ZymkfU5qMll/vps5TKCDdMwgaqNfZ2/bHE0tV MFLBDO4eEiIyDPNdW6CiyWkKaKRV6crgpiJYUzSLkUuoLtMqnBOoQft5guZHLkbjYfAn PTs3fESrl5oFzjxiyg3d9x8DiqLDsgttOk6u9mg9A9a5GD5HlmfMd7K/VTa1Yv9swQwD wIheF96ap2fQhM0QDteQSTIxW/nKAk0PV5rQ9oqxeMSj1/CdyHYdrtEY5XK3Dt836vGV VDPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=E3/rOKm1QTvuiZWOnhZm85T3H9X0wfw9bJL1827CU8Y=; b=MCdGxmnKqfZHVOH67XBqIwyTEW6hS62MXmVj/qnGjTNg47gTFpl1SbubSqQjDHgDcV E9VcwePjFMbakyDOxiNUg92vyNRxFRxU3NWIw2LIm7ZFartKrQmigUBPtUhOPmfiVe12 6okVIdtq6sP2iZOO8Vt7v0kK5dsHlMRwz+ZjaqCoBYMuuHRJxvB8diiRDht9kuxRxh4r CzgWg4JkArHJHAG8QEmGDi5UpjmOw4oq5dqWOwInCDejvkKDcHGma3XuX4TooukP0WBD Sl+OaNII5bXgz9BfARXVNn3OqDAAX0/suvf60zxqxHlefeaotByCDm87z13JQDK9So9F iB0Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p7si3744967ejb.486.2020.07.10.05.56.47; Fri, 10 Jul 2020 05:57:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727866AbgGJM4c (ORCPT + 99 others); Fri, 10 Jul 2020 08:56:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726872AbgGJM42 (ORCPT ); Fri, 10 Jul 2020 08:56:28 -0400 Received: from theia.8bytes.org (8bytes.org [IPv6:2a01:238:4383:600:38bc:a715:4b6d:a889]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB2CCC08C5CE for ; Fri, 10 Jul 2020 05:56:27 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit In-Reply-To: <50113530-fae5-bb36-56c2-5b5c4f90426d@linux.alibaba.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding Robin. On Fri, Jul 10, 2020 at 05:34:52PM +0800, Alex Shi wrote: > 在 2020/7/10 下午1:28, Mika Penttilä 写道: > > > > > > On 10.7.2020 7.51, Alex Shi wrote: > >> > >> 在 2020/7/10 上午12:07, Kirill A. Shutemov 写道: > >>> 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 scenario > >>>>> 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 on > >>>> an LRU list. What am I missing?> > >> > >> 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 = 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 > > > > > > In  __iommu_dma_alloc_pages, after split_huge_page(),  who is taking a > > reference on tail pages? Seems tail pages are freed and the function > > errornously returns them in pages[] array for use? > > > > CC Joerg and iommu list, > > That's a good question. seems the split_huge_page was never triggered here, > 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() here? > > Thanks > Alex > > int split_huge_page_to_list(struct page *page, struct list_head *list) > { > struct page *head = compound_head(page); > struct deferred_split *ds_queue = get_deferred_split_queue(head); > struct anon_vma *anon_vma = NULL; > struct address_space *mapping = 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); <== > >