Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp716863ybt; Fri, 10 Jul 2020 10:30:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEaDwk5rafaaS6yo2cEpGGy9K3L2T1N62LRuxh26ahWgpfw3f/IBdt7vXdAlX1FQFpp72H X-Received: by 2002:a17:907:4003:: with SMTP id nj3mr59784901ejb.278.1594402250996; Fri, 10 Jul 2020 10:30:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594402250; cv=none; d=google.com; s=arc-20160816; b=SbQ5fQiKpWs/bPsrNSxSRXo8DeHFDznSm0y9QUqLw2iKsPaRHpjWZt55MCAIHA5CM7 qyY0oNIkmdyKXvua9DQfof+41rgZZC7lf6ipATNxGshjgbNFzuldqfVBG/hfIweeojpl Gr2AInYX8rBod8h9AwesdnYNjYtePvx/5ja30oboQly3VwqFRyVm2QPhs05HvKFF8iuf w8cWy4V3nU9igRSLaXBhE33KRbKVpxTrhmXZ0n9ZxArCbdouNYfWyxwKV7H9GyQ5Rm/y KgIpkS0a8aHd6ze/2oP5yLCaps2Huph2f1chivYDAtw1Hk0I+chG92YHFEfNcBnarB9H EQIA== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=dhYqHDXmVB851MO24k0xJG8pSyIioIjacD8y0LsCCxY=; b=rd4TpDeHrxEPLzjYTm3gVPBgGWNYd80jtf62umkVT3d10CoLSVenWZYrl9dIk93Bkd YUm8XQqTI8spJNvLhkWhUiOoPlSNmAs4E4i5Ck/fHTzGQiFhsIJE6BQz4lCgqqVXeH0y ZdH4b1Pa3FBGc4nE+yKBRKYt+6BCWFrJJdS0AwbW0BKinRJDkqrtTzveNwr6Iba7o0rK fgsGATiOzFjRTK5LLbHn3k9ynvKO9v1jx6VVb3fd1+4+Ye6YStAKIOffkYTTAHZG2+Ex HPHKJO6PDtzwJ1K18jO2EgIVfG0DeGMb9yOwHBvfWtSI84HGLtWl8JaHFJfxMT1ikbdJ 5zvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dLMJe+V9; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p7si4154665edm.514.2020.07.10.10.30.27; Fri, 10 Jul 2020 10:30:50 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dLMJe+V9; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728044AbgGJR3s (ORCPT + 99 others); Fri, 10 Jul 2020 13:29:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726962AbgGJR3s (ORCPT ); Fri, 10 Jul 2020 13:29:48 -0400 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7007C08C5DC for ; Fri, 10 Jul 2020 10:29:47 -0700 (PDT) Received: by mail-ej1-x641.google.com with SMTP id y10so6971790eje.1 for ; Fri, 10 Jul 2020 10:29:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=dhYqHDXmVB851MO24k0xJG8pSyIioIjacD8y0LsCCxY=; b=dLMJe+V9OFFRHOT42hrZZ1af8nQv7C6RUMqJRqQTx5tKDOZ8GvnlINDSvRebp84+iU m7IQVo5KdPxMFgtHzn8b+huKWXTMhwT9YtcAEAjYMQA2ytWBrN/gts3Imut/Hysm0f86 FMd6HXbnlMjLcq1Pu1reAqpngO8kLHyS10S+JLt06MgNOdupDkW2kNYqn2dDOkMsZS+L 1xrS2mpxHCeQFfcdO5nV9spuB/E4DmmcsY/a88MrBRyF2I3DZp8wL4+L3eTUP0ZTPTQL iL1nofMyqqy/pfiAZW6rku3LfcG4tO0SCqavMgENEzHFSwiClEjGVHkrJd1tF783H9dh ALZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=dhYqHDXmVB851MO24k0xJG8pSyIioIjacD8y0LsCCxY=; b=W1pCKiUnUfOTRbH7QbgbRjDF0/hp7LwSRTaTw7cKSvQgoFJNclIs04awVaO1Nfg4+S xQ256KxJhfxjeXjZAUjxtlbwkjWZvTSRvx/KPDCExpysfXRjeWuBPukjOAeSbyf2Dxz8 9zF5yE7N/cGPkOEhblIURWczr6lNFcEr/fZ/3YUQoNgGt6ImzddYI61R29/i4EOOL+Wh NuNx+SxSdeX1CAnh3MsRcEXbIz2l/McxX+dhg8nZgAQW2EbYv/qEeAobBDIrKgbuVOgo r7jAJ7fkSFyqbUh/1s+Ges1V/utrWX8LfuO4J5Expih1x2AbLpWUWunFsksB1rkvezVO Aotw== X-Gm-Message-State: AOAM533Nw1sI47/8itP0d1xggCDmOFYS7bxzYqPtSSzC44wAJtYHksiL yNNldkc/baNT0R8YmLIcCiFwZfrszKs94Ay9KmIw4nuCcBk= X-Received: by 2002:a17:906:c209:: with SMTP id d9mr38452213ejz.449.1594402186385; Fri, 10 Jul 2020 10:29:46 -0700 (PDT) MIME-Version: 1.0 References: <20200709155002.GF12769@casper.infradead.org> <20200709160750.utl46xvavceuvnom@box> <441ebbeb-0408-e22e-20f4-1be571c4a18e@nextfour.com> <50113530-fae5-bb36-56c2-5b5c4f90426d@linux.alibaba.com> In-Reply-To: <50113530-fae5-bb36-56c2-5b5c4f90426d@linux.alibaba.com> From: Yang Shi Date: Fri, 10 Jul 2020 10:29:27 -0700 Message-ID: Subject: Re: a question of split_huge_page To: Alex Shi Cc: =?UTF-8?Q?Mika_Penttil=C3=A4?= , "Kirill A. Shutemov" , Matthew Wilcox , Johannes Weiner , Linux-MM , "linux-kernel@vger.kernel.org" , Hugh Dickins , Joerg Roedel , iommu@lists.linux-foundation.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 10, 2020 at 2:35 AM 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: > > > > > > 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?> > >> > >> 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 > > > > > > 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 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? I think this is the same problem which has been discussed a couple of weeks ago. Please refer to: https://lore.kernel.org/linux-mm/20200619001938.GA135965@carbon.dhcp.thefac= ebook.com/ I think the conclusion is split_huge_page() can't be used in this path at all. But we didn't reach a fix yet. > > 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 > > >