Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp394555ybt; Fri, 10 Jul 2020 02:36:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5K8+QnZhHrY25zqft31gc3jrptJxpkcUBc8AmCPkDxzcUmybnsjQxq8dKnwktIiHMB51S X-Received: by 2002:a05:6402:1757:: with SMTP id v23mr62377165edx.356.1594373789411; Fri, 10 Jul 2020 02:36:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594373789; cv=none; d=google.com; s=arc-20160816; b=cN/iVlukSELVtujhswz8PKPqaZBgkQwY7w1Yzka9A4GoTKGY7KLgcD3G5+C9/TxC13 fO6RK13mJP+2aP0pG2TqiGvowI6dal9C4fOfm99T6r9x2FbqiWI67PEH0uwCgHwKdtnx RfkfJGtyTEplE4jugQp4RyT8+aN6VMzVIW2KxQ96TDuXbtymQIm/4oSELkkt8i6IKGoE 6r4UU3Okbk+Maaf2CLHubZQQNqZZChBHrqE08t6DuD2K+aF7O8d0/tW1jkcMRCY+zNc0 /CchF9MKuXm3f43BPfLrtwLtP55WvhVS84FN1+Fs90vMSD2r32datRZ5uzxeLzzaiL0k pK9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=zQo8p6XqPIiG3FDeNN+0d4GiCyXIwW04JhuvpZ+I2Lk=; b=gxg9D/7NTZT6HQ5Jw2nF5zwXHMqAwdNqWEyRhGtuwS3vgIpjUyabA6ErPLsx/lu9zf x8V+ibugZlkAdpbgIlm0PdapeFzJacYM/kq4A8FeCvbAXFzrbo1w/p0h821KJ2HHqkpH t56AQcYo9cFWnk/zWPARMuVumGN2LYT2KeP9kj0g0qVQ5osryaXis6Y69/ODSOEZaXzw Lkgs6vO2In9HF+odQ03QdpworlUHqPP8GxQePSutrpuKyP/OfaCJBWqnRt7zIOKwaMnm MqbmVKoRXalc9tzIlnVl2jMJchwo0EN0Siu7H2S5GbQal/ymO5gBDEV1E7nCjD5DrHAJ u5yA== 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=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r8si4098734edl.19.2020.07.10.02.36.06; Fri, 10 Jul 2020 02:36:29 -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=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726867AbgGJJfd (ORCPT + 99 others); Fri, 10 Jul 2020 05:35:33 -0400 Received: from out30-42.freemail.mail.aliyun.com ([115.124.30.42]:33774 "EHLO out30-42.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726288AbgGJJfd (ORCPT ); Fri, 10 Jul 2020 05:35:33 -0400 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 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); <== >